Skip to content

Commit 649497d

Browse files
committed
KVM: MMU: Fix incorrect direct gfn for unpaged mode shadow
We use the physical address instead of the base gfn for the four PAE page directories we use in unpaged mode. When the guest accesses an address above 1GB that is backed by a large host page, a BUG_ON() in kvm_mmu_set_gfn() triggers. Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=21962 Reported-and-tested-by: Nicolas Prochazka <[email protected]> KVM-Stable-Tag. Signed-off-by: Avi Kivity <[email protected]>
1 parent 0a59228 commit 649497d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,8 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
23942394
ASSERT(!VALID_PAGE(root));
23952395
spin_lock(&vcpu->kvm->mmu_lock);
23962396
kvm_mmu_free_some_pages(vcpu);
2397-
sp = kvm_mmu_get_page(vcpu, i << 30, i << 30,
2397+
sp = kvm_mmu_get_page(vcpu, i << (30 - PAGE_SHIFT),
2398+
i << 30,
23982399
PT32_ROOT_LEVEL, 1, ACC_ALL,
23992400
NULL);
24002401
root = __pa(sp->spt);

0 commit comments

Comments
 (0)