[tip: x86/cleanups] x86/cpu: Move intel_get_platform_id() to cpu/intel.c

From: tip-bot2 for Borislav Petkov

Date: Wed Jul 01 2026 - 17:30:00 EST


The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID: 77d34d39509341d76ab10f63ef67648545c90da1
Gitweb: https://git.kernel.org/tip/77d34d39509341d76ab10f63ef67648545c90da1
Author: Borislav Petkov <bp@xxxxxxxxx>
AuthorDate: Wed, 13 May 2026 22:07:13 +02:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Wed, 01 Jul 2026 13:59:55 -07:00

x86/cpu: Move intel_get_platform_id() to cpu/intel.c

It is not only used in the microcode loader anymore and the platform ID is
cached in the cpuinfo_x86 structure so move the getter to Intel CPU-specific
code.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>
Reviewed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
Link: https://lore.kernel.org/all/20260430020953.1405535-1-binbin.wu@xxxxxxxxxxxxxxx
---
arch/x86/include/asm/microcode.h | 2 +-
arch/x86/include/asm/processor.h | 1 +-
arch/x86/kernel/cpu/intel.c | 35 +++++++++++++++++++++++++-
arch/x86/kernel/cpu/microcode/intel.c | 36 +--------------------------
4 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
index 9cd136d..645e65a 100644
--- a/arch/x86/include/asm/microcode.h
+++ b/arch/x86/include/asm/microcode.h
@@ -62,8 +62,6 @@ static inline int intel_microcode_get_datasize(struct microcode_header_intel *hd
return hdr->datasize ? : DEFAULT_UCODE_DATASIZE;
}

-extern u32 intel_get_platform_id(void);
-
static inline u32 intel_get_microcode_revision(void)
{
u32 rev, dummy;
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 87b1d4c..8d8f890 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -238,6 +238,7 @@ extern void early_cpu_init(void);
extern void identify_secondary_cpu(unsigned int cpu);
extern void print_cpu_info(struct cpuinfo_x86 *);
void print_cpu_msr(struct cpuinfo_x86 *);
+extern u32 intel_get_platform_id(void);

/*
* Friendlier CR3 helpers.
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index abb3984..03073b9 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -199,6 +199,41 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
c->cpuid_level = cpuid_eax(0);
}

+/*
+ * Use CPUID to generate a "vfm" value. Useful before cpuinfo_x86
+ * structures are populated.
+ */
+static u32 intel_cpuid_vfm(void)
+{
+ u32 eax = cpuid_eax(1);
+ u32 fam = x86_family(eax);
+ u32 model = x86_model(eax);
+
+ return IFM(fam, model);
+}
+
+u32 intel_get_platform_id(void)
+{
+ unsigned int val[2];
+
+ if (x86_hypervisor_present)
+ return 0;
+
+ /*
+ * This can be called early. Use CPUID directly instead of
+ * relying on cpuinfo_x86 which may not be fully initialized.
+ * The PII does not have MSR_IA32_PLATFORM_ID. Everything
+ * before _it_ has no microcode (for Linux at least).
+ */
+ if (intel_cpuid_vfm() <= INTEL_PENTIUM_II_KLAMATH)
+ return 0;
+
+ /* get processor flags from MSR 0x17 */
+ native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
+
+ return (val[1] >> 18) & 7;
+}
+
static void early_init_intel(struct cpuinfo_x86 *c)
{
u64 misc_enable;
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index f4a444e..1142183 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -121,42 +121,6 @@ static inline unsigned int exttable_size(struct extended_sigtable *et)
return et->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE;
}

-
-/*
- * Use CPUID to generate a "vfm" value. Useful before cpuinfo_x86
- * structures are populated.
- */
-static u32 intel_cpuid_vfm(void)
-{
- u32 eax = cpuid_eax(1);
- u32 fam = x86_family(eax);
- u32 model = x86_model(eax);
-
- return IFM(fam, model);
-}
-
-u32 intel_get_platform_id(void)
-{
- unsigned int val[2];
-
- if (x86_hypervisor_present)
- return 0;
-
- /*
- * This can be called early. Use CPUID directly instead of
- * relying on cpuinfo_x86 which may not be fully initialized.
- * The PII does not have MSR_IA32_PLATFORM_ID. Everything
- * before _it_ has no microcode (for Linux at least).
- */
- if (intel_cpuid_vfm() <= INTEL_PENTIUM_II_KLAMATH)
- return 0;
-
- /* get processor flags from MSR 0x17 */
- native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
-
- return (val[1] >> 18) & 7;
-}
-
void intel_collect_cpu_info(struct cpu_signature *sig)
{
sig->sig = cpuid_eax(1);