aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/paging_tmpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r--drivers/kvm/paging_tmpl.h28
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 149fa45fd9a5..b6b90e9e1301 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -443,31 +443,17 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
443static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr) 443static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
444{ 444{
445 struct guest_walker walker; 445 struct guest_walker walker;
446 pt_element_t guest_pte; 446 gpa_t gpa = UNMAPPED_GVA;
447 gpa_t gpa; 447 int r;
448
449 FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0, 0);
450 guest_pte = *walker.ptep;
451 FNAME(release_walker)(&walker);
452
453 if (!is_present_pte(guest_pte))
454 return UNMAPPED_GVA;
455
456 if (walker.level == PT_DIRECTORY_LEVEL) {
457 ASSERT((guest_pte & PT_PAGE_SIZE_MASK));
458 ASSERT(PTTYPE == 64 || is_pse(vcpu));
459 448
460 gpa = (guest_pte & PT_DIR_BASE_ADDR_MASK) | (vaddr & 449 r = FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0, 0);
461 (PT_LEVEL_MASK(PT_PAGE_TABLE_LEVEL) | ~PAGE_MASK));
462 450
463 if (PTTYPE == 32 && is_cpuid_PSE36()) 451 if (r) {
464 gpa |= (guest_pte & PT32_DIR_PSE36_MASK) << 452 gpa = (gpa_t)walker.gfn << PAGE_SHIFT;
465 (32 - PT32_DIR_PSE36_SHIFT); 453 gpa |= vaddr & ~PAGE_MASK;
466 } else {
467 gpa = (guest_pte & PT_BASE_ADDR_MASK);
468 gpa |= (vaddr & ~PAGE_MASK);
469 } 454 }
470 455
456 FNAME(release_walker)(&walker);
471 return gpa; 457 return gpa;
472} 458}
473 459