Skip to content

Commit 8eb19bb

Browse files
committed
x86/bugs: Move cpu_bugs_smt_update() down
JIRA: https://issues.redhat.com/browse/RHEL-114277 CVE: CVE-2025-40300 commit 6449f5b Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Date: Thu, 14 Aug 2025 10:20:43 -0700 x86/bugs: Move cpu_bugs_smt_update() down 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: Waiman Long <longman@redhat.com>
1 parent 63ac98e commit 8eb19bb

File tree

1 file changed

+83
-82
lines changed

1 file changed

+83
-82
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,88 +2362,6 @@ static void update_mds_branch_idle(void)
23622362
}
23632363
}
23642364

2365-
#define MDS_MSG_SMT "MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details.\n"
2366-
#define TAA_MSG_SMT "TAA CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html for more details.\n"
2367-
#define MMIO_MSG_SMT "MMIO Stale Data CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/processor_mmio_stale_data.html for more details.\n"
2368-
2369-
void cpu_bugs_smt_update(void)
2370-
{
2371-
mutex_lock(&spec_ctrl_mutex);
2372-
2373-
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
2374-
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
2375-
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
2376-
2377-
switch (spectre_v2_user_stibp) {
2378-
case SPECTRE_V2_USER_NONE:
2379-
break;
2380-
case SPECTRE_V2_USER_STRICT:
2381-
case SPECTRE_V2_USER_STRICT_PREFERRED:
2382-
update_stibp_strict();
2383-
break;
2384-
case SPECTRE_V2_USER_PRCTL:
2385-
case SPECTRE_V2_USER_SECCOMP:
2386-
update_indir_branch_cond();
2387-
break;
2388-
}
2389-
2390-
switch (mds_mitigation) {
2391-
case MDS_MITIGATION_FULL:
2392-
case MDS_MITIGATION_AUTO:
2393-
case MDS_MITIGATION_VMWERV:
2394-
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
2395-
pr_warn_once(MDS_MSG_SMT);
2396-
update_mds_branch_idle();
2397-
break;
2398-
case MDS_MITIGATION_OFF:
2399-
break;
2400-
}
2401-
2402-
switch (taa_mitigation) {
2403-
case TAA_MITIGATION_VERW:
2404-
case TAA_MITIGATION_AUTO:
2405-
case TAA_MITIGATION_UCODE_NEEDED:
2406-
if (sched_smt_active())
2407-
pr_warn_once(TAA_MSG_SMT);
2408-
break;
2409-
case TAA_MITIGATION_TSX_DISABLED:
2410-
case TAA_MITIGATION_OFF:
2411-
break;
2412-
}
2413-
2414-
switch (mmio_mitigation) {
2415-
case MMIO_MITIGATION_VERW:
2416-
case MMIO_MITIGATION_AUTO:
2417-
case MMIO_MITIGATION_UCODE_NEEDED:
2418-
if (sched_smt_active())
2419-
pr_warn_once(MMIO_MSG_SMT);
2420-
break;
2421-
case MMIO_MITIGATION_OFF:
2422-
break;
2423-
}
2424-
2425-
switch (tsa_mitigation) {
2426-
case TSA_MITIGATION_USER_KERNEL:
2427-
case TSA_MITIGATION_VM:
2428-
case TSA_MITIGATION_AUTO:
2429-
case TSA_MITIGATION_FULL:
2430-
/*
2431-
* TSA-SQ can potentially lead to info leakage between
2432-
* SMT threads.
2433-
*/
2434-
if (sched_smt_active())
2435-
static_branch_enable(&cpu_buf_idle_clear);
2436-
else
2437-
static_branch_disable(&cpu_buf_idle_clear);
2438-
break;
2439-
case TSA_MITIGATION_NONE:
2440-
case TSA_MITIGATION_UCODE_NEEDED:
2441-
break;
2442-
}
2443-
2444-
mutex_unlock(&spec_ctrl_mutex);
2445-
}
2446-
24472365
#undef pr_fmt
24482366
#define pr_fmt(fmt) "Speculative Store Bypass: " fmt
24492367

