Skip to content

Commit d424986

Browse files
author
Martin Schwidefsky
committed
s390: add sysfs attributes for spectre
Set CONFIG_GENERIC_CPU_VULNERABILITIES and provide the two functions cpu_show_spectre_v1 and cpu_show_spectre_v2 to report the spectre mitigations. Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent bc03559 commit d424986

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ config S390
120120
select GENERIC_CLOCKEVENTS
121121
select GENERIC_CPU_AUTOPROBE
122122
select GENERIC_CPU_DEVICES if !SMP
123+
select GENERIC_CPU_VULNERABILITIES
123124
select GENERIC_FIND_FIRST_BIT
124125
select GENERIC_SMP_IDLE_THREAD
125126
select GENERIC_TIME_VSYSCALL

arch/s390/kernel/nospec-branch.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/module.h>
3+
#include <linux/device.h>
34
#include <asm/nospec-branch.h>
45

56
static int __init nobp_setup_early(char *str)
@@ -42,6 +43,24 @@ static int __init nospec_report(void)
4243
}
4344
arch_initcall(nospec_report);
4445

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

4766
int nospec_disable = IS_ENABLED(CONFIG_EXPOLINE_OFF);

0 commit comments

Comments
 (0)