diff options
author | Michael Cree <mcree@orcon.net.nz> | 2018-02-26 04:02:12 -0500 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2018-04-07 18:04:04 -0400 |
commit | 6fd16ce5590e30d0ed8b21e977102361ff9f92ef (patch) | |
tree | 5f785735470f60b11bc8191c6431fea4c5d67e17 | |
parent | 54f16b1967bd7c6a252b3c128032deb37cc61cf3 (diff) |
alpha: Implement CPU vulnerabilities sysfs functions.
Implement the CPU vulnerabilty show functions for meltdown, spectre_v1
and spectre_v2 on Alpha.
Tests on XP1000 (EV67/667MHz) and ES45 (EV68CB/1.25GHz) show them
to be vulnerable to Meltdown and Spectre V1. In the case of
Meltdown I saw a 1 to 2% success rate in reading bytes on the
XP1000 and 50 to 60% success rate on the ES45. (This compares to
99.97% success reported for Intel CPUs.) Report EV6 and later
CPUs as vulnerable.
Tests on PWS600au (EV56/600MHz) for Spectre V1 attack were
unsuccessful (though I did not try particularly hard) so mark EV4
through to EV56 as not vulnerable.
Signed-off-by: Michael Cree <mcree@orcon.net.nz>
Signed-off-by: Matt Turner <mattst88@gmail.com>
-rw-r--r-- | arch/alpha/Kconfig | 1 | ||||
-rw-r--r-- | arch/alpha/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/alpha/kernel/bugs.c | 45 |
3 files changed, 47 insertions, 1 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index e96adcbcab41..b2022885ced8 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig | |||
@@ -18,6 +18,7 @@ config ALPHA | |||
18 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 18 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
19 | select AUDIT_ARCH | 19 | select AUDIT_ARCH |
20 | select GENERIC_CLOCKEVENTS | 20 | select GENERIC_CLOCKEVENTS |
21 | select GENERIC_CPU_VULNERABILITIES | ||
21 | select GENERIC_SMP_IDLE_THREAD | 22 | select GENERIC_SMP_IDLE_THREAD |
22 | select GENERIC_STRNCPY_FROM_USER | 23 | select GENERIC_STRNCPY_FROM_USER |
23 | select GENERIC_STRNLEN_USER | 24 | select GENERIC_STRNLEN_USER |
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile index bf7b41fa7b01..5a74581bf0ee 100644 --- a/arch/alpha/kernel/Makefile +++ b/arch/alpha/kernel/Makefile | |||
@@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare | |||
9 | 9 | ||
10 | obj-y := entry.o traps.o process.o osf_sys.o irq.o \ | 10 | obj-y := entry.o traps.o process.o osf_sys.o irq.o \ |
11 | irq_alpha.o signal.o setup.o ptrace.o time.o \ | 11 | irq_alpha.o signal.o setup.o ptrace.o time.o \ |
12 | systbls.o err_common.o io.o | 12 | systbls.o err_common.o io.o bugs.o |
13 | 13 | ||
14 | obj-$(CONFIG_VGA_HOSE) += console.o | 14 | obj-$(CONFIG_VGA_HOSE) += console.o |
15 | obj-$(CONFIG_SMP) += smp.o | 15 | obj-$(CONFIG_SMP) += smp.o |
diff --git a/arch/alpha/kernel/bugs.c b/arch/alpha/kernel/bugs.c new file mode 100644 index 000000000000..08cc10d7fa17 --- /dev/null +++ b/arch/alpha/kernel/bugs.c | |||
@@ -0,0 +1,45 @@ | |||
1 | |||
2 | #include <asm/hwrpb.h> | ||
3 | #include <linux/device.h> | ||
4 | |||
5 | |||
6 | #ifdef CONFIG_SYSFS | ||
7 | |||
8 | static int cpu_is_ev6_or_later(void) | ||
9 | { | ||
10 | struct percpu_struct *cpu; | ||
11 | unsigned long cputype; | ||
12 | |||
13 | cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset); | ||
14 | cputype = cpu->type & 0xffffffff; | ||
15 | /* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */ | ||
16 | return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU)); | ||
17 | } | ||
18 | |||
19 | ssize_t cpu_show_meltdown(struct device *dev, | ||
20 | struct device_attribute *attr, char *buf) | ||
21 | { | ||
22 | if (cpu_is_ev6_or_later()) | ||
23 | return sprintf(buf, "Vulnerable\n"); | ||
24 | else | ||
25 | return sprintf(buf, "Not affected\n"); | ||
26 | } | ||
27 | |||
28 | ssize_t cpu_show_spectre_v1(struct device *dev, | ||
29 | struct device_attribute *attr, char *buf) | ||
30 | { | ||
31 | if (cpu_is_ev6_or_later()) | ||
32 | return sprintf(buf, "Vulnerable\n"); | ||
33 | else | ||
34 | return sprintf(buf, "Not affected\n"); | ||
35 | } | ||
36 | |||
37 | ssize_t cpu_show_spectre_v2(struct device *dev, | ||
38 | struct device_attribute *attr, char *buf) | ||
39 | { | ||
40 | if (cpu_is_ev6_or_later()) | ||
41 | return sprintf(buf, "Vulnerable\n"); | ||
42 | else | ||
43 | return sprintf(buf, "Not affected\n"); | ||
44 | } | ||
45 | #endif | ||