From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:3201:214:fdff:fe10:1be6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40BsJn1J3hzF1TR for ; Fri, 30 Mar 2018 04:32:37 +1100 (AEDT) Date: Thu, 29 Mar 2018 18:31:03 +0100 From: Russell King - ARM Linux To: Rob Landley Cc: Shea Levy , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Catalin Marinas , Will Deacon , Mark Salter , Aurelien Jacquiot , Mikael Starvik , Jesper Nilsson , Yoshinori Sato , Richard Kuo , Tony Luck , Fenghua Yu , Geert Uytterhoeven , James Hogan , Michal Simek , Ralf Baechle , David Howells , Ley Foon Tan , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Palmer Dabbelt , Albert Ou , Martin Schwidefsky , Heiko Carstens , Chen Liqin , Lennox Wu , Rich Felker , "David S. Miller" , Jeff Dike , Richard Weinberger , Guan Xuetao , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Chris Zankel , Max Filippov , Kate Stewart , Greg Kroah-Hartman , Philippe Ombredanne , Eugeniy Paltsev , Al Viro , Vladimir Murzin , Linus Walleij , Michal Hocko , Andrew Morton , Sudip Mukherjee , Marc Zyngier , Rob Herring , Kees Cook , Vlastimil Babka , Balbir Singh , Christophe Leroy , Joe Perches , Oliver O'Halloran , Dan Williams , Wei Yang , Christian =?iso-8859-1?Q?K=F6nig?= , Arnd Bergmann , Deepa Dinamani , Daniel Thompson , Florian Fainelli , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, adi-buildroot-devel@lists.sourceforge.net, linux-c6x-dev@linux-c6x.org, linux-cris-kernel@axis.com, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-am33-list@redhat.com, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, linux-xtensa@linux-xtensa.org Subject: Re: [PATCH] Extract initrd free logic from arch-specific code. Message-ID: <20180329173103.GE16141@n2100.armlinux.org.uk> References: <20180325221853.10839-1-shea@shealevy.com> <20180328152714.6103-1-shea@shealevy.com> <05620fee-e8b5-0668-77b8-da073dc78c40@landley.net> <20180328164813.GA3888@n2100.armlinux.org.uk> <20180328221401.GA14084@n2100.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Sender: Russell King - ARM Linux List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Mar 29, 2018 at 11:39:24AM -0500, Rob Landley wrote: > > > On 03/28/2018 05:14 PM, Russell King - ARM Linux wrote: > > On Wed, Mar 28, 2018 at 02:04:22PM -0500, Rob Landley wrote: > >> > >> > >> On 03/28/2018 11:48 AM, Russell King - ARM Linux wrote: > >>> On Wed, Mar 28, 2018 at 10:58:51AM -0500, Rob Landley wrote: > >>>> On 03/28/2018 10:26 AM, Shea Levy wrote: > >>>>> Now only those architectures that have custom initrd free requirements > >>>>> need to define free_initrd_mem. > >>>> ... > >>>>> --- a/arch/arc/mm/init.c > >>>>> +++ b/arch/arc/mm/init.c > >>>>> @@ -229,10 +229,3 @@ void __ref free_initmem(void) > >>>>> { > >>>>> free_initmem_default(-1); > >>>>> } > >>>>> - > >>>>> -#ifdef CONFIG_BLK_DEV_INITRD > >>>>> -void __init free_initrd_mem(unsigned long start, unsigned long end) > >>>>> -{ > >>>>> - free_reserved_area((void *)start, (void *)end, -1, "initrd"); > >>>>> -} > >>>>> -#endif > >>>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > >>>>> index 3f972e83909b..19d1c5594e2d 100644 > >>>>> --- a/arch/arm/Kconfig > >>>>> +++ b/arch/arm/Kconfig > >>>>> @@ -47,6 +47,7 @@ config ARM > >>>>> select HARDIRQS_SW_RESEND > >>>>> select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT) > >>>>> select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 > >>>>> + select HAVE_ARCH_FREE_INITRD_MEM > >>>>> select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU > >>>>> select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU > >>>>> select HAVE_ARCH_MMAP_RND_BITS if MMU > >>>> > >>>> Isn't this why weak symbols were invented? > >>> > >>> Weak symbols means that we end up with both the weakly-referenced code > >>> and the arch code in the kernel image. That's fine if the weak code > >>> is small. > >> > >> The kernel's been able to build with link time garbage collection since 2016: > >> > >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b67067f1176d > >> > >> Wouldn't that remove the unused one? > > > > Probably, if anyone bothered to use that, which they don't. > > > > LD_DEAD_CODE_DATA_ELIMINATION is a symbol without a prompt, and from > > what I can see, nothing selects it. Therefore, the symbol is always > > disabled, and so the feature never gets used in mainline kernels. > > It looks like there are per-architecture linker scripts that need to be updated? > So if an architecture supports it, it's always done (well, it probes for the > toolchain supporting the flag). And if the architecture doesn't support it, the > linker script needs to be updated to mark sections with "I know nothing seems to > reference this at the ELF level but keep it anyway, we're pulling an assembly > trick". It looks like it needs much more than just architecture changes as the reason it fails on ARM is because the init thread structure is missing due to missing KEEP()s in INIT_TASK_DATA(). Probably means it doesn't work anywhere. 8<=== From: Russell King Subject: [PATCH] Fix LD_DEAD_CODE_DATA_ELIMINATION LD_DEAD_CODE_DATA_ELIMINATION fails to boot on ARM because the linker eliminates the init thread data from the bottom of the init threads stack. This causes recursive faults that end up overwriting parts of the kernel before they can print any message. Signed-off-by: Russell King --- include/asm-generic/vmlinux.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 1ab0e520d6fc..41af8a74aae4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -279,8 +279,8 @@ VMLINUX_SYMBOL(__start_init_task) = .; \ VMLINUX_SYMBOL(init_thread_union) = .; \ VMLINUX_SYMBOL(init_stack) = .; \ - *(.data..init_task) \ - *(.data..init_thread_info) \ + KEEP(*(.data..init_task)) \ + KEEP(*(.data..init_thread_info)) \ . = VMLINUX_SYMBOL(__start_init_task) + THREAD_SIZE; \ VMLINUX_SYMBOL(__end_init_task) = .; -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up