Re: [PATCH 1/2] KVM: SVM: Fix UBSAN warning when reading avic parameter

From: Naveen N Rao

Date: Wed Feb 25 2026 - 01:36:56 EST


On Tue, Feb 24, 2026 at 11:18:01AM +0200, Gal Pressman wrote:
> On 23/02/2026 18:38, Naveen N Rao wrote:
> > On Tue, Feb 10, 2026 at 08:46:20AM +0200, Gal Pressman wrote:
> >>
> >> +static int avic_param_get(char *buffer, const struct kernel_param *kp)
> >> +{
> >> + int val = *(int *)kp->arg;
> >> +
> >> + if (val == AVIC_AUTO_MODE)
> >> + return sysfs_emit(buffer, "auto\n");
> >
> > My preference would be to return 'N' here, so that this continues to
> > return a boolean value when read.
>
> I guess the boolean conversion used to return 'Y' before this patch, why
> is 'N' better?

Because that would reflect the state of AVIC more accurately:
- in the case of kvm-amd module still being loaded, AVIC has not yet
been enabled, and
- in the case of a non-AMD system, AVIC is not enabled and is not
active.

Also, note that AVIC used to default to 'N' until recently.


- Naveen