bugs.c 1.1 KB

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