Skip to content

Commit 0e11073

Browse files
bp3tk0vtorvalds
authored andcommitted
x86/retpoline: Do the necessary fixup to the Zen3/4 srso return thunk for !SRSO
The srso_alias_untrain_ret() dummy thunk in the !CONFIG_MITIGATION_SRSO case is there only for the altenative in CALL_UNTRAIN_RET to have a symbol to resolve. However, testing with kernels which don't have CONFIG_MITIGATION_SRSO enabled, leads to the warning in patch_return() to fire: missing return thunk: srso_alias_untrain_ret+0x0/0x10-0x0: eb 0e 66 66 2e WARNING: CPU: 0 PID: 0 at arch/x86/kernel/alternative.c:826 apply_returns (arch/x86/kernel/alternative.c:826 Put in a plain "ret" there so that gcc doesn't put a return thunk in in its place which special and gets checked. In addition: ERROR: modpost: "srso_alias_untrain_ret" [arch/x86/kvm/kvm-amd.ko] undefined! make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Chyba 1 make[1]: *** [/usr/src/linux-6.8.3/Makefile:1873: modpost] Chyba 2 make: *** [Makefile:240: __sub-make] Chyba 2 since !SRSO builds would use the dummy return thunk as reported by [email protected], https://bugzilla.kernel.org/show_bug.cgi?id=218679. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3e92c1e commit 0e11073

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/lib/retpoline.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ SYM_CODE_END(srso_return_thunk)
228228
#else /* !CONFIG_MITIGATION_SRSO */
229229
/* Dummy for the alternative in CALL_UNTRAIN_RET. */
230230
SYM_CODE_START(srso_alias_untrain_ret)
231-
RET
231+
ANNOTATE_UNRET_SAFE
232+
ret
233+
int3
232234
SYM_FUNC_END(srso_alias_untrain_ret)
235+
__EXPORT_THUNK(srso_alias_untrain_ret)
233236
#define JMP_SRSO_UNTRAIN_RET "ud2"
234237
#endif /* CONFIG_MITIGATION_SRSO */
235238

0 commit comments

Comments
 (0)