Re: [PATCH v3 5/6] KVM: SVM: Move global "avic" variable to avic.c

From: Sean Christopherson

Date: Fri Sep 19 2025 - 10:44:31 EST


On Fri, Sep 19, 2025, Naveen N Rao wrote:
> On Thu, Sep 18, 2025 at 05:21:35PM -0700, Sean Christopherson wrote:
> > @@ -1141,15 +1149,9 @@ void avic_vcpu_unblocking(struct kvm_vcpu *vcpu)
> > avic_vcpu_load(vcpu, vcpu->cpu);
> > }
> >
> > -/*
> > - * Note:
> > - * - The module param avic enable both xAPIC and x2APIC mode.
> > - * - Hypervisor can support both xAVIC and x2AVIC in the same guest.
> > - * - The mode can be switched at run-time.
> > - */
> > -bool __init avic_hardware_setup(struct kvm_x86_ops *svm_ops)
> > +static bool __init avic_want_avic_enable(void)
>
> Maybe avic_can_enable()?

That was actualy one of my first names, but I didn't want to use "can" because
(to me at least) that doesn't capture that the helper is incorporating input from
the user, i.e. that it's also checking what the user "wants".

I agree the name isn't great. Does avic_want_avic_enabled() read any better?

> > {
> > - if (!npt_enabled)
> > + if (!avic || !npt_enabled)
> > return false;
> >
> > /* AVIC is a prerequisite for x2AVIC. */
> > @@ -1174,6 +1176,20 @@ bool __init avic_hardware_setup(struct kvm_x86_ops *svm_ops)
> > pr_warn("AVIC unsupported in CPUID but force enabled, your system might crash and burn\n");
> >
> > pr_info("AVIC enabled\n");
>
> I think it would be good to keep this in avic_hardware_setup() alongside
> the message printing "x2AVIC enabled".

+1, looks waaay better that way.