From: Wanpeng Li <kernellwp@gmail.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>,
"Ladi Prosek" <lprosek@redhat.com>
Subject: [PATCH] KVM: nVMX: Fix L2 guest hang if shadow page tables on EPT
Date: Fri, 17 Mar 2017 07:41:31 -0700 [thread overview]
Message-ID: <1489761691-11441-1-git-send-email-wanpeng.li@hotmail.com> (raw)
From: Wanpeng Li <wanpeng.li@hotmail.com>
The L2 guest hang if shadow page tables on EPT, the trace on L1 shows that
L2 kvm_exit reason EXCEPTION_NMI and page fault repeatedly:
qemu-system-x86-2821 [003] d..2 45.848814: kvm_entry: vcpu 0
qemu-system-x86-2821 [003] ...1 45.848827: kvm_exit: reason EXCEPTION_NMI rip 0xe05b info fe05b 80000b0e
qemu-system-x86-2821 [003] ...1 45.848827: kvm_page_fault: address fe05b error_code 14
Commit 7ca29de21362 (KVM: nVMX: fix CR3 load if L2 uses PAE paging and EPT)
prevents to load L2's PDPTRs according to dereferencing L2's CR3 since it is
uninitialized in real mode. Hyper-V L1 will emulate L2 real mode with PAE
paging and EPT enabled. However, there is a progress to switch from Legacy
mode's such-mode Protected mode to Long mode during system boot, the check
in nested_vmx_load_cr3() will prevent to load PDPTRs if it is still in
Protected mode w/ PAE paging and nested EPT/shadow page tables on EPT. Actually
the original commit should just intended to prevent to dereference L2's CR3
if the L1 hypervisor emulates L2's real mode through vm8086.
This patch fixes it by allowing load PDPTRs if PAE paing, EPT enabled and
!vm86_active.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/vmx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c664365..2b2a05f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9933,7 +9933,7 @@ static bool nested_cr3_valid(struct kvm_vcpu *vcpu, unsigned long val)
static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool nested_ept,
u32 *entry_failure_code)
{
- if (cr3 != kvm_read_cr3(vcpu) || (!nested_ept && pdptrs_changed(vcpu))) {
+ if (cr3 != kvm_read_cr3(vcpu) || pdptrs_changed(vcpu)) {
if (!nested_cr3_valid(vcpu, cr3)) {
*entry_failure_code = ENTRY_FAIL_DEFAULT;
return 1;
@@ -9944,7 +9944,7 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne
* must not be dereferenced.
*/
if (!is_long_mode(vcpu) && is_pae(vcpu) && is_paging(vcpu) &&
- !nested_ept) {
+ !(nested_ept && to_vmx(vcpu)->rmode.vm86_active)) {
if (!load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3)) {
*entry_failure_code = ENTRY_FAIL_PDPTE;
return 1;
--
2.7.4
next reply other threads:[~2017-03-17 14:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 14:41 Wanpeng Li [this message]
2017-03-17 14:47 ` [PATCH] KVM: nVMX: Fix L2 guest hang if shadow page tables on EPT Paolo Bonzini
2017-03-17 17:28 ` Ladi Prosek
2017-03-17 17:33 ` Paolo Bonzini
2017-03-18 6:37 ` Wanpeng Li
2017-03-22 12:00 ` Ladi Prosek
2017-03-22 13:44 ` Wanpeng Li
2017-03-22 14:17 ` 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=1489761691-11441-1-git-send-email-wanpeng.li@hotmail.com \
--to=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lprosek@redhat.com \
--cc=pbonzini@redhat.com \
--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