Skip to content

Commit e383095

Browse files
committed
x86/cpu/bugs: Make retpoline module warning conditional
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Woodhouse <[email protected]>
1 parent 55fa19d commit e383095

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ static const char *spectre_v2_strings[] = {
9494
#define pr_fmt(fmt) "Spectre V2 : " fmt
9595

9696
static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
97-
static bool spectre_v2_bad_module;
9897

9998
#ifdef RETPOLINE
99+
static bool spectre_v2_bad_module;
100+
100101
bool retpoline_module_ok(bool has_retpoline)
101102
{
102103
if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
@@ -106,6 +107,13 @@ bool retpoline_module_ok(bool has_retpoline)
106107
spectre_v2_bad_module = true;
107108
return false;
108109
}
110+
111+
static inline const char *spectre_v2_module_string(void)
112+
{
113+
return spectre_v2_bad_module ? " - vulnerable module loaded" : "";
114+
}
115+
#else
116+
static inline const char *spectre_v2_module_string(void) { return ""; }
109117
#endif
110118

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

302310
return sprintf(buf, "%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
303-
boot_cpu_has(X86_FEATURE_IBPB) ? ", IPBP" : "",
304-
spectre_v2_bad_module ? " - vulnerable module loaded" : "");
311+
boot_cpu_has(X86_FEATURE_IBPB) ? ", IBPB" : "",
312+
spectre_v2_module_string());
305313
}
306314
#endif

0 commit comments

Comments
 (0)