Skip to contentSkip to conversation

2

MODERATED Borislav Petkov 2 participants 3 messages Apr 13, 2018 – Apr 17, 2018 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 35 lines · On Thu, Apr 12, 2018 at 05:08:32PM -0400, [email protected] wrote:

[PATCH 1/6] x86/mdd: Expose the /sys/../md and BUG_MD

It does not do much except show the words 'Vulnerable'.

It assumes that Cyrix, Old Intel CPUs are immune to this.

---
v3: Remove AMD

    s/md/mdd/
---
 arch/x86/include/asm/cpufeatures.h |  1 +
 arch/x86/kernel/cpu/bugs.c         |  8 ++++++++
 arch/x86/kernel/cpu/common.c       | 17 +++++++++++++++++
 drivers/base/cpu.c                 |  8 ++++++++
 include/linux/cpu.h                |  2 ++
 5 files changed, 36 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
index d554c11e01ff..4393c10fcc6f 100644
@@ -362,5 +362,6 @@
 #define X86_BUG_CPU_MELTDOWN		X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
 #define X86_BUG_SPECTRE_V1		X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
 #define X86_BUG_SPECTRE_V2		X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
+#define X86_BUG_CPU_MD			X86_BUG(17) /* CPU is affected by memory disambiguation. */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/kernel/cpu/bugs.c +0 -0
index bfca937bdcc3..79dfc80c4b9c 100644
@@ -340,4 +340,12 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
 		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",

arch/x86/kernel/cpu/bugs.c ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c · line 350

Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8 -0
 		       spectre_v2_module_string());
 }
+
+ssize_t cpu_show_md(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	if (!boot_cpu_has_bug(X86_BUG_CPU_MD))
+		return sprintf(buf, "Not affected\n");
+
+	return sprintf(buf, "Vulnerable\n");
+}

I guess those can be unified into a single function at some point - otherwise we'll have one set per CPU bug and that could become unwieldy at some point.

Quoted 14 lines
arch/x86/kernel/cpu/bugs.c +0 -0
 #endif
arch/x86/kernel/cpu/common.c +5 -0
index 348cf4821240..4cd1c95e21b2 100644
@@ -935,6 +935,21 @@ static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c)
 	return true;
 }
 
+static const __initconst struct x86_cpu_id cpu_no_md[] = {
+	{ X86_VENDOR_CENTAUR,	5 },
+	{ X86_VENDOR_INTEL,	5 },
+	{ X86_VENDOR_NSC,	5 },
+	{ X86_VENDOR_ANY,	4 },

arch/x86/kernel/cpu/common.c static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c) · line 952

Quoted 10 lines
arch/x86/kernel/cpu/common.c +10 -0
+	{}
+};
+
+static bool __init cpu_vulnerable_to_md(struct cpuinfo_x86 *c)
+{
+	if (x86_match_cpu(cpu_no_md))
+		return false;
+
+	return true;
+}

This too could be merged with cpu_vulnerable_to_meltdown() and made into a common cpu_set_bug_bits() or so which goes through all those x86_x86_id matching structures.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#2 lore raw
In reply to a message not in the archive

Resend from correct mail address.

Quoted 35 lines · On Thu, Apr 12, 2018 at 05:08:32PM -0400, [email protected] wrote:

[PATCH 1/6] x86/mdd: Expose the /sys/../md and BUG_MD

It does not do much except show the words 'Vulnerable'.

It assumes that Cyrix, Old Intel CPUs are immune to this.

---
v3: Remove AMD

    s/md/mdd/
---
 arch/x86/include/asm/cpufeatures.h |  1 +
 arch/x86/kernel/cpu/bugs.c         |  8 ++++++++
 arch/x86/kernel/cpu/common.c       | 17 +++++++++++++++++
 drivers/base/cpu.c                 |  8 ++++++++
 include/linux/cpu.h                |  2 ++
 5 files changed, 36 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
index d554c11e01ff..4393c10fcc6f 100644
@@ -362,5 +362,6 @@
 #define X86_BUG_CPU_MELTDOWN		X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
 #define X86_BUG_SPECTRE_V1		X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
 #define X86_BUG_SPECTRE_V2		X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
+#define X86_BUG_CPU_MD			X86_BUG(17) /* CPU is affected by memory disambiguation. */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/kernel/cpu/bugs.c +0 -0
index bfca937bdcc3..79dfc80c4b9c 100644
@@ -340,4 +340,12 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
 		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",

arch/x86/kernel/cpu/bugs.c ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c · line 350

Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8 -0
 		       spectre_v2_module_string());
 }
