xref: /openbmc/linux/arch/s390/kernel/nospec-sysfs.c (revision 17e89e1340a377b2f14a14d7050f609328592793)
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 
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 
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");
18475c8e9eSJoe Perches 	if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
194253b0e0SMartin Schwidefsky 		return sprintf(buf, "Mitigation: execute trampolines\n");
20*17e89e13SSven 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