From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796061099; b=YuAyNpE+w+LaIBWf7S8Q2O/9BEfrAdwX39AeB4QDdABnzS6Wwlg+YrbUkHkERTuePWe+ 6+SFb4EtRiRGkLTx3jCjz+h5AOZepjCnVCs6oQOcyhhq3NW3HFAHeRirSw2npV1P9qvpX 4m+mkrgmdopNCEMVvGRodHwt23YoPjMypF+Ip6Q7Ad9pKor9hgHq+QSSNac2qE5CZt4BQ 9/YdqI51XrP39iqmoELpxitOjlKuAiQiRWoM4z8tXORADHalJL0ULXvJHK0ywi2/bnn9+ RcSpq5HQSPURbVHIhi9G8+Wnzd5IHhk4smMZdEBcT4z5jZlBlsFTBLw5+jUNVRbXzLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796061099; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Developer-Key:X-Developer-Signature:X-Mailer:Message-ID:Subject: From:To:Cc:Content-Type; bh=eAOABzB+o/NlsmKBey7ZWNapcW4iywkF5bKvbpMlmeQ=; b=ugmns1vV/XVAbGKN+LoGHKAVNJUM0Kg2e0EscE2x4XqXcjDsD48m1p8ojFzjZqIZQvy4 sbdiu9vnfgqd8KWjFzQOx3L1dRXKgZuPQxu0IzcxNWL5EWf2W2+9S+12GGGL8er1btRP7 lODeJTlQcKrFrx5LeizKB3Jethewg1enLRA9iQT4E/TYka++JWTwtTE95qSAC2WN8vPWw vGDs4jr6rWaZGPr8rqv1T1lWnYwEMUd92jcRKwtNQVaP2KIeN1aDCFZwFDQyvbWvbUKCJ lspWrWR4bulF8f9s6uXVBotUl5Axw9fBQF2bxjU1teVOrO1jjcGh/6hP1NeUsqK9Zgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=VX5f7Tg8; arc=none smtp.remote-ip=209.85.128.70 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B92B0606A31C for ; Mon, 30 Nov 2026 17:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B92B0606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=VX5f7Tg8 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a359c7f47bso88885285e9.2 for ; Mon, 30 Nov 2026 09:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796061097; x=1796665897; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=eAOABzB+o/NlsmKBey7ZWNapcW4iywkF5bKvbpMlmeQ=; b=VX5f7Tg8RkscYKlHcGOAQlzFXqWqwee4A/ZVSURjSzFoXyXAhMoiFXYRqrn5mL5uBb zVqkm/eZeicZZycrpcGNI7vtpezLyf9Pkd4VIL1WiVPmQcHYPmPzTvGEj54pk8CmTBIl 6OTXRHr0dhe6FjizDibC/bf2emS18nonikfGNot7I/xSewwvGgWw22Uu994vU3Q9faom Q2RPDJxaXJsPNpEptFLINbg7Tkv0MB35cHr2PcqQxlOirULlXIJnzjWkNCEHm/3+15R0 Crjj22xoPOTJCOwbgv3PZcH8/5EyPhdPQ2ywqDag4LAv4sIYTemKBxN7+4PtgtHtBTuH lmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796061097; x=1796665897; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eAOABzB+o/NlsmKBey7ZWNapcW4iywkF5bKvbpMlmeQ=; b=Ff6ZlyW/yZwxlrOqT4HI+ZdHO/WQ+G5vLFr6vJipoSxQHzjKFX4DtTL8ivf/WS9ccV jOiaPKag93absbxqLATOJW+0zpiANIe9uBmCDOarzEXRyn7f1Haq9i4XX/zQfZb/dHrq K/BrmwoZi3UMM6SNGztsvLJD3SmBi9DtGk73Uv8++Bw/7hfiqMfZ6ICZf02i/o/vb9hh huxsOe/7ejyfvHdu5zKRpizR7mAt/+FyOSe4QnqF5OnIOzF/VqpqAlWHv/Poo8VAH4TW VqwMsTfapRTP+hHHWWxM4I0Qf8ZO5GrmIH0k16Pa1RIAK1cKt/c4JdyVehUb3Sl3WktU qs4g== X-Forwarded-Encrypted: i=1; AL+hErE7bIdDQWSG/l7ehDcpx9xK0M9mHEjIaiSh7d4xPlyJjTspNdxVGQWxxHlqIiHZLHWkzfyt@lists.linux.dev X-Gm-Message-State: APuU4Z8JlY1JurHekuFpb2T1K0bwo6YcHAUUxNWZhYWN6Y7D6EynIZpS d+FF8xMc14F81pkH8ofWcMjg33wnJMQILjIz3+8TqpxGO/P1NgxBd0yqFc9hPmu215vejFTkfA= = X-Received: from wmaw11.prod.google.com ([2002:a05:600c:6d4b:b0:4ae:7292:22a7]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3103:b0:4bb:69d8:3e92 with SMTP id 5b1f17b1804b1-4bb8881f095mr715598975e9.29.1796061096907; Mon, 30 Nov 2026 09:51:36 -0800 (PST) Date: Mon, 30 Nov 2026 18:51:22 +0100 X-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=3882; i=ardb@kernel.org; h=from:subject; bh=Ejfj8eZRNQZ0LIezhb5Onm/F1OuErTk7yDNlyYI9HQI=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIZt3+6yU5TIXHrHJ+C+rnvD+INuKD0b3T17z5pwwbaulj n3M1+WRHaUsDGJcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAi6TcY/krvcJCTqDiw4fta 6fTUueJ/Rb8f/LqjWO+VaXzAvA7n/10M/yukOEqbQuYvrd776Mcn6+Mz3m1fYJM7s0RC/9ZE06N er7kB X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130175121.1358891-2-ardb+git@google.com> Subject: [PATCH] arm64: Fix transient negative image size observed by the linker From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, llvm@lists.linux.dev, arnd@arndb.de, Ard Biesheuvel , kernel test robot Content-Type: text/plain; charset="UTF-8" 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/ Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/kernel-pgtable.h | 13 +++++++++++-- arch/arm64/kernel/image-vars.h | 11 ----------- 2 files changed, 11 insertions(+), 13 deletions(-) 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. + * + * 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) #define EARLY_ENTRIES(lvl, vstart, vend) \ SPAN_NR_ENTRIES(vstart, vend, SWAPPER_BLOCK_SHIFT + lvl * PTDESC_TABLE_SHIFT) @@ -58,7 +67,7 @@ #define INIT_DIR_SIZE (PAGE_SIZE * (EARLY_PAGES(SWAPPER_PGTABLE_LEVELS, KIMAGE_VADDR, _end, EXTRA_PAGE) \ + EARLY_SEGMENT_EXTRA_PAGES)) -#define INIT_IDMAP_DIR_PAGES (EARLY_PAGES(INIT_IDMAP_PGTABLE_LEVELS, KIMAGE_VADDR, kimage_limit, 1)) +#define INIT_IDMAP_DIR_PAGES (EARLY_PAGES(INIT_IDMAP_PGTABLE_LEVELS, KIMAGE_VADDR, _end, 1)) #define INIT_IDMAP_DIR_SIZE ((INIT_IDMAP_DIR_PAGES + EARLY_IDMAP_EXTRA_PAGES) * PAGE_SIZE) #define INIT_IDMAP_FDT_PAGES (EARLY_PAGES(INIT_IDMAP_PGTABLE_LEVELS, 0UL, UL(MAX_FDT_SIZE), 1) - 1) 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); - #undef ASSERT #endif /* __ARM64_KERNEL_IMAGE_VARS_H */ -- 2.56.1.839.g22a8290db9-goog