From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
live-patching@vger.kernel.org, Song Liu <song@kernel.org>,
Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>,
Joe Lawrence <joe.lawrence@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Mark Brown <broonie@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Kees Cook <kees@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
linux-toolchains@vger.kernel.org
Subject: [PATCH 08/12] arm64/bti: Enable BTI in the pi/ startup code
Date: Fri, 14 Aug 2026 21:45:25 -0700 [thread overview]
Message-ID: <5c25e0a625b4d16a6e91e63c8d82e33d8c043d74.1786768375.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1786768375.git.jpoimboe@kernel.org>
The early startup code in kernel/pi/ is built with
-mbranch-protection=none and has its property note stripped, which
prevents the linker from generating BTI veneers in >128MB kernels.
Unlike the assembly objects, which only lacked the note because
SYM_FUNC_START*() already emits the landing pads, pi/ needs the real
thing. Some of it runs with the MMU on, where the kernel text is mapped
PTE_GP and BTI is enforced: __pi_scs_patch() is called when loading a
module, and __pi_map_range() is called from create_idmap().
Add -mbranch-protection=bti. The added "bti c" landing pads execute as
NOPs in the startup code wherever BTI isn't implemented or isn't enforced.
Also stop stripping the objects' property notes, as the linker only
marks the output BTI-compatible if *all* objects advertise it. Keeping
the note as-is isn't enough either: --prefix-alloc-sections=.init
renames it to .init.note.gnu.property, which GNU ld still parses but LLD
ignores. Rename it back afterwards so both linkers see it.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
arch/arm64/kernel/pi/Makefile | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile
index be92d73c25b21..2101d96d754e5 100644
--- a/arch/arm64/kernel/pi/Makefile
+++ b/arch/arm64/kernel/pi/Makefile
@@ -4,7 +4,7 @@
KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
-Os -DDISABLE_BRANCH_PROFILING $(DISABLE_KSTACK_ERASE) \
$(DISABLE_LATENT_ENTROPY_PLUGIN) \
- $(call cc-option,-mbranch-protection=none) \
+ $(call cc-option,-mbranch-protection=bti) \
-I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
-include $(srctree)/include/linux/hidden.h \
-D__DISABLE_EXPORTS -ffreestanding -D__NO_FORTIFY \
@@ -21,11 +21,14 @@ KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
hostprogs := relacheck
+# --prefix-alloc-sections=.init also renames .note.gnu.property, which LLD then
+# ignores, dropping the BTI property. Rename it back.
quiet_cmd_piobjcopy = $(quiet_cmd_objcopy)
- cmd_piobjcopy = $(cmd_objcopy) && $(obj)/relacheck $(@) $(<)
+ cmd_piobjcopy = $(cmd_objcopy) && \
+ $(OBJCOPY) --rename-section .init.note.gnu.property=.note.gnu.property $(@) && \
+ $(obj)/relacheck $(@) $(<)
-$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
- --remove-section=.note.gnu.property
+$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_
$(obj)/%.pi.o: $(obj)/%.o $(obj)/relacheck FORCE
$(call if_changed,piobjcopy)
--
2.55.0
next prev parent reply other threads:[~2026-08-15 4:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 4:45 [PATCH 00/12] arm64/bti: Fix kernel BTI issues with livepatch, large kernels, toolchains Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 01/12] arm64/bti: Add BTI landing pad to __sdei_asm_handler() Josh Poimboeuf
2026-08-15 5:01 ` sashiko-bot
2026-08-15 4:45 ` [PATCH 02/12] arm64/module: Fix BTI exceptions caused by omitted landing pads in Clang 21 Josh Poimboeuf
2026-08-15 5:00 ` sashiko-bot
2026-08-15 9:56 ` Ard Biesheuvel
2026-08-15 18:57 ` Josh Poimboeuf
2026-08-17 11:11 ` Ard Biesheuvel
2026-08-17 21:44 ` Josh Poimboeuf
2026-08-16 9:41 ` Will Deacon
2026-08-16 13:49 ` Ard Biesheuvel
2026-08-16 18:46 ` Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 03/12] arm64/bti: Fix BTI linker failures with long branches into .idmap.text Josh Poimboeuf
2026-08-17 11:05 ` Ard Biesheuvel
2026-08-15 4:45 ` [PATCH 04/12] arm64/bti: Work around ld crash caused by linker script aliases Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 05/12] arm64/bti: Add link error for large kernels with BTI and unsupported toolchains Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 06/12] arm64/bti: Add link error for large kernels with BTI and livepatch Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 07/12] arm64/bti: Advertise BTI in assembly objects Josh Poimboeuf
2026-08-15 5:03 ` sashiko-bot
2026-08-15 21:53 ` Mark Brown
2026-08-15 4:45 ` Josh Poimboeuf [this message]
2026-08-15 4:45 ` [PATCH 09/12] efi/libstub: Preserve the GNU property note Josh Poimboeuf
2026-08-15 4:45 ` [PATCH 10/12] efi/libstub: Remove obsolete .note.gnu.property workaround Josh Poimboeuf
2026-08-17 19:54 ` Nick Desaulniers
2026-08-18 14:15 ` Ard Biesheuvel
2026-08-15 4:45 ` [PATCH 11/12] arm64/bti: Force-enable BTI linker veneers Josh Poimboeuf
2026-08-15 5:00 ` sashiko-bot
2026-08-15 4:45 ` [PATCH 12/12] arm64/bti: Enable kernel BTI for GCC Josh Poimboeuf
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=5c25e0a625b4d16a6e91e63c8d82e33d8c043d74.1786768375.git.jpoimboe@kernel.org \
--to=jpoimboe@kernel.org \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=joe.lawrence@redhat.com \
--cc=kees@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-toolchains@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=pmladek@suse.com \
--cc=song@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®