All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Gleb Natapov <gleb@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Nadav Har'El <nyh@math.technion.ac.il>
Subject: Re: [PATCH v2 2/5] KVM: nVMX: Rework event injection and recovery
Date: Sun, 17 Mar 2013 16:17:19 +0100	[thread overview]
Message-ID: <5145DE7F.9000200@web.de> (raw)
In-Reply-To: <20130317151451.GN11223@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2691 bytes --]

On 2013-03-17 16:14, Gleb Natapov wrote:
> On Sun, Mar 17, 2013 at 04:02:07PM +0100, Jan Kiszka wrote:
>> On 2013-03-17 14:45, Gleb Natapov wrote:
>>> On Sat, Mar 16, 2013 at 11:23:16AM +0100, Jan Kiszka wrote:
>>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>>
>>>> The basic idea is to always transfer the pending event injection on
>>>> vmexit into the architectural state of the VCPU and then drop it from
>>>> there if it turns out that we left L2 to enter L1.
>>>>
>>>> VMX and SVM are now identical in how they recover event injections from
>>>> unperformed vmlaunch/vmresume: We detect that VM_ENTRY_INTR_INFO_FIELD
>>>> still contains a valid event and, if yes, transfer the content into L1's
>>>> idt_vectoring_info_field.
>>>>
>>> But how this can happens with VMX code? VMX has this nested_run_pending
>>> thing that prevents #vmexit emulation from happening without vmlaunch.
>>> This means that VM_ENTRY_INTR_INFO_FIELD should never be valid during
>>> #vmexit emulation since it is marked invalid during vmlaunch.
>>
>> Now that nmi/interrupt_allowed is strict /wrt nested_run_pending again,
>> it may indeed no longer happen. It was definitely a problem before, also
>> with direct vmexit on pending INIT. Requires a second thought, maybe
>> also a WARN_ON(vmx->nested.nested_run_pending) in nested_vmx_vmexit.
>>
>>>
>>>> However, we differ on how to deal with events that L0 wanted to inject
>>>> into L2. Likely, this case is still broken in SVM. For VMX, the function
>>>> vmcs12_save_pending_events deals with transferring pending L0 events
>>>> into the queue of L1. That is mandatory as L1 may decide to switch the
>>>> guest state completely, invalidating or preserving the pending events
>>>> for later injection (including on a different node, once we support
>>>> migration).
>>>>
>>>> Note that we treat directly injected NMIs differently as they can hit
>>>> both L1 and L2. In this case, we let L0 try to injection again also over
>>>> L1 after leaving L2.
>>>>
>>> Hmm, where SDM says NMI behaves this way?
>>
>> NMIs are only blocked in root mode if we took an NMI-related vmexit (or,
>> of course, an NMI is being processed). Thus, every arriving NMI can
>> either hit the guest or the host - pure luck.
>>
>> However, I have missed the fact that an NMI may have been injected from
>> L1 as well. If injection triggers a vmexit, that NMI could now leak into
>> L1. So we have to process them as well in vmcs12_save_pending_events.
>>
> You mean "should not leak into L0" not L1?

No, L1. If we keep the NMI in the architectural queue, L0 will try to
reinject it over L1 after the vmexit to it.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2013-03-17 15:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-16 10:23 [PATCH v2 0/5] KVM: nVMX: Make direct IRQ/NMI injection work Jan Kiszka
2013-03-16 10:23 ` [PATCH v2 1/5] KVM: nVMX: Fix injection of PENDING_INTERRUPT and NMI_WINDOW exits to L1 Jan Kiszka
2013-03-17 13:47   ` Gleb Natapov
2013-03-16 10:23 ` [PATCH v2 2/5] KVM: nVMX: Rework event injection and recovery Jan Kiszka
2013-03-17 13:45   ` Gleb Natapov
2013-03-17 15:02     ` Jan Kiszka
2013-03-17 15:14       ` Gleb Natapov
2013-03-17 15:17         ` Jan Kiszka [this message]
2013-03-17 15:19           ` Gleb Natapov
2013-03-16 10:23 ` [PATCH v2 3/5] KVM: VMX: Move vmx_nmi_allowed after vmx_set_nmi_mask Jan Kiszka
2013-03-16 10:23 ` [PATCH v2 4/5] KVM: nVMX: Fix conditions for interrupt injection Jan Kiszka
2013-03-16 10:23 ` [PATCH v2 5/5] KVM: nVMX: Fix conditions for NMI injection Jan Kiszka
2013-03-16 10:42 ` [PATCH v2 0/5] KVM: nVMX: Make direct IRQ/NMI injection work Jan Kiszka

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=5145DE7F.9000200@web.de \
    --to=jan.kiszka@web.de \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=nyh@math.technion.ac.il \
    --cc=pbonzini@redhat.com \
    /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.