From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Wanpeng Li <wanpeng.li@hotmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Jan Kiszka <jan.kiszka@siemens.com>, Bandan Das <bsd@redhat.com>
Subject: Re: [PATCH v2] KVM: nVMX: Fix the NMI IDT-vectoring handling
Date: Fri, 23 Sep 2016 01:12:40 +0200 [thread overview]
Message-ID: <20160922231240.GC25134@potion> (raw)
In-Reply-To: <1474538154-14119-1-git-send-email-wanpeng.li@hotmail.com>
2016-09-22 17:55+0800, Wanpeng Li:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> Run kvm-unit-tests/eventinj.flat in L1:
>
> Sending NMI to self
> After NMI to self
> FAIL: NMI
>
> This test scenario is to test whether VMM can handle NMI IDT-vectoring info correctly.
>
> At the beginning, L2 writes LAPIC to send a self NMI, the EPT page tables on both L1
> and L0 are empty so:
>
> - The L2 accesses memory can generate EPT violation which can be intercepted by L0.
>
> The EPT violation vmexit occurred during delivery of this NMI, and the NMI info is
> recorded in vmcs02's IDT-vectoring info.
>
> - L0 walks L1's EPT12 and L0 sees the mapping is invalid, it injects the EPT violation into L1.
>
> The vmcs02's IDT-vectoring info is reflected to vmcs12's IDT-vectoring info since
> it is a nested vmexit.
>
> - L1 receives the EPT violation, then fixes its EPT12.
> - L1 executes VMRESUME to resume L2 which generates vmexit and causes L1 exits to L0.
> - L0 emulates VMRESUME which is called from L1, then return to L2.
>
> L0 merges the requirement of vmcs12's IDT-vectoring info and injects it to L2 through
> vmcs02.
>
> - The L2 re-executes the fault instruction and cause EPT violation again.
> - Since the L1's EPT12 is valid, L0 can fix its EPT02
> - L0 resume L2
>
> The EPT violation vmexit occurred during delivery of this NMI again, and the NMI info
> is recorded in vmcs02's IDT-vectoring info. L0 should inject the NMI through vmentry
> event injection since it is caused by EPT02's EPT violation.
>
> However, vmx_inject_nmi() refuses to inject NMI from IDT-vectoring info if vCPU is in
> guest mode, this patch fix it by permitting to inject NMI from IDT-vectoring if it is
> the L0's responsibility to inject NMI from IDT-vectoring info to L2.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Jan Kiszka <jan.kiszka@siemens.com>
> Cc: Bandan Das <bsd@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
Applied to kvm/queue, thanks.
prev parent reply other threads:[~2016-09-22 23:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 9:55 [PATCH v2] KVM: nVMX: Fix the NMI IDT-vectoring handling Wanpeng Li
2016-09-22 9:58 ` Paolo Bonzini
2016-09-22 23:12 ` Radim Krčmář [this message]
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=20160922231240.GC25134@potion \
--to=rkrcmar@redhat.com \
--cc=bsd@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=wanpeng.li@hotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).