[PATCH 09/15] x86/split_lock: Explicitly enable or disable #AC for split locked accesses

From: Fenghua Yu
Date: Mon May 14 2018 - 14:54:08 EST


By default, we don't set or clear the bit 29 in TEST_CTL MSR 0x33 and
the bit is inherited from BIOS/hardware setting.

The kernel parameter "split_lock_ac=on/off" explicitly sets or clears
the bit during boot time.

Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>
---
Documentation/admin-guide/kernel-parameters.txt | 11 +++++++++++
arch/x86/kernel/cpu/split_lock.c | 16 ++++++++++++++++
2 files changed, 27 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 11fc28ecdb6d..862758533346 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4030,6 +4030,17 @@
spia_pedr=
spia_peddr=

+ split_lock_ac= [X86] Enable or disable #AC exception for
+ split locked accesses
+ By default, kernel just inherits setting by
+ hardware and BIOS which may enable or disable
+ the feature. User can explicitly enable or disable
+ the feature by this parameter to override
+ BIOS/hardware setting.
+
+ on Enable #AC exception for split locked accesses.
+ off Disable #AC exception for split locked accesses.
+
srcutree.counter_wrap_check [KNL]
Specifies how frequently to check for
grace-period sequence counter wrap for the
diff --git a/arch/x86/kernel/cpu/split_lock.c b/arch/x86/kernel/cpu/split_lock.c
index 5187a9c6cea6..bc66c21b0ca9 100644
--- a/arch/x86/kernel/cpu/split_lock.c
+++ b/arch/x86/kernel/cpu/split_lock.c
@@ -85,6 +85,22 @@ void __init enumerate_split_lock(void)
pr_info("#AC exception for split locked accesses is supported\n");
}

+static __init int setup_split_lock_ac(char *str)
+{
+ if (!str)
+ return -EINVAL;
+
+ if (!strncmp(str, "on", 2))
+ split_lock_ac = ENABLE_SPLIT_LOCK_AC;
+ else if (!strncmp(str, "off", 3))
+ split_lock_ac = DISABLE_SPLIT_LOCK_AC;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+__setup("split_lock_ac=", setup_split_lock_ac);
+
static bool _setup_split_lock(int split_lock_ac_val)
{
u32 l, h;
--
2.5.0