Skip to content

Commit 48fd5b5

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/split_lock: Bits in IA32_CORE_CAPABILITIES are not architectural
The Intel Software Developers' Manual erroneously listed bit 5 of the IA32_CORE_CAPABILITIES register as an architectural feature. It is not. Features enumerated by IA32_CORE_CAPABILITIES are model specific and implementation details may vary in different cpu models. Thus it is only safe to trust features after checking the CPU model. Icelake client and server models are known to implement the split lock detect feature even though they don't enumerate IA32_CORE_CAPABILITIES [ tglx: Use switch() for readability and massage comments ] Fixes: 6650cdd ("x86/split_lock: Enable split lock detection by kernel") Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 9fe0450 commit 48fd5b5

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

arch/x86/kernel/cpu/intel.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,10 +1120,17 @@ void switch_to_sld(unsigned long tifn)
11201120
}
11211121

11221122
/*
1123-
* The following processors have the split lock detection feature. But
1124-
* since they don't have the IA32_CORE_CAPABILITIES MSR, the feature cannot
1125-
* be enumerated. Enable it by family and model matching on these
1126-
* processors.
1123+
* Bits in the IA32_CORE_CAPABILITIES are not architectural, so they should
1124+
* only be trusted if it is confirmed that a CPU model implements a
1125+
* specific feature at a particular bit position.
1126+
*
1127+
* The possible driver data field values:
1128+
*
1129+
* - 0: CPU models that are known to have the per-core split-lock detection
1130+
* feature even though they do not enumerate IA32_CORE_CAPABILITIES.
1131+
*
1132+
* - 1: CPU models which may enumerate IA32_CORE_CAPABILITIES and if so use
1133+
* bit 5 to enumerate the per-core split-lock detection feature.
11271134
*/
11281135
static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
11291136
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0),
@@ -1133,19 +1140,29 @@ static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
11331140

11341141
void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c)
11351142
{
1136-
u64 ia32_core_caps = 0;
1143+
const struct x86_cpu_id *m;
1144+
u64 ia32_core_caps;
1145+
1146+
if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
1147+
return;
11371148

1138-
if (c->x86_vendor != X86_VENDOR_INTEL)
1149+
m = x86_match_cpu(split_lock_cpu_ids);
1150+
if (!m)
11391151
return;
1140-
if (cpu_has(c, X86_FEATURE_CORE_CAPABILITIES)) {
1141-
/* Enumerate features reported in IA32_CORE_CAPABILITIES MSR. */
1152+
1153+
switch (m->driver_data) {
1154+
case 0:
1155+
break;
1156+
case 1:
1157+
if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
1158+
return;
11421159
rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
1143-
} else if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
1144-
/* Enumerate split lock detection by family and model. */
1145-
if (x86_match_cpu(split_lock_cpu_ids))
1146-
ia32_core_caps |= MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT;
1160+
if (!(ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT))
1161+
return;
1162+
break;
1163+
default:
1164+
return;
11471165
}
11481166

1149-
if (ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT)
1150-
split_lock_setup();
1167+
split_lock_setup();
11511168
}

0 commit comments

Comments
 (0)