Skip to content

Commit 0fddfe3

Browse files
committed
driver core: cpu: Unify redundant silly stubs
Make them all a weak function, aliasing to a single function which issues the "Not affected" string. No functional changes. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Link: https://lore.kernel.org/r/20230809102700.29449-3-bp@alien8.de
1 parent 182ac87 commit 0fddfe3

File tree

1 file changed

+19
-68
lines changed

1 file changed

+19
-68
lines changed

drivers/base/cpu.c

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -509,79 +509,30 @@ static void __init cpu_dev_register_generic(void)
509509
}
510510

511511
#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
512-
513-
ssize_t __weak cpu_show_meltdown(struct device *dev,
514-
struct device_attribute *attr, char *buf)
515-
{
516-
return sysfs_emit(buf, "Not affected\n");
517-
}
518-
519-
ssize_t __weak cpu_show_spectre_v1(struct device *dev,
520-
struct device_attribute *attr, char *buf)
521-
{
522-
return sysfs_emit(buf, "Not affected\n");
523-
}
524-
525-
ssize_t __weak cpu_show_spectre_v2(struct device *dev,
526-
struct device_attribute *attr, char *buf)
527-
{
528-
return sysfs_emit(buf, "Not affected\n");
529-
}
530-
531-
ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
532-
struct device_attribute *attr, char *buf)
533-
{
534-
return sysfs_emit(buf, "Not affected\n");
535-
}
536-
537-
ssize_t __weak cpu_show_l1tf(struct device *dev,
538-
struct device_attribute *attr, char *buf)
539-
{
540-
return sysfs_emit(buf, "Not affected\n");
541-
}
542-
543-
ssize_t __weak cpu_show_mds(struct device *dev,
544-
struct device_attribute *attr, char *buf)
545-
{
546-
return sysfs_emit(buf, "Not affected\n");
547-
}
548-
549-
ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
550-
struct device_attribute *attr,
551-
char *buf)
552-
{
553-
return sysfs_emit(buf, "Not affected\n");
554-
}
555-
556-
ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
557-
struct device_attribute *attr, char *buf)
558-
{
559-
return sysfs_emit(buf, "Not affected\n");
560-
}
561-
562-
ssize_t __weak cpu_show_srbds(struct device *dev,
512+
ssize_t cpu_show_not_affected(struct device *dev,
563513
struct device_attribute *attr, char *buf)
564514
{
565515
return sysfs_emit(buf, "Not affected\n");
566516
}
567517

568-
ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
569-
struct device_attribute *attr, char *buf)
570-
{
571-
return sysfs_emit(buf, "Not affected\n");
572-
}
573-
574-
ssize_t __weak cpu_show_retbleed(struct device *dev,
575-
struct device_attribute *attr, char *buf)
576-
{
577-
return sysfs_emit(buf, "Not affected\n");
578-
}
579-
580-
ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
581-
struct device_attribute *attr, char *buf)
582-
{
583-
return sysfs_emit(buf, "Not affected\n");
584-
}
518+
#define CPU_SHOW_VULN_FALLBACK(func) \
519+
ssize_t cpu_show_##func(struct device *, \
520+
struct device_attribute *, char *) \
521+
__attribute__((weak, alias("cpu_show_not_affected")))
522+
523+
CPU_SHOW_VULN_FALLBACK(meltdown);
524+
CPU_SHOW_VULN_FALLBACK(spectre_v1);
525+
CPU_SHOW_VULN_FALLBACK(spectre_v2);
526+
CPU_SHOW_VULN_FALLBACK(spec_store_bypass);
527+
CPU_SHOW_VULN_FALLBACK(l1tf);
528+
CPU_SHOW_VULN_FALLBACK(mds);
529+
CPU_SHOW_VULN_FALLBACK(tsx_async_abort);
530+
CPU_SHOW_VULN_FALLBACK(itlb_multihit);
531+
CPU_SHOW_VULN_FALLBACK(srbds);
532+
CPU_SHOW_VULN_FALLBACK(mmio_stale_data);
533+
CPU_SHOW_VULN_FALLBACK(retbleed);
534+
CPU_SHOW_VULN_FALLBACK(spec_rstack_overflow);
535+
CPU_SHOW_VULN_FALLBACK(gather_data_sampling);
585536

586537
ssize_t __weak cpu_show_gds(struct device *dev,
587538
struct device_attribute *attr, char *buf)

0 commit comments

Comments
 (0)