lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20180110220554.141703-1-arnd@arndb.de>
Date:   Wed, 10 Jan 2018 23:05:30 +0100
From:   Arnd Bergmann <arnd@...db.de>
To:     David Woodhouse <dwmw@...zon.co.uk>,
        Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org
Cc:     Arnd Bergmann <arnd@...db.de>, Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andy Lutomirski <luto@...nel.org>,
        Laura Abbott <labbott@...hat.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] x86/spectre: hide 'spectre_v2_enabled' when disabled

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@...db.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