+
+ssize_t cpu_show_md(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	if (!boot_cpu_has_bug(X86_BUG_CPU_MD))
+		return sprintf(buf, "Not affected\n");
+
+	return sprintf(buf, "Vulnerable\n");
+}

I guess those can be unified into a single function at some point - otherwise we'll have one set per CPU bug and that could become unwieldy at some point.

Quoted 14 lines
arch/x86/kernel/cpu/bugs.c +0 -0
 #endif
arch/x86/kernel/cpu/common.c +5 -0
index 348cf4821240..4cd1c95e21b2 100644
@@ -935,6 +935,21 @@ static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c)
 	return true;
 }
 
+static const __initconst struct x86_cpu_id cpu_no_md[] = {
+	{ X86_VENDOR_CENTAUR,	5 },
+	{ X86_VENDOR_INTEL,	5 },
+	{ X86_VENDOR_NSC,	5 },
+	{ X86_VENDOR_ANY,	4 },

arch/x86/kernel/cpu/common.c static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c) · line 952

Quoted 10 lines
arch/x86/kernel/cpu/common.c +10 -0
+	{}
+};
+
+static bool __init cpu_vulnerable_to_md(struct cpuinfo_x86 *c)
+{
+	if (x86_match_cpu(cpu_no_md))
+		return false;
+
+	return true;
+}

This too could be merged with cpu_vulnerable_to_meltdown() and made into a common cpu_set_bug_bits() or so which goes through all those x86_x86_id matching structures.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#3 lore raw
In reply to a message not in the archive

Resending for Konrad.

Quoted 35 lines · On Thu, Apr 12, 2018 at 05:08:32PM -0400, [email protected] wrote:

[PATCH 1/6] x86/mdd: Expose the /sys/../md and BUG_MD

It does not do much except show the words 'Vulnerable'.

It assumes that Cyrix, Old Intel CPUs are immune to this.

---
v3: Remove AMD

    s/md/mdd/
---
 arch/x86/include/asm/cpufeatures.h |  1 +
 arch/x86/kernel/cpu/bugs.c         |  8 ++++++++
 arch/x86/kernel/cpu/common.c       | 17 +++++++++++++++++
 drivers/base/cpu.c                 |  8 ++++++++
 include/linux/cpu.h                |  2 ++
 5 files changed, 36 insertions(+)
arch/x86/include/asm/cpufeatures.h +1 -0
index d554c11e01ff..4393c10fcc6f 100644
@@ -362,5 +362,6 @@
 #define X86_BUG_CPU_MELTDOWN		X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
 #define X86_BUG_SPECTRE_V1		X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
 #define X86_BUG_SPECTRE_V2		X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
+#define X86_BUG_CPU_MD			X86_BUG(17) /* CPU is affected by memory disambiguation. */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/kernel/cpu/bugs.c +0 -0
index bfca937bdcc3..79dfc80c4b9c 100644
@@ -340,4 +340,12 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
 		       boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",

arch/x86/kernel/cpu/bugs.c ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c · line 350

Quoted 10 lines
arch/x86/kernel/cpu/bugs.c +8 -0
 		       spectre_v2_module_string());
 }
+
+ssize_t cpu_show_md(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	if (!boot_cpu_has_bug(X86_BUG_CPU_MD))
+		return sprintf(buf, "Not affected\n");
+
+	return sprintf(buf, "Vulnerable\n");
+}

I guess those can be unified into a single function at some point - otherwise we'll have one set per CPU bug and that could become unwieldy at some point.

Quoted 14 lines
arch/x86/kernel/cpu/bugs.c +0 -0
 #endif
arch/x86/kernel/cpu/common.c +5 -0
index 348cf4821240..4cd1c95e21b2 100644
@@ -935,6 +935,21 @@ static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c)
 	return true;
 }
 
+static const __initconst struct x86_cpu_id cpu_no_md[] = {
+	{ X86_VENDOR_CENTAUR,	5 },
+	{ X86_VENDOR_INTEL,	5 },
+	{ X86_VENDOR_NSC,	5 },
+	{ X86_VENDOR_ANY,	4 },

arch/x86/kernel/cpu/common.c static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c) · line 952

Quoted 10 lines
arch/x86/kernel/cpu/common.c +10 -0
+	{}
+};
+
+static bool __init cpu_vulnerable_to_md(struct cpuinfo_x86 *c)
+{
+	if (x86_match_cpu(cpu_no_md))
+		return false;
+
+	return true;
+}

This too could be merged with cpu_vulnerable_to_meltdown() and made into a common cpu_set_bug_bits() or so which goes through all those x86_x86_id matching structures.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--