Skip to content

Commit 4253b0e

Browse files
author
Martin Schwidefsky
committed
s390: move spectre sysfs attribute code
The nospec-branch.c file is compiled without the gcc options to generate expoline thunks. The return branch of the sysfs show functions cpu_show_spectre_v1 and cpu_show_spectre_v2 is an indirect branch as well. These need to be compiled with expolines. Move the sysfs functions for spectre reporting to a separate file and loose an '.' for one of the messages. Cc: [email protected] # 4.16 Fixes: d424986 ("s390: add sysfs attributes for spectre") Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent c50c84c commit 4253b0e

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

arch/s390/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ obj-y += nospec-branch.o
6565

6666
extra-y += head.o head64.o vmlinux.lds
6767

68+
obj-$(CONFIG_SYSFS) += nospec-sysfs.o
6869
CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE)
6970

7071
obj-$(CONFIG_MODULES) += module.o

arch/s390/kernel/nospec-branch.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/module.h>
33
#include <linux/device.h>
4-
#include <linux/cpu.h>
54
#include <asm/nospec-branch.h>
65

76
static int __init nobp_setup_early(char *str)
@@ -44,24 +43,6 @@ static int __init nospec_report(void)
4443
}
4544
arch_initcall(nospec_report);
4645

47-
#ifdef CONFIG_SYSFS
48-
ssize_t cpu_show_spectre_v1(struct device *dev,
49-
struct device_attribute *attr, char *buf)
50-
{
51-
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
52-
}
53-
54-
ssize_t cpu_show_spectre_v2(struct device *dev,
55-
struct device_attribute *attr, char *buf)
56-
{
57-
if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable)
58-
return sprintf(buf, "Mitigation: execute trampolines\n");
59-
if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
60-
return sprintf(buf, "Mitigation: limited branch prediction.\n");
61-
return sprintf(buf, "Vulnerable\n");
62-
}
63-
#endif
64-
6546
#ifdef CONFIG_EXPOLINE
6647

6748
int nospec_disable = IS_ENABLED(CONFIG_EXPOLINE_OFF);

arch/s390/kernel/nospec-sysfs.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <linux/device.h>
3+
#include <linux/cpu.h>
4+
#include <asm/facility.h>
5+
#include <asm/nospec-branch.h>
6+
7+
ssize_t cpu_show_spectre_v1(struct device *dev,
8+
struct device_attribute *attr, char *buf)
9+
{
10+
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
11+
}
12+
13+
ssize_t cpu_show_spectre_v2(struct device *dev,
14+
struct device_attribute *attr, char *buf)
15+
{
16+
if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable)
17+
return sprintf(buf, "Mitigation: execute trampolines\n");
18+
if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
19+
return sprintf(buf, "Mitigation: limited branch prediction\n");
20+
return sprintf(buf, "Vulnerable\n");
21+
}

0 commit comments

Comments
 (0)