Skip to content

Commit 64870ed

Browse files
Waiman-Longsuryasaimadhu
authored andcommitted
x86/speculation: Fix incorrect MDS/TAA mitigation status
For MDS vulnerable processors with TSX support, enabling either MDS or TAA mitigations will enable the use of VERW to flush internal processor buffers at the right code path. IOW, they are either both mitigated or both not. However, if the command line options are inconsistent, the vulnerabilites sysfs files may not report the mitigation status correctly. For example, with only the "mds=off" option: vulnerabilities/mds:Vulnerable; SMT vulnerable vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vulnerable The mds vulnerabilities file has wrong status in this case. Similarly, the taa vulnerability file will be wrong with mds mitigation on, but taa off. Change taa_select_mitigation() to sync up the two mitigation status and have them turned off if both "mds=off" and "tsx_async_abort=off" are present. Update documentation to emphasize the fact that both "mds=off" and "tsx_async_abort=off" have to be specified together for processors that are affected by both TAA and MDS to be effective. [ bp: Massage and add kernel-parameters.txt change too. ] Fixes: 1b42f01 ("x86/speculation/taa: Add mitigation for TSX Async Abort") Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: [email protected] Cc: Mark Gross <[email protected]> Cc: <[email protected]> Cc: Pawan Gupta <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tim Chen <[email protected]> Cc: Tony Luck <[email protected]> Cc: Tyler Hicks <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent eb094f0 commit 64870ed

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

Documentation/admin-guide/hw-vuln/mds.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ time with the option "mds=". The valid arguments for this option are:
265265

266266
============ =============================================================
267267

268-
Not specifying this option is equivalent to "mds=full".
269-
268+
Not specifying this option is equivalent to "mds=full". For processors
269+
that are affected by both TAA (TSX Asynchronous Abort) and MDS,
270+
specifying just "mds=off" without an accompanying "tsx_async_abort=off"
271+
will have no effect as the same mitigation is used for both
272+
vulnerabilities.
270273

271274
Mitigation selection guide
272275
--------------------------

Documentation/admin-guide/hw-vuln/tsx_async_abort.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ the option "tsx_async_abort=". The valid arguments for this option are:
174174
CPU is not vulnerable to cross-thread TAA attacks.
175175
============ =============================================================
176176

177-
Not specifying this option is equivalent to "tsx_async_abort=full".
177+
Not specifying this option is equivalent to "tsx_async_abort=full". For
178+
processors that are affected by both TAA and MDS, specifying just
179+
"tsx_async_abort=off" without an accompanying "mds=off" will have no
180+
effect as the same mitigation is used for both vulnerabilities.
178181

179182
The kernel command line also allows to control the TSX feature using the
180183
parameter "tsx=" on CPUs which support TSX control. MSR_IA32_TSX_CTRL is used

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,12 @@
24732473
SMT on vulnerable CPUs
24742474
off - Unconditionally disable MDS mitigation
24752475

2476+
On TAA-affected machines, mds=off can be prevented by
2477+
an active TAA mitigation as both vulnerabilities are
2478+
mitigated with the same mechanism so in order to disable
2479+
this mitigation, you need to specify tsx_async_abort=off
2480+
too.
2481+
24762482
Not specifying this option is equivalent to
24772483
mds=full.
24782484

@@ -4931,6 +4937,11 @@
49314937
vulnerable to cross-thread TAA attacks.
49324938
off - Unconditionally disable TAA mitigation
49334939

4940+
On MDS-affected machines, tsx_async_abort=off can be
4941+
prevented by an active MDS mitigation as both vulnerabilities
4942+
are mitigated with the same mechanism so in order to disable
4943+
this mitigation, you need to specify mds=off too.
4944+
49344945
Not specifying this option is equivalent to
49354946
tsx_async_abort=full. On CPUs which are MDS affected
49364947
and deploy MDS mitigation, TAA mitigation is not

arch/x86/kernel/cpu/bugs.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void)
304304
return;
305305
}
306306

307-
/* TAA mitigation is turned off on the cmdline (tsx_async_abort=off) */
308-
if (taa_mitigation == TAA_MITIGATION_OFF)
307+
/*
308+
* TAA mitigation via VERW is turned off if both
309+
* tsx_async_abort=off and mds=off are specified.
310+
*/
311+
if (taa_mitigation == TAA_MITIGATION_OFF &&
312+
mds_mitigation == MDS_MITIGATION_OFF)
309313
goto out;
310314

311315
if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
@@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void)
339343
if (taa_nosmt || cpu_mitigations_auto_nosmt())
340344
cpu_smt_disable(false);
341345

346+
/*
347+
* Update MDS mitigation, if necessary, as the mds_user_clear is
348+
* now enabled for TAA mitigation.
349+
*/
350+
if (mds_mitigation == MDS_MITIGATION_OFF &&
351+
boot_cpu_has_bug(X86_BUG_MDS)) {
352+
mds_mitigation = MDS_MITIGATION_FULL;
353+
mds_select_mitigation();
354+
}
342355
out:
343356
pr_info("%s\n", taa_strings[taa_mitigation]);
344357
}

0 commit comments

Comments
 (0)