Re: [PATCH v2] x86/cpu: Skip reading MSR_IA32_PLATFORM_ID in virtualized environment

From: Borislav Petkov

Date: Mon May 11 2026 - 06:08:44 EST


On Thu, Apr 30, 2026 at 10:09:53AM +0800, Binbin Wu wrote:
> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
> index 37ac4afe0972..1bc0c350726c 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -147,6 +147,10 @@ u32 intel_get_platform_id(void)
> if (intel_cpuid_vfm() <= INTEL_PENTIUM_II_KLAMATH)
> return 0;
>
> + /* Don't try to read microcode bits when virtualized. */
> + if (cpuid_ecx(1) & BIT(X86_FEATURE_HYPERVISOR & 0x1f))
> + return 0;
> +
> /* get processor flags from MSR 0x17 */
> native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
>
>
> base-commit: 9974969c14031a097d6b45bcb7a06bb4aa525c40
> --

Does that work too?

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 18d2eff7a4b7..1b24de94bdd5 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -139,6 +139,9 @@ u32 intel_get_platform_id(void)
{
unsigned int val[2];

+ if (hypervisor_present)
+ return 0;
+
/*
* This can be called early. Use CPUID directly instead of
* relying on cpuinfo_x86 which may not be fully initialized.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette