lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1526323945-211107-13-git-send-email-fenghua.yu@intel.com>
Date:   Mon, 14 May 2018 11:52:22 -0700
From:   Fenghua Yu <fenghua.yu@...el.com>
To:     "Thomas Gleixner" <tglx@...utronix.de>,
        "Ingo Molnar" <mingo@...e.hu>,
        "H. Peter Anvin" <hpa@...ux.intel.com>,
        "Ashok Raj" <ashok.raj@...el.com>,
        "Ravi V Shankar" <ravi.v.shankar@...el.com>,
        "Tony Luck" <tony.luck@...el.com>,
        "Dave Hansen" <dave.hansen@...el.com>,
        "Rafael Wysocki" <rafael.j.wysocki@...el.com>,
        "Arjan van de Ven" <arjan@...radead.org>,
        "Alan Cox" <alan@...ux.intel.com>
Cc:     "x86" <x86@...nel.org>,
        "linux-kernel" <linux-kernel@...r.kernel.org>,
        Fenghua Yu <fenghua.yu@...el.com>
Subject: [PATCH 12/15] x86/split_lock: Add sysfs interface to show and control BIOS split lock setting

By default, the split lock BIOS setting inherits from BIOS setting
before kernel boots.

The sysfs interface /sys/kernel/split_lock/bios shows the BIOS split
lock setting: 0 for disabled and 1 for enabled.

User can override the BIOS setting by writing 1 to enable split
lock in BIOS and write 0 to disable split lock in BIOS.

When control flow comes to BIOS (e.g. in S3, S4, S5, and EFI runtime),
kernel sets the BIOS setting and restores to kernel setting after
coming back to kernel.

In cases (e.g. real time) user wants to identify split lock cases in BIOS
even when there is no BIOS setting before kernel boot, the user may
explicitly enable split lock for BIOS. Getting bang whenever there is
a split lock in BIOS helps identify and fix the BIOS split lock issue.

Please note: System Management Mode (SMM) is out of control of
kernel. So this interface cannot control split lock in SMM.

Signed-off-by: Fenghua Yu <fenghua.yu@...el.com>
---
 arch/x86/kernel/cpu/split_lock.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/x86/kernel/cpu/split_lock.c b/arch/x86/kernel/cpu/split_lock.c
index 02b461c48b3c..020af331594d 100644
--- a/arch/x86/kernel/cpu/split_lock.c
+++ b/arch/x86/kernel/cpu/split_lock.c
@@ -411,9 +411,43 @@ user_mode_store(struct kobject *kobj, struct kobj_attribute *attr,
 
 static struct kobj_attribute split_lock_ac_user = __ATTR_RW(user_mode);
 
+static ssize_t
+bios_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%u\n", split_lock_ac_bios);
+}
+
+static ssize_t
+bios_store(struct kobject *kobj, struct kobj_attribute *attr,
+	   const char *buf, size_t count)
+{
+	u32 val;
+	int ret;
+
+	ret = kstrtou32(buf, 10, &val);
+	if (ret)
+		return ret;
+
+	if (val != DISABLE_SPLIT_LOCK_AC && val != ENABLE_SPLIT_LOCK_AC)
+		return -EINVAL;
+
+	/* No need to update setting if new setting is the same as old one. */
+	if (val == split_lock_ac_bios)
+		return count;
+
+	mutex_lock(&split_lock_mutex);
+	split_lock_ac_bios = val;
+	mutex_unlock(&split_lock_mutex);
+
+	return count;
+}
+
+static struct kobj_attribute split_lock_ac_bios_enable = __ATTR_RW(bios);
+
 static struct attribute *split_lock_attrs[] = {
 	&split_lock_ac_enable.attr,
 	&split_lock_ac_user.attr,
+	&split_lock_ac_bios_enable.attr,
 	NULL,
 };
 
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