bugs.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <asm/hwrpb.h>
  2. #include <linux/device.h>
  3. #ifdef CONFIG_SYSFS
  4. static int cpu_is_ev6_or_later(void)
  5. {
  6. struct percpu_struct *cpu;
  7. unsigned long cputype;
  8. cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset);
  9. cputype = cpu->type & 0xffffffff;
  10. /* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */
  11. return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU));
  12. }
  13. ssize_t cpu_show_meltdown(struct device *dev,
  14. struct device_attribute *attr, char *buf)
  15. {
  16. if (cpu_is_ev6_or_later())
  17. return sprintf(buf, "Vulnerable\n");
  18. else
  19. return sprintf(buf, "Not affected\n");
  20. }
  21. ssize_t cpu_show_spectre_v1(struct device *dev,
  22. struct device_attribute *attr, char *buf)
  23. {
  24. if (cpu_is_ev6_or_later())
  25. return sprintf(buf, "Vulnerable\n");
  26. else
  27. return sprintf(buf, "Not affected\n");
  28. }
  29. ssize_t cpu_show_spectre_v2(struct device *dev,
  30. struct device_attribute *attr, char *buf)
  31. {
  32. if (cpu_is_ev6_or_later())
  33. return sprintf(buf, "Vulnerable\n");
  34. else
  35. return sprintf(buf, "Not affected\n");
  36. }
  37. #endif