Skip to content

Commit 9d9c22c

Browse files
committed
x86/retpoline: Document some thunk handling aspects
After a lot of experimenting (see thread Link points to) document for now the issues and requirements for future improvements to the thunk handling and potential issuing of a diagnostic when the default thunk hasn't been patched out. This documentation is only temporary and that close before the merge window it is only a placeholder for those future improvements. Suggested-by: Ingo Molnar <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2d7ce49 commit 9d9c22c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

arch/x86/lib/retpoline.S

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ SYM_CODE_END(__x86_indirect_jump_thunk_array)
129129

130130
#ifdef CONFIG_RETHUNK
131131

132+
/*
133+
* Be careful here: that label cannot really be removed because in
134+
* some configurations and toolchains, the JMP __x86_return_thunk the
135+
* compiler issues is either a short one or the compiler doesn't use
136+
* relocations for same-section JMPs and that breaks the returns
137+
* detection logic in apply_returns() and in objtool.
138+
*/
132139
.section .text..__x86.return_thunk
133140

134141
#ifdef CONFIG_CPU_SRSO
@@ -361,6 +368,14 @@ SYM_FUNC_END(call_depth_return_thunk)
361368
* This code is only used during kernel boot or module init. All
362369
* 'JMP __x86_return_thunk' sites are changed to something else by
363370
* apply_returns().
371+
*
372+
* This should be converted eventually to call a warning function which
373+
* should scream loudly when the default return thunk is called after
374+
* alternatives have been applied.
375+
*
376+
* That warning function cannot BUG() because the bug splat cannot be
377+
* displayed in all possible configurations, leading to users not really
378+
* knowing why the machine froze.
364379
*/
365380
SYM_CODE_START(__x86_return_thunk)
366381
UNWIND_HINT_FUNC

0 commit comments

Comments
 (0)