Re: [PATCH 09/13] x86/microcode: Add a generic mechanism to declare support for minrev

From: Ashok Raj
Date: Wed Oct 19 2022 - 09:06:46 EST


On Tue, Oct 18, 2022 at 09:03:03PM -0700, Huang, Kai wrote:
> On Fri, 2022-10-14 at 13:09 -0700, Ashok Raj wrote:
> > @@ -606,6 +606,7 @@ static ssize_t reload_store(struct device *dev,
> >   enum ucode_state tmp_ret = UCODE_OK;
> >   int bsp = boot_cpu_data.cpu_index;
> >   unsigned long val;
> > + int minrev;
> >   ssize_t ret = 0;
> >  
> >   ret = kstrtoul(buf, 0, &val);
> > @@ -621,8 +622,14 @@ static ssize_t reload_store(struct device *dev,
> >   if (ret)
> >   goto put;
> >  
> > - pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n");
> > - pr_err("You should switch to early loading, if possible.\n");
> > + if (microcode_ops->check_minrev())
> > + minrev = microcode_ops->check_minrev();
> > +
> > + if (!minrev) {
> > + pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n");
> > + pr_err("You should switch to early loading, if possible.\n");
> > + }
> > +
>
> Hi Ashok,
>
> IIUC a variable in stack isn't initialized to 0 automatically. So looks if
> check_minrev() callback is NULL, you will get an uninitialized 'minrev' in the
> above if() statement check.
>

Thanks for the review Kai.

Correct, that's a miss. I originally had a weak function bound for AMD.
But later i removed and forgot to initialize the local variable.

I've already queued this for next post. Just waiting for a few more review
comments to come on.

Cheers,
Ashok