From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8E21C5B56A for ; Tue, 11 Aug 2026 17:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Subject:References:In-Reply-To:Message-Id:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vuLc+eBTQsRcHHndOJtc/5UNxFkquB47Vebh+uHg3po=; b=xLDci4Ve/phPbjq2yrPBasWL80 MfB3y06CTNqaRJcKPfsyf41wASk4lioaBYMXQnX4gRj+7JjKebBYavL5/sIY4Qu+oef5FrM+TxkpN UN69fX3XFDbKh4IJp65Z+g5XJ7kdWbWxPaEM9LWgLN3PtoqvcyuBIP4okDiPBwJH4hW18YQJjrxZr ifuRe7brKZUZDdXWdgLSMf3OQFhmsweftOs6/pNrapF+oEsDEJKKW6Jsd10pHKtJPLOsmPjL3RNhd 79koN0K8VHp5NOzemZXCDU+gFfzK0IXGeUNA/5toZAL+mVUFPQca+x38IOx5wOa3lKWnSk58XKm2c +CLMf9/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wtpyg-0000000EbfF-2bMI; Tue, 11 Aug 2026 17:09:26 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wtpye-0000000Ebeu-42Ir for linux-arm-kernel@lists.infradead.org; Tue, 11 Aug 2026 17:09:25 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6B45A600C8; Tue, 11 Aug 2026 17:09:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 588361F00A3D; Tue, 11 Aug 2026 17:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786468164; bh=vuLc+eBTQsRcHHndOJtc/5UNxFkquB47Vebh+uHg3po=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=Tu1rqMC0YY3TBle4xI4qDvvm97eT9c7rCqaamZWMNMo0iqCUcCsWFC49SfTx1SHoM Bsv/WGkoTgGTZEeWXzhplmTRq+THfEH/iOBDN1WNb3jQtd/GPVnLXOQAEwu3zpWx2h 5p2XtoVdCQpqRk6m88Vl7Ns0VJHx/wtLNhL/0ZYObWEdE8H4HbexF9em7TEjY+b07L qSQRRzaGbY70K8DP2+Rtp0J/wA9/SdLDCrITfQSZePK73EWgkog2jzUis29QRZAsG/ tHkbC4W6OObl/7ENcbd/ZsR0u5AaJq+beHSf0Sp6tNfFrTvVm4JNhc0SowPesNaouO gtzdYvnL4fV3g== Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfauth.ams.internal (Postfix) with ESMTP id E68BB1980070; Tue, 11 Aug 2026 13:09:21 -0400 (EDT) Received: from ams-imap-11 ([10.64.2.31]) by ams-compute-02.internal (MEProxy); Tue, 11 Aug 2026 13:09:21 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTFofdFgFJq0nU6Moe8TviOaDqvGA8zMt6timdp8+AgUPcYdPRc42onFU7azTHwDiP 9LuwvxeI17UeVWze+z0jCic3+3Lafd6oh7mNIfJ2UmbZhnqcLwQR001qZ1r4TtSvxgCR9H FTEbzbDzEUS6B8BkT/nxHlt4+HseYTUAGg1wssOiJUKjjNJNvu87QM62SGN0ayNxoaQb0p J/qdoi3M4vgUk2XSNf44f4FB3an1kqdXoylI4HW7mGco9e+Uy+ypK63bWkbdJsp8RPgaOW GiQkxEJmVFpC2jo6H1d8s/Wee94SFIJ7WNztrk5RYAw8aSTbJVPXUGxPFpaLiQtKX/cEIy YzIBgCHFHTeEZvRZRMqIsQtvvDo9cDdgN+LaU4jHTP7EgAT+Lnd0/ip91k/2geQfmA8Y12 +T0p8Lx937DoHYJE6SoPxK5DmxsPx4V1v8SIeVwKKRb0ZvpDLmYAKFC/tfb3UQiaSYC6Rn cdP5jCG+rOZ5SAcvNnvjrA9TxyMcNWp8LSjVsCZ4DZByTuq8fALLlFEE+pvuo1jTOXNyxU Jwb73iYqabgcjO4M9XRpycJ69TbpzdMuHYxJTsHTjd6w2ZyM2Em5qz27+s3aK0zAQ062qE LBQ79zVLuo3QZCz+dpRvMcBh6ZSd61oXPbOsOSq7btBw2bvrQwXO50uFdx6Q X-ME-Proxy: Feedback-ID: ice86485a:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id EC402F8006A; Tue, 11 Aug 2026 13:09:18 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Tue, 11 Aug 2026 19:08:58 +0200 From: "Ard Biesheuvel" To: "Nick Desaulniers" Cc: "Josh Poimboeuf" , "Will Deacon" , "Catalin Marinas" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, "Song Liu" , "Miroslav Benes" , "Petr Mladek" , "Joe Lawrence" , "Mark Rutland" , "Mark Brown" , "Kees Cook" Message-Id: In-Reply-To: References: <08d6c5cd-9924-4359-9181-a03718161528@app.fastmail.com> <4986ac98-d6da-474a-b218-b6468b68cb9f@app.fastmail.com> <16e3ed42-1b1f-4ddc-9d8c-5e12ee7dbe3c@app.fastmail.com> Subject: Re: [PATCH] arm64/module: Fix livepatch BTI exceptions with Clang 21+ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 11 Aug 2026, at 19:05, Nick Desaulniers wrote: > On Tue, Aug 11, 2026 at 9:55=E2=80=AFAM Ard Biesheuvel wrote: >> >> >> On Tue, 11 Aug 2026, at 18:52, Nick Desaulniers wrote: >> > On Tue, Aug 11, 2026 at 9:41=E2=80=AFAM Josh Poimboeuf wrote: >> >> >> >> On Tue, Aug 11, 2026 at 09:27:28AM -0700, Nick Desaulniers wrote: >> >> > On Tue, Aug 11, 2026 at 7:23=E2=80=AFAM Will Deacon wrote: >> >> > > >> >> > > On Tue, Aug 11, 2026 at 03:18:17PM +0200, Ard Biesheuvel wrote: >> >> > > > >> >> > > > On Tue, 11 Aug 2026, at 14:02, Ard Biesheuvel wrote: >> >> > > > > On Tue, 11 Aug 2026, at 11:44, Will Deacon wrote: >> >> > > > >> On Mon, Aug 10, 2026 at 09:41:35AM -0700, Nick Desaulnier= s wrote: >> >> > > > > >> >> > > > >>> Sure, but let's replace this with a link to a bug report= in llvm's >> >> > > > >>> issue tracker? >> >> > > > >> >> >> > > > >> Yes, please! I can apply the patch once we have the bug n= umber. >> >> > > > >> >> >> > > > > >> >> > > > > I can look into that. >> >> > > > >> >> > > > https://github.com/llvm/llvm-project/issues/215547 >> >> > > >> >> > > Thanks, Ard. I've ended up with the patch below. >> >> > >> >> > What's the extent that HAVE_LIVEPATCH will be used? >> >> > >> >> > Does this penalize kernels built with BTI in favor of HAVE_LIVEP= ATCH? >> >> > >> >> > For example, with my Android hat on, if we have a kernel that's = built >> >> > with ARM64_BTI_KERNEL=3Dy, and _dont_ use HAVE_LIVEPATCH, we're = going to >> >> > turn off BTI for a feature we're not using? But maybe we _do_ i= ntend >> >> > to use HAVE_LIVEPATCH, and my assumption was wrong? >> >> >> >> The problem isn't specific to livepatch, livepatch just makes it e= asier >> >> to hit. >> > >> > Rereading Ard's report, let me see if I can articulate _how_ and te= ll >> > me if I'm still not getting it. >> > >> > Let's say we have code in .init.text that calls code in .text. If >> > .text was placed large enough away from .init.text, we get a veneer >> > inserted by _the kernel_ (not the linker). This veneer has an >> > indirect call to the destination. No landing pad. Boom. >> > >> > Is that precise? >> > >> >> Yes. > > Naive question: Could the machinery that emits the veneer instead emit > N veneers, one for each cross section reference? Rather than one > veneer that could branch indirectly to N destinations (that probably > don't have landing pads), could we instead have N veneers that branch > directly to 1 location each? Are the veneers larger than just a > branch? Is the destination unknown when the veneers are created? This > would retain the landing pad elision optimization for .text (which is > likely run more frequently than .init.text), and you could probably > put those veneers in .init.text and throw them away with the rest of > __init. > The current veneer code emits veneers close to the call site, so that the veneer is in range for the caller. These BTI veneers need to be emitted at the target end, so that the real target is withing direct branching range of the veneer. The PLT veneers are 12 bytes (ADRP + ADD + BR). These BTI veneers will need to be BTI_C + B, so 8 bytes. I'm prototyping something atm that may be able to address the .init.text vs .text issue. Fixing livepatch is a taller order.