|
@@ -10,6 +10,7 @@
|
|
|
*/
|
|
|
#include <linux/init.h>
|
|
|
#include <linux/utsname.h>
|
|
|
+#include <linux/cpu.h>
|
|
|
#include <asm/bugs.h>
|
|
|
#include <asm/processor.h>
|
|
|
#include <asm/processor-flags.h>
|
|
@@ -60,3 +61,31 @@ void __init check_bugs(void)
|
|
|
set_memory_4k((unsigned long)__va(0), 1);
|
|
|
#endif
|
|
|
}
|
|
|
+
|
|
|
+#ifdef CONFIG_SYSFS
|
|
|
+ssize_t cpu_show_meltdown(struct device *dev,
|
|
|
+ struct device_attribute *attr, char *buf)
|
|
|
+{
|
|
|
+ if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
|
|
|
+ return sprintf(buf, "Not affected\n");
|
|
|
+ if (boot_cpu_has(X86_FEATURE_PTI))
|
|
|
+ return sprintf(buf, "Mitigation: PTI\n");
|
|
|
+ return sprintf(buf, "Vulnerable\n");
|
|
|
+}
|
|
|
+
|
|
|
+ssize_t cpu_show_spectre_v1(struct device *dev,
|
|
|
+ struct device_attribute *attr, char *buf)
|
|
|
+{
|
|
|
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
|
|
|
+ return sprintf(buf, "Not affected\n");
|
|
|
+ return sprintf(buf, "Vulnerable\n");
|
|
|
+}
|
|
|
+
|
|
|
+ssize_t cpu_show_spectre_v2(struct device *dev,
|
|
|
+ struct device_attribute *attr, char *buf)
|
|
|
+{
|
|
|
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
|
|
|
+ return sprintf(buf, "Not affected\n");
|
|
|
+ return sprintf(buf, "Vulnerable\n");
|
|
|
+}
|
|
|
+#endif
|