aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 685a4ffac8e6..89a49fb46a27 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -477,7 +477,7 @@ static int host_mapping_level(struct kvm *kvm, gfn_t gfn)
477 477
478 addr = gfn_to_hva(kvm, gfn); 478 addr = gfn_to_hva(kvm, gfn);
479 if (kvm_is_error_hva(addr)) 479 if (kvm_is_error_hva(addr))
480 return page_size; 480 return PT_PAGE_TABLE_LEVEL;
481 481
482 down_read(&current->mm->mmap_sem); 482 down_read(&current->mm->mmap_sem);
483 vma = find_vma(current->mm, addr); 483 vma = find_vma(current->mm, addr);
@@ -515,11 +515,9 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn)
515 if (host_level == PT_PAGE_TABLE_LEVEL) 515 if (host_level == PT_PAGE_TABLE_LEVEL)
516 return host_level; 516 return host_level;
517 517
518 for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) { 518 for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level)
519
520 if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) 519 if (has_wrprotected_page(vcpu->kvm, large_gfn, level))
521 break; 520 break;
522 }
523 521
524 return level - 1; 522 return level - 1;
525} 523}
@@ -748,7 +746,8 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn)
748 return write_protected; 746 return write_protected;
749} 747}
750 748
751static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data) 749static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
750 unsigned long data)
752{ 751{
753 u64 *spte; 752 u64 *spte;
754 int need_tlb_flush = 0; 753 int need_tlb_flush = 0;
@@ -763,7 +762,8 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
763 return need_tlb_flush; 762 return need_tlb_flush;
764} 763}
765 764
766static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data) 765static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
766 unsigned long data)
767{ 767{
768 int need_flush = 0; 768 int need_flush = 0;
769 u64 *spte, new_spte; 769 u64 *spte, new_spte;
@@ -799,9 +799,10 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data)
799 return 0; 799 return 0;
800} 800}
801 801
802static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, u64 data, 802static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
803 unsigned long data,
803 int (*handler)(struct kvm *kvm, unsigned long *rmapp, 804 int (*handler)(struct kvm *kvm, unsigned long *rmapp,
804 u64 data)) 805 unsigned long data))
805{ 806{
806 int i, j; 807 int i, j;
807 int retval = 0; 808 int retval = 0;
@@ -846,10 +847,11 @@ int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
846 847
847void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) 848void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
848{ 849{
849 kvm_handle_hva(kvm, hva, (u64)&pte, kvm_set_pte_rmapp); 850 kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp);
850} 851}
851 852
852static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, u64 data) 853static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
854 unsigned long data)
853{ 855{
854 u64 *spte; 856 u64 *spte;
855 int young = 0; 857 int young = 0;
@@ -2785,7 +2787,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
2785 if (r) 2787 if (r)
2786 goto out; 2788 goto out;
2787 2789
2788 er = emulate_instruction(vcpu, vcpu->run, cr2, error_code, 0); 2790 er = emulate_instruction(vcpu, cr2, error_code, 0);
2789 2791
2790 switch (er) { 2792 switch (er) {
2791 case EMULATE_DONE: 2793 case EMULATE_DONE:
@@ -2796,6 +2798,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
2796 case EMULATE_FAIL: 2798 case EMULATE_FAIL:
2797 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 2799 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
2798 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; 2800 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
2801 vcpu->run->internal.ndata = 0;
2799 return 0; 2802 return 0;
2800 default: 2803 default:
2801 BUG(); 2804 BUG();