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

From: Sean Christopherson

Date: Tue Apr 07 2026 - 13:00:44 EST


On Tue, Apr 07, 2026, Jim Mattson wrote:
> On Mon, Apr 6, 2026 at 4:27 PM Sean Christopherson <seanjc@xxxxxxxxxx> 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?

There's a "medium-firm" limit at 80 and a "mostly-hard" limit at 100. 100 isn't
a true hard limit to allow for things like pre-formatted strings, and cases where
the only way to stay under 100 chars would (arguably) yield less readable code
overall, e.g. msr-index.h deliberately has this

#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI (1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT)

and not

#define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI \
(1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT)

> > > +{
> > > + /*
> > > + * 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.

Heh, no. Any time I unintentionally end up in Emacs, I have to do a search just
to figure out how to save and exit :-)