[PATCH 4/6] x86/cpu: Add platform ID to CPU info structure

Dave Hansen posted 6 patches 1 day, 18 hours ago
[PATCH 4/6] x86/cpu: Add platform ID to CPU info structure
Posted by Dave Hansen 1 day, 18 hours ago

From: Dave Hansen <dave.hansen@linux.intel.com>

The end goal here is to be able to do x86_match_cpu() and match on a
specific platform ID. While it would be possible to stash this ID
off somewhere or read it dynamically, that approaches would not be
consistent with the other fields which can be matched.

Read the platform ID and store it in cpuinfo_x86->x86_platform_id.

There are lots of sites to set this new field. Place it near
the place c->microcode is established since the platform ID is
so closely intertwined with microcode updates.

Note: This should not grow the size of 'struct cpuinfo_x86' in
practice since the u8 fits next to another u8 in the structure.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: x86@kernel.org
Cc: Jon Kohler <jon@nutanix.com>
---

 b/arch/x86/include/asm/processor.h |    2 ++
 b/arch/x86/kernel/cpu/common.c     |    4 +++-
 b/arch/x86/kernel/cpu/intel.c      |    1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff -puN arch/x86/include/asm/processor.h~cpu-x86_stepping arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~cpu-x86_stepping	2026-02-06 15:14:23.528790212 -0800
+++ b/arch/x86/include/asm/processor.h	2026-02-06 15:14:23.567791582 -0800
@@ -140,6 +140,8 @@ struct cpuinfo_x86 {
 		__u32		x86_vfm;
 	};
 	__u8			x86_stepping;
+	/* Intel-only. 3 bits: */
+	__u8			x86_platform_id;
 #ifdef CONFIG_X86_64
 	/* Number of 4K pages in DTLB/ITLB combined(in pages): */
 	int			x86_tlbsize;
diff -puN arch/x86/kernel/cpu/common.c~cpu-x86_stepping arch/x86/kernel/cpu/common.c
--- a/arch/x86/kernel/cpu/common.c~cpu-x86_stepping	2026-02-06 15:14:23.552791055 -0800
+++ b/arch/x86/kernel/cpu/common.c	2026-02-06 15:14:23.568791618 -0800
@@ -1981,7 +1981,9 @@ static void identify_cpu(struct cpuinfo_
 	c->loops_per_jiffy = loops_per_jiffy;
 	c->x86_cache_size = 0;
 	c->x86_vendor = X86_VENDOR_UNKNOWN;
-	c->x86_model = c->x86_stepping = 0;	/* So far unknown... */
+	c->x86_model = 0;
+	c->x86_stepping = 0;
+	c->x86_platform_id = 0;
 	c->x86_vendor_id[0] = '\0'; /* Unset */
 	c->x86_model_id[0] = '\0';  /* Unset */
 #ifdef CONFIG_X86_64
diff -puN arch/x86/kernel/cpu/intel.c~cpu-x86_stepping arch/x86/kernel/cpu/intel.c
--- a/arch/x86/kernel/cpu/intel.c~cpu-x86_stepping	2026-02-06 15:14:23.564791477 -0800
+++ b/arch/x86/kernel/cpu/intel.c	2026-02-06 15:14:23.568791618 -0800
@@ -205,6 +205,7 @@ static void early_init_intel(struct cpui
 
 	if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
 		c->microcode = intel_get_microcode_revision();
+	c->x86_platform_id = intel_get_platform_id();
 
 	/* Now if any of them are set, check the blacklist and clear the lot */
 	if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) ||
_