[0/5] KVM: x86/mmu: TDP MMU fixes for 6.2

Message ID 20221213033030.83345-1-seanjc@google.com
Headers
Series KVM: x86/mmu: TDP MMU fixes for 6.2 |

Message

Sean Christopherson Dec. 13, 2022, 3:30 a.m. UTC
  Fix three fatal TDP MMU bugs introduced in 6.2, harden related code,
and clean up kvm_tdp_mmu_map() to eliminate the need for gotos.

Sean Christopherson (5):
  KVM: x86/mmu: Don't attempt to map leaf if target TDP MMU SPTE is
    frozen
  KVM: x86/mmu: Map TDP MMU leaf SPTE iff target level is reached
  KVM: x86/mmu: Re-check under lock that TDP MMU SP hugepage is
    disallowed
  KVM: x86/mmu: Don't install TDP MMU SPTE if SP has unexpected level
  KVM: x86/mmu: Move kvm_tdp_mmu_map()'s prolog and epilog to its caller

 arch/x86/kvm/mmu/mmu.c          |  9 +++++++-
 arch/x86/kvm/mmu/mmu_internal.h |  1 -
 arch/x86/kvm/mmu/tdp_mmu.c      | 39 +++++++++++++++------------------
 3 files changed, 26 insertions(+), 23 deletions(-)


base-commit: 51229fd7872f82af07498aef5c79ad51baf81ea0
  

Comments

Robert Hoo Dec. 14, 2022, 12:01 p.m. UTC | #1
On Tue, 2022-12-13 at 03:30 +0000, Sean Christopherson wrote:
> Fix three fatal TDP MMU bugs introduced in 6.2,

introduced in 6.1? or earlier?

>  harden related code,
> and clean up kvm_tdp_mmu_map() to eliminate the need for gotos.
> 
> Sean Christopherson (5):
>   KVM: x86/mmu: Don't attempt to map leaf if target TDP MMU SPTE is
>     frozen
>   KVM: x86/mmu: Map TDP MMU leaf SPTE iff target level is reached
>   KVM: x86/mmu: Re-check under lock that TDP MMU SP hugepage is
>     disallowed
>   KVM: x86/mmu: Don't install TDP MMU SPTE if SP has unexpected level
>   KVM: x86/mmu: Move kvm_tdp_mmu_map()'s prolog and epilog to its
> caller
> 
>  arch/x86/kvm/mmu/mmu.c          |  9 +++++++-
>  arch/x86/kvm/mmu/mmu_internal.h |  1 -
>  arch/x86/kvm/mmu/tdp_mmu.c      | 39 +++++++++++++++--------------
> ----
>  3 files changed, 26 insertions(+), 23 deletions(-)
> 
> 
> base-commit: 51229fd7872f82af07498aef5c79ad51baf81ea0

I cannot find this base commit in my tree, where I just pulled to
latest queue yesterday. But find this series can be applied to this
latest queue as well.

commit 9d75a3251adfbcf444681474511b58042a364863 (origin/queue, queue)
Author: Sean Christopherson <seanjc@google.com>
Date:   Wed Dec 7 00:09:59 2022 +0000

    KVM: x86: Add proper ReST tables for userspace MSR exits/flags
  
Sean Christopherson Dec. 14, 2022, 3:48 p.m. UTC | #2
On Wed, Dec 14, 2022, Robert Hoo wrote:
> On Tue, 2022-12-13 at 03:30 +0000, Sean Christopherson wrote:
> > Fix three fatal TDP MMU bugs introduced in 6.2,
> 
> introduced in 6.1? or earlier?

6.2, or more precisely, code sitting in kvm/next that will hopefully become part
of 6.2-rc1.

> >  harden related code,
> > and clean up kvm_tdp_mmu_map() to eliminate the need for gotos.
> > 
> > Sean Christopherson (5):
> >   KVM: x86/mmu: Don't attempt to map leaf if target TDP MMU SPTE is
> >     frozen
> >   KVM: x86/mmu: Map TDP MMU leaf SPTE iff target level is reached
> >   KVM: x86/mmu: Re-check under lock that TDP MMU SP hugepage is
> >     disallowed
> >   KVM: x86/mmu: Don't install TDP MMU SPTE if SP has unexpected level
> >   KVM: x86/mmu: Move kvm_tdp_mmu_map()'s prolog and epilog to its
> > caller
> > 
> >  arch/x86/kvm/mmu/mmu.c          |  9 +++++++-
> >  arch/x86/kvm/mmu/mmu_internal.h |  1 -
> >  arch/x86/kvm/mmu/tdp_mmu.c      | 39 +++++++++++++++--------------
> > ----
> >  3 files changed, 26 insertions(+), 23 deletions(-)
> > 
> > 
> > base-commit: 51229fd7872f82af07498aef5c79ad51baf81ea0
> 
> I cannot find this base commit in my tree, where I just pulled to
> latest queue yesterday. But find this series can be applied to this
> latest queue as well.

Ya, I have an extra commit in my local repo sitting on top of kvm/queue so that
my standard builds don't fail.

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index cc3e8c7d0850..2c7f2a26421e 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -898,6 +898,7 @@ bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu)
                return false;
        return vcpu->arch.pv_eoi.msr_val & KVM_MSR_ENABLED;
 }
+EXPORT_SYMBOL_GPL(kvm_hv_assist_page_enabled);
 
 int kvm_hv_get_assist_page(struct kvm_vcpu *vcpu)
 {
  
Paolo Bonzini Dec. 23, 2022, 5:32 p.m. UTC | #3
Queued, thanks.

Paolo