aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/mmu.c')
-rw-r--r--drivers/kvm/mmu.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index bbf5eb427dc6..2ad14fbdcfa0 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -850,23 +850,17 @@ static void page_header_update_slot(struct kvm *kvm, void *pte, gpa_t gpa)
850 __set_bit(slot, &page_head->slot_bitmap); 850 __set_bit(slot, &page_head->slot_bitmap);
851} 851}
852 852
853hpa_t safe_gpa_to_hpa(struct kvm *kvm, gpa_t gpa)
854{
855 hpa_t hpa = gpa_to_hpa(kvm, gpa);
856
857 return is_error_hpa(hpa) ? bad_page_address | (gpa & ~PAGE_MASK): hpa;
858}
859
860hpa_t gpa_to_hpa(struct kvm *kvm, gpa_t gpa) 853hpa_t gpa_to_hpa(struct kvm *kvm, gpa_t gpa)
861{ 854{
862 struct page *page; 855 struct page *page;
856 hpa_t hpa;
863 857
864 ASSERT((gpa & HPA_ERR_MASK) == 0); 858 ASSERT((gpa & HPA_ERR_MASK) == 0);
865 page = gfn_to_page(kvm, gpa >> PAGE_SHIFT); 859 page = gfn_to_page(kvm, gpa >> PAGE_SHIFT);
866 if (!page) 860 hpa = ((hpa_t)page_to_pfn(page) << PAGE_SHIFT) | (gpa & (PAGE_SIZE-1));
867 return gpa | HPA_ERR_MASK; 861 if (is_error_page(page))
868 return ((hpa_t)page_to_pfn(page) << PAGE_SHIFT) 862 return hpa | HPA_ERR_MASK;
869 | (gpa & (PAGE_SIZE-1)); 863 return hpa;
870} 864}
871 865
872hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva) 866hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva)