x86/spectre: Check CONFIG_RETPOLINE in command line parser
[pandora-kernel.git] / arch / x86 / kernel / cpu / bugs.c
index 8838d31..db76bc8 100644 (file)
@@ -233,12 +233,13 @@ static const char *spectre_v2_strings[] = {
 };
 
 #undef pr_fmt
-#define pr_fmt(fmt)     "Spectre V2 mitigation: " fmt
+#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)
@@ -248,6 +249,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)
@@ -347,10 +355,10 @@ static void __init spectre_v2_select_mitigation(void)
                return;
 
        case SPECTRE_V2_CMD_FORCE:
-               /* FALLTRHU */
        case SPECTRE_V2_CMD_AUTO:
-               goto retpoline_auto;
-
+               if (IS_ENABLED(CONFIG_RETPOLINE))
+                       goto retpoline_auto;
+               break;
        case SPECTRE_V2_CMD_RETPOLINE_AMD:
                if (IS_ENABLED(CONFIG_RETPOLINE))
                        goto retpoline_amd;
@@ -435,6 +443,6 @@ ssize_t cpu_show_spectre_v2(struct sysdev_class *dev,
                return sprintf(buf, "Not affected\n");
 
        return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled],
-                      spectre_v2_bad_module ? " - vulnerable module loaded" : "");
+                      spectre_v2_module_string());
 }
 #endif