lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZVEINlaIIMUO221@google.com>
Date:   Wed, 17 Nov 2021 18:04:16 +0000
From:   Sean Christopherson <seanjc@...gle.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     Hou Wenlong <houwenlong93@...ux.alibaba.com>, kvm@...r.kernel.org,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] KVM: x86/mmu: Skip tlb flush if it has been done in
 zap_gfn_range()

On Wed, Nov 17, 2021, Sean Christopherson wrote:
> On Wed, Nov 17, 2021, Paolo Bonzini wrote:
> > On 11/17/21 10:20, Hou Wenlong wrote:
> > > If the parameter flush is set, zap_gfn_range() would flush remote tlb
> > > when yield, then tlb flush is not needed outside. So use the return
> > > value of zap_gfn_range() directly instead of OR on it in
> > > kvm_unmap_gfn_range() and kvm_tdp_mmu_unmap_gfn_range().
> > > 
> > > Fixes: 3039bcc744980 ("KVM: Move x86's MMU notifier memslot walkers to generic code")
> > > Signed-off-by: Hou Wenlong <houwenlong93@...ux.alibaba.com>
> > > ---
> > >   arch/x86/kvm/mmu/mmu.c     | 2 +-
> > >   arch/x86/kvm/mmu/tdp_mmu.c | 4 ++--
> > >   2 files changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > > index 354d2ca92df4..d57319e596a9 100644
> > > --- a/arch/x86/kvm/mmu/mmu.c
> > > +++ b/arch/x86/kvm/mmu/mmu.c
> > > @@ -1582,7 +1582,7 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
> > >   		flush = kvm_handle_gfn_range(kvm, range, kvm_unmap_rmapp);
> > >   	if (is_tdp_mmu_enabled(kvm))
> > > -		flush |= kvm_tdp_mmu_unmap_gfn_range(kvm, range, flush);
> > > +		flush = kvm_tdp_mmu_unmap_gfn_range(kvm, range, flush);
> > >   	return flush;
> > >   }
> > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> > > index 7c5dd83e52de..9d03f5b127dc 100644
> > > --- a/arch/x86/kvm/mmu/tdp_mmu.c
> > > +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> > > @@ -1034,8 +1034,8 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
> > >   	struct kvm_mmu_page *root;
> > >   	for_each_tdp_mmu_root(kvm, root, range->slot->as_id)
> > > -		flush |= zap_gfn_range(kvm, root, range->start, range->end,
> > > -				       range->may_block, flush, false);
> > > +		flush = zap_gfn_range(kvm, root, range->start, range->end,
> > > +				      range->may_block, flush, false);
> > >   	return flush;
> > >   }
> > > 
> > 
> > Queued both, thanks.
> 
> Please replace patch 02 with the below.  Hou's patch isn't wrong, but it's nowhere
> near agressive enough in purging the unecessary flush.  I was too slow in writing
> a changelog for this patch in my local repo.

Even better, take Ben's patch :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