^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <asm/facility.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/nospec-branch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ssize_t cpu_show_spectre_v1(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) return sprintf(buf, "Mitigation: __user pointer sanitization\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ssize_t cpu_show_spectre_v2(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) if (test_facility(156))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return sprintf(buf, "Mitigation: etokens\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return sprintf(buf, "Mitigation: execute trampolines\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) return sprintf(buf, "Mitigation: limited branch prediction\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return sprintf(buf, "Vulnerable\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }