All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 0/6] Enable split lock detection for real time and debug
@ 2019-11-21  0:53 Fenghua Yu
  2019-11-21  0:53 ` [PATCH v10 1/6] x86/msr-index: Add two new MSRs Fenghua Yu
                   ` (5 more replies)
  0 siblings, 6 replies; 145+ messages in thread
From: Fenghua Yu @ 2019-11-21  0:53 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H Peter Anvin,
	Peter Zijlstra, Tony Luck, Ashok Raj, Ravi V Shankar
  Cc: linux-kernel, x86, Fenghua Yu

This is a stripped down version of the patch series.

Goals:
======
1) To provide a boot time option (default off) to enable split lock
   detection.
2) To ensure that kernel crashes cleanly if OS code executes an
   atomic instruction that crosses cache lines.
3) Enable for some existing CPUs that do not provide CPUID enumeration
   of the feature together with architectural enumeration for future CPUs.

Non-goals:
==========
1) Fancy methods to have the kernel recover/continue
2) Selective enabling (it is either "on" or "off").
3) /sys files to enable/disable at run time
4) Virtualization support (guests just SIGBUS)

Access to misaligned data across two cache lines in an atomic instruction
(a.k.a split lock) takes over 1000 extra cycles compared to an atomic
access within one cache line. Split lock degrades performance not only
on the current CPU but also on the whole system because during split lock
the instruction holds bus lock and prohibits any other memory access on
the bus.

Some real time environments cannot meet deadlines if the processor
is handling split locks.

On Intel Tremont and future processors, split lock is detected by
triggering #AC exception after setting bit 29 in the TEST_CTRL
MSR (0x33) [1].

When split lock detection is enabled, if split lock happens in the
kernel, the kernel panics. Otherwise, the user process is killed by
SIGBUS.

To get a split lock free real time system, kernel and user application
developers need to enable split lock detection and find and fix all
possible split lock issues.

The split lock detection is disabled by default because potential split
lock issues can cause kernel panic or kill user processes. It is enabled
only for real time or debug purpose through a kernel parameter
"split_lock_detect".

Enabling split lock detection already finds split lock issues in atomic
bit operations and some of the blocking issues are fixed in the tip tree:
https://lore.kernel.org/lkml/157384597983.12247.8995835529288193538.tip-bot2@tip-bot2/
https://lore.kernel.org/lkml/157384597947.12247.7200239597382357556.tip-bot2@tip-bot2/

[1] Please check the latest Intel 64 and IA-32 Architectures Software
Developer's Manual for more detailed information on the TEST_CTRL MSR
and the split lock detection bit and how to enumerate the feature.

==Changelog==
v10:
- Reduce the scope of this patch set to real time and debug usage only
  because this usage is requested by customers and is easier to be
  implemented than enabling the feature by default:
  1. Disable split lock detection by default and enable it only for
     real time or debug purpose.
  2. Kernel panics or kill user process in #AC for split lock
  3. Drop KVM and debugfs knobs.

v9:
Address Thomas Gleixner's comments:
- wrmsr() in split_lock_update_msr() to spare RMW
- Print warnings in atomic bit operations xxx_bit() if the address is
unaligned to unsigned long.
- When host enables split lock detection, forcing it enabled for guest.
- Using the msr_test_ctl_mask to decide which bits need to be switched in
atomic_switch_msr_test_ctl().
- Warn if addr is unaligned to unsigned long in atomic ops xxx_bit().

Address Ingo Molnar's comments:
- Follow right MSR register and bits naming convention
- Use right naming convention for variables and functions
- Use split_lock_debug for atomic opertions of WARN_ONCE in #AC handler
and split_lock_detect_wr();
- Move the sysfs interface to debugfs interface /sys/kernel/debug/x86/
split_lock_detect

Other fixes:
- update vmx->msr_test_ctl_mask when changing MSR_IA32_CORE_CAP.
- Support resume from suspend/hibernation

