Skip to content

Commit d025b7b

Browse files
Peter Zijlstrabp3tk0v
authored andcommitted
x86/cpu: Rename original retbleed methods
Rename the original retbleed return thunk and untrain_ret to retbleed_return_thunk() and retbleed_untrain_ret(). No functional changes. Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20230814121148.909378169@infradead.org
1 parent d43490d commit d025b7b

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

arch/x86/include/asm/nospec-branch.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
.endm
273273

274274
#ifdef CONFIG_CPU_UNRET_ENTRY
275-
#define CALL_ZEN_UNTRAIN_RET "call zen_untrain_ret"
275+
#define CALL_ZEN_UNTRAIN_RET "call retbleed_untrain_ret"
276276
#else
277277
#define CALL_ZEN_UNTRAIN_RET ""
278278
#endif
@@ -282,7 +282,7 @@
282282
* return thunk isn't mapped into the userspace tables (then again, AMD
283283
* typically has NO_MELTDOWN).
284284
*
285-
* While zen_untrain_ret() doesn't clobber anything but requires stack,
285+
* While retbleed_untrain_ret() doesn't clobber anything but requires stack,
286286
* entry_ibpb() will clobber AX, CX, DX.
287287
*
288288
* As such, this must be placed after every *SWITCH_TO_KERNEL_CR3 at a point
@@ -347,11 +347,11 @@ extern void __x86_return_thunk(void);
347347
static inline void __x86_return_thunk(void) {}
348348
#endif
349349

350-
extern void zen_return_thunk(void);
350+
extern void retbleed_return_thunk(void);
351351
extern void srso_return_thunk(void);
352352
extern void srso_alias_return_thunk(void);
353353

354-
extern void zen_untrain_ret(void);
354+
extern void retbleed_untrain_ret(void);
355355
extern void srso_untrain_ret(void);
356356
extern void srso_untrain_ret_alias(void);
357357

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ static void __init retbleed_select_mitigation(void)
10431043
setup_force_cpu_cap(X86_FEATURE_UNRET);
10441044

10451045
if (IS_ENABLED(CONFIG_RETHUNK))
1046-
x86_return_thunk = zen_return_thunk;
1046+
x86_return_thunk = retbleed_return_thunk;
10471047

10481048
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
10491049
boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)

arch/x86/kernel/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ INIT_PER_CPU(irq_stack_backing_store);
521521
#endif
522522

523523
#ifdef CONFIG_RETHUNK
524-
. = ASSERT((zen_return_thunk & 0x3f) == 0, "zen_return_thunk not cacheline-aligned");
524+
. = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned");
525525
. = ASSERT((srso_safe_ret & 0x3f) == 0, "srso_safe_ret not cacheline-aligned");
526526
#endif
527527

arch/x86/lib/retpoline.S

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,32 +188,32 @@ SYM_CODE_END(srso_alias_return_thunk)
188188

189189
/*
190190
* Safety details here pertain to the AMD Zen{1,2} microarchitecture:
191-
* 1) The RET at zen_return_thunk must be on a 64 byte boundary, for
191+
* 1) The RET at retbleed_return_thunk must be on a 64 byte boundary, for
192192
* alignment within the BTB.
193-
* 2) The instruction at zen_untrain_ret must contain, and not
193+
* 2) The instruction at retbleed_untrain_ret must contain, and not
194194
* end with, the 0xc3 byte of the RET.
195195
* 3) STIBP must be enabled, or SMT disabled, to prevent the sibling thread
196196
* from re-poisioning the BTB prediction.
197197
*/
198198
.align 64
199-
.skip 64 - (zen_return_thunk - zen_untrain_ret), 0xcc
200-
SYM_START(zen_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
199+
.skip 64 - (retbleed_return_thunk - retbleed_untrain_ret), 0xcc
200+
SYM_START(retbleed_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
201201
ANNOTATE_NOENDBR
202202
/*
203-
* As executed from zen_untrain_ret, this is:
203+
* As executed from retbleed_untrain_ret, this is:
204204
*
205205
* TEST $0xcc, %bl
206206
* LFENCE
207-
* JMP zen_return_thunk
207+
* JMP retbleed_return_thunk
208208
*
209209
* Executing the TEST instruction has a side effect of evicting any BTB
210210
* prediction (potentially attacker controlled) attached to the RET, as
211-
* zen_return_thunk + 1 isn't an instruction boundary at the moment.
211+
* retbleed_return_thunk + 1 isn't an instruction boundary at the moment.
212212
*/
213213
.byte 0xf6
214214

215215
/*
216-
* As executed from zen_return_thunk, this is a plain RET.
216+
* As executed from retbleed_return_thunk, this is a plain RET.
217217
*
218218
* As part of the TEST above, RET is the ModRM byte, and INT3 the imm8.
219219
*
@@ -225,13 +225,13 @@ SYM_START(zen_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE)
225225
* With SMT enabled and STIBP active, a sibling thread cannot poison
226226
* RET's prediction to a type of its choice, but can evict the
227227
* prediction due to competitive sharing. If the prediction is
228-
* evicted, zen_return_thunk will suffer Straight Line Speculation
228+
* evicted, retbleed_return_thunk will suffer Straight Line Speculation
229229
* which will be contained safely by the INT3.
230230
*/
231-
SYM_INNER_LABEL(zen_return_thunk, SYM_L_GLOBAL)
231+
SYM_INNER_LABEL(retbleed_return_thunk, SYM_L_GLOBAL)
232232
ret
233233
int3
234-
SYM_CODE_END(zen_return_thunk)
234+
SYM_CODE_END(retbleed_return_thunk)
235235

236236
/*
237237
* Ensure the TEST decoding / BTB invalidation is complete.
@@ -242,13 +242,13 @@ SYM_CODE_END(zen_return_thunk)
242242
* Jump back and execute the RET in the middle of the TEST instruction.
243243
* INT3 is for SLS protection.
244244
*/
245-
jmp zen_return_thunk
245+
jmp retbleed_return_thunk
246246
int3
247-
SYM_FUNC_END(zen_untrain_ret)
248-
__EXPORT_THUNK(zen_untrain_ret)
247+
SYM_FUNC_END(retbleed_untrain_ret)
248+
__EXPORT_THUNK(retbleed_untrain_ret)
249249

250250
/*
251-
* SRSO untraining sequence for Zen1/2, similar to zen_untrain_ret()
251+
* SRSO untraining sequence for Zen1/2, similar to retbleed_untrain_ret()
252252
* above. On kernel entry, srso_untrain_ret() is executed which is a
253253
*
254254
* movabs $0xccccc30824648d48,%rax

tools/objtool/arch/x86/decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,6 @@ bool arch_is_rethunk(struct symbol *sym)
829829

830830
bool arch_is_embedded_insn(struct symbol *sym)
831831
{
832-
return !strcmp(sym->name, "zen_return_thunk") ||
832+
return !strcmp(sym->name, "retbleed_return_thunk") ||
833833
!strcmp(sym->name, "srso_safe_ret");
834834
}

tools/objtool/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ static int add_jump_destinations(struct objtool_file *file)
15931593
struct symbol *sym = find_symbol_by_offset(dest_sec, dest_off);
15941594

15951595
/*
1596-
* This is a special case for zen_untrain_ret().
1596+
* This is a special case for retbleed_untrain_ret().
15971597
* It jumps to __x86_return_thunk(), but objtool
15981598
* can't find the thunk's starting RET
15991599
* instruction, because the RET is also in the

0 commit comments

Comments
 (0)