Commit 48fd5b5e authored by Tony Luck's avatar Tony Luck Committed by Thomas Gleixner

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: 6650cdd9 ("x86/split_lock: Enable split lock detection by kernel")
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200416205754.21177-3-tony.luck@intel.com
parent 9fe04507
...@@ -1120,10 +1120,17 @@ void switch_to_sld(unsigned long tifn) ...@@ -1120,10 +1120,17 @@ void switch_to_sld(unsigned long tifn)
} }
/* /*
* The following processors have the split lock detection feature. But * Bits in the IA32_CORE_CAPABILITIES are not architectural, so they should
* since they don't have the IA32_CORE_CAPABILITIES MSR, the feature cannot * only be trusted if it is confirmed that a CPU model implements a
* be enumerated. Enable it by family and model matching on these * specific feature at a particular bit position.
* processors. *
* The possible driver data field values:
*
* - 0: CPU models that are known to have the per-core split-lock detection
* feature even though they do not enumerate IA32_CORE_CAPABILITIES.
*
* - 1: CPU models which may enumerate IA32_CORE_CAPABILITIES and if so use
* bit 5 to enumerate the per-core split-lock detection feature.
*/ */
static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = { static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0), X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0),
...@@ -1133,19 +1140,29 @@ static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = { ...@@ -1133,19 +1140,29 @@ static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c) void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c)
{ {
u64 ia32_core_caps = 0; const struct x86_cpu_id *m;
u64 ia32_core_caps;
if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
return;
if (c->x86_vendor != X86_VENDOR_INTEL) m = x86_match_cpu(split_lock_cpu_ids);
if (!m)
return; return;
if (cpu_has(c, X86_FEATURE_CORE_CAPABILITIES)) {
/* Enumerate features reported in IA32_CORE_CAPABILITIES MSR. */ switch (m->driver_data) {
case 0:
break;
case 1:
if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
return;
rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps); rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
} else if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) { if (!(ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT))
/* Enumerate split lock detection by family and model. */ return;
if (x86_match_cpu(split_lock_cpu_ids)) break;
ia32_core_caps |= MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT; default:
return;
} }
if (ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT) split_lock_setup();
split_lock_setup();
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment