mirror-linux/arch/x86/kernel/cpu
Borislav Petkov cda64169ba x86/microcode: Do not access MSR_IA32_PLATFORM_ID when running as a guest
Patch in Fixes: causes the usual:

  unchecked MSR access error: RDMSR from 0x17 at ... (intel_get_platform_id)
  Call Trace:
   early_init_intel
   early_cpu_init
   setup_arch
   _printk
   start_kernel
   x86_64_start_reservations
   x86_64_start_kernel
   common_startup_64

because the kernel is booted in a guest.

In order to avoid it, this MSR access needs to be prevented when running
virtualized. That is usually done by checking X86_FEATURE_HYPERVISOR but
for this particular case it is too early yet.

The platform ID needs to be read as early as when microcode is loaded on
the BSP:

  load_ucode_bsp ... -> get_microcode_blob ... -> intel_find_matching_signature

and by that time, CPUID leafs haven't been parsed yet.

The microcode loader already has logic to check early whether the kernel
is running virtualized so make that globally available to arch/x86/. The
query whether running virtualized is getting more and more prominent in
recent times so might as well make it an arch-global var which the rest
of the code can use.

Fixes: d8630b67ca ("x86/cpu: Add platform ID to CPU info structure")
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Tested-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://lore.kernel.org/all/20260430020953.1405535-1-binbin.wu@linux.intel.com
2026-05-26 13:36:23 -07:00
..
mce x86/mce: Restore MCA polling interval halving 2026-05-13 17:38:35 +02:00
microcode x86/microcode: Do not access MSR_IA32_PLATFORM_ID when running as a guest 2026-05-26 13:36:23 -07:00
mtrr x86/mtrr: Use kstrtoul() in parse_mtrr_spare_reg() 2026-03-02 17:25:31 +01:00
resctrl x86/resctrl: Fix SNC detection 2026-03-04 16:35:09 +01:00
sgx mm: rename zap_vma_ptes() to zap_special_vma_range() 2026-04-05 13:53:15 -07:00
.gitignore
Makefile x86/cpu: Detect FreeBSD Bhyve hypervisor 2025-09-15 14:06:44 +02:00
acrn.c
amd.c x86/CPU/AMD: Prevent improper isolation of shared resources in Zen2's op cache 2026-05-11 20:06:36 -07:00
amd_cache_disable.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
aperfmperf.c syscore: Pass context data to callbacks 2025-11-14 10:01:52 +01:00
bhyve.c x86/cpu: Detect FreeBSD Bhyve hypervisor 2025-09-15 14:06:44 +02:00
bugs.c x86/paravirt: Remove not needed includes of paravirt.h 2026-01-12 11:26:52 +01:00
bus_lock.c x86/split_lock: Don't warn about unknown split_lock_detect parameter 2026-04-05 23:12:40 +02:00
cacheinfo.c x86/cpu/cacheinfo: Simplify cacheinfo_amd_init_llc_id() using _cpuid4_info 2025-09-17 11:22:40 +02:00
centaur.c * VDSO rework and cleanups 2026-02-10 19:34:26 -08:00
common.c Arm: 2026-04-17 07:18:03 -07:00
cpu.h x86/tsx: Make tsx_ctrl_state static 2025-10-24 18:24:42 +02:00
cpuid-deps.c x86/mm: Disable broadcast TLB flush when PCID is disabled 2026-05-20 14:15:07 -07:00
cpuid_0x2_table.c x86/cpu: Consolidate CPUID leaf 0x2 tables 2025-03-25 10:23:04 +01:00
cyrix.c x86/cpu: Drop vestigial PBE logic in AMD/Hygon/Centaur/Cyrix 2025-12-14 09:57:13 +01:00
debugfs.c x86/cpu: Prefix hexadecimal values with 0x in cpu_debug_show() 2025-02-27 13:26:53 +01:00
feat_ctl.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
hygon.c x86/cpu: Drop vestigial PBE logic in AMD/Hygon/Centaur/Cyrix 2025-12-14 09:57:13 +01:00
hypervisor.c x86/cpu: Detect FreeBSD Bhyve hypervisor 2025-09-15 14:06:44 +02:00
intel.c x86/cpu: Add platform ID to CPU info structure 2026-03-05 12:25:32 -08:00
intel_epb.c syscore: Pass context data to callbacks 2025-11-14 10:01:52 +01:00
match.c x86/cpu: Add platform ID to CPU matching structure 2026-03-05 12:25:38 -08:00
mkcapflags.sh x86/cpufeatures: Flip the /proc/cpuinfo appearance logic 2024-06-20 21:04:22 +02:00
mshyperv.c hyperv-next for v7.1 2026-04-22 09:50:46 -07:00
perfctr-watchdog.c
powerflags.c
proc.c cpufreq: Allow arch_freq_get_on_cpu to return an error 2025-02-17 18:09:20 +00:00
rdrand.c
scattered.c x86/cpufeatures: Add AMD CPPC Performance Priority feature. 2026-04-02 11:28:21 -05:00
topology.c x86/topology: use bitmap_weight_from() 2026-03-23 13:33:51 -04:00
topology.h
topology_amd.c x86/cpu/topology: Define AMD64_CPUID_EXT_FEAT MSR 2025-09-17 11:24:33 +02:00
topology_common.c x86/cpu/topology: Consolidate AMD and Hygon cases in parse_topology() 2026-03-23 16:25:26 +01:00
topology_ext.c x86/cpu/topology: Add support for the AMD 0x80000026 leaf 2024-03-22 11:22:14 +01:00
transmeta.c
tsx.c x86/tsx: Get the tsx= command line parameter with early_param() 2025-10-24 18:35:17 +02:00
umc.c
umwait.c syscore: Pass context data to callbacks 2025-11-14 10:01:52 +01:00
vmware.c x86/paravirt: Replace io_delay() hook with a bool 2026-03-22 08:43:05 +01:00
vortex.c
zhaoxin.c x86/cpufeature: Replace X86_FEATURE_SYSENTER32 with X86_FEATURE_SYSFAST32 2026-01-13 16:37:58 -08:00