@@ -3218,6 +3136,89 @@ static void __init vmscape_apply_mitigation(void)
32183136
#undef pr_fmt
32193137
#define pr_fmt(fmt) fmt
32203138

3139+
#define MDS_MSG_SMT "MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details.\n"
3140+
#define TAA_MSG_SMT "TAA CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html for more details.\n"
3141+
#define MMIO_MSG_SMT "MMIO Stale Data CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/processor_mmio_stale_data.html for more details.\n"
3142+
#define VMSCAPE_MSG_SMT "VMSCAPE: SMT on, STIBP is required for full protection. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/vmscape.html for more details.\n"
3143+
3144+
void cpu_bugs_smt_update(void)
3145+
{
3146+
mutex_lock(&spec_ctrl_mutex);
3147+
3148+
if (sched_smt_active() && unprivileged_ebpf_enabled() &&
3149+
spectre_v2_enabled == SPECTRE_V2_EIBRS_LFENCE)
3150+
pr_warn_once(SPECTRE_V2_EIBRS_LFENCE_EBPF_SMT_MSG);
3151+
3152+
switch (spectre_v2_user_stibp) {
3153+
case SPECTRE_V2_USER_NONE:
3154+
break;
3155+
case SPECTRE_V2_USER_STRICT:
3156+
case SPECTRE_V2_USER_STRICT_PREFERRED:
3157+
update_stibp_strict();
3158+
break;
3159+
case SPECTRE_V2_USER_PRCTL:
3160+
case SPECTRE_V2_USER_SECCOMP:
3161+
update_indir_branch_cond();
3162+
break;
3163+
}
3164+
3165+
switch (mds_mitigation) {
3166+
case MDS_MITIGATION_FULL:
3167+
case MDS_MITIGATION_AUTO:
3168+
case MDS_MITIGATION_VMWERV:
3169+
if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
3170+
pr_warn_once(MDS_MSG_SMT);
3171+
update_mds_branch_idle();
3172+
break;
3173+
case MDS_MITIGATION_OFF:
3174+
break;
3175+
}
3176+
3177+
switch (taa_mitigation) {
3178+
case TAA_MITIGATION_VERW:
3179+
case TAA_MITIGATION_AUTO:
3180+
case TAA_MITIGATION_UCODE_NEEDED:
3181+
if (sched_smt_active())
3182+
pr_warn_once(TAA_MSG_SMT);
3183+
break;
3184+
case TAA_MITIGATION_TSX_DISABLED:
3185+
case TAA_MITIGATION_OFF:
3186+
break;
3187+
}
3188+
3189+
switch (mmio_mitigation) {
3190+
case MMIO_MITIGATION_VERW:
3191+
case MMIO_MITIGATION_AUTO:
3192+
case MMIO_MITIGATION_UCODE_NEEDED:
3193+
if (sched_smt_active())
3194+
pr_warn_once(MMIO_MSG_SMT);
3195+
break;
3196+
case MMIO_MITIGATION_OFF:
3197+
break;
3198+
}
3199+
3200+
switch (tsa_mitigation) {
3201+
case TSA_MITIGATION_USER_KERNEL:
3202+
case TSA_MITIGATION_VM:
3203+
case TSA_MITIGATION_AUTO:
3204+
case TSA_MITIGATION_FULL:
3205+
/*
3206+
* TSA-SQ can potentially lead to info leakage between
3207+
* SMT threads.
3208+
*/
3209+
if (sched_smt_active())
3210+
static_branch_enable(&cpu_buf_idle_clear);
3211+
else
3212+
static_branch_disable(&cpu_buf_idle_clear);
3213+
break;
3214+
case TSA_MITIGATION_NONE:
3215+
case TSA_MITIGATION_UCODE_NEEDED:
3216+
break;
3217+
}
3218+
3219+
mutex_unlock(&spec_ctrl_mutex);
3220+
}
3221+
32213222
#ifdef CONFIG_SYSFS
32223223

32233224
#define L1TF_DEFAULT_MSG "Mitigation: PTE Inversion"

0 commit comments

Comments
 (0)