Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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