Skip to content

Commit e6cfcdd

Browse files
kimphillamdsuryasaimadhu
authored andcommitted
x86/bugs: Enable STIBP for IBPB mitigated RETBleed
AMD's "Technical Guidance for Mitigating Branch Type Confusion, Rev. 1.0 2022-07-12" whitepaper, under section 6.1.2 "IBPB On Privileged Mode Entry / SMT Safety" says: Similar to the Jmp2Ret mitigation, if the code on the sibling thread cannot be trusted, software should set STIBP to 1 or disable SMT to ensure SMT safety when using this mitigation. So, like already being done for retbleed=unret, and now also for retbleed=ibpb, force STIBP on machines that have it, and report its SMT vulnerability status accordingly. [ bp: Remove the "we" and remove "[AMD]" applicability parameter which doesn't work here. ] Fixes: 3ebc170 ("x86/bugs: Add retbleed=ibpb") Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: [email protected] # 5.10, 5.15, 5.19 Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Link: https://lore.kernel.org/r/[email protected]
1 parent de979c8 commit e6cfcdd

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,20 +5209,33 @@
52095209
Speculative Code Execution with Return Instructions)
52105210
vulnerability.
52115211

5212+
AMD-based UNRET and IBPB mitigations alone do not stop
5213+
sibling threads from influencing the predictions of other
5214+
sibling threads. For that reason, STIBP is used on pro-
5215+
cessors that support it, and mitigate SMT on processors
5216+
that don't.
5217+
52125218
off - no mitigation
52135219
auto - automatically select a migitation
52145220
auto,nosmt - automatically select a mitigation,
52155221
disabling SMT if necessary for
52165222
the full mitigation (only on Zen1
52175223
and older without STIBP).
5218-
ibpb - mitigate short speculation windows on
5219-
basic block boundaries too. Safe, highest
5220-
perf impact.
5221-
unret - force enable untrained return thunks,
5222-
only effective on AMD f15h-f17h
5223-
based systems.
5224-
unret,nosmt - like unret, will disable SMT when STIBP
5225-
is not available.
5224+
ibpb - On AMD, mitigate short speculation
5225+
windows on basic block boundaries too.
5226+
Safe, highest perf impact. It also
5227+
enables STIBP if present. Not suitable
5228+
on Intel.
5229+
ibpb,nosmt - Like "ibpb" above but will disable SMT
5230+
when STIBP is not available. This is
5231+
the alternative for systems which do not
5232+
have STIBP.
5233+
unret - Force enable untrained return thunks,
5234+
only effective on AMD f15h-f17h based
5235+
systems.
5236+
unret,nosmt - Like unret, but will disable SMT when STIBP
5237+
is not available. This is the alternative for
5238+
systems which do not have STIBP.
52265239

52275240
Selecting 'auto' will choose a mitigation method at run
52285241
time according to the CPU.

arch/x86/kernel/cpu/bugs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void __init check_bugs(void)
152152
/*
153153
* spectre_v2_user_select_mitigation() relies on the state set by
154154
* retbleed_select_mitigation(); specifically the STIBP selection is
155-
* forced for UNRET.
155+
* forced for UNRET or IBPB.
156156
*/
157157
spectre_v2_user_select_mitigation();
158158
ssb_select_mitigation();
@@ -1179,7 +1179,8 @@ spectre_v2_user_select_mitigation(void)
11791179
boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
11801180
mode = SPECTRE_V2_USER_STRICT_PREFERRED;
11811181

1182-
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) {
1182+
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET ||
1183+
retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
11831184
if (mode != SPECTRE_V2_USER_STRICT &&
11841185
mode != SPECTRE_V2_USER_STRICT_PREFERRED)
11851186
pr_info("Selecting STIBP always-on mode to complement retbleed mitigation\n");
@@ -2320,10 +2321,11 @@ static ssize_t srbds_show_state(char *buf)
23202321

23212322
static ssize_t retbleed_show_state(char *buf)
23222323
{
2323-
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) {
2324+
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET ||
2325+
retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
23242326
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
23252327
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)
2326-
return sprintf(buf, "Vulnerable: untrained return thunk on non-Zen uarch\n");
2328+
return sprintf(buf, "Vulnerable: untrained return thunk / IBPB on non-AMD based uarch\n");
23272329

23282330
return sprintf(buf, "%s; SMT %s\n",
23292331
retbleed_strings[retbleed_mitigation],

0 commit comments

Comments
 (0)