Re: [PATCH 2/2] x86/cpu: Move intel_get_platform_id() to cpu/intel.c

From: Binbin Wu

Date: Thu May 14 2026 - 02:25:52 EST




On 5/14/2026 4:07 AM, Borislav Petkov wrote:
> It is not only used in the microcode loader anymore and the platform ID
> is cached in the cpuindo_x86 structure so move the getter to

Typo:
cpuindo_x86 -> cpuinfo_x86

> Intel CPU-specific code.
>
> No functional changes.
>
> Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>

Reviewed-by: Binbin Wu <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 3c317d155771..8b41f26f003b 100644
> --- a/arch/x86/include/asm/microcode.h
> +++ b/arch/x86/include/asm/microcode.h
> @@ -61,8 +61,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 67dd932305db..1a68a955863d 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -237,6 +237,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 f28c0efb7c8f..3473b89e6907 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 a4c0a0cf928b..f55ff81682e5 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -120,42 +120,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);