Merge tag 'rfds-for-linus-2024-03-11' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / arch / x86 / kernel / cpu / bugs.c
index 01ac18f56147f5e184e014e4661308a738c774ff..e7ba936d798b8198f5837118d5bb33d40389ccc7 100644 (file)
@@ -56,7 +56,7 @@ EXPORT_SYMBOL_GPL(x86_spec_ctrl_base);
 
 /* The current value of the SPEC_CTRL MSR with task-specific bits set */
 DEFINE_PER_CPU(u64, x86_spec_ctrl_current);
-EXPORT_SYMBOL_GPL(x86_spec_ctrl_current);
+EXPORT_PER_CPU_SYMBOL_GPL(x86_spec_ctrl_current);
 
 u64 x86_pred_cmd __ro_after_init = PRED_CMD_IBPB;
 EXPORT_SYMBOL_GPL(x86_pred_cmd);
@@ -737,7 +737,7 @@ enum gds_mitigations {
        GDS_MITIGATION_HYPERVISOR,
 };
 
-#if IS_ENABLED(CONFIG_GDS_FORCE_MITIGATION)
+#if IS_ENABLED(CONFIG_MITIGATION_GDS_FORCE)
 static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FORCE;
 #else
 static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FULL;
@@ -1048,10 +1048,10 @@ static void __init retbleed_select_mitigation(void)
                return;
 
        case RETBLEED_CMD_UNRET:
-               if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY)) {
+               if (IS_ENABLED(CONFIG_MITIGATION_UNRET_ENTRY)) {
                        retbleed_mitigation = RETBLEED_MITIGATION_UNRET;
                } else {
-                       pr_err("WARNING: kernel not compiled with CPU_UNRET_ENTRY.\n");
+                       pr_err("WARNING: kernel not compiled with MITIGATION_UNRET_ENTRY.\n");
                        goto do_cmd_auto;
                }
                break;
@@ -1060,24 +1060,24 @@ static void __init retbleed_select_mitigation(void)
                if (!boot_cpu_has(X86_FEATURE_IBPB)) {
                        pr_err("WARNING: CPU does not support IBPB.\n");
                        goto do_cmd_auto;
-               } else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) {
+               } else if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY)) {
                        retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
                } else {
-                       pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n");
+                       pr_err("WARNING: kernel not compiled with MITIGATION_IBPB_ENTRY.\n");
                        goto do_cmd_auto;
                }
                break;
 
        case RETBLEED_CMD_STUFF:
-               if (IS_ENABLED(CONFIG_CALL_DEPTH_TRACKING) &&
+               if (IS_ENABLED(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) &&
                    spectre_v2_enabled == SPECTRE_V2_RETPOLINE) {
                        retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
 
                } else {
-                       if (IS_ENABLED(CONFIG_CALL_DEPTH_TRACKING))
+                       if (IS_ENABLED(CONFIG_MITIGATION_CALL_DEPTH_TRACKING))
                                pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
                        else
-                               pr_err("WARNING: kernel not compiled with CALL_DEPTH_TRACKING.\n");
+                               pr_err("WARNING: kernel not compiled with MITIGATION_CALL_DEPTH_TRACKING.\n");
 
                        goto do_cmd_auto;
                }
@@ -1087,9 +1087,10 @@ do_cmd_auto:
        case RETBLEED_CMD_AUTO:
                if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
                    boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
-                       if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY))
+                       if (IS_ENABLED(CONFIG_MITIGATION_UNRET_ENTRY))
                                retbleed_mitigation = RETBLEED_MITIGATION_UNRET;
-                       else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY) && boot_cpu_has(X86_FEATURE_IBPB))
+                       else if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY) &&
+                                boot_cpu_has(X86_FEATURE_IBPB))
                                retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
                }
 
@@ -1168,7 +1169,7 @@ static enum spectre_v2_user_mitigation spectre_v2_user_stibp __ro_after_init =
 static enum spectre_v2_user_mitigation spectre_v2_user_ibpb __ro_after_init =
        SPECTRE_V2_USER_NONE;
 
-#ifdef CONFIG_RETPOLINE
+#ifdef CONFIG_MITIGATION_RETPOLINE
 static bool spectre_v2_bad_module;
 
 bool retpoline_module_ok(bool has_retpoline)
