Re: [PATCH v1 1/2] x86/cpufeature: Add facility to match microcode revisions

From: Andi Kleen
Date: Sat Oct 06 2018 - 14:15:22 EST


On Sat, Oct 06, 2018 at 04:14:54PM +0200, Thomas Gleixner wrote:
> On Fri, 5 Oct 2018, Andi Kleen wrote:
> > +/*
> > + * Match specific microcodes or steppings.
>
> What means microcodes or steppings? If you mean microcode revisions then
> please spell it out and use it all over the place. steppings is confusing
> at best as its associated to the CPU stepping.

The matcher can be used to match specific hardware steppings by setting
the min/max_ucode to 0 or specific microcode revisions
(which are associated with steppings)

> > +const struct x86_ucode_id *x86_match_ucode_all(const struct x86_ucode_id *match)
>
> Can you please name that so it's obvious that this checks all cpus, but
> aside of that, why would a system ever end up with different microcode
> revisions at all? The changelog is not mentioning any reason for this
> function and "/* Check all CPUs */" is not helpful either.

We still support the old microcode interface that allows updates
per CPU, and also it could happen during CPU hotplug.

>
> > + int cpu;
> > + const struct x86_ucode_id *all_m = NULL;
> > + bool first = true;
> > +
> > + for_each_online_cpu(cpu) {
>
> What guarantees that CPUs cannot be plugged? You either need to have
> cpus_read_lock() in this function or a lockdep_assert_cpus_held().

In my case the caller, but yes should be documented.

-Andi