Skip to content

Commit a5d029f

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 34e5667 commit a5d029f

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
@@ -2192,80 +2192,6 @@ static void __init tsa_select_mitigation(void)
21922192
pr_info("%s\n", tsa_strings[tsa_mitigation]);
21932193
}
21942194

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

@@ -3016,6 +2942,80 @@ static void __init vmscape_select_mitigation(void)
30162942
#undef pr_fmt
30172943
#define pr_fmt(fmt) fmt
30182944

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

30213021
#define L1TF_DEFAULT_MSG "Mitigation: PTE Inversion"

0 commit comments

Comments
 (0)