From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 337D9606A31A for ; Tue, 1 Dec 2026 13:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Aa9H6e+o; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iW3RCXw0 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-Unsubscribe-Post: List-Owner; bh=TWbCt1GyS7jbV/+pSSnQQUw2fn6Oz2WuyN9/1nEuFjk=; b=Aa9H6e+oqzr2s9 CoAy9JYMLHnPRc+hise/D/KkjwNWsy6XrpmtxOPD9BpBOaLowmdN8FN0ePjeLCLxSBUhbcAv04Fe3 ZIGNvdj+97strZljTD/bbfRIWa8Fnezoiauc9a14c1AW2De3Ym6XoJN3A8iUVOfWQRPW71GTm5oQX f2otuK7KLaXWlRa6l7lxI6JHQSkadfTx6VpAYjHQBeEPLrMGaJFYL5VOb0SWdpBLSlUxIajNReg9b 30oyTDlUr7ClBXyoFAHlNCrHXVjfGiddfBTF67QvTWXuMDWOiBd/hZi+wvyLkeWYLXnS1IpmhMf8j b/PdwBNe5cJryLCxkBLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNvE-00000008FzB-1TKZ; Tue, 01 Dec 2026 13:29:28 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYNvC-00000008Fz1-3pZ3 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 13:29:27 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id F13F3601F1; Tue, 1 Dec 2026 13:29:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C62DB1F00898; Tue, 1 Dec 2026 13:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796131765; bh=TWbCt1GyS7jbV/+pSSnQQUw2fn6Oz2WuyN9/1nEuFjk=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=iW3RCXw0dB0f/Eiu2OKIX2vZ4AWPDYX0dEGqPhmiqyfUMWbgOytA90tEiut/WYg79 m4rBOgmWaiQKhGIHBD67CaMFGr4D7zgRE3ZB70rUkLR0uXMtp9r81c4iBSCyPPuFrl IDSWXXKQJMz9dMdI5uJ3my7WLLElUBuMNThAMIyQ+Xu1W4ia88c6VLXrQ3IKSjX10h p/31Gta2UXQE374inTgBgz1BdpmLwoG2S3pd+IwQxXLWC0wHVx/EB+kHaLlXbAAIV7 BhIwZGu3ygB2jyODs9fqrFzZkI7MB9eSOox05K0TvrzI8YK4eUI35Ie3NsY2HGHFY9 tii7xpUrC4drg== Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfauth.ams.internal (Postfix) with ESMTP id E637B198003A; Tue, 1 Dec 2026 08:29:22 -0500 (EST) Received: from ams-imap-11 ([10.64.2.31]) by ams-compute-02.internal (MEProxy); Tue, 01 Dec 2026 08:29:22 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTE+KJnhYrUZWMa6wu0my1ZZVj2EnHnP8ziaHMfHtZsk9Y3cc4+nweV7zC78uIMCCg MB5uvzqylT7VqEfmD01hR+7rMQm3Gtdtqfgv58AMDgO1Jtf6XeySizuFY17BqDaJCgSltK 1dJatL4ss9aZWKCiFVrvyiSg/hAMnyxT6pRRTMBkXML5rAHWDGfSwmmxXSdiblMbdfgTuB yXysg5Q7z8FHuXmJsVKlTTrZ62Dn20pyaYOUUdAv0CMLV2dSSZTiVRt5OydkIlXUtJk+Vv GLgyXr9efYf23zQBegRhHnflZOJR7q7hI6aN7BNnEWVasMEgFbbA9+I+LxHvFc3msCMGZJ T0nnt5OmO/qh1JFBupCzyb+49zddLh8uYNLzAJRLA8eLClRVGwUM9cyilnJPOKn5u0J0s8 mOB/ecnKwtWc0O2zCHHop7F3vJc5CibrN8Y4JDu3qCL0dJSNdkIBl69oRrRD1UOm/Bk+gi 53jgU8Rw+nkRczpP0OM5sY4GSogQysI0FrtLnn1yoR0OwFdy3yoTfnDkLnfi9Qvu3cde8W Z+NG76oqYWxSfj+4fnx6pdCcHtV0Jd6Z9mAC62Tak0Kv0Cay5DscIXDKWG5ApSBC5Kj6cp Ml1TVjvKPZ35Glznv5tJiQ5g/7a7GxFShq7QSsGH4QnIWbg03ANi2PQJIo6A X-ME-Proxy: Feedback-ID: ice86485a:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id 181A4F80093; Tue, 1 Dec 2026 08:29:21 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Archived-By: MIME-Version: 1.0 Date: Tue, 01 Dec 2026 14:29:00 +0100 From: "Ard Biesheuvel" To: "Catalin Marinas" , "Ard Biesheuvel" Cc: linux-arm-kernel@lists.infradead.org, "Will Deacon" , llvm@lists.linux.dev, "Arnd Bergmann" , "kernel test robot" Message-Id: <7ef4ec68-6fee-477c-a270-a3a0eae7bf50@app.fastmail.com> In-Reply-To: References: <20261130175121.1358891-2-ardb+git@google.com> Subject: Re: [PATCH] arm64: Fix transient negative image size observed by the linker Content-Type: text/plain Content-Transfer-Encoding: 7bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Tue, 1 Dec 2026, at 14:17, Catalin Marinas wrote: > Hi Ard, > > On Mon, Nov 30, 2026 at 06:51:22PM +0100, Ard Biesheuvel wrote: >> From: Ard Biesheuvel >> >> LLD occasionally errors out with a mysterious 'assignment to symbol foo >> does not converge', usually with a 16k page size kernel config. >> >> This turns out to be caused by the evaluation of the SPAN_NR_ENTRIES() >> macro using a preliminary value for _end that is below KIMAGE_VADDR, >> resulting in the difference to become negative. Subsequent passes >> usually recover from this, but not always, hence the config-dependent >> error. >> >> So ensure that SPAN_NR_ENTRIES() returns 1 for spans where the end >> address is smaller than or equal to the start address. This never >> occurs on the linker passes that matter, but prevents the iterative >> algorithm that LLD implements from diverging. >> >> This reverts commit dc0a08394804 ("arm64: Work around convergence >> issue with LLD linker"), which is superseded by this change. >> >> Reported-by: kernel test robot >> Closes: https://lore.kernel.org/oe-kbuild-all/20261129124345.eiR8unSx-lkp@intel.com/ > > Is this happening with your efi-zboot-elf branch only or mainline as > well? If the latter, we'd need a Fixes tag and cc stable. I'm not sure > what Arnd tested on. > > Your branch moves the INIT_IDMAP_DIR_SIZE and INIT_DIR_SIZE reservations > inside the sections and they depend on _end. IIUC, they become part of > the section size and moving '.' backwards is an error. I found another > report on your branch, not sure it's related but it looks like it's > caused by wrapped values: > > https://lore.kernel.org/all/20261120005637.8iy6yHZU-lkp@intel.com/ > That just happens to be the branch where it was found this time, but it is not related to any of those changes. Arnd's testing should be entirely unrelated to any of this. >> diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h >> index 229ee7976f69..929b5ac39981 100644 >> --- a/arch/arm64/include/asm/kernel-pgtable.h >> +++ b/arch/arm64/include/asm/kernel-pgtable.h >> @@ -42,8 +42,17 @@ >> */ >> #define EXTRA_PAGE __is_defined(CONFIG_RELOCATABLE) >> >> +/* >> + * LLD may evaluate SPAN_NR_ENTRIES() before _end has assumed its final value, >> + * and if the chosen preliminary value happens to be below KIMAGE_VADDR, the >> + * linker may go off into the weeds due to the negative result, ultimately >> + * leading to a 'assignment to symbol foo does not converge' error. > > Nit: it's probably implied but the negative result is actually a very > big uint64_t number. Not sure it needs any clarification. > Essentially, yes. >> + * >> + * Work around this by ensuring that SPAN_NR_ENTRIES() returns '1' in such >> + * transient cases. The final pass will observe the correct result. >> + */ >> #define SPAN_NR_ENTRIES(vstart, vend, shift) \ >> - ((((vend) - 1) >> (shift)) - ((vstart) >> (shift)) + 1) >> + ((vend) <= (vstart) ? 1 : (((vend) - 1) >> (shift)) - ((vstart) >> (shift)) + 1) > > This looks correct. > >> diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h >> index 19d602e45523..7fc1417aab14 100644 >> --- a/arch/arm64/kernel/image-vars.h >> +++ b/arch/arm64/kernel/image-vars.h >> @@ -154,17 +154,6 @@ KVM_NVHE_ALIAS(kvm_protected_mode_initialized); >> _kernel_codesize = ABSOLUTE(__inittext_end - _text); >> #endif >> >> -/* >> - * LLD will occasionally error out with a '__init_end does not converge' error >> - * if INIT_IDMAP_DIR_SIZE is defined in terms of _end, as this results in a >> - * circular dependency. Counter this by dimensioning the initial IDMAP page >> - * tables based on kimage_limit, which is defined such that its value should >> - * not change as a result of the initdata segment being pushed over a 64k >> - * segment boundary due to changes in INIT_IDMAP_DIR_SIZE, provided that its >> - * value doesn't change by more than 2M between linker passes. >> - */ >> -kimage_limit = ALIGN(ABSOLUTE(_end + SZ_64K), SZ_2M); > > dc0a08394804 ("arm64: Work around convergence issue with LLD linker") > was about the circular dependency (_end -> INIT_IDMAP_DIR_SIZE -> _end). > Does that earlier problem go away with your patch here? > Yes. The earlier problem was not as well understood as it is today :-) dc0a08394804 failed to update both occurrences of _end (it missed INIT_DIR_SIZE) or the issue wouldn't have happened again, as far as I can tell. But simply avoiding the wraparound in SPAN_NR_ENTRIES() is sufficient.