Re: [PATCH v7 1/9] KVM: x86: Define KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT

Jim Mattson
2026-04-07T16:28:01Z

On Mon, Apr 6, 2026 at 4:27 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Fri, Mar 27, 2026, Jim Mattson wrote:
> > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> > index ff1e4b4dc998..74014110b550 100644
> > --- a/arch/x86/kvm/svm/svm.h
> > +++ b/arch/x86/kvm/svm/svm.h
> > @@ -616,6 +616,17 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm)
> > return svm->nested.ctl.misc_ctl & SVM_MISC_ENABLE_NP;
> > }
> >
> > +static inline bool l2_has_separate_pat(struct vcpu_svm *svm)
>
> Take @vcpu instead of @svm. All of the callers have a "vcpu", but not all have
> a local "svm". That will shorten the quirk check far enough to let it poke out.

What is the actual line length limit?

> > +{
> > + /*
> > + * If KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT is disabled while a vCPU
> > + * is running, the L2 IA32_PAT semantics for that vCPU are undefined.
> > + */
> > + return nested_npt_enabled(svm) &&
> > + !kvm_check_has_quirk(svm->vcpu.kvm,
> > + KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT);
>
> Align indentation. With the @svm => @vcpu change, this becomes:
>
> return nested_npt_enabled(to_svm(vcpu)) &&
> !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT);

You wouldn't happen to know the Emacs configuration for the alignment
you like, would you? I asked Gemini, but it lied to me.

> > +}
> > +
> > static inline bool nested_vnmi_enabled(struct vcpu_svm *svm)
> > {
> > return guest_cpu_cap_has(&svm->vcpu, X86_FEATURE_VNMI) &&
> > --
> > 2.53.0.1018.g2bb0e51243-goog
> >