Skip to content

Commit 6fd16ce

Browse files
Michael Creemattst88
authored andcommitted
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 <[email protected]> Signed-off-by: Matt Turner <[email protected]>
1 parent 54f16b1 commit 6fd16ce

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

arch/alpha/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config ALPHA
1818
select ARCH_HAVE_NMI_SAFE_CMPXCHG
1919
select AUDIT_ARCH
2020
select GENERIC_CLOCKEVENTS
21+
select GENERIC_CPU_VULNERABILITIES
2122
select GENERIC_SMP_IDLE_THREAD
2223
select GENERIC_STRNCPY_FROM_USER
2324
select GENERIC_STRNLEN_USER

arch/alpha/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare
99

1010
obj-y := entry.o traps.o process.o osf_sys.o irq.o \
1111
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
1313

1414
obj-$(CONFIG_VGA_HOSE) += console.o
1515
obj-$(CONFIG_SMP) += smp.o

arch/alpha/kernel/bugs.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)