16fd16ce5SMichael Cree
26fd16ce5SMichael Cree #include <asm/hwrpb.h>
36fd16ce5SMichael Cree #include <linux/device.h>
46fd16ce5SMichael Cree
56fd16ce5SMichael Cree
66fd16ce5SMichael Cree #ifdef CONFIG_SYSFS
76fd16ce5SMichael Cree
cpu_is_ev6_or_later(void)86fd16ce5SMichael Cree static int cpu_is_ev6_or_later(void)
96fd16ce5SMichael Cree {
106fd16ce5SMichael Cree struct percpu_struct *cpu;
116fd16ce5SMichael Cree unsigned long cputype;
126fd16ce5SMichael Cree
136fd16ce5SMichael Cree cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset);
146fd16ce5SMichael Cree cputype = cpu->type & 0xffffffff;
156fd16ce5SMichael Cree /* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */
166fd16ce5SMichael Cree return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU));
176fd16ce5SMichael Cree }
186fd16ce5SMichael Cree
cpu_show_meltdown(struct device * dev,struct device_attribute * attr,char * buf)196fd16ce5SMichael Cree ssize_t cpu_show_meltdown(struct device *dev,
206fd16ce5SMichael Cree struct device_attribute *attr, char *buf)
216fd16ce5SMichael Cree {
226fd16ce5SMichael Cree if (cpu_is_ev6_or_later())
236fd16ce5SMichael Cree return sprintf(buf, "Vulnerable\n");
246fd16ce5SMichael Cree else
256fd16ce5SMichael Cree return sprintf(buf, "Not affected\n");
266fd16ce5SMichael Cree }
276fd16ce5SMichael Cree
cpu_show_spectre_v1(struct device * dev,struct device_attribute * attr,char * buf)286fd16ce5SMichael Cree ssize_t cpu_show_spectre_v1(struct device *dev,
296fd16ce5SMichael Cree struct device_attribute *attr, char *buf)
306fd16ce5SMichael Cree {
316fd16ce5SMichael Cree if (cpu_is_ev6_or_later())
326fd16ce5SMichael Cree return sprintf(buf, "Vulnerable\n");
336fd16ce5SMichael Cree else
346fd16ce5SMichael Cree return sprintf(buf, "Not affected\n");
356fd16ce5SMichael Cree }
366fd16ce5SMichael Cree
cpu_show_spectre_v2(struct device * dev,struct device_attribute * attr,char * buf)376fd16ce5SMichael Cree ssize_t cpu_show_spectre_v2(struct device *dev,
386fd16ce5SMichael Cree struct device_attribute *attr, char *buf)
396fd16ce5SMichael Cree {
406fd16ce5SMichael Cree if (cpu_is_ev6_or_later())
416fd16ce5SMichael Cree return sprintf(buf, "Vulnerable\n");
426fd16ce5SMichael Cree else
436fd16ce5SMichael Cree return sprintf(buf, "Not affected\n");
446fd16ce5SMichael Cree }
456fd16ce5SMichael Cree #endif
46