git: bea44a836317 - main - kernel: Use external retpoline thunks
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 23 Oct 2026 15:53:27 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=bea44a83631704110de8bbd7693b683c81d4fe55
commit bea44a83631704110de8bbd7693b683c81d4fe55
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2018-03-16 02:29:38 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-10-23 15:53:05 +0000
kernel: Use external retpoline thunks
External retpoline thunks for amd64 and i386 were added in commit
74d971fe1561 ("x86: Add external retpoline thunk"). Use them when
WITH_KERNEL_RETPOLINE is set.
There should not be any material performance impact -- the call sites
are identical, and this just replaces (on amd64) compiler-generated
__llvm_retpoline_r11 functions in each object with our
__x86_indirect_thunk_r11.
After this change we could implement boot-time patching, replacing
__x86_indirect_thunk_r11 with just jmp %r11 when retpoline is not
required.
Note on i386: An i386 build WITH_KERNEL_RETPOLINE was successful, but
has not been extensively tested. Clang may use registers other than
just eax on i386 and so in the future additional thunks beyond the one
added in 74d971fe1561 could be required for i386. Patches are welcome
if this is important to you.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
---
sys/conf/kern.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 83881cc05b94..35b7a66bab49 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -246,7 +246,7 @@ CFLAGS+= -fstack-protector-strong
#
.if defined(COMPILER_FEATURES) && ${COMPILER_FEATURES:Mretpoline} != "" && \
${MK_KERNEL_RETPOLINE} != "no"
-CFLAGS+= -mretpoline
+CFLAGS+= -mretpoline-external-thunk
.endif
#