Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Binbin Wu <binbin.wu@linux.intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	kvm@vger.kernel.org, dave.hansen@intel.com, seanjc@google.com,
	pbonzini@redhat.com, kas@kernel.org, rick.p.edgecombe@intel.com,
	vishal.l.verma@intel.com, xiaoyao.li@intel.com,
	chao.gao@intel.com
Subject: Re: [PATCH 2/2] x86/cpu: Move intel_get_platform_id() to cpu/intel.c
Date: Thu, 14 May 2026 14:25:32 +0800	[thread overview]
Message-ID: <7cb5e6ca-cddf-4fea-8d72-c73ed0563fee@linux.intel.com> (raw)
In-Reply-To: <20260513200713.GNagTZ8QI_BHBeZXXr@fat_crate.local>



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@alien8.de>

Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>

> ---
>  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);


  reply	other threads:[~2026-05-14  6:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  2:09 [PATCH v2] x86/cpu: Skip reading MSR_IA32_PLATFORM_ID in virtualized environment Binbin Wu
2026-05-11  9:38 ` Kiryl Shutsemau
2026-05-11 10:04 ` Borislav Petkov
2026-05-12  1:57   ` Binbin Wu
2026-05-13 10:14     ` Borislav Petkov
2026-05-13 11:02       ` Binbin Wu
2026-05-13 11:08         ` Borislav Petkov
2026-05-13 12:20           ` Binbin Wu
2026-05-13 13:11             ` Borislav Petkov
2026-05-13 14:41       ` Binbin Wu
2026-05-13 20:00         ` Borislav Petkov
2026-05-13 20:06           ` [PATCH 1/2] x86/microcode: Do not access MSR_IA32_PLATFORM_ID when running as a guest Borislav Petkov
2026-05-14  6:22             ` Binbin Wu
2026-05-14 10:40               ` Borislav Petkov
2026-05-14 12:38             ` Xiaoyao Li
2026-05-13 20:07           ` [PATCH 2/2] x86/cpu: Move intel_get_platform_id() to cpu/intel.c Borislav Petkov
2026-05-14  6:25             ` Binbin Wu [this message]
2026-05-14 12:39             ` Xiaoyao Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cb5e6ca-cddf-4fea-8d72-c73ed0563fee@linux.intel.com \
    --to=binbin.wu@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=vishal.l.verma@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox