From patchwork Thu Jun 19 20:32:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 4386021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DD7009F314 for ; Thu, 19 Jun 2014 20:36:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5D6B20397 for ; Thu, 19 Jun 2014 20:36:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73FA42012F for ; Thu, 19 Jun 2014 20:36:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wxj0j-0002bp-Mm; Thu, 19 Jun 2014 20:32:41 +0000 Received: from mail-qg0-f43.google.com ([209.85.192.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wxj0h-0002ZX-7C for linux-arm-kernel@lists.infradead.org; Thu, 19 Jun 2014 20:32:39 +0000 Received: by mail-qg0-f43.google.com with SMTP id z60so2622970qgd.16 for ; Thu, 19 Jun 2014 13:32:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=gz3eCOYBYM2EKax4i+QCmccEphSW0tN5sdiSdhJOoko=; b=Gpqrq98BJ7AGjrAZUxYpsMjUcSvMcpn0vo5mbbop4TO/6ruExXVT/j0O1VmXusRpHV ZF1TSGTx4pPopM4L0jlqATR4bM0IdOjPH2zFtJUbmWi+/oEqd8LFpWa0SY7453BNOU8Z D2cTOaIdHW+Bea/RGWkjDNbcsPfppi8sUczK6TkNd4TwGd+b0V24Ko/mqxyWfPiZ45mz Agm2YeJwTup8CEnFaKF2l6OUhBwWOAUNdVQFZvmMb2AZ6GsnuB8ZLkaBbKwDCr8CAAjI BzkzTcXc7xF+MvroidUP5Bg8M6fapB/cQxCi3S44TOAluYAOhcGhmaX5SLFJV5cfi0L3 9Q0Q== X-Gm-Message-State: ALoCoQm1SieNIXsDE4IW854pfRuMiGpygQQ41WN728WODPig2ieC1X12vb9lPmQylunchou9JJcN X-Received: by 10.224.160.142 with SMTP id n14mr11012615qax.32.1403209934318; Thu, 19 Jun 2014 13:32:14 -0700 (PDT) Received: from xanadu.home (modemcable177.143-130-66.mc.videotron.ca. [66.130.143.177]) by mx.google.com with ESMTPSA id r3sm10125667qal.8.2014.06.19.13.32.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Jun 2014 13:32:13 -0700 (PDT) Date: Thu, 19 Jun 2014 16:32:12 -0400 (EDT) From: Nicolas Pitre To: Kevin Hilman Subject: Re: [PATCH] ARM: zImage: ensure header in LE format for BE8 kernels In-Reply-To: <7hk38cycuh.fsf@paris.lan> Message-ID: References: <1397147232-28516-1-git-send-email-taras.kondratiuk@linaro.org> <53A1D701.8060404@codeaurora.org> <53A1D8FE.6030404@codeaurora.org> <7hk38cycuh.fsf@paris.lan> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140619_133239_331867_12825099 X-CRM114-Status: GOOD ( 17.93 ) X-Spam-Score: -0.1 (/) Cc: Thomas Petazzoni , Russell King , Jason Cooper , Victor Kamensky , Taras Kondratiuk , Stephen Boyd , LKML , Ben Dooks , Olof Johansson , Linaro Networking , linux-arm-kernel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 19 Jun 2014, Kevin Hilman wrote: > I think this should probably be officialized since we've taken away the > ability for magic-number checking tools (like 'file') to distinguish > between big- and little-endian zImages. > > For now, I've updated my tools to check for 'setend be' in ARM and > Thumb2 mode, but if this does get officialized, I'll gladly move over to > it. Would you ACK this patch? ----- >8 ARM: zImage: identify kernel endianness With patch #8067/1 applied, it is no longer possible to determine the endianness of a compiled kernel image. This normally shouldn't matter to the boot environment, except for those cases where the selection of a ramdisk or root filesystem with a matching endianness has to be automated. Let's add a flag to the zImage header indicating the actual endianness. Four bytes from offset 0x30 can be interpreted as follows: 04 03 02 01 big endian kernel 01 02 03 04 little endian kernel Anything else should be interpreted as "unknown", in which case it is most likely that patch #8067/1 was not applied either and the zImage magic number at offset 0x24 could be used instead to determine endianness. No zImage before this patch ever produced 0x01020304 nor 0x04030201 at offset 0x30 so there is no confusion possible. Signed-off-by: Nicolas Pitre Acked-by: Kevin Hilman diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index c95feab6ce..413fd94b53 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -128,6 +128,7 @@ start: .word _magic_sig @ Magic numbers to help the loader .word _magic_start @ absolute load/run zImage address .word _magic_end @ zImage end address + .word 0x04030201 @ endianness flag THUMB( .thumb ) 1: