]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - arch/x86/kernel/cpu/bugs.c
x86/speculation: Move arch_smt_update() call to after mitigation decisions
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / kernel / cpu / bugs.c
index e7dbdeb2b70f565d11719394fad201d100a7cf50..086bb04cf15fef7939e6563d64754c1c6075042e 100644 (file)
@@ -109,6 +109,8 @@ void __init check_bugs(void)
 
        mds_select_mitigation();
 
+       arch_smt_update();
+
 #ifdef CONFIG_X86_32
        /*
         * Check whether we are able to run this kernel safely on SMP.
@@ -219,6 +221,7 @@ static void x86_amd_ssb_disable(void)
 
 /* Default mitigation for L1TF-affected CPUs */
 static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL;
+static bool mds_nosmt __ro_after_init = false;
 
 static const char * const mds_strings[] = {
        [MDS_MITIGATION_OFF]    = "Vulnerable",
@@ -236,8 +239,13 @@ static void mds_select_mitigation(void)
        if (mds_mitigation == MDS_MITIGATION_FULL) {
                if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
                        mds_mitigation = MDS_MITIGATION_VMWERV;
+
                static_branch_enable(&mds_user_clear);
+
+               if (mds_nosmt && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
+                       cpu_smt_disable(false);
        }
+
        pr_info("%s\n", mds_strings[mds_mitigation]);
 }
 
@@ -253,6 +261,10 @@ static int __init mds_cmdline(char *str)
                mds_mitigation = MDS_MITIGATION_OFF;
        else if (!strcmp(str, "full"))
                mds_mitigation = MDS_MITIGATION_FULL;
+       else if (!strcmp(str, "full,nosmt")) {
+               mds_mitigation = MDS_MITIGATION_FULL;
+               mds_nosmt = true;
+       }
 
        return 0;
 }
@@ -624,9 +636,6 @@ specv2_set_mode:
 
        /* Set up IBPB and STIBP depending on the general spectre V2 command */
        spectre_v2_user_select_mitigation(cmd);
-
-       /* Enable STIBP if appropriate */
-       arch_smt_update();
 }
 
 static void update_stibp_msr(void * __unused)