Skip to content

Commit 96ab738

Browse files
pa1guptagregkh
authored andcommitted
x86/bugs: Move cpu_bugs_smt_update() down
Commit 6449f5b upstream. cpu_bugs_smt_update() uses global variables from different mitigations. For SMT updates it can't currently use vmscape_mitigation that is defined after it. Since cpu_bugs_smt_update() depends on many other mitigations, move it after all mitigations are defined. With that, it can use vmscape_mitigation in a moment. No functional change. Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 893387c commit 96ab738

1 file changed

Lines changed: 74 additions & 74 deletions

File tree

arch/x86/kernel/cpu/bugs.c

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,80 +2138,6 @@ static void __init tsa_select_mitigation(void)
21382138
pr_info("%s\n", tsa_strings[tsa_mitigation]);
21392139
}
21402140

2141-
void cpu_bugs_smt_update(void)
2142-
{
2143-
mutex_lock(&spec_ctrl_mutex);
2144-
2145-
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
2146-
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
2147-
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
2148-
2149-
switch (spectre_v2_user_stibp) {
2150-
case SPECTRE_V2_USER_NONE:
2151-
break;
2152-
case SPECTRE_V2_USER_STRICT:
2153-
case SPECTRE_V2_USER_STRICT_PREFERRED:
2154-
update_stibp_strict();
2155-
break;
2156-
case SPECTRE_V2_USER_PRCTL:
2157-
case SPECTRE_V2_USER_SECCOMP:
2158-
update_indir_branch_cond();
2159-
break;
2160-
}
2161-
2162-
switch (mds_mitigation) {
2163-
case MDS_MITIGATION_FULL:
2164-
case MDS_MITIGATION_VMWERV:
2165-
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
2166-
pr_warn_once(MDS_MSG_SMT);
2167-
update_mds_branch_idle();
2168-
break;
2169-
case MDS_MITIGATION_OFF:
2170-
break;
2171-
}
2172-
2173-
switch (taa_mitigation) {
2174-
case TAA_MITIGATION_VERW:
2175-
case TAA_MITIGATION_UCODE_NEEDED:
2176-
if (sched_smt_active())
2177-
pr_warn_once(TAA_MSG_SMT);
2178-
break;
2179-
case TAA_MITIGATION_TSX_DISABLED:
2180-
case TAA_MITIGATION_OFF:
2181-
break;
2182-
}
2183-
2184-
switch (mmio_mitigation) {
2185-
case MMIO_MITIGATION_VERW:
2186-
case MMIO_MITIGATION_UCODE_NEEDED:
2187-
if (sched_smt_active())
2188-
pr_warn_once(MMIO_MSG_SMT);
2189-
break;
2190-
case MMIO_MITIGATION_OFF:
2191-
break;
2192-
}
2193-
2194-
switch (tsa_mitigation) {
2195-
case TSA_MITIGATION_USER_KERNEL:
2196-
case TSA_MITIGATION_VM:
2197-
case TSA_MITIGATION_FULL:
2198-
case TSA_MITIGATION_UCODE_NEEDED:
2199-
/*
2200-
* TSA-SQ can potentially lead to info leakage between
2201-
* SMT threads.
2202-
*/
2203-
if (sched_smt_active())
2204-
static_branch_enable(&cpu_buf_idle_clear);
2205-
else
2206-
static_branch_disable(&cpu_buf_idle_clear);
2207-
break;
2208-
case TSA_MITIGATION_NONE:
2209-
break;
2210-
}
2211-
2212-
mutex_unlock(&spec_ctrl_mutex);
2213-
}
2214-
22152141
#undef pr_fmt
22162142
#define pr_fmt(fmt) "Speculative Store Bypass: " fmt
22172143

@@ -2965,6 +2891,80 @@ static void __init vmscape_select_mitigation(void)
29652891
#undef pr_fmt
29662892
#define pr_fmt(fmt) fmt
29672893

2894+
void cpu_bugs_smt_update(void)
2895+
{
2896+
mutex_lock(&spec_ctrl_mutex);
2897+
2898+
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
2899+
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
2900+
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
2901+
2902+
switch (spectre_v2_user_stibp) {
2903+
case SPECTRE_V2_USER_NONE:
2904+
break;
2905+
case SPECTRE_V2_USER_STRICT:
2906+
case SPECTRE_V2_USER_STRICT_PREFERRED:
2907+
update_stibp_strict();
2908+
break;
2909+
case SPECTRE_V2_USER_PRCTL:
2910+
case SPECTRE_V2_USER_SECCOMP:
2911+
update_indir_branch_cond();
2912+
break;
2913+
}
2914+
2915+
switch (mds_mitigation) {
2916+
case MDS_MITIGATION_FULL:
2917+
case MDS_MITIGATION_VMWERV:
2918+
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
2919+
pr_warn_once(MDS_MSG_SMT);
2920+
update_mds_branch_idle();
2921+
break;
2922+
case MDS_MITIGATION_OFF:
2923+
break;
2924+
}
2925+
2926+
switch (taa_mitigation) {
2927+
case TAA_MITIGATION_VERW:
2928+
case TAA_MITIGATION_UCODE_NEEDED:
2929+
if (sched_smt_active())
2930+
pr_warn_once(TAA_MSG_SMT);
2931+
break;
2932+
case TAA_MITIGATION_TSX_DISABLED:
2933+
case TAA_MITIGATION_OFF:
2934+
break;
2935+
}
2936+
2937+
switch (mmio_mitigation) {
2938+
case MMIO_MITIGATION_VERW:
2939+
case MMIO_MITIGATION_UCODE_NEEDED:
2940+
if (sched_smt_active())
2941+
pr_warn_once(MMIO_MSG_SMT);
2942+
break;
2943+
case MMIO_MITIGATION_OFF:
2944+
break;
2945+
}
2946+
2947+
switch (tsa_mitigation) {
2948+
case TSA_MITIGATION_USER_KERNEL:
2949+
case TSA_MITIGATION_VM:
2950+
case TSA_MITIGATION_FULL:
2951+
case TSA_MITIGATION_UCODE_NEEDED:
2952+
/*
2953+
* TSA-SQ can potentially lead to info leakage between
2954+
* SMT threads.
2955+
*/
2956+
if (sched_smt_active())
2957+
static_branch_enable(&cpu_buf_idle_clear);
2958+
else
2959+
static_branch_disable(&cpu_buf_idle_clear);
2960+
break;
2961+
case TSA_MITIGATION_NONE:
2962+
break;
2963+
}
2964+
2965+
mutex_unlock(&spec_ctrl_mutex);
2966+
}
2967+
29682968
#ifdef CONFIG_SYSFS
29692969

29702970
#define L1TF_DEFAULT_MSG "Mitigation: PTE Inversion"

0 commit comments

Comments
 (0)