mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: X86 ML <x86@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 2/3] driver core: cpu: Unify redundant silly stubs
Date: Wed,  9 Aug 2023 12:26:59 +0200	[thread overview]
Message-ID: <20230809102700.29449-3-bp@alien8.de> (raw)
In-Reply-To: <20230809102700.29449-1-bp@alien8.de>

From: "Borislav Petkov (AMD)" <bp@alien8.de>

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>
---
 drivers/base/cpu.c | 86 ++++++++++------------------------------------
 1 file changed, 18 insertions(+), 68 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 52df435eecf8..971771347aa6 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -509,79 +509,29 @@ static void __init cpu_dev_register_generic(void)
 }
 
 #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
-
-ssize_t __weak cpu_show_meltdown(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v1(struct device *dev,
-				   struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spectre_v2(struct device *dev,
-				   struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
-					  struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_l1tf(struct device *dev,
-			     struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_mds(struct device *dev,
-			    struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_tsx_async_abort(struct device *dev,
-					struct device_attribute *attr,
-					char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_itlb_multihit(struct device *dev,
-				      struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_srbds(struct device *dev,
+ssize_t cpu_show_not_affected(struct device *dev,
 			      struct device_attribute *attr, char *buf)
 {
 	return sysfs_emit(buf, "Not affected\n");
 }
 
-ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
-					struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_retbleed(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
-
-ssize_t __weak cpu_show_spec_rstack_overflow(struct device *dev,
-					     struct device_attribute *attr, char *buf)
-{
-	return sysfs_emit(buf, "Not affected\n");
-}
+#define CPU_VULN_FALLBACK(func)						\
+	ssize_t cpu_show_##func(struct device *,			\
+				  struct device_attribute *, char *)	\
+		 __attribute__((weak, alias("cpu_show_not_affected")))
+
+CPU_VULN_FALLBACK(meltdown);
+CPU_VULN_FALLBACK(spectre_v1);
+CPU_VULN_FALLBACK(spectre_v2);
+CPU_VULN_FALLBACK(spec_store_bypass);
+CPU_VULN_FALLBACK(l1tf);
+CPU_VULN_FALLBACK(mds);
+CPU_VULN_FALLBACK(tsx_async_abort);
+CPU_VULN_FALLBACK(itlb_multihit);
+CPU_VULN_FALLBACK(srbds);
+CPU_VULN_FALLBACK(mmio_stale_data);
+CPU_VULN_FALLBACK(retbleed);
+CPU_VULN_FALLBACK(spec_rstack_overflow);
 
 ssize_t __weak cpu_show_gds(struct device *dev,
 			    struct device_attribute *attr, char *buf)
-- 
2.41.0


  parent reply	other threads:[~2023-08-09 10:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 10:26 [PATCH 0/3] x86/bugs: Some SRSO fixes Borislav Petkov
2023-08-09 10:26 ` [PATCH 1/3] Documentation/hw-vuln: Unify filename specification in index Borislav Petkov
2023-08-09 21:32   ` Pawan Gupta
2023-08-09 22:00     ` Borislav Petkov
2023-08-10  9:11   ` [tip: x86/bugs] " tip-bot2 for Borislav Petkov (AMD)
2023-08-09 10:26 ` Borislav Petkov [this message]
2023-08-09 10:56   ` [PATCH 2/3] driver core: cpu: Unify redundant silly stubs Nikolay Borisov
2023-08-09 21:47   ` Pawan Gupta
2023-08-09 22:01     ` Borislav Petkov
2023-08-10  9:11   ` [tip: x86/bugs] " tip-bot2 for Borislav Petkov (AMD)
2023-08-09 10:27 ` [PATCH 3/3] Documentation/srso: Document IBPB aspect and fix formatting Borislav Petkov
2023-08-09 22:03   ` Pawan Gupta
2023-08-10  9:11   ` [tip: x86/bugs] " tip-bot2 for Borislav Petkov (AMD)
2023-08-09 11:11 ` [PATCH 0/3] x86/bugs: Some SRSO fixes Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230809102700.29449-3-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®