All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Nadav Har'El" <nyh@math.technion.ac.il>
Cc: Gleb Natapov <gleb@redhat.com>, kvm@vger.kernel.org, abelg@il.ibm.com
Subject: Re: [PATCH 0/30] nVMX: Nested VMX, v9
Date: Mon, 23 May 2011 12:52:50 +0300	[thread overview]
Message-ID: <4DDA2E72.8070907@redhat.com> (raw)
In-Reply-To: <20110522193239.GA13130@fermat.math.technion.ac.il>

On 05/22/2011 10:32 PM, Nadav Har'El wrote:
> On Thu, May 12, 2011, Gleb Natapov wrote about "Re: [PATCH 0/30] nVMX: Nested VMX, v9":
> >  >  But if my interpretation of the code is correct, SVM isn't much closer
> >  >  than VMX to the goal of moving this logic to x86.c. When some logic is
> >  >  moved there, both SVM and VMX code will need to change - perhaps even
> >  >  considerably. So how will it be helpful to make VMX behave exactly like
> >  >  SVM does now, when the latter will also need to change considerably?
> >  >
> >  SVM design is much close to the goal of moving the logic into x86.c
> >  because IIRC it does not bypass parsing of IDT vectoring info into arch
> >  independent structure. VMX code uses vmx->idt_vectoring_info directly.
>
> At the risk of sounding blasphemous, I'd like to make the case that perhaps
> the current nested-VMX design - regarding the IDT-vectoring-info-field
> handling - is actually closer than nested-SVM to the goal of moving clean
> nested-supporting logic into x86.c, instead of having ad-hoc, unnatural,
> workarounds.
>
> Let me explain, and see if you agree with my logic:
>
> We discover at exit time whether the virtualization hardware (VMX or SVM)
> exited while *delivering* an interrupt or exception to the current guest.
> This is known as "idt-vectoring-information" in VMX.
>
> What do we need to do with this idt-vectoring-information? In regular (non-
> nested) guests, the answer is simple: On the next entry, we need to inject
> this event again into the guest, so it can resume the delivery of the
> same event it was trying to deliver. This is why the nested-unaware code
> has a vmx_complete_interrupts which basically adds this idt-vectoring-info
> into KVM's event queue, which on the next entry will be injected similarly
> to the way virtual interrupts from userspace are injected, and so on.

The other thing we may need to do, is to expose it to userspace in case 
we're live migrating at exactly this point in time.

> But with nested virtualization, this is *not* what is supposed to happen -
> we do not *always* need to inject the event to the guest. We will only need
> to inject the event if the next entry will be again to the same guest, i.e.,
> L1 after L1, or L2 after L2. If the idt-vectoring-info came from L2, but
> our next entry will be into L1 (i.e., a nested exit), we *shouldn't* inject
> the event as usual, but should rather pass this idt-vectoring-info field
> as the exit information that L1 gets (in nested vmx terminology, in vmcs12).
>
> However, at the time of exit, we cannot know for sure whether L2 will actually
> run next, because it is still possible that an injection from user space,
> before the next entry, will cause us to decide to exit to L1.
>
> Therefore, I believe that the clean solution isn't to leave the original
> non-nested logic that always queues the idt-vectoring-info assuming it will
> be injected, and then if it shouldn't (because we want to exit during entry)
> we need to skip the entry once as a "trick" to avoid this wrong injection.
>
> Rather, a clean solution is, I think, to recognize that in nested
> virtualization, idt-vectoring-info is a different kind of beast than regular
> injected events, and it needs to be saved at exit time in a different field
> (which will of course be common to SVM and VMX). Only at entry time, after
> the regular injection code (which may cause a nested exit), we can call a
> x86_op to handle this special injection.
>
> The benefit of this approach, which is closer to the current vmx code,
> is, I think, that x86.c will contain clear, self-explanatory nested logic,
> instead of relying on vmx.c or svm.c circumventing various x86.c functions
> and mechanisms to do something different from what they were meant to do.
>

