This function's TLB flush was moved sometimes in the past:

1.
  commit 4539b35881ae9664b0e2953438dd83f5ee02c0b4
  KVM: Fix missing smp tlb flush in invlpg

inserted it in the critical section.

2.
  commit 505aef8f30a95f7e4abf2c07e54ded1521587ba0
  KVM: MMU: cleanup FNAME(invlpg)

moved it inside the loop:  right after mmu_page_zap_pte().

3.
  commit f57f2ef58f6703e6df70ed52a198920cb3e8edba
  KVM: MMU: fast prefetch spte on invlpg path

inserted update_pte() after it.

In addition, the caller, kvm_mmu_invlpg(), still does flush.

This patch simplifies the logic and removes this redundancy.

Signed-off-by: Takuya Yoshikawa <yoshikawa.tak...@oss.ntt.co.jp>
---
 arch/x86/kvm/mmu.c         |    1 -
 arch/x86/kvm/paging_tmpl.h |    6 ++++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ae76cc3..ea27ee3 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3769,7 +3769,6 @@ EXPORT_SYMBOL_GPL(kvm_mmu_page_fault);
 void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva)
 {
        vcpu->arch.mmu.invlpg(vcpu, gva);
-       kvm_mmu_flush_tlb(vcpu);
        ++vcpu->stat.invlpg;
 }
 EXPORT_SYMBOL_GPL(kvm_mmu_invlpg);
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 1561028..69d06f5 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -682,6 +682,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
        mmu_topup_memory_caches(vcpu);
 
        spin_lock(&vcpu->kvm->mmu_lock);
+
        for_each_shadow_entry(vcpu, gva, iterator) {
                level = iterator.level;
                sptep = iterator.sptep;
@@ -697,8 +698,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
                        pte_gpa = FNAME(get_level1_sp_gpa)(sp);
                        pte_gpa += (sptep - sp->spt) * sizeof(pt_element_t);
 
-                       if (mmu_page_zap_pte(vcpu->kvm, sp, sptep))
-                               kvm_flush_remote_tlbs(vcpu->kvm);
+                       mmu_page_zap_pte(vcpu->kvm, sp, sptep);
 
                        if (!rmap_can_add(vcpu))
                                break;
@@ -713,6 +713,8 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
                if (!is_shadow_present_pte(*sptep) || !sp->unsync_children)
                        break;
        }
+
+       kvm_flush_remote_tlbs(vcpu->kvm);
        spin_unlock(&vcpu->kvm->mmu_lock);
 }
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to