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

From: Thomas Gleixner
Date: Mon Feb 12 2024 - 09:06:49 EST


On Wed, Jan 24 2024 at 21:02, Borislav Petkov wrote:
> 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...

Yes, that's the idea.