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