]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/speculation/mds: Add sysfs reporting for MDS
authorThomas Gleixner <tglx@linutronix.de>
Thu, 28 Mar 2019 17:57:22 +0000 (13:57 -0400)
committerMihai Carabas <mihai.carabas@oracle.com>
Mon, 22 Apr 2019 18:16:18 +0000 (21:16 +0300)
commit 8a4b06d391b0a42a373808979b5028f5c84d9c6a upstream

Add the sysfs reporting file for MDS. It exposes the vulnerability and
mitigation state similar to the existing files for the other speculative
hardware vulnerabilities.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jon Masters <jcm@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
(cherry picked from commit db366061fff1f76407cb5d1b0975fcc381400cc3)

Orabug: 29526900
CVE: CVE-2018-12126
CVE: CVE-2018-12130
CVE: CVE-2018-12127

Signed-off-by: Kanth Ghatraju <kanth.ghatraju@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Conflicts:
The changes to arch/x86/kernel/cpu/bugs.c instead need to be made to
arch/x86/kernel/cpu/bugs_64.c.
X86_HYPER_NATIVE doesn't exist so just leave that change out.
sched_smt_active() does not exist, instead use cpu_smp_control.
hypervisor_is_type replaced with cpu_has_hypervisor

Documentation/ABI/testing/sysfs-devices-system-cpu
arch/x86/kernel/cpu/bugs_64.c
drivers/base/cpu.c
include/linux/cpu.h

index 23348a84462d41aa1c861117c4199c4514a8af74..fdaf7e4d7dd6e4fdb4b3966fe03ee6a64c165f05 100644 (file)
@@ -278,6 +278,7 @@ What:               /sys/devices/system/cpu/vulnerabilities
                /sys/devices/system/cpu/vulnerabilities/spectre_v2
                /sys/devices/system/cpu/vulnerabilities/spec_store_bypass
                /sys/devices/system/cpu/vulnerabilities/l1tf
+               /sys/devices/system/cpu/vulnerabilities/mds
 Date:          January 2018
 Contact:       Linux kernel mailing list <linux-kernel@vger.kernel.org>
 Description:   Information about CPU vulnerabilities
index afc91d319b2216e0c226f895297c7034172097b8..7babe5d1c4b2f97b3adbfe1691f0f416c23ce147 100644 (file)
@@ -1373,6 +1373,22 @@ static ssize_t l1tf_show_state(char *buf)
                       l1tf_vmx_states[l1tf_vmx_mitigation],
                       cpu_smt_control == CPU_SMT_ENABLED ? "vulnerable" : "disabled");
 }
+
+static ssize_t mds_show_state(char *buf)
+{
+       if (cpu_has_hypervisor) {
+               return sprintf(buf, "%s; SMT Host state unknown\n",
+                              mds_strings[mds_mitigation]);
+       }
+
+       if (boot_cpu_has(X86_BUG_MSBDS_ONLY)) {
+               return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
+                       (cpu_smt_control == CPU_SMT_ENABLED) ? "mitigated" : "disabled");
+       }
+
+       return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
+               (cpu_smt_control == CPU_SMT_ENABLED) ? "vulnerable" : "disabled");
+}
 #else
 static ssize_t l1tf_show_state(char *buf)
 {
@@ -1475,6 +1491,10 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
                        return l1tf_show_state(buf);
                break;
 
+       case X86_BUG_MDS:
+               return mds_show_state(buf);
+               break;
+
        default:
                break;
        }
@@ -1510,4 +1530,9 @@ ssize_t cpu_show_l1tf(struct device *dev, struct device_attribute *attr, char *b
 {
        return cpu_show_common(dev, attr, buf, X86_BUG_L1TF);
 }
+
+ssize_t cpu_show_mds(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       return cpu_show_common(dev, attr, buf, X86_BUG_MDS);
+}
 #endif
index e495e904c0261ac6d341019cb07f63afc2f37d37..adb1315b21ab5f289fdba4bf514bab6bd92fffe6 100644 (file)
@@ -501,11 +501,18 @@ ssize_t __weak cpu_show_l1tf(struct device *dev,
        return sprintf(buf, "Not affected\n");
 }
 
+ssize_t __weak cpu_show_mds(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "Not affected\n");
+}
+
 static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
 static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
 static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
 static DEVICE_ATTR(spec_store_bypass, 0444, cpu_show_spec_store_bypass, NULL);
 static DEVICE_ATTR(l1tf, 0444, cpu_show_l1tf, NULL);
+static DEVICE_ATTR(mds, 0444, cpu_show_mds, NULL);
 
 static struct attribute *cpu_root_vulnerabilities_attrs[] = {
        &dev_attr_meltdown.attr,
@@ -513,6 +520,7 @@ static struct attribute *cpu_root_vulnerabilities_attrs[] = {
        &dev_attr_spectre_v2.attr,
        &dev_attr_spec_store_bypass.attr,
        &dev_attr_l1tf.attr,
+       &dev_attr_mds.attr,
        NULL
 };
 
index 20f0013a719e2d73aa071a2de2effa55305f99a9..00ddb1b5d0ba89c9130617e1cf50773845b92792 100644 (file)
@@ -50,6 +50,8 @@ extern ssize_t cpu_show_spec_store_bypass(struct device *dev,
                                          struct device_attribute *attr, char *buf);
 extern ssize_t cpu_show_l1tf(struct device *dev,
                             struct device_attribute *attr, char *buf);
+extern ssize_t cpu_show_mds(struct device *dev,
+                           struct device_attribute *attr, char *buf);
 
 extern struct device *cpu_device_create(struct device *parent, void *drvdata,
                                        const struct attribute_group **groups,