Skip to content

Commit ffa6482

Browse files
QiangcyIngo Molnar
authored andcommitted
x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
It's possible that this kernel has been kexec'd from a kernel that enabled bus lock detection, or (hypothetically) BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT. Disable bus lock detection explicitly if not wanted. Fixes: ebb1064 ("x86/traps: Handle #DB for bus lock") Signed-off-by: Chenyi Qiang <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Tony Luck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9de1f9c commit ffa6482

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

arch/x86/kernel/cpu/intel.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,22 +1216,23 @@ static void bus_lock_init(void)
12161216
{
12171217
u64 val;
12181218

1219-
/*
1220-
* Warn and fatal are handled by #AC for split lock if #AC for
1221-
* split lock is supported.
1222-
*/
1223-
if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) ||
1224-
(boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
1225-
(sld_state == sld_warn || sld_state == sld_fatal)) ||
1226-
sld_state == sld_off)
1219+
if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
12271220
return;
12281221

1229-
/*
1230-
* Enable #DB for bus lock. All bus locks are handled in #DB except
1231-
* split locks are handled in #AC in the fatal case.
1232-
*/
12331222
rdmsrl(MSR_IA32_DEBUGCTLMSR, val);
1234-
val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
1223+
1224+
if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
1225+
(sld_state == sld_warn || sld_state == sld_fatal)) ||
1226+
sld_state == sld_off) {
1227+
/*
1228+
* Warn and fatal are handled by #AC for split lock if #AC for
1229+
* split lock is supported.
1230+
*/
1231+
val &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
1232+
} else {
1233+
val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
1234+
}
1235+
12351236
wrmsrl(MSR_IA32_DEBUGCTLMSR, val);
12361237
}
12371238

0 commit comments

Comments
 (0)