Commit bc029d87 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Stefan Bader

x86/cpu/bugs: Make retpoline module warning conditional

BugLink: http://bugs.launchpad.net/bugs/1756866

(cherry picked from commit e383095c)

If sysfs is disabled and RETPOLINE not defined:

arch/x86/kernel/cpu/bugs.c:97:13: warning: ‘spectre_v2_bad_module’ defined but not used
[-Wunused-variable]
 static bool spectre_v2_bad_module;

Hide it.

Fixes: caf7501a ("module/retpoline: Warn about missing retpoline in module")
Reported-by: default avatarBorislav Petkov <bp@alien8.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
[jwang: port to 4.4]
Signed-off-by: default avatarJack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 814529c9
...@@ -95,9 +95,10 @@ static const char *spectre_v2_strings[] = { ...@@ -95,9 +95,10 @@ static const char *spectre_v2_strings[] = {
static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
static bool spectre_v2_bad_module;
#ifdef RETPOLINE #ifdef RETPOLINE
static bool spectre_v2_bad_module;
bool retpoline_module_ok(bool has_retpoline) bool retpoline_module_ok(bool has_retpoline)
{ {
if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline) if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
...@@ -107,6 +108,13 @@ bool retpoline_module_ok(bool has_retpoline) ...@@ -107,6 +108,13 @@ bool retpoline_module_ok(bool has_retpoline)
spectre_v2_bad_module = true; spectre_v2_bad_module = true;
return false; return false;
} }
static inline const char *spectre_v2_module_string(void)
{
return spectre_v2_bad_module ? " - vulnerable module loaded" : "";
}
#else
static inline const char *spectre_v2_module_string(void) { return ""; }
#endif #endif
static void __init spec2_print_if_insecure(const char *reason) static void __init spec2_print_if_insecure(const char *reason)
...@@ -322,6 +330,6 @@ ssize_t cpu_show_spectre_v2(struct device *dev, ...@@ -322,6 +330,6 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
return sprintf(buf, "%s%s%s\n", spectre_v2_strings[spectre_v2_enabled], return sprintf(buf, "%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
ibpb_inuse ? ", IBPB (Intel v4)" : "", ibpb_inuse ? ", IBPB (Intel v4)" : "",
spectre_v2_bad_module ? " - vulnerable module loaded" : ""); spectre_v2_module_string());
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment