* [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
@ 2021-09-01 8:40 Chenyi Qiang
2021-09-17 2:52 ` Chenyi Qiang
2021-10-19 17:05 ` Sean Christopherson
0 siblings, 2 replies; 5+ messages in thread
From: Chenyi Qiang @ 2021-09-01 8:40 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Tony Luck,
Fenghua Yu, Xiaoyao Li
Cc: Chenyi Qiang, linux-kernel, x86
It's possible that BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT, or
this kernel has been kexec'd from a kernel that enabled bus lock
detection.
Disable bus lock detection explicitly if not wanted.
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/intel.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 8321c43554a1..38dda04d9342 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -1152,22 +1152,23 @@ static void bus_lock_init(void)
{
u64 val;
- /*
- * Warn and fatal are handled by #AC for split lock if #AC for
- * split lock is supported.
- */
- if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) ||
- (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
- (sld_state == sld_warn || sld_state == sld_fatal)) ||
- sld_state == sld_off)
+ if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
return;
- /*
- * Enable #DB for bus lock. All bus locks are handled in #DB except
- * split locks are handled in #AC in the fatal case.
- */
rdmsrl(MSR_IA32_DEBUGCTLMSR, val);
- val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
+
+ if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
+ (sld_state == sld_warn || sld_state == sld_fatal)) ||
+ sld_state == sld_off) {
+ /*
+ * Warn and fatal are handled by #AC for split lock if #AC for
+ * split lock is supported.
+ */
+ val &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
+ } else {
+ val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
+ }
+
wrmsrl(MSR_IA32_DEBUGCTLMSR, val);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
2021-09-01 8:40 [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero Chenyi Qiang
@ 2021-09-17 2:52 ` Chenyi Qiang
2021-10-19 7:34 ` Chenyi Qiang
2021-10-19 17:05 ` Sean Christopherson
1 sibling, 1 reply; 5+ messages in thread
From: Chenyi Qiang @ 2021-09-17 2:52 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Tony Luck,
Fenghua Yu, Xiaoyao Li
Cc: linux-kernel, x86
Kindly ping for this minor change.
Thanks
Chenyi
On 9/1/2021 4:40 PM, Chenyi Qiang wrote:
> It's possible that BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT, or
> this kernel has been kexec'd from a kernel that enabled bus lock
> detection.
>
> Disable bus lock detection explicitly if not wanted.
>
> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> ---
> arch/x86/kernel/cpu/intel.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
> index 8321c43554a1..38dda04d9342 100644
> --- a/arch/x86/kernel/cpu/intel.c
> +++ b/arch/x86/kernel/cpu/intel.c
> @@ -1152,22 +1152,23 @@ static void bus_lock_init(void)
> {
> u64 val;
>
> - /*
> - * Warn and fatal are handled by #AC for split lock if #AC for
> - * split lock is supported.
> - */
> - if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) ||
> - (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
> - (sld_state == sld_warn || sld_state == sld_fatal)) ||
> - sld_state == sld_off)
> + if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
> return;
>
> - /*
> - * Enable #DB for bus lock. All bus locks are handled in #DB except
> - * split locks are handled in #AC in the fatal case.
> - */
> rdmsrl(MSR_IA32_DEBUGCTLMSR, val);
> - val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
> +
> + if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
> + (sld_state == sld_warn || sld_state == sld_fatal)) ||
> + sld_state == sld_off) {
> + /*
> + * Warn and fatal are handled by #AC for split lock if #AC for
> + * split lock is supported.
> + */
> + val &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
> + } else {
> + val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
> + }
> +
> wrmsrl(MSR_IA32_DEBUGCTLMSR, val);
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
2021-09-17 2:52 ` Chenyi Qiang
@ 2021-10-19 7:34 ` Chenyi Qiang
0 siblings, 0 replies; 5+ messages in thread
From: Chenyi Qiang @ 2021-10-19 7:34 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Tony Luck,
Fenghua Yu, Xiaoyao Li
Cc: linux-kernel, x86
Reminder for this minor fix.
On 9/17/2021 10:52 AM, Chenyi Qiang wrote:
> Kindly ping for this minor change.
>
> Thanks
> Chenyi
>
> On 9/1/2021 4:40 PM, Chenyi Qiang wrote:
>> It's possible that BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT, or
>> this kernel has been kexec'd from a kernel that enabled bus lock
>> detection.
>>
>> Disable bus lock detection explicitly if not wanted.
>>
>> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
>> Reviewed-by: Tony Luck <tony.luck@intel.com>
>> ---
>> arch/x86/kernel/cpu/intel.c | 27 ++++++++++++++-------------
>> 1 file changed, 14 insertions(+), 13 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
>> index 8321c43554a1..38dda04d9342 100644
>> --- a/arch/x86/kernel/cpu/intel.c
>> +++ b/arch/x86/kernel/cpu/intel.c
>> @@ -1152,22 +1152,23 @@ static void bus_lock_init(void)
>> {
>> u64 val;
>> - /*
>> - * Warn and fatal are handled by #AC for split lock if #AC for
>> - * split lock is supported.
>> - */
>> - if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT) ||
>> - (boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
>> - (sld_state == sld_warn || sld_state == sld_fatal)) ||
>> - sld_state == sld_off)
>> + if (!boot_cpu_has(X86_FEATURE_BUS_LOCK_DETECT))
>> return;
>> - /*
>> - * Enable #DB for bus lock. All bus locks are handled in #DB except
>> - * split locks are handled in #AC in the fatal case.
>> - */
>> rdmsrl(MSR_IA32_DEBUGCTLMSR, val);
>> - val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
>> +
>> + if ((boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT) &&
>> + (sld_state == sld_warn || sld_state == sld_fatal)) ||
>> + sld_state == sld_off) {
>> + /*
>> + * Warn and fatal are handled by #AC for split lock if #AC for
>> + * split lock is supported.
>> + */
>> + val &= ~DEBUGCTLMSR_BUS_LOCK_DETECT;
>> + } else {
>> + val |= DEBUGCTLMSR_BUS_LOCK_DETECT;
>> + }
>> +
>> wrmsrl(MSR_IA32_DEBUGCTLMSR, val);
>> }
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
2021-09-01 8:40 [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero Chenyi Qiang
2021-09-17 2:52 ` Chenyi Qiang
@ 2021-10-19 17:05 ` Sean Christopherson
2021-10-25 6:14 ` Chenyi Qiang
1 sibling, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2021-10-19 17:05 UTC (permalink / raw)
To: Chenyi Qiang
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Tony Luck,
Fenghua Yu, Xiaoyao Li, linux-kernel, x86
On Wed, Sep 01, 2021, Chenyi Qiang wrote:
> It's possible that BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT, or
> this kernel has been kexec'd from a kernel that enabled bus lock
> detection.
This feels like the kernel should explicitly zero out the entire MSR somewhere
in the generic boot flow. E.g. something like this somewhere.
#ifndef CONFIG_X86_DEBUGCTLMSR
if (boot_cpu_data.x86 < 6)
return;
#endifa
wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero
2021-10-19 17:05 ` Sean Christopherson
@ 2021-10-25 6:14 ` Chenyi Qiang
0 siblings, 0 replies; 5+ messages in thread
From: Chenyi Qiang @ 2021-10-25 6:14 UTC (permalink / raw)
To: Sean Christopherson
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Tony Luck,
Fenghua Yu, Xiaoyao Li, linux-kernel, x86
On 10/20/2021 1:05 AM, Sean Christopherson wrote:
> On Wed, Sep 01, 2021, Chenyi Qiang wrote:
>> It's possible that BIOS/firmware has set DEBUGCTLMSR_BUS_LOCK_DETECT, or
>> this kernel has been kexec'd from a kernel that enabled bus lock
>> detection.
>
> This feels like the kernel should explicitly zero out the entire MSR somewhere
> in the generic boot flow. E.g. something like this somewhere.
>
Yes. Meanwhile, I think kernel code prefers to explicitly set/clear the
control bit according to the parameter. Maybe both changes should be
applied.
> #ifndef CONFIG_X86_DEBUGCTLMSR
> if (boot_cpu_data.x86 < 6)
> return;
> #endifa
>
> wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-25 6:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 8:40 [PATCH] x86/bus_lock: Don't assume the init value of DEBUGCTLMSR.BUS_LOCK_DETECT to be zero Chenyi Qiang
2021-09-17 2:52 ` Chenyi Qiang
2021-10-19 7:34 ` Chenyi Qiang
2021-10-19 17:05 ` Sean Christopherson
2021-10-25 6:14 ` Chenyi Qiang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.