Skip to content

Commit 350afa8

Browse files
Ravi BangoriaKAGA-KOKO
authored andcommitted
x86/split_lock: Move Split and Bus lock code to a dedicated file
Bus Lock Detect functionality on AMD platforms works identical to Intel. Move split_lock and bus_lock specific code from intel.c to a dedicated file so that it can be compiled and supported on non-Intel platforms. Also, introduce CONFIG_X86_BUS_LOCK_DETECT, make it dependent on CONFIG_CPU_SUP_INTEL and add compilation dependency of the new bus_lock.c file on CONFIG_X86_BUS_LOCK_DETECT. Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/all/20240808062937.1149-2-ravi.bangoria@amd.com
1 parent de9c2c6 commit 350afa8

File tree

7 files changed

+427
-410
lines changed

7 files changed

+427
-410
lines changed

arch/x86/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,14 @@ config CFI_AUTO_DEFAULT
24262426

24272427
source "kernel/livepatch/Kconfig"
24282428

2429+
config X86_BUS_LOCK_DETECT
2430+
bool "Split Lock Detect and Bus Lock Detect support"
2431+
depends on CPU_SUP_INTEL
2432+
default y
2433+
help
2434+
Enable Split Lock Detect and Bus Lock Detect functionalities.
2435+
See <file:Documentation/arch/x86/buslock.rst> for more information.
2436+
24292437
endmenu
24302438

24312439
config CC_HAS_NAMED_AS

arch/x86/include/asm/cpu.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ int mwait_usable(const struct cpuinfo_x86 *);
2626
unsigned int x86_family(unsigned int sig);
2727
unsigned int x86_model(unsigned int sig);
2828
unsigned int x86_stepping(unsigned int sig);
29-
#ifdef CONFIG_CPU_SUP_INTEL
29+
#ifdef CONFIG_X86_BUS_LOCK_DETECT
3030
extern void __init sld_setup(struct cpuinfo_x86 *c);
3131
extern bool handle_user_split_lock(struct pt_regs *regs, long error_code);
3232
extern bool handle_guest_split_lock(unsigned long ip);
3333
extern void handle_bus_lock(struct pt_regs *regs);
34-
u8 get_this_hybrid_cpu_type(void);
34+
void split_lock_init(void);
35+
void bus_lock_init(void);
3536
#else
3637
static inline void __init sld_setup(struct cpuinfo_x86 *c) {}
3738
static inline bool handle_user_split_lock(struct pt_regs *regs, long error_code)
@@ -45,7 +46,13 @@ static inline bool handle_guest_split_lock(unsigned long ip)
4546
}
4647

4748
static inline void handle_bus_lock(struct pt_regs *regs) {}
49+
static inline void split_lock_init(void) {}
50+
static inline void bus_lock_init(void) {}
51+
#endif
4852

53+
#ifdef CONFIG_CPU_SUP_INTEL
54+
u8 get_this_hybrid_cpu_type(void);
55+
#else
4956
static inline u8 get_this_hybrid_cpu_type(void)
5057
{
5158
return 0;

arch/x86/kernel/cpu/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ obj-$(CONFIG_ACRN_GUEST) += acrn.o
5959

6060
obj-$(CONFIG_DEBUG_FS) += debugfs.o
6161

62+
obj-$(CONFIG_X86_BUS_LOCK_DETECT) += bus_lock.o
63+
6264
quiet_cmd_mkcapflags = MKCAP $@
6365
cmd_mkcapflags = $(CONFIG_SHELL) $(src)/mkcapflags.sh $@ $^
6466

0 commit comments

Comments
 (0)