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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C23F4C433F5 for ; Mon, 27 Sep 2021 10:50:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 88E2360FC0 for ; Mon, 27 Sep 2021 10:50:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 88E2360FC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mcdjGpygrM4bAr5Q4eetNHj9aadFh+lVdppqrkH33EY=; b=lp5tor2kz56biS z0qc8txklJhtAqlP896NrluRM+glh7g3ZmNIH00Rk6ZkMutbTEpgu++EWvvu8VLJetQkRkWdwQY/R zXQ6X6V+/HIFva+U5uUmM9RAmgYjBds3a1YqpiUaq5OleqQslWMR3b2tsomkUPXysz9qmlm8VcPtc 37AfaqBV33x0DtMsn8qlS+GlpjW9YgOI8li/Tr+dbx1Kh6r+HWlBIc91fDMwUGEBatNUMRjhvGuCX ZR2SkikoDfd8o7JgF9ZUIWr8cQBEIPr8Wt75/p3GvUEyK+H2p8VGzApQA84rG9ZNXfu8tNxSO7cFP 5VxCLKZtBS6NALFFPqPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUoC2-002LJo-7a; Mon, 27 Sep 2021 10:49:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUoBy-002LIz-5v for linux-arm-kernel@lists.infradead.org; Mon, 27 Sep 2021 10:49:03 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACA89ED1; Mon, 27 Sep 2021 03:49:00 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.49.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0088A3F70D; Mon, 27 Sep 2021 03:48:57 -0700 (PDT) Date: Mon, 27 Sep 2021 11:48:51 +0100 From: Mark Rutland To: Arnd Bergmann Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Arnd Bergmann , Marc Zyngier , David Brazdil , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: fix non-converging vmlinux link Message-ID: <20210927104851.GA3292@C02TD0UTHF1T.local> References: <20210927093043.380604-1-arnd@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210927093043.380604-1-arnd@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210927_034902_337779_F5493B83 X-CRM114-Status: GOOD ( 32.86 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Arnd, Ard, On Mon, Sep 27, 2021 at 11:30:11AM +0200, Arnd Bergmann wrote: > From: Ard Biesheuvel > > When the size of the vmlinux file is just below 64MB, the kernel > may fail to link with lld, producing output such as > > ld.lld: error: assignment to symbol init_pg_end does not converge > ld.lld: error: assignment to symbol __pecoff_data_size does not converge > > Change the INIT_DIR_SIZE definition to include init_pg_dir ^ Missing "not" here ---------------------' We *need* to access `init_pg_dir` while using `init_pg_dir`, since e.g. early_fixmap_init() needs to conntect the fixmap tables into it, so we *must* map at least a portion of `init_pg_dir`. We happen to over-map when using 4K pages, and so depending on the alignment and size of the kernel Image this can work by chance. Also, prior to v5.15-rc1, we'd over-map in all configurations, and this could happen to work, but that was fixed in commit: 90268574a3e8a6b8 ("arm64: head: avoid over-mapping in map_memory") So as-is, this patch regresses working configurations at runtime, including all 16K and 64K configs. Is there some way we can over-estimate the size such that this will converge? e.g. add some alignment padding such that `_end` won't oscillate as `init_pg_end` changes? Thanks, Mark. > to get a stable size calculation. > > Arnd did the original report and analysis, but Ard figured what > to do about and wrote the changes to the code. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1219 > Co-developed-by: Ard Biesheuvel > Signed-off-by: Arnd Bergmann > --- > Ard, I had this in my randconfig tree with comment "Ard will > submit this with a proper changelog", but it seems we both forgot > about it, or maybe there was something wrong with it in the > end. > > While looking for randconfig -Werror warnings in mainline I came > across it again and can confirm that this patch (or something like > it) is still needed. Let me know if you are happy with this version > or if you have a better description for it. I unfortunately forgot > the details of how this works. > --- > arch/arm64/include/asm/kernel-pgtable.h | 2 +- > arch/arm64/kernel/head.S | 5 ++--- > arch/arm64/kernel/vmlinux.lds.S | 3 +++ > 3 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h > index 96dc0f7da258..5c622c18280a 100644 > --- a/arch/arm64/include/asm/kernel-pgtable.h > +++ b/arch/arm64/include/asm/kernel-pgtable.h > @@ -86,7 +86,7 @@ > + EARLY_PGDS((vstart), (vend)) /* each PGDIR needs a next level page table */ \ > + EARLY_PUDS((vstart), (vend)) /* each PUD needs a next level page table */ \ > + EARLY_PMDS((vstart), (vend))) /* each PMD needs a next level page table */ > -#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end)) > +#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, init_pg_dir)) > #define IDMAP_DIR_SIZE (IDMAP_PGTABLE_LEVELS * PAGE_SIZE) > > /* Initial memory map size */ > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S > index 17962452e31d..2c3011660e48 100644 > --- a/arch/arm64/kernel/head.S > +++ b/arch/arm64/kernel/head.S > @@ -366,10 +366,9 @@ SYM_FUNC_START_LOCAL(__create_page_tables) > mov_q x5, KIMAGE_VADDR // compile time __va(_text) > add x5, x5, x23 // add KASLR displacement > mov x4, PTRS_PER_PGD > - adrp x6, _end // runtime __pa(_end) > adrp x3, _text // runtime __pa(_text) > - sub x6, x6, x3 // _end - _text > - add x6, x6, x5 // runtime __va(_end) > + sub x6, x0, x3 // init_pg_dir - _text > + add x6, x6, x5 // runtime __va(init_pg_dir) > > map_memory x0, x1, x5, x6, x7, x3, x4, x10, x11, x12, x13, x14 > > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > index f6b1a88245db..4792ddd1ae73 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -287,6 +287,9 @@ SECTIONS > BSS_SECTION(SBSS_ALIGN, 0, 0) > > . = ALIGN(PAGE_SIZE); > + > + /* ----- kernel virtual mapping ends here ---- */ > + > init_pg_dir = .; > . += INIT_DIR_SIZE; > init_pg_end = .; > -- > 2.29.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel