mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-15 10:06:52 +07:00
6fd16ce559
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>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
|
|
#include <asm/hwrpb.h>
|
|
#include <linux/device.h>
|
|
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
|
|
static int cpu_is_ev6_or_later(void)
|
|
{
|
|
struct percpu_struct *cpu;
|
|
unsigned long cputype;
|
|
|
|
cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset);
|
|
cputype = cpu->type & 0xffffffff;
|
|
/* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */
|
|
return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU));
|
|
}
|
|
|
|
ssize_t cpu_show_meltdown(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
if (cpu_is_ev6_or_later())
|
|
return sprintf(buf, "Vulnerable\n");
|
|
else
|
|
return sprintf(buf, "Not affected\n");
|
|
}
|
|
|
|
ssize_t cpu_show_spectre_v1(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
if (cpu_is_ev6_or_later())
|
|
return sprintf(buf, "Vulnerable\n");
|
|
else
|
|
return sprintf(buf, "Not affected\n");
|
|
}
|
|
|
|
ssize_t cpu_show_spectre_v2(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
if (cpu_is_ev6_or_later())
|
|
return sprintf(buf, "Vulnerable\n");
|
|
else
|
|
return sprintf(buf, "Not affected\n");
|
|
}
|
|
#endif
|