From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: nVMX: Fix exception injection
Date: Mon, 5 Jun 2017 14:07:29 +0200 [thread overview]
Message-ID: <2ba5e53d-14f4-14a1-0084-a8b521a3ec3e@redhat.com> (raw)
In-Reply-To: <1496460115-12654-1-git-send-email-wanpeng.li@hotmail.com>
On 03/06/2017 05:21, Wanpeng Li wrote:
> Commit 0b6ac343fc (KVM: nVMX: Correct handling of exception injection) mentioned
> that "KVM wants to inject page-faults which it got to the guest. This function
> assumes it is called with the exit reason in vmcs02 being a #PF exception".
> Commit e011c663 (KVM: nVMX: Check all exceptions for intercept during delivery to
> L2) allows to check all exceptions for intercept during delivery to L2. However,
> there is no guarantee the exit reason is exception currently, when there is an
> external interrupt occurred on host, maybe a time interrupt for host which should
> not be injected to guest, and somewhere queues an exception, then the function
> nested_vmx_check_exception() will be called and the vmexit emulation codes will
> try to emulate the "Acknowledge interrupt on exit" behavior, the warning is
> triggered.
>
> This patch fixes it by confirming to inject exception to the guest when the exit
> reason in vmcs02 is exception.
I am confused. On one hand, the comment originally "this is the only
case in which KVM injects a #PF when L2 is running", but I'm not sure
it's true. For example, KVM could emulate a movs while running L2. If
the source is MMIO and the destination is a missing page, the original
failure could be an EPT misconfig, but the access to the destination
would cause a #PF in the guest (could be a nice testcase for
kvm-unit-tests, BTW :)).
On the other hand, why would you reuse to_vmx(vcpu)->exit_reason in
nested_vmx_check_exception? Would the following fix the bug:
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9b4b5d6dcd34..ca5d2b93385c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2425,7 +2425,7 @@ static int nested_vmx_check_exception(struct
kvm_vcpu *vcpu, unsigned nr)
if (!(vmcs12->exception_bitmap & (1u << nr)))
return 0;
- nested_vmx_vmexit(vcpu, to_vmx(vcpu)->exit_reason,
+ nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI,
vmcs_read32(VM_EXIT_INTR_INFO),
vmcs_readl(EXIT_QUALIFICATION));
return 1;
?
Thanks,
Paolo
next prev parent reply other threads:[~2017-06-05 12:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-03 3:21 Wanpeng Li
2017-06-05 12:07 ` Paolo Bonzini [this message]
2017-06-05 12:19 ` Wanpeng Li
2017-07-18 18:47 ` Jim Mattson
2017-07-20 2:31 ` Wanpeng Li
2017-07-20 19:16 ` Jim Mattson
2017-07-21 8:39 ` Wanpeng Li
2017-07-22 14:25 ` Jim Mattson
2017-07-23 0:29 ` Wanpeng Li
2017-07-23 1:11 ` Jim Mattson
2017-07-24 13:02 ` Paolo Bonzini
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=2ba5e53d-14f4-14a1-0084-a8b521a3ec3e@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@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
all inboxes | Powered by JetHome®