[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1502433443-4126-1-git-send-email-wanpeng.li@hotmail.com>
Date: Thu, 10 Aug 2017 23:37:23 -0700
From: Wanpeng Li <kernellwp@...il.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Wanpeng Li <wanpeng.li@...mail.com>,
Brijesh Singh <brijesh.singh@....com>
Subject: [PATCH v2] KVM: MMU: Fix guest stuck during boot due to read/write emulation against GVA
From: Wanpeng Li <wanpeng.li@...mail.com>
Commit c016004494b0 (KVM: x86: Avoid guest page table walk when gpa_available
is set) avoids the page table walk when cr2 has already contained a valid GPA.
However, that is not the truth if ept == 0 and shadow page table is used. In
this scenario cr2 can just contains a valid GVA. The commit results in guest
stuck during boot due to read/write emulation against GVA instead of GPA of
the guest.
This patch fixes it by setting the gpa_available flag under direct mode.
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Radim Krčmář <rkrcmar@...hat.com>
Cc: Brijesh Singh <brijesh.singh@....com>
Signed-off-by: Wanpeng Li <wanpeng.li@...mail.com>
---
arch/x86/kvm/mmu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 849312d..a038879 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3791,8 +3791,10 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
if (need_unprotect && kvm_event_needs_reinjection(vcpu))
kvm_mmu_unprotect_page_virt(vcpu, fault_address);
- vcpu->arch.gpa_available = true;
- vcpu->arch.gpa_val = fault_address;
+ if (vcpu->arch.mmu.direct_map) {
+ vcpu->arch.gpa_available = true;
+ vcpu->arch.gpa_val = fault_address;
+ }
r = kvm_mmu_page_fault(vcpu, fault_address, error_code, insn,
insn_len);
break;
--
2.7.4
Powered by blists - more mailing lists