5a39acb
Bugzilla: 924916
5a39acb
Upstream-status: Queued for 3.14 in kvm tree
5a39acb
5a39acb
From 989c6b34f6a9480e397b170cc62237e89bf4fdb9 Mon Sep 17 00:00:00 2001
5a39acb
From: Marcelo Tosatti <mtosatti@redhat.com>
5a39acb
Date: Thu, 19 Dec 2013 17:28:51 +0000
5a39acb
Subject: KVM: MMU: handle invalid root_hpa at __direct_map
5a39acb
5a39acb
It is possible for __direct_map to be called on invalid root_hpa
5a39acb
(-1), two examples:
5a39acb
5a39acb
1) try_async_pf -> can_do_async_pf
5a39acb
    -> vmx_interrupt_allowed -> nested_vmx_vmexit
5a39acb
2) vmx_handle_exit -> vmx_interrupt_allowed -> nested_vmx_vmexit
5a39acb
5a39acb
Then to load_vmcs12_host_state and kvm_mmu_reset_context.
5a39acb
5a39acb
Check for this possibility, let fault exception be regenerated.
5a39acb
5a39acb
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=924916
5a39acb
5a39acb
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
5a39acb
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5a39acb
---
5a39acb
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
5a39acb
index 40772ef..31a5702 100644
5a39acb
--- a/arch/x86/kvm/mmu.c
5a39acb
+++ b/arch/x86/kvm/mmu.c
5a39acb
@@ -2659,6 +2659,9 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
5a39acb
 	int emulate = 0;
5a39acb
 	gfn_t pseudo_gfn;
5a39acb
 
5a39acb
+	if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
5a39acb
+		return 0;
5a39acb
+
5a39acb
 	for_each_shadow_entry(vcpu, (u64)gfn << PAGE_SHIFT, iterator) {
5a39acb
 		if (iterator.level == level) {
5a39acb
 			mmu_set_spte(vcpu, iterator.sptep, ACC_ALL,
5a39acb
--
5a39acb
cgit v0.9.2