]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.133/s390-move-spectre-sysfs-attribute-code.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.4.133 / s390-move-spectre-sysfs-attribute-code.patch
CommitLineData
69d801ac
GKH
1From foo@baz Wed May 23 19:42:20 CEST 2018
2From: Martin Schwidefsky <schwidefsky@de.ibm.com>
3Date: Wed, 23 May 2018 18:21:33 +0200
4Subject: s390: move spectre sysfs attribute code
5To: stable@vger.kernel.org
6Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
7Message-ID: <1527092496-24207-7-git-send-email-schwidefsky@de.ibm.com>
8
9From: Martin Schwidefsky <schwidefsky@de.ibm.com>
10
11[ Upstream commit 4253b0e0627ee3461e64c2495c616f1c8f6b127b ]
12
13The nospec-branch.c file is compiled without the gcc options to
14generate expoline thunks. The return branch of the sysfs show
15functions cpu_show_spectre_v1 and cpu_show_spectre_v2 is an indirect
16branch as well. These need to be compiled with expolines.
17
18Move the sysfs functions for spectre reporting to a separate file
19and loose an '.' for one of the messages.
20
21Cc: stable@vger.kernel.org # 4.16
22Fixes: d424986f1d ("s390: add sysfs attributes for spectre")
23Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
24Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25---
26 arch/s390/kernel/Makefile | 1 +
27 arch/s390/kernel/nospec-branch.c | 18 ------------------
28 arch/s390/kernel/nospec-sysfs.c | 21 +++++++++++++++++++++
29 3 files changed, 22 insertions(+), 18 deletions(-)
30 create mode 100644 arch/s390/kernel/nospec-sysfs.c
31
32--- a/arch/s390/kernel/Makefile
33+++ b/arch/s390/kernel/Makefile
34@@ -49,6 +49,7 @@ obj-y += nospec-branch.o
35
36 extra-y += head.o head64.o vmlinux.lds
37
38+obj-$(CONFIG_SYSFS) += nospec-sysfs.o
39 CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE)
40
41 obj-$(CONFIG_MODULES) += s390_ksyms.o module.o
42--- a/arch/s390/kernel/nospec-branch.c
43+++ b/arch/s390/kernel/nospec-branch.c
44@@ -44,24 +44,6 @@ static int __init nospec_report(void)
45 }
46 arch_initcall(nospec_report);
47
48-#ifdef CONFIG_SYSFS
49-ssize_t cpu_show_spectre_v1(struct device *dev,
50- struct device_attribute *attr, char *buf)
51-{
52- return sprintf(buf, "Mitigation: __user pointer sanitization\n");
53-}
54-
55-ssize_t cpu_show_spectre_v2(struct device *dev,
56- struct device_attribute *attr, char *buf)
57-{
58- if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable)
59- return sprintf(buf, "Mitigation: execute trampolines\n");
60- if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
61- return sprintf(buf, "Mitigation: limited branch prediction.\n");
62- return sprintf(buf, "Vulnerable\n");
63-}
64-#endif
65-
66 #ifdef CONFIG_EXPOLINE
67
68 int nospec_disable = IS_ENABLED(CONFIG_EXPOLINE_OFF);
69--- /dev/null
70+++ b/arch/s390/kernel/nospec-sysfs.c
71@@ -0,0 +1,21 @@
72+// SPDX-License-Identifier: GPL-2.0
73+#include <linux/device.h>
74+#include <linux/cpu.h>
75+#include <asm/facility.h>
76+#include <asm/nospec-branch.h>
77+
78+ssize_t cpu_show_spectre_v1(struct device *dev,
79+ struct device_attribute *attr, char *buf)
80+{
81+ return sprintf(buf, "Mitigation: __user pointer sanitization\n");
82+}
83+
84+ssize_t cpu_show_spectre_v2(struct device *dev,
85+ struct device_attribute *attr, char *buf)
86+{
87+ if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable)
88+ return sprintf(buf, "Mitigation: execute trampolines\n");
89+ if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
90+ return sprintf(buf, "Mitigation: limited branch prediction\n");
91+ return sprintf(buf, "Vulnerable\n");
92+}