Skip to content

Commit 262448f

Browse files
nathanchancePeter Zijlstra
authored andcommitted
x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0
Commit 156ff4a ("x86/ibt: Base IBT bits") added a check for a crash with 'clang -fcf-protection=branch -mfentry -pg', which intended to exclude Clang versions older than 14.0.0 from selecting CONFIG_X86_KERNEL_IBT. clang-11 does not have the issue that the check is testing for, so CONFIG_X86_KERNEL_IBT is selectable. Unfortunately, there is a different crash in clang-11 that was fixed in clang-12. To make matters worse, that crash does not appear to be entirely deterministic, as the same input to the compiler will sometimes crash and other times not, which makes dynamically checking for the crash like the '-pg' one unreliable. To make everything work properly for all common versions of clang, use a hard version check of 14.0.0, as that will be the first release upstream that has both bugs properly fixed. Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d31ed5d commit 262448f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,9 +1865,10 @@ config CC_HAS_IBT
18651865
# GCC >= 9 and binutils >= 2.29
18661866
# Retpoline check to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654
18671867
# Clang/LLVM >= 14
1868-
# fentry check to work around https://reviews.llvm.org/D111108
1868+
# https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf31d7f6aac00e0f
1869+
# https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c66454934a37c1f35332
18691870
def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=branch -mindirect-branch-register)) || \
1870-
(CC_IS_CLANG && $(success,echo "void a(void) {}" | $(CC) -Werror $(CLANG_FLAGS) -fcf-protection=branch -mfentry -pg -x c - -c -o /dev/null))) && \
1871+
(CC_IS_CLANG && CLANG_VERSION >= 140000)) && \
18711872
$(as-instr,endbr64)
18721873

18731874
config X86_KERNEL_IBT

0 commit comments

Comments
 (0)