Skip to content

Commit 394ed15

Browse files
committed
x86/bugs: Enable STIBP for IBPB mitigated RETBleed
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2138389 commit e6cfcdd Author: Kim Phillips <kim.phillips@amd.com> Date: Mon, 8 Aug 2022 09:32:33 -0500 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 <kim.phillips@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: stable@vger.kernel.org # 5.10, 5.15, 5.19 Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Link: https://lore.kernel.org/r/20220804192201.439596-1-kim.phillips@amd.com Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 6579554 commit 394ed15

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
@@ -5099,20 +5099,33 @@
50995099
Speculative Code Execution with Return Instructions)
51005100
vulnerability.
51015101

5102+
AMD-based UNRET and IBPB mitigations alone do not stop
5103+
sibling threads from influencing the predictions of other
5104+
sibling threads. For that reason, STIBP is used on pro-
5105+
cessors that support it, and mitigate SMT on processors
5106+
that don't.
5107+
51025108
off - no mitigation
51035109
auto - automatically select a migitation
51045110
auto,nosmt - automatically select a mitigation,
51055111
disabling SMT if necessary for
51065112
the full mitigation (only on Zen1
51075113
and older without STIBP).
5108-
ibpb - mitigate short speculation windows on
5109-
basic block boundaries too. Safe, highest
5110-
perf impact.
5111-
unret - force enable untrained return thunks,
5112-
only effective on AMD f15h-f17h
5113-
based systems.
5114-
unret,nosmt - like unret, will disable SMT when STIBP
5115-
is not available.
5114+
ibpb - On AMD, mitigate short speculation
5115+
windows on basic block boundaries too.
5116+
Safe, highest perf impact. It also
5117+
enables STIBP if present. Not suitable
5118+
on Intel.
5119+
ibpb,nosmt - Like "ibpb" above but will disable SMT
5120+
when STIBP is not available. This is
5121+
the alternative for systems which do not
5122+
have STIBP.
5123+
unret - Force enable untrained return thunks,
5124+
only effective on AMD f15h-f17h based
5125+
systems.
5126+
unret,nosmt - Like unret, but will disable SMT when STIBP
5127+
is not available. This is the alternative for
5128+
systems which do not have STIBP.
51165129

51175130
Selecting 'auto' will choose a mitigation method at run
51185131
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();
@@ -1175,7 +1175,8 @@ spectre_v2_user_select_mitigation(void)
11751175
boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
11761176
mode = SPECTRE_V2_USER_STRICT_PREFERRED;
11771177

1178-
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) {
1178+
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET ||
1179+
retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
11791180
if (mode != SPECTRE_V2_USER_STRICT &&
11801181
mode != SPECTRE_V2_USER_STRICT_PREFERRED)
11811182
pr_info("Selecting STIBP always-on mode to complement retbleed mitigation\n");
@@ -2359,10 +2360,11 @@ static ssize_t srbds_show_state(char *buf)
23592360

23602361
static ssize_t retbleed_show_state(char *buf)
23612362
{
2362-
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET) {
2363+
if (retbleed_mitigation == RETBLEED_MITIGATION_UNRET ||
2364+
retbleed_mitigation == RETBLEED_MITIGATION_IBPB) {
23632365
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
23642366
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)
2365-
return sprintf(buf, "Vulnerable: untrained return thunk on non-Zen uarch\n");
2367+
return sprintf(buf, "Vulnerable: untrained return thunk / IBPB on non-AMD based uarch\n");
23662368

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

0 commit comments

Comments
 (0)