mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: David Woodhouse <dwmw@amazon.co.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>, Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@kernel.org>,
	Laura Abbott <labbott@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86/spectre: hide 'spectre_v2_enabled' when disabled
Date: Wed, 10 Jan 2018 23:05:30 +0100	[thread overview]
Message-ID: <20180110220554.141703-1-arnd@arndb.de> (raw)

gcc prints a harmless warning when both CONFIG_RETPOLINE and
CONFIG_SYSFS are disabled:

arch/x86/kernel/cpu/bugs.c:79:12: warning: 'spectre_v2_enabled' defined but not used [-Wunused-variable]

This hides the spectre_v2_enabled variable from compilation
when CONFIG_RETPOLINE is disabled, to avoid that warning.

Fixes: 54d5103245ff ("x86/spectre: Add boot time option to select Spectre v2 mitigation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/kernel/cpu/bugs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b957f771a5b7..6f0105875c3a 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -76,7 +76,9 @@ enum spectre_v2_mitigation {
 #undef pr_fmt
 #define pr_fmt(fmt)     "Spectre V2 mitigation: " fmt
 
+#ifdef CONFIG_RETPOLINE
 static int spectre_v2_enabled = SPECTRE_V2_NONE;
+#endif
 
 static void __init spec2_print_if_insecure(const char *reason)
 {
@@ -195,6 +197,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
 	if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
 		return sprintf(buf, "Not affected\n");
 
+#ifdef CONFIG_RETPOLINE
 	switch (spectre_v2_enabled) {
 	case SPECTRE_V2_RETPOLINE_MINIMAL:
 		return sprintf(buf, "Mitigation: Minimal generic ASM retpoline\n");
@@ -204,8 +207,8 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
 		return sprintf(buf, "Mitigation: Full generic retpoline\n");
 	case SPECTRE_V2_RETPOLINE_AMD:
 		return sprintf(buf, "Mitigation: Full AMD retpoline\n");
-	default:
-		return sprintf(buf, "Vulnerable\n");
 	}
+#endif
+	return sprintf(buf, "Vulnerable\n");
 }
 #endif
-- 
2.9.0

                 reply	other threads:[~2018-01-10 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180110220554.141703-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=dwmw@amazon.co.uk \
    --cc=hpa@zytor.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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®