@@ -1481,7 +1482,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
             cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC ||
             cmd == SPECTRE_V2_CMD_EIBRS_LFENCE ||
             cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) &&
-           !IS_ENABLED(CONFIG_RETPOLINE)) {
+           !IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)) {
                pr_err("%s selected but not compiled in. Switching to AUTO select\n",
                       mitigation_options[i].option);
                return SPECTRE_V2_CMD_AUTO;
@@ -1504,7 +1505,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
                return SPECTRE_V2_CMD_AUTO;
        }
 
-       if (cmd == SPECTRE_V2_CMD_IBRS && !IS_ENABLED(CONFIG_CPU_IBRS_ENTRY)) {
+       if (cmd == SPECTRE_V2_CMD_IBRS && !IS_ENABLED(CONFIG_MITIGATION_IBRS_ENTRY)) {
                pr_err("%s selected but not compiled in. Switching to AUTO select\n",
                       mitigation_options[i].option);
                return SPECTRE_V2_CMD_AUTO;
@@ -1535,7 +1536,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
 
 static enum spectre_v2_mitigation __init spectre_v2_select_retpoline(void)
 {
-       if (!IS_ENABLED(CONFIG_RETPOLINE)) {
+       if (!IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)) {
                pr_err("Kernel not compiled with retpoline; no mitigation available!");
                return SPECTRE_V2_NONE;
        }
@@ -1630,7 +1631,7 @@ static void __init spectre_v2_select_mitigation(void)
                        break;
                }
 
-               if (IS_ENABLED(CONFIG_CPU_IBRS_ENTRY) &&
+               if (IS_ENABLED(CONFIG_MITIGATION_IBRS_ENTRY) &&
                    boot_cpu_has_bug(X86_BUG_RETBLEED) &&
                    retbleed_cmd != RETBLEED_CMD_OFF &&
                    retbleed_cmd != RETBLEED_CMD_STUFF &&
@@ -2523,7 +2524,7 @@ static void __init srso_select_mitigation(void)
                break;
 
        case SRSO_CMD_SAFE_RET:
-               if (IS_ENABLED(CONFIG_CPU_SRSO)) {
+               if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
                        /*
                         * Enable the return thunk for generated code
                         * like ftrace, static_call, etc.
@@ -2543,29 +2544,29 @@ static void __init srso_select_mitigation(void)
                        else
                                srso_mitigation = SRSO_MITIGATION_SAFE_RET_UCODE_NEEDED;
                } else {
-                       pr_err("WARNING: kernel not compiled with CPU_SRSO.\n");
+                       pr_err("WARNING: kernel not compiled with MITIGATION_SRSO.\n");
                }
                break;
 
        case SRSO_CMD_IBPB:
-               if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) {
+               if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY)) {
                        if (has_microcode) {
                                setup_force_cpu_cap(X86_FEATURE_ENTRY_IBPB);
                                srso_mitigation = SRSO_MITIGATION_IBPB;
                        }
                } else {
-                       pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n");
+                       pr_err("WARNING: kernel not compiled with MITIGATION_IBPB_ENTRY.\n");
                }
                break;
 
        case SRSO_CMD_IBPB_ON_VMEXIT:
-               if (IS_ENABLED(CONFIG_CPU_SRSO)) {
+               if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
                        if (!boot_cpu_has(X86_FEATURE_ENTRY_IBPB) && has_microcode) {
                                setup_force_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
                                srso_mitigation = SRSO_MITIGATION_IBPB_ON_VMEXIT;
                        }
                } else {
-                       pr_err("WARNING: kernel not compiled with CPU_SRSO.\n");
+                       pr_err("WARNING: kernel not compiled with MITIGATION_SRSO.\n");
                 }
                break;
        }
@@ -2928,3 +2929,8 @@ ssize_t cpu_show_reg_file_data_sampling(struct device *dev, struct device_attrib
        return cpu_show_common(dev, attr, buf, X86_BUG_RFDS);
 }
 #endif
+
+void __warn_thunk(void)
+{
+       WARN_ONCE(1, "Unpatched return thunk in use. This should not happen!\n");
+}