Re: [PATCH v7 018/120] x86/cpuid: Parse CPUID(0x16)

From: Borislav Petkov

Date: Thu Jun 18 2026 - 23:04:20 EST


On Thu, Jun 18, 2026 at 09:36:50PM +0200, Ahmed S. Darwish wrote:
> The confusion stems from naming the vendor tags table with an _ENTRIES
> suffix, just like EARLY and COMMON.
>
> I'll find a better name for it. I guess CPUID_VENDOR_TAGS should work.

Well, this parser clearly needs a lot more documentation.

/*
* CPUID leaf vendor table:
*/

struct cpuid_vendor_entry {
unsigned int leaf;
u8 vendors[X86_VENDOR_NUM];
u8 nvendors;
};

that reads like a CPUID leaf to me.

Btw, for some reason you have

/*
* Comment...
*/

static ... thing

with an empty line between the comment and the thing. Zap all those empty
lines pls.

In any case, this cpuid_vendor_entries is a mapping between which CPUID leafs
belong to which vendors.

So call it

cpuid_leaf_vendor_map

or so and explain above it what that is and how that is supposed to be used.

The aspect of saving yourself vendor checks is most prominent one so put it
there.

However, that vendor thing is problematic. If a vendor implements a leaf that
belongs to another vendor, that table will have to be updated.

So make sure you document this fact very clearly so that people can find their
way here when they extend the parser.

And so on.

But to come back to the original thing you're trying to solve: why are you
even trying to remove vendor checks? What vendor checks where?

The agreement with CPUID leaves is that, IF you're a second vendor
implementing the CPUID leaf of the vendor to which it belongs to, then you
better implement it exactly the same.

IOW, if AMD implements Intel leaves in the base range, then we make sure we
implement them exactly this way.

If not, those CPUID leafs return zeros.

So what vendor checks exactly are we fixing here?

Even without that, code reading CPUID leafs on a machine which doesn't
implement them, should get all 0s and all fine.

So what is going on here?

--
Regards/Gruss,
Boris.

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