Skip to content

Commit 28504e3

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 <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Dave Hansen <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 459274c commit 28504e3

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

arch/x86/kernel/cpu/bugs.c

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

2205-
void cpu_bugs_smt_update(void)
2206-
{
2207-
mutex_lock(&spec_ctrl_mutex);
2208-
2209-
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
2210-
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
2211-
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
2212-
2213-
switch (spectre_v2_user_stibp) {
2214-
case SPECTRE_V2_USER_NONE:
2215-
break;
2216-
case SPECTRE_V2_USER_STRICT:
2217-
case SPECTRE_V2_USER_STRICT_PREFERRED:
2218-
update_stibp_strict();
2219-
break;
2220-
case SPECTRE_V2_USER_PRCTL:
2221-
case SPECTRE_V2_USER_SECCOMP:
2222-
update_indir_branch_cond();
2223-
break;
2224-
}
2225-
2226-
switch (mds_mitigation) {
2227-
case MDS_MITIGATION_FULL:
2228-
case MDS_MITIGATION_VMWERV:
2229-
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
2230-
pr_warn_once(MDS_MSG_SMT);
2231-
update_mds_branch_idle();
2232-
break;
2233-
case MDS_MITIGATION_OFF:
2234-
break;
2235-
}
2236-
2237-
switch (taa_mitigation) {
2238-
case TAA_MITIGATION_VERW:
2239-
case TAA_MITIGATION_UCODE_NEEDED:
2240-
if (sched_smt_active())
2241-
pr_warn_once(TAA_MSG_SMT);
2242-
break;
2243-
case TAA_MITIGATION_TSX_DISABLED:
2244-
case TAA_MITIGATION_OFF:
2245-
break;
2246-
}
2247-
2248-
switch (mmio_mitigation) {
2249-
case MMIO_MITIGATION_VERW:
2250-
case MMIO_MITIGATION_UCODE_NEEDED:
2251-
if (sched_smt_active())
2252-
pr_warn_once(MMIO_MSG_SMT);
2253-
break;
2254-
case MMIO_MITIGATION_OFF:
2255-
break;
2256-
}
2257-
2258-
switch (tsa_mitigation) {
2259-
case TSA_MITIGATION_USER_KERNEL:
2260-
case TSA_MITIGATION_VM:
2261-
case TSA_MITIGATION_FULL:
2262-
case TSA_MITIGATION_UCODE_NEEDED:
2263-
/*
2264-
* TSA-SQ can potentially lead to info leakage between
2265-
* SMT threads.
2266-
*/
2267-
if (sched_smt_active())
2268-
static_branch_enable(&cpu_buf_idle_clear);
2269-
else
2270-
static_branch_disable(&cpu_buf_idle_clear);
2271-
break;
2272-
case TSA_MITIGATION_NONE:
2273-
break;
2274-
}
2275-
2276-
mutex_unlock(&spec_ctrl_mutex);
2277-
}
2278-
22792205
#undef pr_fmt
22802206
#define pr_fmt(fmt) "Speculative Store Bypass: " fmt
22812207

@@ -3025,6 +2951,80 @@ static void __init vmscape_select_mitigation(void)
30252951
#undef pr_fmt
30262952
#define pr_fmt(fmt) fmt
30272953

2954+
void cpu_bugs_smt_update(void)
2955+
{
2956+
mutex_lock(&spec_ctrl_mutex);
2957+
2958+
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
2959+
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
2960+
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
2961+
2962+
switch (spectre_v2_user_stibp) {
2963+
case SPECTRE_V2_USER_NONE:
2964+
break;
2965+
case SPECTRE_V2_USER_STRICT:
2966+
case SPECTRE_V2_USER_STRICT_PREFERRED:
2967+
update_stibp_strict();
2968+
break;
2969+
case SPECTRE_V2_USER_PRCTL:
2970+
case SPECTRE_V2_USER_SECCOMP:
2971+
update_indir_branch_cond();
2972+
break;
2973+
}
2974+
2975+
switch (mds_mitigation) {
2976+
case MDS_MITIGATION_FULL:
2977+
case MDS_MITIGATION_VMWERV:
2978+
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
2979+
pr_warn_once(MDS_MSG_SMT);
2980+
update_mds_branch_idle();
2981+
break;
2982+
case MDS_MITIGATION_OFF:
2983+
break;
2984+
}
2985+
2986+
switch (taa_mitigation) {
2987+
case TAA_MITIGATION_VERW:
2988+
case TAA_MITIGATION_UCODE_NEEDED:
2989+
if (sched_smt_active())
2990+
pr_warn_once(TAA_MSG_SMT);
2991+
break;
2992+
case TAA_MITIGATION_TSX_DISABLED:
2993+
case TAA_MITIGATION_OFF:
2994+
break;
2995+
}
2996+
2997+
switch (mmio_mitigation) {
2998+
case MMIO_MITIGATION_VERW:
2999+
case MMIO_MITIGATION_UCODE_NEEDED:
3000+
if (sched_smt_active())
3001+
pr_warn_once(MMIO_MSG_SMT);
3002+
break;
3003+
case MMIO_MITIGATION_OFF:
3004+
break;
3005+
}
3006+
3007+
switch (tsa_mitigation) {
3008+
case TSA_MITIGATION_USER_KERNEL:
3009+
case TSA_MITIGATION_VM:
3010+
case TSA_MITIGATION_FULL:
3011+
case TSA_MITIGATION_UCODE_NEEDED:
3012+
/*
3013+
* TSA-SQ can potentially lead to info leakage between
3014+
* SMT threads.
3015+
*/
3016+
if (sched_smt_active())
3017+
static_branch_enable(&cpu_buf_idle_clear);
3018+
else
3019+
static_branch_disable(&cpu_buf_idle_clear);
3020+
break;
3021+
case TSA_MITIGATION_NONE:
3022+
break;
3023+
}
3024+
3025+
mutex_unlock(&spec_ctrl_mutex);
3026+
}
3027+
30283028
#ifdef CONFIG_SYSFS
30293029

30303030
#define L1TF_DEFAULT_MSG "Mitigation: PTE Inversion"

0 commit comments

Comments
 (0)