From: Emanuele Rocca <emanuele.rocca@arm.com>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org,
broonie@kernel.org, jpoimboe@kernel.org, nathan@kernel.org,
nsc@kernel.org, mcgrof@kernel.org, petr.pavlu@suse.com,
da.gomez@kernel.org, samitolvanen@google.com,
atomlin@atomlin.com, ndesaulniers@google.com,
mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com,
ardb@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 0/3] kbuild: modules: Fixup arm64 BTI relocations
Date: Wed, 7 Oct 2026 10:09:37 +0200 [thread overview]
Message-ID: <asX-QZPtpUG5UdBU@NH27D9T0LF> (raw)
In-Reply-To: <20261006221815.2823252-1-jeremy.linton@arm.com>
On 2026-10-06 05:18, Jeremy Linton wrote:
> The kernel module loader, the arm64 ABI, GCC/Clang, and the static
> linkers operate with slightly different assumptions about which
> functions require BTI landing pads.
>
> A static function called only directly does not normally need a BTI
> landing pad, so compilers omit it. A static linker producing an ET_REL
> module treats R_AARCH64_CALL26 as a direct branch and leaves the
> relocation for the module loader or later link pass. It does not know
> the final distance between sections or whether the loader will later
> require an indirect branch fixup.
>
> This matters when a caller and callee are placed in different sections,
> for example by __init. The arm64 module loader may replace such a
> CALL26 relocation with a fixup containing an indirect branch, making an
> otherwise direct only function a BTI target. Ftrace makes this more
> likely because its entry NOP can replace a PAC instruction that would
> otherwise be a valid BTI landing pad.
>
> A linker could conservatively add veneers to affected cross section
> calls, but that would require knowledge of arm64 module loader fixup
> semantics and is not part of the generic relocatable link contract.
>
> Lets fix this by handling the module specific transformation during
> the kernel build. Scan cross section calls and, when the target lacks
> a BTI compatible landing pad, place a veneer in the target section,
> redirect the relocation to the veneer, and branch directly from the
> veneer to the original function entry.
>
> Jeremy Linton (3):
> kbuild: modules: Add arm64 BTI fixup utility
> kbuild: modules: Build and trigger BTI scanner for arm64
> arm64: bti: Drop compiler specific BTI checks
Tested as follows on BTI-capable hardware:
- Built a kernel with these patches and CONFIG_ARM64_BTI_KERNEL=y
- Verified that a test kernel module can successfully branch indirectly
to a valid 'bti c' landing pad
- The same test kernel module triggers an Oops - BTI if branching
indirectly to a nop
Internal error: Oops - BTI: 0000000036000002 [#1] SMP
Modules linked in: bti_probe(OE+) binfmt_misc nls_iso8859_1 aes_ce_blk [...]
[...]
pc : bti_bad+0x1c/0x28 [bti_probe]
lr : bti_bad+0x14/0x28 [bti_probe]
sp : ffff800083933a40
x29: ffff800083933a40 x28: 000000000000000c x27: 0000000000000000
x26: 0000000000000000 x25: ffff800083933c90 x24: ffffaaa7c52c7058
x23: ffffaaa7567d1040 x22: 0000000000000000 x21: 0000000000000000
x20: ffff0000d11cd100 x19: 0000000000000001 x18: ffff800083795058
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
x14: ffffffffffffffff x13: 7465677261742049 x12: 54422064696c6176
x11: 6e6920676e697265 x10: 0000000000000000 x9 : 0000000000000000
x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffaaa7567cf044
Call trace:
bti_bad+0x1c/0x28 [bti_probe] (P)
bti_probe_init+0x78/0xff8 [bti_probe]
No Oops was hit, as expected, booting the kernel with arm64.nobti.
Other than that, the system works fine under regular workloads.
Tested-By: Emanuele Rocca <emanuele.rocca@arm.com>
next prev parent reply other threads:[~2026-10-07 8:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 22:18 [RFC 0/3] kbuild: modules: Fixup arm64 BTI relocations Jeremy Linton
2026-10-06 22:18 ` [RFC 1/3] kbuild: modules: Add arm64 BTI fixup utility Jeremy Linton
2026-10-06 22:32 ` sashiko-bot
2026-10-06 22:18 ` [RFC 2/3] kbuild: modules: Build and trigger BTI scanner for arm64 Jeremy Linton
2026-10-06 22:28 ` sashiko-bot
2026-10-06 22:18 ` [RFC 3/3] arm64: bti: Drop compiler specific BTI checks Jeremy Linton
2026-10-06 22:26 ` sashiko-bot
2026-10-07 8:09 ` Emanuele Rocca [this message]
2026-10-07 8:25 ` [RFC 0/3] kbuild: modules: Fixup arm64 BTI relocations Mark Brown
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=asX-QZPtpUG5UdBU@NH27D9T0LF \
--to=emanuele.rocca@arm.com \
--cc=ardb@kernel.org \
--cc=atomlin@atomlin.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=da.gomez@kernel.org \
--cc=jeremy.linton@arm.com \
--cc=jpoimboe@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.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.