Re: [patch v5 01/19] x86/cpu: Provide cpuid_read() et al.

From: Borislav Petkov
Date: Wed Jan 24 2024 - 15:02:44 EST


On Wed, Jan 24, 2024 at 01:25:12PM +0100, Borislav Petkov wrote:
> > +static inline void __cpuid_read_reg(unsigned int leaf, unsigned int subleaf,
> > + enum cpuid_regs_idx regidx, u32 *reg)
> > +{
> > + u32 regs[4];
> > +
> > + __cpuid_read(leaf, subleaf, regs);
> > + *reg = regs[regidx];
>
> Why not do
>
> return regs[regidx];
>
> instead?

Or do you really want to be able to use anonymous structs with bitfields
in them and then convert them to a u32 * when passing in to
cpuid_leaf_reg() etc in order to save yourself all the masking and
shifting and read out the bitfields directly?

I'm looking at the parse_topology() use case.

Looks like it...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette