Skip to content

Commit 99a83db

Browse files
pa1guptasuryasaimadhu
authored andcommitted
x86/speculation/mmio: Enable CPU Fill buffer clearing on idle
When the CPU is affected by Processor MMIO Stale Data vulnerabilities, Fill Buffer Stale Data Propagator (FBSDP) can propagate stale data out of Fill buffer to uncore buffer when CPU goes idle. Stale data can then be exploited with other variants using MMIO operations. Mitigate it by clearing the Fill buffer before entering idle state. Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Co-developed-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de>
1 parent e5925fb commit 99a83db

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

arch/x86/kernel/cpu/bugs.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ static void __init mmio_select_mitigation(void)
433433
else
434434
static_branch_enable(&mmio_stale_data_clear);
435435

436+
/*
437+
* If Processor-MMIO-Stale-Data bug is present and Fill Buffer data can
438+
* be propagated to uncore buffers, clearing the Fill buffers on idle
439+
* is required irrespective of SMT state.
440+
*/
441+
if (!(ia32_cap & ARCH_CAP_FBSDP_NO))
442+
static_branch_enable(&mds_idle_clear);
443+
436444
/*
437445
* Check if the system has the right microcode.
438446
*
@@ -1225,6 +1233,8 @@ static void update_indir_branch_cond(void)
12251233
/* Update the static key controlling the MDS CPU buffer clear in idle */
12261234
static void update_mds_branch_idle(void)
12271235
{
1236+
u64 ia32_cap = x86_read_arch_cap_msr();
1237+
12281238
/*
12291239
* Enable the idle clearing if SMT is active on CPUs which are
12301240
* affected only by MSBDS and not any other MDS variant.
@@ -1236,10 +1246,12 @@ static void update_mds_branch_idle(void)
12361246
if (!boot_cpu_has_bug(X86_BUG_MSBDS_ONLY))
12371247
return;
12381248

1239-
if (sched_smt_active())
1249+
if (sched_smt_active()) {
12401250
static_branch_enable(&mds_idle_clear);
1241-
else
1251+
} else if (mmio_mitigation == MMIO_MITIGATION_OFF ||
1252+
(ia32_cap & ARCH_CAP_FBSDP_NO)) {
12421253
static_branch_disable(&mds_idle_clear);
1254+
}
12431255
}
12441256

12451257
#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"

0 commit comments

Comments
 (0)