[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YGyvoF3WO4yjIuug@google.com>
Date: Tue, 6 Apr 2021 18:59:44 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/mmu: preserve pending TLB flush across calls to
kvm_tdp_mmu_zap_sp
On Tue, Apr 06, 2021, Paolo Bonzini wrote:
> Right now, if a call to kvm_tdp_mmu_zap_sp returns false, the caller
> will skip the TLB flush, which is wrong. There are two ways to fix
> it:
>
> - since kvm_tdp_mmu_zap_sp will not yield and therefore will not flush
> the TLB itself, we could change the call to kvm_tdp_mmu_zap_sp to
> use "flush |= ..."
>
> - or we can chain the flush argument through kvm_tdp_mmu_zap_sp down
> to __kvm_tdp_mmu_zap_gfn_range.
>
> This patch does the former to simplify application to stable kernels.
Eh, that and passing flush down the stack is pointless because kvm_tdp_mmu_zap_sp()
will never yield. If you want to justify |= over passing flush, it probably
makes sense to link to the discussion that led to me changing from passing flush
to accumulating the result (well, tried to, doh).
https://lkml.kernel.org/r/20210319232006.3468382-3-seanjc@google.com
> Cc: seanjc@...gle.com
> Fixes: 048f49809c526 ("KVM: x86/mmu: Ensure TLBs are flushed for TDP MMU during NX zapping")
> Cc: <stable@...r.kernel.org> # 5.10.x: 048f49809c: KVM: x86/mmu: Ensure TLBs are flushed for TDP MMU during NX zapping
> Cc: <stable@...r.kernel.org> # 5.10.x: 33a3164161: KVM: x86/mmu: Don't allow TDP MMU to yield when recovering NX pages
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
Reviewed-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 486aa94ecf1d..951dae4e7175 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -5906,7 +5906,7 @@ static void kvm_recover_nx_lpages(struct kvm *kvm)
> lpage_disallowed_link);
> WARN_ON_ONCE(!sp->lpage_disallowed);
> if (is_tdp_mmu_page(sp)) {
> - flush = kvm_tdp_mmu_zap_sp(kvm, sp);
> + flush |= kvm_tdp_mmu_zap_sp(kvm, sp);
> } else {
> kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
> WARN_ON_ONCE(sp->lpage_disallowed);
> --
> 2.26.2
>
Powered by blists - more mailing lists