x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0
authorNathan Chancellor <nathan@kernel.org>
Fri, 18 Mar 2022 23:07:46 +0000 (16:07 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 22 Mar 2022 20:12:13 +0000 (21:12 +0100)
commit262448f3d18959d175b10e28a3b65f41d1d7313f
tree812a8053deb0dec87ddfe10e012519bfd3f5cfbd
parentd31ed5d767c0452b4f49846d80a0bfeafa3a4ded
x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0

Commit 156ff4a544ae ("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 <nathan@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220318230747.3900772-2-nathan@kernel.org
arch/x86/Kconfig