[RFC PATCH 09/16] x86/split_lock: Add CONFIG to control #AC for split lock at boot time

From: Fenghua Yu
Date: Sun May 27 2018 - 11:49:20 EST


User wants to specify how to set up #AC for split lock at boot time.

CONFIG_SPLIT_LOCK_AC_ENABLE_DEFAULT is added to control split
lock setting at boot time.

Default value is 2: Don't explicitly enable or disable #AC for split lock.
Inherit setting of #AC for split lock from firmware.

Value 0 to explicitly disable split lock at boot time.

Value 1 to explicitly enable split lock at boot time.

Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>
---
arch/x86/Kconfig | 14 ++++++++++++++
arch/x86/kernel/cpu/test_ctl.c | 12 ++++++++++++
2 files changed, 26 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 043cde9a9b08..1d0dcd6fa69a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -461,6 +461,20 @@ config SPLIT_LOCK_AC

Say N if unsure.

+config SPLIT_LOCK_AC_ENABLE_DEFAULT
+ int "#AC for split lock enable value (0-2) at boot time"
+ range 0 2
+ default "2"
+ depends on SPLIT_LOCK_AC
+ help
+ Set #AC for split lock enable default value at boot time
+ 0: Explicitly disable #AC for split lock at boot time.
+ 1: Explicitly enable #AC for split lock at boot time.
+ 2: Don't explicitly enable or disable #AC for split lock.
+ Inherit setting of #AC for split lock from firmware.
+
+ Leave this to the default value of 2 if you are unsure.
+
if X86_32
config X86_BIGSMP
bool "Support for big SMP systems with more than 8 CPUs"
diff --git a/arch/x86/kernel/cpu/test_ctl.c b/arch/x86/kernel/cpu/test_ctl.c
index 82440740b2b9..a2f84fcd4da1 100644
--- a/arch/x86/kernel/cpu/test_ctl.c
+++ b/arch/x86/kernel/cpu/test_ctl.c
@@ -21,6 +21,7 @@

#define DISABLE_SPLIT_LOCK_AC 0
#define ENABLE_SPLIT_LOCK_AC 1
+#define INHERIT_SPLIT_LOCK_AC_FIRMWARE 2

/* After disabling #AC for split lock in handler, re-enable it 1 msec later. */
#define reenable_split_lock_delay msecs_to_jiffies(1)
@@ -71,6 +72,17 @@ void detect_split_lock_ac(void)
split_lock_ac_firmware = ENABLE_SPLIT_LOCK_AC;
else
split_lock_ac_firmware = DISABLE_SPLIT_LOCK_AC;
+
+ /*
+ * By default configuration, kernel inherits firmware split lock
+ * setting. Kernel can be configured to explicitly enable or disable
+ * #AC for split lock to override firmware setting.
+ */
+ if (CONFIG_SPLIT_LOCK_AC_ENABLE_DEFAULT ==
+ INHERIT_SPLIT_LOCK_AC_FIRMWARE)
+ split_lock_ac_kernel = split_lock_ac_firmware;
+ else
+ split_lock_ac_kernel = CONFIG_SPLIT_LOCK_AC_ENABLE_DEFAULT;
}

static void _setup_split_lock(int split_lock_ac_val)
--
2.5.0