From patchwork Tue Feb 12 22:13:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 2132431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 79730DFB7B for ; Tue, 12 Feb 2013 22:16:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U5O6H-00050d-7r; Tue, 12 Feb 2013 22:13:17 +0000 Received: from relais.videotron.ca ([24.201.245.36]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U5O6E-00050L-Be for linux-arm-kernel@lists.infradead.org; Tue, 12 Feb 2013 22:13:15 +0000 MIME-version: 1.0 Received: from xanadu.home ([24.202.213.203]) by VL-VM-MR002.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0MI400M50OE1EOK1@VL-VM-MR002.ip.videotron.ca> for linux-arm-kernel@lists.infradead.org; Tue, 12 Feb 2013 17:13:13 -0500 (EST) Date: Tue, 12 Feb 2013 17:13:13 -0500 (EST) From: Nicolas Pitre To: Ben Dooks Subject: Re: ARM big-endian on current kernels for linux-3.8 In-reply-to: <511A7CEB.9000006@codethink.co.uk> Message-id: References: <1360365467-25056-1-git-send-email-ben.dooks@codethink.co.uk> <20130212171310.GS17833@n2100.arm.linux.org.uk> <511A7CEB.9000006@codethink.co.uk> User-Agent: Alpine 2.03 (LFD 1266 2009-07-14) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130212_171314_456102_61DB93EB X-CRM114-Status: GOOD ( 16.17 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [24.201.245.36 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Tue, 12 Feb 2013, Ben Dooks wrote: > If we ignore the ATAG issue, then most of the support is currently in > the kernel to do this and there's not a lot of changes. You could make CPU_BE8_BOOT_LE depend on !ATAG. > I think that some of the boot changes could be dealt with by a > post-process of the zImage (such as the zImage magic) which would make > this series less intrusive to the kernel. No, please don't do that. Especially if the kernel binary _expects_ to be booted from a LE environment. Otherwise we might end up with kernels that don't boot because there are environment expectation mismatch, etc. Here's what could be done for the zImage header: diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 4d5f4192ee..2077ebb734 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -129,9 +129,9 @@ start: THUMB( adr r12, BSYM(1f) ) THUMB( bx r12 ) - .word 0x016f2818 @ Magic numbers to help the loader - .word start @ absolute load/run zImage address - .word _edata @ zImage end address + .word _magic_sig @ Signature to help the loader (0x016f2818) + .word _magic_start @ zImage load/run address (0 if relocatable) + .word _magic_end @ zImage end address THUMB( .thumb ) 1: mrs r9, cpsr diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index a517153a13..52539f46c1 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -200,8 +200,11 @@ CFLAGS_font.o := -Dstatic= $(obj)/font.c: $(FONTC) $(call cmd,shipped) -$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) +$(obj)/vmlinux.lds.S: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG) @sed "$(SEDFLAGS)" < $< > $@ +$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.S + $(call if_changed,cpp_lds_S) + $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S $(call cmd,shipped) diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in index 4919f2ac8b..567250fb7d 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.in +++ b/arch/arm/boot/compressed/vmlinux.lds.in @@ -7,6 +7,16 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#ifdef CONFIG_CPU_BE8_BOOT_LE +#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ + (((x) >> 8) & 0x0000ff00) | \ + (((x) << 8) & 0x00ff0000) | \ + (((x) << 24) & 0xff000000) ) +#else +#define ZIMAGE_MAGIC(x) (x) +#endif + OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS @@ -57,6 +67,10 @@ SECTIONS .pad : { BYTE(0); . = ALIGN(8); } _edata = .; + _magic_sig = ZIMAGE_MAGIC(0x016f2818); + _magic_start = ZIMAGE_MAGIC(_start); + _magic_end = ZIMAGE_MAGIC(_edata); + . = BSS_START; __bss_start = .; .bss : { *(.bss) }