blob: 52d4353188ad8cb3328dabe3f437f2e57fa6baaa [file] [log] [blame]
Martin Schwidefsky4253b0e2018-04-24 08:23:54 +02001// 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
7ssize_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
13ssize_t cpu_show_spectre_v2(struct device *dev,
14 struct device_attribute *attr, char *buf)
15{
Martin Schwidefskyaeaf7002018-05-08 15:14:48 +020016 if (test_facility(156))
17 return sprintf(buf, "Mitigation: etokens\n");
Sven Schnelle5d17d4ed72021-10-04 08:51:06 +020018 if (nospec_uses_trampoline())
Martin Schwidefsky4253b0e2018-04-24 08:23:54 +020019 return sprintf(buf, "Mitigation: execute trampolines\n");
Sven Schnelle17e89e12021-05-05 22:01:10 +020020 if (__test_facility(82, alt_stfle_fac_list))
Martin Schwidefsky4253b0e2018-04-24 08:23:54 +020021 return sprintf(buf, "Mitigation: limited branch prediction\n");
22 return sprintf(buf, "Vulnerable\n");
23}