IMO this will cause confusion, especially with the user interfaces used 
to read/write pending events.

I think what we need to do is:

1. change ->interrupt_allowed() to return true if the interrupt flag is 
unmasked OR if in a nested guest, and we're intercepting interrupts
2. change ->set_irq() to cause a nested vmexit if in a nested guest and 
we're intercepting interrupts
3. change ->nmi_allowed() and ->set_nmi() in a similar way
4. add a .injected flag to the interrupt queue which overrides the 
nested vmexit for VM_ENTRY_INTR_INFO_FIELD and the svm equivalent; if 
present normal injection takes place (or an error vmexit if the 
interrupt flag is clear and we cannot inject)


-- 
error compiling committee.c: too many arguments to function


  parent reply	other threads:[~2011-05-23  9:53 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08  8:15 [PATCH 0/30] nVMX: Nested VMX, v9 Nadav Har'El
2011-05-08  8:15 ` [PATCH 01/30] nVMX: Add "nested" module option to kvm_intel Nadav Har'El
2011-05-08  8:16 ` [PATCH 02/30] nVMX: Implement VMXON and VMXOFF Nadav Har'El
2011-05-08  8:16 ` [PATCH 03/30] nVMX: Allow setting the VMXE bit in CR4 Nadav Har'El
2011-05-08  8:17 ` [PATCH 04/30] nVMX: Introduce vmcs12: a VMCS structure for L1 Nadav Har'El
2011-05-08  8:17 ` [PATCH 05/30] nVMX: Implement reading and writing of VMX MSRs Nadav Har'El
2011-05-08  8:18 ` [PATCH 06/30] nVMX: Decoding memory operands of VMX instructions Nadav Har'El
2011-05-09  9:47   ` Avi Kivity
2011-05-08  8:18 ` [PATCH 07/30] nVMX: Introduce vmcs02: VMCS used to run L2 Nadav Har'El
2011-05-16 15:30   ` Marcelo Tosatti
2011-05-16 18:32     ` Nadav Har'El
2011-05-17 13:20       ` Marcelo Tosatti
2011-05-08  8:19 ` [PATCH 08/30] nVMX: Fix local_vcpus_link handling Nadav Har'El
2011-05-08  8:19 ` [PATCH 09/30] nVMX: Add VMCS fields to the vmcs12 Nadav Har'El
2011-05-08  8:20 ` [PATCH 10/30] nVMX: Success/failure of VMX instructions Nadav Har'El
2011-05-08  8:20 ` [PATCH 11/30] nVMX: Implement VMCLEAR Nadav Har'El
2011-05-08  8:21 ` [PATCH 12/30] nVMX: Implement VMPTRLD Nadav Har'El
2011-05-16 14:34   ` Marcelo Tosatti
2011-05-16 18:58     ` Nadav Har'El
2011-05-16 19:09       ` Nadav Har'El
2011-05-08  8:21 ` [PATCH 13/30] nVMX: Implement VMPTRST Nadav Har'El
2011-05-08  8:22 ` [PATCH 14/30] nVMX: Implement VMREAD and VMWRITE Nadav Har'El
2011-05-08  8:22 ` [PATCH 15/30] nVMX: Move host-state field setup to a function Nadav Har'El
2011-05-09  9:56   ` Avi Kivity
2011-05-09 10:40     ` Nadav Har'El
2011-05-08  8:23 ` [PATCH 16/30] nVMX: Move control field setup to functions Nadav Har'El
2011-05-08  8:23 ` [PATCH 17/30] nVMX: Prepare vmcs02 from vmcs01 and vmcs12 Nadav Har'El
2011-05-09 10:12   ` Avi Kivity
2011-05-09 10:27     ` Nadav Har'El
2011-05-09 10:45       ` Avi Kivity
2011-05-08  8:24 ` [PATCH 18/30] nVMX: Implement VMLAUNCH and VMRESUME Nadav Har'El
2011-05-08  8:24 ` [PATCH 19/30] nVMX: No need for handle_vmx_insn function any more Nadav Har'El
2011-05-08  8:25 ` [PATCH 20/30] nVMX: Exiting from L2 to L1 Nadav Har'El
2011-05-09 10:45   ` Avi Kivity
2011-05-08  8:25 ` [PATCH 21/30] nVMX: Deciding if L0 or L1 should handle an L2 exit Nadav Har'El
2011-05-08  8:26 ` [PATCH 22/30] nVMX: Correct handling of interrupt injection Nadav Har'El
2011-05-09 10:57   ` Avi Kivity
2011-05-08  8:27 ` [PATCH 23/30] nVMX: Correct handling of exception injection Nadav Har'El
2011-05-08  8:27 ` [PATCH 24/30] nVMX: Correct handling of idt vectoring info Nadav Har'El
2011-05-09 11:04   ` Avi Kivity
2011-05-08  8:28 ` [PATCH 25/30] nVMX: Handling of CR0 and CR4 modifying instructions Nadav Har'El
2011-05-08  8:28 ` [PATCH 26/30] nVMX: Further fixes for lazy FPU loading Nadav Har'El
2011-05-08  8:29 ` [PATCH 27/30] nVMX: Additional TSC-offset handling Nadav Har'El
2011-05-09 17:27   ` Zachary Amsden
2011-05-08  8:29 ` [PATCH 28/30] nVMX: Add VMX to list of supported cpuid features Nadav Har'El
2011-05-08  8:30 ` [PATCH 29/30] nVMX: Miscellenous small corrections Nadav Har'El
2011-05-08  8:30 ` [PATCH 30/30] nVMX: Documentation Nadav Har'El
2011-05-09 11:18 ` [PATCH 0/30] nVMX: Nested VMX, v9 Avi Kivity
2011-05-09 11:37   ` Nadav Har'El
2011-05-11  8:20   ` Gleb Natapov
2011-05-12 15:42     ` Nadav Har'El
2011-05-12 15:57       ` Gleb Natapov
2011-05-12 16:08         ` Avi Kivity
2011-05-12 16:14           ` Gleb Natapov
2011-05-12 16:31         ` Nadav Har'El
2011-05-12 16:51           ` Gleb Natapov
2011-05-12 17:00             ` Avi Kivity
2011-05-15 23:11               ` Nadav Har'El
2011-05-16  6:38                 ` Gleb Natapov
2011-05-16  7:44                   ` Nadav Har'El
2011-05-16  7:57                     ` Gleb Natapov
2011-05-16  9:50                 ` Avi Kivity
2011-05-16 10:20                   ` Avi Kivity
2011-05-22 19:32             ` Nadav Har'El
2011-05-23  9:37               ` Joerg Roedel
2011-05-23  9:52               ` Avi Kivity [this message]
2011-05-23 13:02                 ` Joerg Roedel
2011-05-23 13:08                   ` Avi Kivity
2011-05-23 13:40                     ` Joerg Roedel
2011-05-23 13:52                       ` Avi Kivity
2011-05-23 14:10                         ` Nadav Har'El
2011-05-23 14:32                           ` Avi Kivity
2011-05-23 14:44                             ` Nadav Har'El
2011-05-23 15:23                               ` Avi Kivity
2011-05-23 18:06                                 ` Alexander Graf
2011-05-24 11:09                                   ` Avi Kivity
2011-05-24 13:07                                     ` Joerg Roedel
2011-05-23 14:28                         ` Joerg Roedel
2011-05-23 14:34                           ` Avi Kivity
2011-05-23 14:58                             ` Joerg Roedel
2011-05-23 15:19                               ` Avi Kivity
2011-05-23 13:18                   ` Nadav Har'El
2011-05-12 16:18       ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DDA2E72.8070907@redhat.com \
    --to=avi@redhat.com \
    --cc=abelg@il.ibm.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=nyh@math.technion.ac.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.