nospec-sysfs.c 691 B

123456789101112131415161718192021
  1. // 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. ssize_t cpu_show_spectre_v1(struct device *dev,
  7. struct device_attribute *attr, char *buf)
  8. {
  9. return sprintf(buf, "Mitigation: __user pointer sanitization\n");
  10. }
  11. ssize_t cpu_show_spectre_v2(struct device *dev,
  12. struct device_attribute *attr, char *buf)
  13. {
  14. if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable)
  15. return sprintf(buf, "Mitigation: execute trampolines\n");
  16. if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))
  17. return sprintf(buf, "Mitigation: limited branch prediction\n");
  18. return sprintf(buf, "Vulnerable\n");
  19. }