aboutsummaryrefslogtreecommitdiff
path: root/drivers/kvm/paging_tmpl.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-11-21 14:44:45 +0200
committerAvi Kivity <avi@qumranet.com>2008-01-30 17:53:11 +0200
commit1755fbcc6666906cada43c1c839ca1fc6616d4a6 (patch)
tree2f878da8de7c7e9043337d7ee028116b0c397829 /drivers/kvm/paging_tmpl.h
parent38c335f1f57bd9edc3cd894e8f5f3fc133320ad3 (diff)
KVM: MMU: Introduce gfn_to_gpa()
Converting a frame number to an address is tricky since the data type changes size. Introduce a function to do it. This fixes an actual bug when accessing guest ptes. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r--drivers/kvm/paging_tmpl.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index a3da98bfd6a..b24bc7c8607 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -110,7 +110,7 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
index = PT_INDEX(addr, walker->level);
table_gfn = gpte_to_gfn(pte);
- pte_gpa = table_gfn << PAGE_SHIFT;
+ pte_gpa = gfn_to_gpa(table_gfn);
pte_gpa += index * sizeof(pt_element_t);
walker->table_gfn[walker->level - 1] = table_gfn;
pgprintk("%s: table_gfn[%d] %lx\n", __FUNCTION__,
@@ -442,7 +442,7 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
r = FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0, 0);
if (r) {
- gpa = (gpa_t)walker.gfn << PAGE_SHIFT;
+ gpa = gfn_to_gpa(walker.gfn);
gpa |= vaddr & ~PAGE_MASK;
}