14253b0e0SMartin Schwidefsky // SPDX-License-Identifier: GPL-2.0
24253b0e0SMartin Schwidefsky #include <linux/device.h>
34253b0e0SMartin Schwidefsky #include <linux/cpu.h>
44253b0e0SMartin Schwidefsky #include <asm/facility.h>
54253b0e0SMartin Schwidefsky #include <asm/nospec-branch.h>
64253b0e0SMartin Schwidefsky
cpu_show_spectre_v1(struct device * dev,struct device_attribute * attr,char * buf)74253b0e0SMartin Schwidefsky ssize_t cpu_show_spectre_v1(struct device *dev,
84253b0e0SMartin Schwidefsky struct device_attribute *attr, char *buf)
94253b0e0SMartin Schwidefsky {
104253b0e0SMartin Schwidefsky return sprintf(buf, "Mitigation: __user pointer sanitization\n");
114253b0e0SMartin Schwidefsky }
124253b0e0SMartin Schwidefsky
cpu_show_spectre_v2(struct device * dev,struct device_attribute * attr,char * buf)134253b0e0SMartin Schwidefsky ssize_t cpu_show_spectre_v2(struct device *dev,
144253b0e0SMartin Schwidefsky struct device_attribute *attr, char *buf)
154253b0e0SMartin Schwidefsky {
16aeaf7002SMartin Schwidefsky if (test_facility(156))
17aeaf7002SMartin Schwidefsky return sprintf(buf, "Mitigation: etokens\n");
18*5d17d4edSSven Schnelle if (nospec_uses_trampoline())
194253b0e0SMartin Schwidefsky return sprintf(buf, "Mitigation: execute trampolines\n");
2017e89e13SSven Schnelle if (__test_facility(82, alt_stfle_fac_list))
214253b0e0SMartin Schwidefsky return sprintf(buf, "Mitigation: limited branch prediction\n");
224253b0e0SMartin Schwidefsky return sprintf(buf, "Vulnerable\n");
234253b0e0SMartin Schwidefsky }
24