- The split lock fix patch (#0003) for wlcore wireless driver is
upstreamed. So remove the patch from this patch set.

v8:
Address issues pointed out by Thomas Gleixner:
- Remove all "clearcpuid=" related patches.
- Add kernel parameter "nosplit_lock_detect" patch.
- Merge definition and initialization of msr_test_ctl_cache into #AC
  handling patch which first uses the variable.
- Add justification for the sysfs knob and combine function and doc
  patches into one patch 0015.
- A few other adjustments.

v7:
- Add per cpu variable to cach MSR TEST_CTL. Suggested by Thomas Gleixner.
- Change a few other changes including locking, simplifying code, work
flow, KVM fixes, etc. Suggested by Thomas Gleixner.
- Fix KVM issues pointed out by Sean Christopherson.

v6:
- Fix #AC handler issues pointed out by Dave Hansen
- Add doc for the sysfs interface pointed out by Dave Hansen
- Fix a lock issue around wrmsr during split lock init, pointed out by Dave
  Hansen
- Update descriptions and comments suggested by Dave Hansen
- Fix __le32 issue in wlcore raised by Kalle Valo
- Add feature enumeration based on family/model/stepping for Icelake mobile

v5:
- Fix wlcore issue from Paolo Bonzini
- Fix b44 issue from Peter Zijlstra
- Change init sequence by Dave Hansen
- Fix KVM issues from Paolo Bonzini
- Re-order patch sequence

v4:
- Remove "setcpuid=" option
- Enable IA32_CORE_CAPABILITY enumeration for split lock
- Handle CPUID faulting by Peter Zijlstra
- Enable /sys interface to enable/disable split lock detection

v3:
- Handle split lock as suggested by Thomas Gleixner.
- Fix a few potential spit lock issues suggested by Thomas Gleixner.
- Support kernel option "setcpuid=" suggested by Dave Hanson and Thomas
Gleixner.
- Support flag string in "clearcpuid=" suggested by Dave Hanson and
Thomas Gleixner.

v2:
- Remove code that handles split lock issue in firmware and fix
x86_capability issue mainly based on comments from Thomas Gleixner and
Peter Zijlstra.

In previous version:
Comments from Dave Hansen:
- Enumerate feature in X86_FEATURE_SPLIT_LOCK_AC
- Separate #AC handler from do_error_trap
- Use CONFIG to configure inherit BIOS setting, enable, or disable split
  lock. Remove kernel parameter "split_lock_ac="
- Change config interface to debugfs from sysfs
- Fix a few bisectable issues
- Other changes.

Comment from Tony Luck and Dave Hansen:
- Dump right information in #AC handler

Comment from Alan Cox and Dave Hansen:
- Description of split lock in patch 0

Others:
- Remove tracing because we can trace split lock in existing
  sq_misc.split_lock.
- Add CONFIG to configure either panic or re-execute faulting instruction
  for split lock in kernel.
- other minor changes.

Fenghua Yu (6):
  x86/msr-index: Add two new MSRs
  x86/cpufeatures: Enumerate the IA32_CORE_CAPABILITIES MSR
  x86/split_lock: Enumerate split lock detection by the
    IA32_CORE_CAPABILITIES MSR
  x86/split_lock: Enumerate split lock detection if the
    IA32_CORE_CAPABILITIES MSR is not supported
  x86/split_lock: Handle #AC exception for split lock
  x86/split_lock: Enable split lock detection by kernel parameter

 .../admin-guide/kernel-parameters.txt         | 10 +++
 arch/x86/include/asm/cpu.h                    |  5 ++
 arch/x86/include/asm/cpufeatures.h            |  2 +
 arch/x86/include/asm/msr-index.h              |  8 +++
 arch/x86/include/asm/traps.h                  |  3 +
 arch/x86/kernel/cpu/common.c                  |  2 +
 arch/x86/kernel/cpu/intel.c                   | 72 +++++++++++++++++++
 arch/x86/kernel/traps.c                       | 22 +++++-
 8 files changed, 123 insertions(+), 1 deletion(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 145+ messages in thread

end of thread, other threads:[~2020-03-03 19:22 UTC | newest]

Thread overview: 145+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21  0:53 [PATCH v10 0/6] Enable split lock detection for real time and debug Fenghua Yu
2019-11-21  0:53 ` [PATCH v10 1/6] x86/msr-index: Add two new MSRs Fenghua Yu
2019-11-21  0:53 ` [PATCH v10 2/6] x86/cpufeatures: Enumerate the IA32_CORE_CAPABILITIES MSR Fenghua Yu
2019-11-21  0:53 ` [PATCH v10 3/6] x86/split_lock: Enumerate split lock detection by " Fenghua Yu
2019-11-21  0:53 ` [PATCH v10 4/6] x86/split_lock: Enumerate split lock detection if the IA32_CORE_CAPABILITIES MSR is not supported Fenghua Yu
2019-11-21 22:07   ` Andy Lutomirski
2019-11-22  0:37     ` Fenghua Yu
2019-11-22  2:13       ` Andy Lutomirski
2019-11-22  9:46         ` Peter Zijlstra
2019-11-21  0:53 ` [PATCH v10 5/6] x86/split_lock: Handle #AC exception for split lock Fenghua Yu
2019-11-21 22:10   ` Andy Lutomirski
2019-11-21 23:14     ` Fenghua Yu
2019-11-21 23:12       ` Andy Lutomirski
2019-11-21  0:53 ` [PATCH v10 6/6] x86/split_lock: Enable split lock detection by kernel parameter Fenghua Yu
2019-11-21  6:04   ` Ingo Molnar
2019-11-21 13:01     ` Peter Zijlstra
2019-11-21 13:15       ` Peter Zijlstra
2019-11-21 21:51         ` Luck, Tony
2019-11-21 22:24           ` Andy Lutomirski
2019-11-21 22:29             ` Luck, Tony
2019-11-21 23:18               ` Andy Lutomirski
2019-11-21 23:53                 ` Fenghua Yu
2019-11-22  1:52                   ` Sean Christopherson
2019-11-22  2:21                     ` Andy Lutomirski
2019-11-22  2:39                       ` Xiaoyao Li
2019-11-22  2:57                         ` Andy Lutomirski
2019-11-21 23:55                 ` Luck, Tony
2019-11-22  0:55             ` Luck, Tony
2019-11-22 10:08           ` Peter Zijlstra
2019-11-21 16:14       ` Fenghua Yu
2019-11-21 17:14         ` Ingo Molnar
2019-11-21 17:35         ` Peter Zijlstra
2019-11-21 17:12       ` Ingo Molnar
2019-11-21 17:34         ` Luck, Tony
2019-11-22 10:51           ` Peter Zijlstra
2019-11-22 15:27             ` Peter Zijlstra
2019-11-22 17:22               ` Luck, Tony
2019-11-22 20:23                 ` Peter Zijlstra
2019-11-22 18:02               ` Luck, Tony
2019-11-22 20:23                 ` Peter Zijlstra
2019-11-22 20:42                   ` Fenghua Yu
2019-11-22 21:25                     ` Andy Lutomirski
2019-12-12  8:57                       ` Peter Zijlstra
2019-12-12 18:52                         ` Luck, Tony
2019-12-12 19:46                           ` Luck, Tony
2019-12-12 20:01                             ` Andy Lutomirski
2019-12-16 16:21                               ` David Laight
2019-11-22 18:44               ` Sean Christopherson
2019-11-22 20:30                 ` Peter Zijlstra
2019-11-23  0:30               ` Luck, Tony
2019-11-25 16:13                 ` Sean Christopherson
2019-12-02 18:20                   ` Luck, Tony
2019-12-12  8:59                   ` Peter Zijlstra
2020-01-10 19:24                     ` [PATCH v11] x86/split_lock: Enable split lock detection by kernel Luck, Tony
2020-01-14  5:55                       ` Sean Christopherson
2020-01-15 22:27                         ` Luck, Tony
2020-01-15 22:57                           ` Sean Christopherson
2020-01-15 23:48                             ` Luck, Tony
2020-01-22 18:55                             ` [PATCH v12] " Luck, Tony
2020-01-22 19:04                               ` Borislav Petkov
2020-01-22 20:03                                 ` Luck, Tony
2020-01-22 20:55                                   ` Borislav Petkov
2020-01-22 22:42                               ` Arvind Sankar
2020-01-22 22:52                                 ` Arvind Sankar
2020-01-22 23:24                                 ` Luck, Tony
2020-01-23  0:45                                   ` Arvind Sankar
2020-01-23  1:23                                     ` Luck, Tony
2020-01-23  4:21                                       ` Arvind Sankar
2020-01-23 17:15                                         ` Luck, Tony
2020-01-23  3:53                                     ` [PATCH v13] " Luck, Tony
2020-01-23  4:45                                       ` Arvind Sankar
2020-01-23 23:16                                         ` [PATCH v14] " Luck, Tony
2020-01-24 21:36                                           ` Thomas Gleixner
2020-01-25  2:47                                             ` [PATCH v15] " Luck, Tony
2020-01-25 10:44                                               ` Borislav Petkov
2020-01-25 19:55                                                 ` Luck, Tony
2020-01-25 20:12                                                   ` Peter Zijlstra
2020-01-25 20:33                                                     ` Borislav Petkov
2020-01-25 21:42                                                       ` Luck, Tony
2020-01-25 22:17                                                         ` Borislav Petkov
2020-01-25 20:29                                                   ` Borislav Petkov
2020-01-25 13:41                                               ` Thomas Gleixner
2020-01-25 22:07                                                 ` [PATCH v16] " Luck, Tony
2020-01-25 22:43                                                   ` Mark D Rustad
2020-01-25 23:10                                                     ` Luck, Tony
2020-01-26 17:27                                                       ` Mark D Rustad
2020-01-26 20:05                                                         ` [PATCH v17] " Luck, Tony
2020-01-29 12:31                                                           ` Thomas Gleixner
2020-01-29 15:24                                                           ` [tip: x86/cpu] " tip-bot2 for Peter Zijlstra (Intel)
2020-02-03 20:41                                                           ` [PATCH v17] " Sean Christopherson
2020-02-06  0:49                                                             ` [PATCH] x86/split_lock: Avoid runtime reads of the TEST_CTRL MSR Luck, Tony
2020-02-06  1:18                                                               ` Andy Lutomirski
2020-02-06 16:46                                                                 ` Luck, Tony
2020-02-06 19:37                                                                   ` Andy Lutomirski
2020-03-03 19:22                                                                     ` Sean Christopherson
2020-02-04  0:04                                                           ` [PATCH v17] x86/split_lock: Enable split lock detection by kernel Sean Christopherson
2020-02-04 12:52                                                             ` Thomas Gleixner
2020-01-26  0:34                                                   ` [PATCH v16] " Andy Lutomirski
2020-01-26 20:01                                                     ` Luck, Tony
2020-01-25 21:25                                               ` [PATCH v15] " Arvind Sankar
2020-01-25 21:50                                                 ` Luck, Tony
2020-01-25 23:51                                                   ` Arvind Sankar
2020-01-26  2:52                                                     ` Luck, Tony
2020-01-27  2:05                                                       ` Tony Luck
2020-01-27  8:04                                                   ` Peter Zijlstra
2020-01-27  8:36                                                     ` Peter Zijlstra
2020-01-27 17:35                                                     ` Luck, Tony
2020-01-27  8:02                                                 ` Peter Zijlstra
2019-12-13  0:09               ` [PATCH v11] x86/split_lock: Enable split lock detection by kernel parameter Tony Luck
2019-12-13  0:16                 ` Luck, Tony
2019-11-21 17:43         ` [PATCH v10 6/6] " David Laight
2019-11-21 17:51           ` Andy Lutomirski
2019-11-21 18:53             ` Fenghua Yu
2019-11-21 19:01               ` Andy Lutomirski
2019-11-21 20:25                 ` Fenghua Yu
2019-11-21 20:19                   ` Peter Zijlstra
2019-11-21 19:46               ` Peter Zijlstra
2019-11-21 20:25               ` Peter Zijlstra
2019-11-21 21:22                 ` Andy Lutomirski
2019-11-22  9:25                   ` Peter Zijlstra
2019-11-22 17:48                     ` Luck, Tony
2019-11-22 20:31                       ` Peter Zijlstra
2019-11-22 21:23                         ` Andy Lutomirski
2019-12-11 17:52                           ` Peter Zijlstra
2019-12-11 18:12                             ` Andy Lutomirski
2019-12-11 22:34                               ` Peter Zijlstra
2019-12-12 19:40                                 ` Andy Lutomirski
2019-12-16  9:59                                   ` David Laight
2019-12-16 17:22                                     ` Andy Lutomirski
2019-12-16 17:45                                       ` David Laight
2019-12-16 18:06                                         ` Andy Lutomirski
2019-12-17 10:03                                           ` David Laight
2019-12-11 18:44                             ` Luck, Tony
2019-12-11 22:39                               ` Peter Zijlstra
2019-12-12 10:36                                 ` David Laight
2019-12-12 13:04                                   ` Peter Zijlstra
2019-12-12 16:02                                     ` Andy Lutomirski
2019-12-12 16:23                                       ` David Laight
2019-12-12 16:29                                     ` David Laight
2019-11-21 19:56             ` Peter Zijlstra
2019-11-21 21:01               ` Andy Lutomirski
2019-11-22  9:36                 ` Peter Zijlstra
2019-11-22  9:46             ` David Laight
2019-11-22 20:32               ` Peter Zijlstra
2019-11-21  8:00   ` Peter Zijlstra

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.