On Fri, Feb 25, 2022 at 4:16 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > Don't flush the TLBs when zapping all TDP MMU pages, as the only time KVM > uses the slow version of "zap everything" is when the VM is being > destroyed or the owning mm has exited. In either case, KVM_RUN is > unreachable for the VM, i.e. the guest TLB entries cannot be consumed. > > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> Reviewed-by: Ben Gardon <bgardon@xxxxxxxxxx> > --- > arch/x86/kvm/mmu/tdp_mmu.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index c231b60e1726..87706e9cc6f3 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -874,14 +874,15 @@ bool __kvm_tdp_mmu_zap_gfn_range(struct kvm *kvm, int as_id, gfn_t start, > > void kvm_tdp_mmu_zap_all(struct kvm *kvm) > { > - bool flush = false; > int i; > > + /* > + * A TLB flush is unnecessary, KVM zaps everything if and only the VM > + * is being destroyed or the userspace VMM has exited. In both cases, > + * KVM_RUN is unreachable, i.e. no vCPUs will ever service the request. > + */ > for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) > - flush = kvm_tdp_mmu_zap_gfn_range(kvm, i, 0, -1ull, flush); > - > - if (flush) > - kvm_flush_remote_tlbs(kvm); > + (void)kvm_tdp_mmu_zap_gfn_range(kvm, i, 0, -1ull, false); > } > > /* > -- > 2.35.1.574.g5d30c73bfb-goog >