From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 683AC413D62 for ; Thu, 13 Aug 2026 07:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786607641; cv=none; b=rHzKBYBXak9UJFQd8oppNImYFres5pxmq7/xe67K/fAagiVic2SFj6Sl0sTIsA/58c7R6P2xCtGi/cZPviHcNeksoMUXkTAX7q0NXMYuBNPqrasPo6kXj9HvaLHV3D5Z6C3okayLyifetlsBI2WosmL5C74CRbtlB9qIftQf9Ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786607641; c=relaxed/simple; bh=cG3hrDkslFCCtONRa1ngYdeX2HJlN7mkTBYNyPAPzYw=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=dnf6sWUyZ08Sa9q6oPetRFqh+mRAZ2VNjEPPox8xs3azrEsGLsdg5x9MDMGY1hWcD3tAMWjrP5ElcPvS/Ll0pCQ3ft84CvzzU3nmgMcYsI49vpC9E42BC7I6Zk8Vm+AqVIqjYefjGHNkIUdxWrN+QvyW44fenYv4/K9FCkgWzpw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mg6bvTjs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mg6bvTjs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3499B1F000E9; Thu, 13 Aug 2026 07:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786607640; bh=YsriNMG9eHDYtRKou8lVO1tS7JrbkBO3e2Yn3QQ/v4s=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=mg6bvTjszpjgQ49NEO6kKwWADtk4ymymbV58x2toHJWTiF0DC2e+RImy/pKPMPDPR 4KEFMx0CSqpoPGxKdXMkEVGG0l1x39lkWNrjMPJ+YMLoxydpvQr+if/BouUvbnnuJG +ahQl4Zdd9sjv7P0tNKqPsd6KACHO6I7+ktevTDWszqYDuEpIGvbNzkXMiBO04X0lg ctcDYNw3KVEVrbFlT6Z0UHTN3lREJlnp6AJshrJ0ysngwN5JQ5S1aCKLCg7Nogt60o roPS3B45o77RMzAEhKYa1elVxehPIvlhUXY0DmQapia2F1ZXo8+ULBXhqAo53A6s/q 6gZN7XgyD01RA== Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfauth.ams.internal (Postfix) with ESMTP id B0A7E1980062; Thu, 13 Aug 2026 03:53:57 -0400 (EDT) Received: from ams-imap-11 ([10.64.2.31]) by ams-compute-02.internal (MEProxy); Thu, 13 Aug 2026 03:53:57 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTF/JtEOdBnZjFp8xd8bqyDhKQWuoFDWh/xxaVzRKVjQ6OA+aoka10v0HuFh1axTah W5nYZFTHeheEQ5hqEpHj1P3+s9vEPq5fqblBz89MIleAKbhs1U1vzgI9BDvKYbzFDOhIdt wXAOjOv8CzELhjKJ+fGKTvqH50UbeBZ3ylbGstsCNw8SiSsizIQERl0l3tuhdDmlold50M adijXyJZalBUbvmWwZVfQZ9T7/o9U5J4KkZuFlILeI2UxEr7xmG8Gj3Hcs5Ei3ukP1p3/n Zb5tKIYGN+cgVXav1oKE5W0NPH8DHIh1r7xEIY2+k5V4rg+3U+HvSsRGM/VbYLx02g9wkz FUIOtBGaVRsG0IOcr1TJsMR0oAUVZsWoKS8uWXjXyqAiFsxruGtc8o7TvMYXPrc/9M8a/o IchhH5ZCXbgddpBezeajhY6W07/V9OHtczrkuQKb8QXEZ8z/zL6n/MWGZ3mEVcIKeRn1bd n5DzcTLMHC7LOD2fLbfb8T8h8rmUh2UABKDGeZZhobaB0YrRv4X3yOfm0Y87U161A4kQNw B4BOFcb+ZC4VWqn3JdWRyZbmBEuH3XGG5+QGfxvzBmCX1GI0TM6cX088h84fHEe65rKKur c4nt/o6j4PjKdOu/UuMuVZkB5DZPJ9898O/nwtF+x9dKYbDBAscDivZn6ajw X-ME-Proxy: Feedback-ID: ice86485a:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id ADC14F8006A; Thu, 13 Aug 2026 03:53:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Thu, 13 Aug 2026 10:53:34 +0300 From: "Ard Biesheuvel" To: "Josh Poimboeuf" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Will Deacon" , "Catalin Marinas" , "Mark Rutland" , "Mark Brown" , "Nick Desaulniers" Message-Id: In-Reply-To: References: <20260812162058.612202-4-ardb@kernel.org> <20260812162058.612202-5-ardb@kernel.org> Subject: Re: [PATCH 1/2] arm64: module: Emit BTI veneers for cross-section calls Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 13 Aug 2026, at 09:34, Ard Biesheuvel wrote: > On Thu, 13 Aug 2026, at 00:52, Josh Poimboeuf wrote: >> On Wed, Aug 12, 2026 at 06:21:00PM +0200, Ard Biesheuvel wrote: >>> The compiler is permitted to omit BTI landing pads from static functions >>> that never have their address taken, but are only called directly, even >>> if those calls originate from other code sections. >>> >>> This means that calls into a module's .text section from .init.text, >>> which may need to be routed via a PLT if .text is out of direct >>> branching range, may result in BTI exceptions due to the indirect calls >>> performed by the PLT veneers. (Note that calls to .init.text from .text >>> are not allowed.) >>> >>> The 'solution' is to emit yet another veneer - this is what the ELF >>> psABI for AArch64 mandates in this case. >>> >>> So derive an upper bound for the number of veneers that may be needed in >>> the core module region to ensure that any call from init code that ends >>> up needing a PLT can be directed at a veneer with a BTI landing pad, and >>> allocate the additional space. >>> >>> Then, emit these veneers as needed, i.e., only when emitting a PLT entry >>> for a call from an init code section to a normal code section in the >>> same module. In practice, this only occurs when a module's .init.text >>> happens to be allocated far away from its .text section, which might >>> happen when the initial 128M 'near' module region runs out of space >>> between allocating the core module and allocating its init region. >>> >>> Signed-off-by: Ard Biesheuvel >>> --- >>> arch/arm64/Kconfig | 2 - >>> arch/arm64/include/asm/module.h | 12 ++ >>> arch/arm64/include/asm/module.lds.h | 3 + >>> arch/arm64/kernel/module-plts.c | 128 +++++++++++++++++++- >>> 4 files changed, 138 insertions(+), 7 deletions(-) >>> >>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig >>> index b3afe0688919..25fa80b5591d 100644 >>> --- a/arch/arm64/Kconfig >>> +++ b/arch/arm64/Kconfig >>> @@ -2114,8 +2114,6 @@ config ARM64_BTI_KERNEL >>> depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI >>> # 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 >> >> This doesn't work for livepatch though, and removing the "depends on >> !CC_IS_GCC" is a livepatch regression as it broadly increases the >> likelihood of ARM64_BTI_KERNEL (default y) getting enabled. >> >> So "livepatch broken on arm64 clang 21+" now becomes "livepatch broken >> on arm64". >> > > ... when kernel mode BTI is enabled. > > I have no insight into which pieces of livepatch for arm64 are actually > upstream. Is it just the tooling that is missing? In this case, though, > I think HAVE_LIVEPATCH should depend on !ARM64_BTI_KERNEL, rather than > the other way around. I can add that in v2. > BTW we may still try and get the compiler folks to add a command line option to force BTI landing pads to be emitted for static functions, and enable it for vmlinux only when livepatch is enabled. That way, we can re-enable kernel mode BTI for all toolchains for the common case, and have livepatch on arm64 (with BTI) depend on recent versions that implement this option.