diff options
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r-- | arch/x86/kvm/mmu.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d8172aabc660..e55af12e11b7 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -222,8 +222,7 @@ static int is_io_pte(unsigned long pte) | |||
222 | 222 | ||
223 | static int is_rmap_pte(u64 pte) | 223 | static int is_rmap_pte(u64 pte) |
224 | { | 224 | { |
225 | return pte != shadow_trap_nonpresent_pte | 225 | return is_shadow_present_pte(pte); |
226 | && pte != shadow_notrap_nonpresent_pte; | ||
227 | } | 226 | } |
228 | 227 | ||
229 | static gfn_t pse36_gfn_delta(u32 gpte) | 228 | static gfn_t pse36_gfn_delta(u32 gpte) |
@@ -893,14 +892,25 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, | |||
893 | int *ptwrite, gfn_t gfn, struct page *page) | 892 | int *ptwrite, gfn_t gfn, struct page *page) |
894 | { | 893 | { |
895 | u64 spte; | 894 | u64 spte; |
896 | int was_rmapped = is_rmap_pte(*shadow_pte); | 895 | int was_rmapped = 0; |
897 | int was_writeble = is_writeble_pte(*shadow_pte); | 896 | int was_writeble = is_writeble_pte(*shadow_pte); |
897 | hfn_t host_pfn = (*shadow_pte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT; | ||
898 | 898 | ||
899 | pgprintk("%s: spte %llx access %x write_fault %d" | 899 | pgprintk("%s: spte %llx access %x write_fault %d" |
900 | " user_fault %d gfn %lx\n", | 900 | " user_fault %d gfn %lx\n", |
901 | __FUNCTION__, *shadow_pte, pt_access, | 901 | __FUNCTION__, *shadow_pte, pt_access, |
902 | write_fault, user_fault, gfn); | 902 | write_fault, user_fault, gfn); |
903 | 903 | ||
904 | if (is_rmap_pte(*shadow_pte)) { | ||
905 | if (host_pfn != page_to_pfn(page)) { | ||
906 | pgprintk("hfn old %lx new %lx\n", | ||
907 | host_pfn, page_to_pfn(page)); | ||
908 | rmap_remove(vcpu->kvm, shadow_pte); | ||
909 | } | ||
910 | else | ||
911 | was_rmapped = 1; | ||
912 | } | ||
913 | |||
904 | /* | 914 | /* |
905 | * We don't set the accessed bit, since we sometimes want to see | 915 | * We don't set the accessed bit, since we sometimes want to see |
906 | * whether the guest actually used the pte (in order to detect | 916 | * whether the guest actually used the pte (in order to detect |
@@ -1402,7 +1412,7 @@ static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, | |||
1402 | up_read(¤t->mm->mmap_sem); | 1412 | up_read(¤t->mm->mmap_sem); |
1403 | 1413 | ||
1404 | vcpu->arch.update_pte.gfn = gfn; | 1414 | vcpu->arch.update_pte.gfn = gfn; |
1405 | vcpu->arch.update_pte.page = gfn_to_page(vcpu->kvm, gfn); | 1415 | vcpu->arch.update_pte.page = page; |
1406 | } | 1416 | } |
1407 | 1417 | ||
1408 | void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, | 1418 | void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, |