Skip to content

Commit a693b9c

Browse files
committed
Merge tag 'x86-urgent-2024-06-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Miscellaneous topology parsing fixes: - Fix topology parsing regression on older CPUs in the new AMD/Hygon parser - Fix boot crash on odd Intel Quark and similar CPUs that do not fill out cpuinfo_x86::x86_clflush_size and zero out cpuinfo_x86::x86_cache_alignment as a result. Provide 32 bytes as a general fallback value. - Fix topology enumeration on certain rare CPUs where the BIOS locks certain CPUID leaves and the kernel unlocked them late, which broke with the new topology parsing code. Factor out this unlocking logic and move it earlier in the parsing sequence" * tag 'x86-urgent-2024-06-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/topology/intel: Unlock CPUID before evaluating anything x86/cpu: Provide default cache line size if not enumerated x86/topology/amd: Evaluate SMT in CPUID leaf 0x8000001e only on family 0x17 and greater
2 parents 3fca58f + 0c2f6d0 commit a693b9c

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ void get_cpu_address_sizes(struct cpuinfo_x86 *c)
10751075

10761076
c->x86_virt_bits = (eax >> 8) & 0xff;
10771077
c->x86_phys_bits = eax & 0xff;
1078+
1079+
/* Provide a sane default if not enumerated: */
1080+
if (!c->x86_clflush_size)
1081+
c->x86_clflush_size = 32;
10781082
}
10791083

10801084
c->x86_cache_bits = c->x86_phys_bits;
@@ -1585,6 +1589,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15851589
if (have_cpuid_p()) {
15861590
cpu_detect(c);
15871591
get_cpu_vendor(c);
1592+
intel_unlock_cpuid_leafs(c);
15881593
get_cpu_cap(c);
15891594
setup_force_cpu_cap(X86_FEATURE_CPUID);
15901595
get_cpu_address_sizes(c);
@@ -1744,7 +1749,7 @@ static void generic_identify(struct cpuinfo_x86 *c)
17441749
cpu_detect(c);
17451750

17461751
get_cpu_vendor(c);
1747-
1752+
intel_unlock_cpuid_leafs(c);
17481753
get_cpu_cap(c);
17491754

17501755
get_cpu_address_sizes(c);

arch/x86/kernel/cpu/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state;
6161

6262
extern void __init tsx_init(void);
6363
void tsx_ap_init(void);
64+
void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c);
6465
#else
6566
static inline void tsx_init(void) { }
6667
static inline void tsx_ap_init(void) { }
68+
static inline void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c) { }
6769
#endif /* CONFIG_CPU_SUP_INTEL */
6870

6971
extern void init_spectral_chicken(struct cpuinfo_x86 *c);

arch/x86/kernel/cpu/intel.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,26 @@ static void detect_tme_early(struct cpuinfo_x86 *c)
269269
c->x86_phys_bits -= keyid_bits;
270270
}
271271

272+
void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c)
273+
{
274+
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
275+
return;
276+
277+
if (c->x86 < 6 || (c->x86 == 6 && c->x86_model < 0xd))
278+
return;
279+
280+
/*
281+
* The BIOS can have limited CPUID to leaf 2, which breaks feature
282+
* enumeration. Unlock it and update the maximum leaf info.
283+
*/
284+
if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT) > 0)
285+
c->cpuid_level = cpuid_eax(0);
286+
}
287+
272288
static void early_init_intel(struct cpuinfo_x86 *c)
273289
{
274290
u64 misc_enable;
275291

276-
/* Unmask CPUID levels if masked: */
277-
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
278-
if (msr_clear_bit(MSR_IA32_MISC_ENABLE,
279-
MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT) > 0) {
280-
c->cpuid_level = cpuid_eax(0);
281-
get_cpu_cap(c);
282-
}
283-
}
284-
285292
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
286293
(c->x86 == 0x6 && c->x86_model >= 0x0e))
287294
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool has_topoext)
8484

8585
/*
8686
* If leaf 0xb is available, then the domain shifts are set
87-
* already and nothing to do here.
87+
* already and nothing to do here. Only valid for family >= 0x17.
8888
*/
89-
if (!has_topoext) {
89+
if (!has_topoext && tscan->c->x86 >= 0x17) {
9090
/*
9191
* Leaf 0x80000008 set the CORE domain shift already.
9292
* Update the SMT domain, but do not propagate it.

0 commit comments

Comments
 (0)