From: Nathan Chancellor <nathan@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
D Scott Phillips <scott@os.amperecomputing.com>,
Mark Brown <broonie@kernel.org>
Subject: Re: Revisiting c0a454b9044f
Date: Wed, 16 Jul 2025 12:26:41 -0600 [thread overview]
Message-ID: <20250716182641.GA2746700@ax162> (raw)
In-Reply-To: <aHY4d46ehF-j_pbw@J2N7QTR9R3>
On Tue, Jul 15, 2025 at 12:16:07PM +0100, Mark Rutland wrote:
> On Mon, Jul 14, 2025 at 12:52:05PM -0700, Nathan Chancellor wrote:
> > I am looking to potentially bump the minimum version of LLVM for
> > building the kernel to 15.0.0 after the next merge window. In my quest
> > to look for workarounds that can be dropped, I noticed that
> > CONFIG_ARM64_BTI_KERNEL was disabled unconditionally for GCC in commit
> > c0a454b9044f ("arm64/bti: Disable in kernel BTI when cross section
> > thunks are broken") as a result of [1]. Looking at that GCC report, it
> > seems like the AArch64 ABI now documents [2] the GNU toolchain's
> > behavior as expected
>
> For context, at the time of commit c0a454b9044f, GNU LD did not handle
> this appropriately, leading to runtime BTI failures where two sections
> were too far apart.
>
> GNU LD was subsequently fixed, and the ABI documentation was updated,
> but I'm not sure which specific versions of GNU LD have the fix, and we
> hadn't chased that up to re-enable BTI with GCC.
Based on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671#c7 and
https://sourceware.org/bugzilla/show_bug.cgi?id=30076, it sounds like
binutils 2.41 would be the first fixed version.
> > and LLVM has been adjusted [3][4][5] to match. Do I need to block
> > CONFIG_ARM64_BTI_KERNEL from being selected with LLVM 21.0.0?
>
> I'm missing something; why would we need to dsiable BTI in that case?
Nope, you are not missing anything, I missed the correlation between the
compiler and linker.
> The concern from the kernel side is simply whether we get unexpected BTI
> failures. IIUC so long as compiler and linker agree we should be good,
> and we simply need to forbid broken combinations.
Mark Brown did mention something about the module loader as well so I
was not sure if that was relevant here.
> > Or should the kernel adjust its expectations now that the ABI and
> > toolchains all agree?
>
> Yes, we can probably rework this.
>
> IIUC we'd need to forbid BTI with:
>
> * GCC + old GNU LD
> * GCC + old LLD
> * new clang + old GNU LD
> * new clang + old LLD
>
> ... and can enable BTI otherwise.
>
> Does that make sense to you?
So something like this if I understand correctly?
Cheers,
Nathan
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 393d71124f5d..fe523f9f2d61 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2097,7 +2097,11 @@ config ARM64_BTI_KERNEL
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697
depends on !CC_IS_GCC || GCC_VERSION >= 100100
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671
- depends on !CC_IS_GCC
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=30076
+ depends on !CC_IS_GCC || LD_VERSION >= 24100 || LLD_VERSION >= 210000
+ # https://github.com/llvm/llvm-project/commit/7af2b51e761f49974a64c3009882239cea618f2a
+ # https://github.com/llvm/llvm-project/commit/098b0d18add97dea94e16006486b2fded65e228d
+ depends on !CC_IS_CLANG || CLANG_VERSION < 210000 || (CLANG_VERSION >= 210000 && (LD_VERSION >= 24100 || LLD_VERSION >= 210000))
depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS)
help
Build the kernel with Branch Target Identification annotations
next prev parent reply other threads:[~2025-07-16 18:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 19:52 Revisiting c0a454b9044f Nathan Chancellor
2025-07-15 11:16 ` Mark Rutland
2025-07-16 18:26 ` Nathan Chancellor [this message]
2025-07-17 13:47 ` Mark Rutland
2025-12-30 15:06 ` ARM64_BTI_KERNEL and gcc? (was Re: Revisiting c0a454b9044f ) Mikko Rapeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250716182641.GA2746700@ax162 \
--to=nathan@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=scott@os.amperecomputing.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.