diff mbox

[4/5] KVM: MMU: Use correct root gfn for direct maps

Message ID 1272271723-9070-5-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity April 26, 2010, 8:48 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 4da4ff1..6e925b3 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2070,16 +2070,17 @@  static int mmu_alloc_roots(struct kvm_vcpu *vcpu)
 	for (i = 0; i < nr_roots; ++i) {
 		root = rootp[i];
 		ASSERT(!VALID_PAGE(root));
-		if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) {
+
+		if (direct)
+			root_gfn = 0;
+		else if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) {
 			pdptr = kvm_pdptr_read(vcpu, i);
 			if (!is_present_gpte(pdptr)) {
 				rootp[i] = 0;
 				continue;
 			}
 			root_gfn = pdptr >> PAGE_SHIFT;
-		} else if (vcpu->arch.mmu.root_level == 0)
-			root_gfn = 0;
-		else
+		} else
 			root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT;
 
 		if (mmu_check_root(vcpu, root_gfn))