From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 033A3606A32D for ; Thu, 3 Dec 2026 22:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.u-boot-project.org header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default header.b=ORegUSif; dkim=pass (1024-bit key, unprotected) header.d=konsulko.com header.i=@konsulko.com header.a=rsa-sha256 header.s=google header.b=f4bOkTFv Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9BD5A40D4C; Thu, 3 Dec 2026 22:42:45 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NjWIIicea6PO; Thu, 3 Dec 2026 22:42:44 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 53A2D40D03 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796337764; b=qapNxGsnuQhUfEVcv9tnKmUnUMLRutE0pQn0HQgmmw6JCf37DFFlDFJo2eCHNfEgFObc UosbrkKgK4KlLk6WL+MaBJutcHgP26i5nOJLUZuo/i9FXOPc3tl5vUGkvXBeCMTSCP7tR JrWptGiRBjEEQipjGSANfsofqQyW0+Qs6sUhnOW/SWNe1+8i3Mcd8eNEmiLCIBX+J8ANu sqTrm0RlyH4lVeykzmH3+EvzGEIH0FNgdlIBDEJGkfq8DaSVOTzw9t21BErIIsUoASXEc Peauriw+LpuUAqQ/9VlBCwANfV079/kF60mR5nO3JlMdToMU1pCkRuHZVL+B5hq9hxQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796337764; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-Clacks-Overhead:X-BeenThere: X-Mailman-Version:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Errors-To; bh=FDjP1fKPS9dMYjv0EVdC6XKl0/35SFspMqZFPjN5G3M=; b=blkq/AyIAIhW9VqDfn3Qtsfvl6d66WIARRKGUvXVvp8BITf8x7oMPEIZQ//Xp0Ml0Riu yLOPt5SdA53PJedfZ/sUn62uIqjU2i92uGXc8FocWtRM83Dt9kS2mo81+AfHwidKZkEKK LTMEGEeBeHIlyhRJLEgwMgzEfJirXWNK2OhanWdw3oDhg9BPmSlOtHPd9Se8YOqcwBW3r OubhAdTqT5CFgpQLya8pwCQkE2WDAAQ0elyJfryy44mRSy2B2Ric8LgkT/67AqcPAlOsQ juc3rOaLiLpvqhavEBYZ/j1S1x9uoa3xF8saYLi9oOh3LimLW+e3SwjOedWJYW0OuQA== ARC-Authentication-Results: i=1; smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1796337764; bh=FDjP1fKPS9dMYjv0EVdC6XKl0/35SFspMqZFPjN5G3M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ORegUSifs5gbrQauE+UFr1IOBdAowZ6f34W2scNEV859nB3Lx5TAk1rNHxjpu4hqE Pn1bG/7PEgUJsM+UeYhSqBkmloGWC3iGyFKDRIf8VnZV6ggHV+jUvlydcsyxZVPS8Z ldvWmBpmvYIaQiaFiS8Am16cUG39j5av1KIgBTm0D/J8SI6o+vD3579YEY+SNLlIIx gLkNBC9+ojQuFaAiRCfMOyO2DU97aeIE8DMHgfDgGlg1oolMTdm54WxJy0i33zGJ5J I6oXPUHdEIJ0Ap+zwICj3s9b3gA6vv+CKXsnaefKTNDEk3ugKsbD1i46YmJbfiiN96 szmzqPcadog7g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 53A2D40D03; Thu, 3 Dec 2026 22:42:44 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id 48A252FF for ; Thu, 3 Dec 2026 22:42:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3AD7040107 for ; Thu, 3 Dec 2026 22:42:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 8c1AvLqy-Pha for ; Thu, 3 Dec 2026 22:42:41 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org EDB0F400E3 Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:32::8" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:32::8; helo=mail-oi2-x08.google.com; envelope-from=trini@konsulko.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=konsulko.com header.i=@konsulko.com header.a=rsa-sha256 header.s=google header.b=f4bOkTFv Received: from mail-oi2-x08.google.com (mail-oi2-x08.google.com [IPv6:2607:f8b0:4864:32::8]) by smtp2.osuosl.org (Postfix) with ESMTPS id EDB0F400E3 for ; Thu, 3 Dec 2026 22:42:40 +0000 (UTC) Received: by mail-oi2-x08.google.com with SMTP id 5614622812f47-545a4fb8d5dso148725b6e.1 for ; Thu, 03 Dec 2026 14:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1796337759; x=1796942559; darn=lists.u-boot-project.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=FDjP1fKPS9dMYjv0EVdC6XKl0/35SFspMqZFPjN5G3M=; b=f4bOkTFv4mtdDAlXPoNV1czd6BhtznhCLSdrKYpBHelRVOsLcPD3JEaeADiVPqkR2K w136jNceGVWhT8Ff99NuyOn4JvhA6Iom0jp4x4md//tAqhyqVulF+VHiFgfz2+0XNsQf dgsge+5zI3pTCcBn6wE1+4rJod621pjTCTJB0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796337759; x=1796942559; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FDjP1fKPS9dMYjv0EVdC6XKl0/35SFspMqZFPjN5G3M=; b=UidEzd+H3gPe6fmBcgPpl4YDfV6O59Wr0MuIB9oMof2k/f5tVH6xcHQHwB0ZXAUqjx MGn/ZoVulwFwp12NOTENJLSOLmCw8YB68XRtVry74dJdL4tq0oi2zz1Pzfc/0FvhnM8z pkd21lpGzm/uNh3hC6+PmXpGOO8hUGSwt1xpllsW+rfITymLk//gInOnUX9VEfbTGQnr j0pJUueI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pcW3sNee6g/0cIpjanQfyxXwDhDinAqLqvjaeCZ3qB+6aYA6+kOHbCDx0o4pDL ySKEtlxX/lYUhsMVuBdqiFnBSm7oOa40U1la78+tOsQXRI8MCadmo= X-Received: by 2002:a05:6808:4fcf:b0:574:f857:6554 with SMTP id 5614622812f47-57f2073cd94mr189497b6e.12.1796337759288; Thu, 03 Dec 2026 14:42:39 -0800 (PST) Received: from bill-the-cat (fixed-189-203-100-56.totalplay.net. [189.203.100.56]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f16740bsm307277b6e.0.2026.12.03.14.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 14:42:38 -0800 (PST) Date: Thu, 3 Dec 2026 16:42:36 -0600 From: Tom Rini To: Ilias Apalodimas Cc: Peter Robinson , Quentin Schulz , richard.henderson@linaro.org, casey.connolly@linaro.org, u-boot@lists.u-boot-project.org Subject: Re: [PATCH 2/2] arm64: Add RELR relocs Message-ID: <20261203224236.GC3176972@bill-the-cat> References: <20261125074122.1965495-1-ilias.apalodimas@linaro.org> <20261125074122.1965495-2-ilias.apalodimas@linaro.org> <3a263d76-c2fc-4e15-9f2c-7795bb27a6e0@cherry.de> <20261127184623.GP3176972@bill-the-cat> X-Archived-By: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="t9L6xLLDzS8Zjrsq" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 --t9L6xLLDzS8Zjrsq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 04, 2026 at 12:27:57AM +0200, Ilias Apalodimas wrote: > Hi Tom >=20 > On Fri, 27 Nov 2026 at 20:46, Tom Rini wrote: > > > > On Thu, Nov 26, 2026 at 05:14:26PM +0200, Ilias Apalodimas wrote: > > > Hi both > > > > > > On Thu, 26 Nov 2026 at 14:48, Peter Robinson w= rote: > > > > > > > > > > > > > > > > On Wed, 25 Nov 2026 at 17:20, Quentin Schulz wrote: > > > >> > > > >> Hi Ilias, > > > >> > > > >> On 11/25/26 8:41 AM, Ilias Apalodimas wrote: > > > >> > Linking U-Boot with -pie emits an R_AARCH64_RELATIVE entry for e= very > > > >> > pointer that needs fixing up. Each Elf64_Rela entry is 24 bytes,= so the > > > >> > .rela.dyn section ends up being quite large. > > > >> > > > > >> > Modern toolchains support packing relative relocations in RELR f= ormat > > > >> > via '-z pack-relative-relocs'. Instead of offset/info/addend tup= les, > > > >> > RELR stores a stream of 64-bit words. An even word is the link-t= ime > > > >> > address of a word to relocate and an odd word is a bitmap descri= bing > > > >> > which of the 63 words following the previous address need reloca= ting. > > > >> > The addend is the value already stored in the place. > > > >> > > > > >> > Compiling for QEMU with RELA vs RELR looks something like this: > > > >> > > > > >> > $~ readelf -SW u-boot | grep relr > > > >> > [ 9] .relr.dyn RELR 000000000016f970 170970 0= 00960 08 A 0 0 8 > > > >> > $~ readelf -SW u-boot.old | grep rela > > > >> > [ 7] .rela.dyn RELA 0000000000115110 116110 0= 184f8 18 A 0 0 8 > > > >> > > > > >> > which is ~98% decrease in the space reloc entries need. > > > >> > > > > >> > So let's add a Kconfig option and teach U-Boot RELR. > > > >> > - pass '-z pack-relative-relocs' to the linker and add .relr.dyn > > > >> > in the linker script and the objcopy'ed binary. relr.dyn is s= till > > > >> > overlayed by .bss > > > >> > - skip checkarmreloc, since we now expect R_AARCH64_RELATIVE ent= ries > > > >> > to be packed in .rel*.dyn and older tools don't decode them > > > >> > properly > > > >> > - process .relr.dyn in pie_fixup. It's worth noting that efi run= time > > > >> > relocs, due to how ld emits RELR, are now packed in .relr.dyn= and > > > >> > efi_runtime_relocate() doesn't have to relocate anything. > > > >> > A sideeffect is that we can't support SetVirtualAddressMap a= nd ConvertPointer > > > >> > for EFI, but some architectures are already ommitting this ca= ll > > > >> > (e.g Linux on arm64, openBSD doesn't call it at all). [0] > > > >> > - process .relr.dyn in relocate_code(). Note that the places are > > > >> > link-time addresses, so we still need the link-to-copy offset= to find > > > >> > them, but the stored value has already been shifted to the ru= n address > > > >> > by pie_fixup, so it needs to be adjusted by the run-to-copy o= ffset > > > >> > > > > >> > [0] EFI runtime services relocate themselves when the OS calls > > > >> > SetVirtualAddressMap, using the relocations between > > > >> > __efi_runtime_rel_start and __efi_runtime_rel_stop. Those are co= llected > > > >> > by the linker script from the .rela sections of the runtime code. > > > >> > RELR packing, however, is done by the linker as a last step and = all > > > >> > relative relocations end up in a single .relr.dyn section for th= e entire > > > >> > image. There's no way to emit an equivalent __efi_runtime_relr_s= tart > > > >> > marker for the runtime region, or emit RELA relocations for the = EFI > > > >> > runtime, so stop advertising SetVirtualAddressMap and ConvertPoi= nter > > > >> > in the EFI_RT_PROPERTIES_TABLE when RELR is enabled. > > > >> > > > > >> > > > >> 6.4% size reduction for u-boot.itb with RELR enabled on > > > >> tiger-rk3588_defconfig. > > > >> > > > >> $ aarch64-linux-gnu-ld --version > > > >> GNU ld version 2.47.20260726 > > > >> > > > >> from Fedora 45. > > > >> > > > >> I reached U-Boot proper CLI, which I have been told is sufficient = to > > > >> test this series, so: > > > > > > > > > > > > I agree with enabling this by default, it should be opt out if ther= e's issues. > > > > > > > > Looking at various default toolchains across distros (thanks Claude= ) Ubuntu 22.04 LTS has gcc11/binutils 2.38, RHEL 9 is gcc11/binutils 2.35.2= , Debian 12 is gcc12.2/binutils 2.40 > > > > > > > > All have options for later versions so I think we should be fine to= enable by default and error if the toolchain isn't new enough. The reality= is a lot of users will be using old U-Boot if they're on ancient distros a= nyway. > > > > > > > >> > > > >> suggestion: make this transparent to the user > > > >> > > > >> We've talked about this in private but wanted to put it in writing= so > > > >> it's available on the mailing list archive. I think it makes more = sense > > > >> to always enable the option (if it's safe!), if the linker support= s it. > > > >> According to > > > >> https://rfc.archlinux.page/0023-pack-relative-relocs/#motivation, = that > > > >> is GNU ld 2.36 and LLVM 15. We can use the same mechanism as in the > > > >> kernel, c.f. CC_HAS_UBSAN_BOUNDS_STRICT with def_bool > > > >> $(cc-option,-fsanitize=3Dbounds-strict). > > > > > > I don't think that's a good idea. You turn on an option that promises > > > to reduce the binary size. You compile but bercause you now made the > > > linker flags conditional the end user finds an *identical* binary > > > after enabling the option. I prefer breaking the build so users > > > understand that this relies on a newer linker. Whether they can update > > > it or not should not be our problem. > > > > So, we should be doing depends on LD_HAS_RELR_SUPPORT in the new options > > and LD_HAS_RELR_SUPPORT is def_bool ..., and then the new option can be > > default y. >=20 > Ok, I can change thayt >=20 > > > > > >> What I don't like about it is that if it's default off, nobody wil= l turn > > > >> it on. If it's on and we force the option like in this patch, then > > > >> builds will fail on older toolchains. I bet most people don't know= where > > > >> to get a newer toolchain than the one they have from their distro,= or > > > >> how to install it so lots of headaches for people I guess. If we s= tay > > > >> with this solution here, is there a way to tell the user how to fi= x it > > > >> (either via a Make message, or at least a comment next to the plac= es > > > >> where we set the flag?) > > > > > > There should be enough explanation in the commit message and Kconfig > > > option why this is not enabled by default. > > > TL;DR there are implications wrt to EFI if you enable RELR that do not > > > affect Linux for arm64, but Linux is not the only OS we boot. Since we > > > have it documented, I'd rather leave the option off, at least till the > > > EFI implications are gone. > > > > Are the EFI implications something we can / will resolve, or should we > > be asking the other OSes? >=20 > We can but it requires many more changes in the EFI subsystem. >=20 > > Or, since the BSD folks do make it easy enough > > to try them out, should the pushback be on you to fire up an installer > > image or two? Or... is this something that won't blow up immediately and > > rather you'd have to do some non-trivial testing to confirm? >=20 > In theory (if the OS isn't buggy), nothing will blow up. When RELR is > enabled SetVirtualAddressMap is marked as unsupported. So worst case > is the OS will end up running without them. OS'es that avoid calling > it, just map RT servives 1:1 already and work fine It sounds like we should document the needed EFI change then, but not proactively do it? But to try and be clearer, is it easy to test at run-time (in the OS) or a quick grep around the kernel sources, if say a BSD is relying on SetVirtualAddressMap being supported, today? --=20 Tom --t9L6xLLDzS8Zjrsq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTzzqh0PWDgGS+bTHor4qD1Cr/kCgUCaxHwWAAKCRAr4qD1Cr/k CipZAQD/RtiyxSjZ2k8eCb9JPe0IzMmncvscZFTqcCt7z6AJewEA/Mll9nnq+EBO JFd+Lv85uqTPs/gKW2kRDUi7GayEPgo= =DMGx -----END PGP SIGNATURE----- --t9L6xLLDzS8Zjrsq--