git: cb1627e40d5c - main - kernel: Add -mindirect-branch-cs-prefix for WITH_KERNEL_RETPOLINE

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 13 Nov 2026 21:19:16 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=cb1627e40d5c0c21f2f7d13e848cf6495390e777

commit cb1627e40d5c0c21f2f7d13e848cf6495390e777
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-10-22 18:21:45 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-11-13 21:18:58 +0000

    kernel: Add -mindirect-branch-cs-prefix for WITH_KERNEL_RETPOLINE
    
    -mindirect-branch-cs-prefix adds a CS segment-override prefix (0x2e)
    to each call or jmp to a retpoline thunk.  The CPU ignores the prefix,
    but it extends the instruction to six bytes instead of five.  This
    leaves enough room for a future kernel change to patch all of the call
    sites at boot time to disable retpoline if not required.
    
    Support for this option arrived in GCC 12 and Clang/LLVM 16.
    
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D61514
---
 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 35b7a66bab49..9fb02ec78eea 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-external-thunk
+CFLAGS+=	-mretpoline-external-thunk -mindirect-branch-cs-prefix
 .endif
 
 #