]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.6.26/x86-retpoline-do-the-necessary-fixup-to-the-zen3-4-srso-return-thunk-for-srso.patch
Linux 6.6.26
[thirdparty/kernel/stable-queue.git] / releases / 6.6.26 / x86-retpoline-do-the-necessary-fixup-to-the-zen3-4-srso-return-thunk-for-srso.patch
CommitLineData
36724c58
GKH
1From 0e110732473e14d6520e49d75d2c88ef7d46fe67 Mon Sep 17 00:00:00 2001
2From: "Borislav Petkov (AMD)" <bp@alien8.de>
3Date: Tue, 2 Apr 2024 16:05:49 +0200
4Subject: x86/retpoline: Do the necessary fixup to the Zen3/4 srso return thunk for !SRSO
5
6From: Borislav Petkov (AMD) <bp@alien8.de>
7
8commit 0e110732473e14d6520e49d75d2c88ef7d46fe67 upstream.
9
10The srso_alias_untrain_ret() dummy thunk in the !CONFIG_MITIGATION_SRSO
11case is there only for the altenative in CALL_UNTRAIN_RET to have
12a symbol to resolve.
13
14However, testing with kernels which don't have CONFIG_MITIGATION_SRSO
15enabled, leads to the warning in patch_return() to fire:
16
17 missing return thunk: srso_alias_untrain_ret+0x0/0x10-0x0: eb 0e 66 66 2e
18 WARNING: CPU: 0 PID: 0 at arch/x86/kernel/alternative.c:826 apply_returns (arch/x86/kernel/alternative.c:826
19
20Put in a plain "ret" there so that gcc doesn't put a return thunk in
21in its place which special and gets checked.
22
23In addition:
24
25 ERROR: modpost: "srso_alias_untrain_ret" [arch/x86/kvm/kvm-amd.ko] undefined!
26 make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Chyba 1
27 make[1]: *** [/usr/src/linux-6.8.3/Makefile:1873: modpost] Chyba 2
28 make: *** [Makefile:240: __sub-make] Chyba 2
29
30since !SRSO builds would use the dummy return thunk as reported by
31petr.pisar@atlas.cz, https://bugzilla.kernel.org/show_bug.cgi?id=218679.
32
33Reported-by: kernel test robot <oliver.sang@intel.com>
34Closes: https://lore.kernel.org/oe-lkp/202404020901.da75a60f-oliver.sang@intel.com
35Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
36Link: https://lore.kernel.org/all/202404020901.da75a60f-oliver.sang@intel.com/
37Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
38Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39---
40 arch/x86/lib/retpoline.S | 5 ++++-
41 1 file changed, 4 insertions(+), 1 deletion(-)
42
43--- a/arch/x86/lib/retpoline.S
44+++ b/arch/x86/lib/retpoline.S
45@@ -222,8 +222,11 @@ SYM_CODE_END(srso_return_thunk)
46 #define JMP_SRSO_UNTRAIN_RET "ud2"
47 /* Dummy for the alternative in CALL_UNTRAIN_RET. */
48 SYM_CODE_START(srso_alias_untrain_ret)
49- RET
50+ ANNOTATE_UNRET_SAFE
51+ ret
52+ int3
53 SYM_FUNC_END(srso_alias_untrain_ret)
54+__EXPORT_THUNK(srso_alias_untrain_ret)
55 #endif /* CONFIG_CPU_SRSO */
56
57 #ifdef CONFIG_CPU_UNRET_ENTRY