]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
KVM/MMU: Move tlb flush in kvm_set_pte_rmapp() to kvm_mmu_notifier_change_pte()
authorLan Tianyu <Tianyu.Lan@microsoft.com>
Thu, 6 Dec 2018 13:21:11 +0000 (21:21 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Dec 2018 10:28:42 +0000 (11:28 +0100)
This patch is to move tlb flush in kvm_set_pte_rmapp() to
kvm_mmu_notifier_change_pte() in order to avoid redundant tlb flush.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c
virt/kvm/kvm_main.c

index dd71864ded39937d53ecd7217455f58cefcc626e..5a046f93a41a74dfad6927698b74b9b99e671961 100644 (file)
@@ -1776,10 +1776,7 @@ restart:
                }
        }
 
-       if (need_flush)
-               kvm_flush_remote_tlbs(kvm);
-
-       return 0;
+       return need_flush;
 }
 
 struct slot_rmap_walk_iterator {
@@ -1915,8 +1912,7 @@ int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
 
 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
 {
-       kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp);
-       return 0;
+       return kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp);
 }
 
 static int kvm_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
index f90ceab3840e3e9ecff23faa24afba6deed6cbc0..cf7cc0554094f9f3e84804718b43c8b5df9193bc 100644 (file)
@@ -354,7 +354,10 @@ static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
        idx = srcu_read_lock(&kvm->srcu);
        spin_lock(&kvm->mmu_lock);
        kvm->mmu_notifier_seq++;
-       kvm_set_spte_hva(kvm, address, pte);
+
+       if (kvm_set_spte_hva(kvm, address, pte))
+               kvm_flush_remote_tlbs(kvm);
+
        spin_unlock(&kvm->mmu_lock);
        srcu_read_unlock(&kvm->srcu, idx);
 }