Re: [PATCH 1/2] x86/topology: Name the AMD core-type values

From: Thomas Gleixner

Date: Thu Jul 02 2026 - 18:06:53 EST


On Wed, Jul 01 2026 at 17:27, Borislav Petkov wrote:
> On Mon, Jun 29, 2026 at 03:13:48PM +0530, Vishal Badole wrote:
> And it does make sense to me - x86_match_vendor_cpu_type() is supposed to
> receive the *hardware* defined CPU type - not the generic ones. And I think
> that was a mistake because the value 0 on AMD means a performance core type
> but in the kernel we called it X86_CPU_TYPE_ANY. Which is also not surprising
> - all our ANY types are 0.
>
> Now, one fix would be if we define X86_CPU_TYPE_ANY as 0xff and hope that
> Intel will never define it.
>
> On AMD that value is guaranteed to be invalid because the core type field is
> only 4 bits.
>
> But it can happen that one vendor's core type field can match another core
> type of the other vendor. Which would mean that we cannot use X86_VENDOR_ANY
> in any of the match_id tables when using a core type.
>
> Or, we do the proper fix and we map all vendor core types to the kernel's,
> vendor-agnostic TOPO_CPU_TYPE_* enums and then we're all good - we'd only need
> to convert the vendor ones to the generic ones on comparison but we do that
> anyway.

Just do the mapping to vendor-agnostic types _once_ when you enumerate the CPU
and store that information in the per CPU data.

Then you can do proper vendor agnostic matching against that and define
the TYPE_ANY value as you want without ever colliding with vendor
muck.

As a bonus get_topology_cpu_type() goes away too as the translation has
been done already.

Thanks,

tglx