Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Ard Biesheuvel <ardb+git@google.com>
Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org,
	llvm@lists.linux.dev, arnd@arndb.de,
	Ard Biesheuvel <ardb@kernel.org>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] arm64: Fix transient negative image size observed by the linker
Date: Tue, 1 Dec 2026 14:19:07 +0000	[thread overview]
Message-ID: <aw7XW4S6qA1TQspK@arm.com> (raw)
In-Reply-To: <aw7WEI-nv8qEQijg@arm.com>

Ignore this duplicate, our smtp server is playing up and I just resent
the wrong reply.

On Tue, Dec 01, 2026 at 02:13:36PM +0000, Catalin Marinas wrote:
> Hi Ard,
> 
> On Mon, Nov 30, 2026 at 06:51:22PM +0100, Ard Biesheuvel wrote:
> > From: Ard Biesheuvel <ardb@kernel.org>
> > 
> > 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 <lkp@intel.com>
> > 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/
> 
> > 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.
> 
> > + *
> > + * 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?
> 
> -- 
> Catalin

      reply	other threads:[~2026-12-01 14:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 17:51 [PATCH] arm64: Fix transient negative image size observed by the linker Ard Biesheuvel
2026-12-01  8:52 ` Arnd Bergmann
2026-12-01 13:17 ` Catalin Marinas
2026-12-01 13:29   ` Ard Biesheuvel
2026-12-01 13:50     ` Ard Biesheuvel
2026-12-01 14:14       ` Catalin Marinas
2026-12-01 14:26         ` Ard Biesheuvel
2026-12-01 14:13 ` Catalin Marinas
2026-12-01 14:19   ` Catalin Marinas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw7XW4S6qA1TQspK@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox