aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@cn.fujitsu.com>2010-05-26 04:48:25 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:35:53 -0400
commitc9fa0b3bef9a0b117b3c3f958ec553c21f609a9f (patch)
tree072850f275f2091c4104960275dc66332bd8e113 /arch/x86/kvm/mmu.c
parent2032a93d66fa282ba0f2ea9152eeff9511fa9a96 (diff)
KVM: MMU: Calculate correct base gfn for direct non-DIR level
In Document/kvm/mmu.txt: gfn: Either the guest page table containing the translations shadowed by this page, or the base page frame for linear translations. See role.direct. But in __direct_map(), the base gfn calculation is incorrect, it does not calculate correctly when level=3 or 4. Fix by using PT64_LVL_ADDR_MASK() which accounts for all levels correctly. Reported-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index f46b6c9aff27..c0350be52c91 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2020,7 +2020,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2020 } 2020 }
2021 2021
2022 if (*iterator.sptep == shadow_trap_nonpresent_pte) { 2022 if (*iterator.sptep == shadow_trap_nonpresent_pte) {
2023 pseudo_gfn = (iterator.addr & PT64_DIR_BASE_ADDR_MASK) >> PAGE_SHIFT; 2023 u64 base_addr = iterator.addr;
2024
2025 base_addr &= PT64_LVL_ADDR_MASK(iterator.level);
2026 pseudo_gfn = base_addr >> PAGE_SHIFT;
2024 sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr, 2027 sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr,
2025 iterator.level - 1, 2028 iterator.level - 1,
2026 1, ACC_ALL, iterator.sptep); 2029 1, ACC_ALL, iterator.sptep);