Skip to content

Commit

Permalink
x86/cpu/bugs: Make retpoline module warning conditional
Browse files Browse the repository at this point in the history
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: caf7501 ("module/retpoline: Warn about missing retpoline in module")
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
Thomas Gleixner committed Jan 27, 2018
1 parent 55fa19d commit e383095
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions arch/x86/kernel/cpu/bugs.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ static const char *spectre_v2_strings[] = {
#define pr_fmt(fmt) "Spectre V2 : " fmt

static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
static bool spectre_v2_bad_module;

#ifdef RETPOLINE
static bool spectre_v2_bad_module;

bool retpoline_module_ok(bool has_retpoline)
{
if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
Expand All @@ -106,6 +107,13 @@ bool retpoline_module_ok(bool has_retpoline)
spectre_v2_bad_module = true;
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

static void __init spec2_print_if_insecure(const char *reason)
Expand Down Expand Up @@ -300,7 +308,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
return sprintf(buf, "Not affected\n");

return sprintf(buf, "%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
boot_cpu_has(X86_FEATURE_IBPB) ? ", IPBP" : "",
spectre_v2_bad_module ? " - vulnerable module loaded" : "");
boot_cpu_has(X86_FEATURE_IBPB) ? ", IBPB" : "",
spectre_v2_module_string());
}
#endif

0 comments on commit e383095

Please sign in to comment.