Re: [PATCH v3 6/6] KVM: SVM: Enable AVIC by default for Zen4+ if x2AVIC is support
From: Sean Christopherson
Date: Fri Sep 19 2025 - 17:56:50 EST
On Fri, Sep 19, 2025, Naveen N Rao wrote:
> On Thu, Sep 18, 2025 at 05:21:36PM -0700, Sean Christopherson wrote:
> > @@ -1151,6 +1170,18 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu)
> >
> > static bool __init avic_want_avic_enable(void)
> > {
> > + /*
> > + * In "auto" mode, enable AVIC by default for Zen4+ if x2AVIC is
> > + * supported (to avoid enabling partial support by default, and because
> > + * x2AVIC should be supported by all Zen4+ CPUs). Explicitly check for
> > + * family 0x19 and later (Zen5+), as the kernel's synthetic ZenX flags
> > + * aren't inclusive of previous generations, i.e. the kernel will set
> > + * at most one ZenX feature flag.
> > + */
> > + if (avic == AVIC_AUTO_MODE)
> > + avic = boot_cpu_has(X86_FEATURE_X2AVIC) &&
>
> This can use cpu_feature_enabled() as well, I think.
It could, but I'm going to leave it as boot_cpu_has() for now, purely because
the existing code uses boot_cpu_has() for X2AVIC and mixing the two adds
"complexity" where none exists.
I'm definitely not opposed to using cpu_feature_enabled() in general, just not
in this case (of course, we could just swap them all, but meh, it's init code).