[PATCH v5 33/35] x86/cpu: Rescan CPUID table after unlocking full CPUID range
"Ahmed S. Darwish" <[email protected]> Fri, 5 Sep 2025 14:15:13 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Intel CPUs have an MSR bit to limit CPUID enumeration to leaf two, which
can be set by old BIOSen before booting Linux.
Rescan the CPUID table after unlocking the CPU's full CPUID range. Use
parsed CPUID(0x0) access, instead of a direct CPUID query, afterwards.
References: 066941bd4eeb ("x86: unmask CPUID levels on Intel CPUs")
References: 0c2f6d04619e ("x86/topology/intel: Unlock CPUID before evaluating anything")
Signed-off-by: Ahmed S. Darwish <[email protected]>
---
arch/x86/kernel/cpu/intel.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index dd284ece0de0..ffaba5a378f5 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -192,11 +192,14 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
return;
/*
- * The BIOS can have limited CPUID to leaf 2, which breaks feature
- * enumeration. Unlock it and update the maximum leaf info.
+ * Intel CPUs have an MSR bit to limit CPUID enumeration to CPUID(0x2),
+ * which can be set by old BIOSes before booting Linux. If enabled,
+ * unlock the CPU's full CPUID range and rescan its CPUID table.
*/
- if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT) > 0)
- c->cpuid_level = cpuid_eax(0);
+ if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT) > 0) {
+ cpuid_parser_scan_cpu(c);
+ c->cpuid_level = cpuid_leaf(c, 0x0)->max_std_leaf;
+ }
}
static void early_init_intel(struct cpuinfo_x86 *c)
--
2.50.1