Re: [Patch V1 4/7] x86/microcode/core: Take a snapshot before and after applying microcode
From: Ashok Raj
Date: Wed Dec 07 2022 - 19:05:56 EST
On Wed, Dec 07, 2022 at 09:25:54PM +0100, Borislav Petkov wrote:
> On Tue, Nov 29, 2022 at 01:08:29PM -0800, Ashok Raj wrote:
> > The kernel caches features about each CPU's features at boot in an
> > x86_capability[] structure. The microcode update takes one snapshot and
> > compares it with the saved copy at boot.
> >
> > However, the capabilities in the boot copy can be turned off as a result of
> > certain command line parameters or configuration restrictions. This can
> > cause a mismatch when comparing the values before and after the microcode
> > update.
>
> Hmm, but if that has happened, the capabilities will be turned off in
> your @orig argument below?
>
> Or are you saying that this copy_cpu_caps() read before the update will
> overwrite the cleared bits with the their actual values from CPUID so
> that what you really wanna compare here is *hardware* CPUID bits before
> and after and not our potentially modified copy?
>
> I.e., some bit in CPUID is 1 and we have cleared it in our copy.
>
> Close?
Correct.
>
> If so, then this should be specifically called out in the commit
> message.
Sounds good, I can certainly add it when I repost.
>
> > +static void copy_cpu_caps(struct cpuinfo_x86 *info)
>
> If anything, that function should be called
>
> store_cpu_caps()
>
The names sounds more fitting, I can change it as suggested.
Cheers,
Ashok