All of lore.kernel.org
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/7] ARM: Thumb-2: Restore sensible zImage header layout for CONFIG_THUMB2_KERNEL
Date: Tue, 16 Nov 2010 13:14:37 +0000	[thread overview]
Message-ID: <1289913277-8822-7-git-send-email-dave.martin@linaro.org> (raw)
In-Reply-To: <1289913277-8822-1-git-send-email-dave.martin@linaro.org>

The code which makes up the zImage header clearly intends to
leave a vector-table-sized gap of 8 words (NOPs, in fact),
followed by a branch to the real entry point, a magic number,
and a word containing the absolute entry point address.

This gets messed up with with CONFIG_THUMB2_KERNEL:

    * The NOPs making up the vector table become halfword-
      sized.

    * The magic number and absolute entry point occur too early
      and become misaligned.

    * The absolute entry point fails to indicate that the entry
      point is Thumb code, which will cause incorrect execution
      if the bootloader uses this to enter the kernel.

This patch makes sure the same layout is generated in the
CONFIG_THUMB2_KERNEL case as in the traditional ARM case, and
sets the Thumb bit (bit 0) in the entry point field.  The ARM
case is unaffected.

This is my best guess as to how the zImage should be laid out
for Thumb-2.  U-Boot in particular uses its own metadata and
ignores the zImage header fields.

If someone knows of a bootloader or other utility which relies
on the strange existing Thumb-2 zImage header layout then this
may require more careful thought.

Applies cleanly on v2.6.37-rc1.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/boot/compressed/head.S |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 1f65080..1e36e2a 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -128,12 +128,12 @@ wait:		mrc	p14, 0, pc, c0, c1, 0
 start:
 		.type	start,#function
 		.rept	8
-		mov	r0, r0
+		W(nop)				@ use 32-bit NOPs for correct padding
 		.endr
 
-		b	1f
+		W(b)	1f
 		.word	0x016f2818		@ Magic numbers to help the loader
-		.word	start			@ absolute load/run zImage address
+		.word	BSYM(start)		@ absolute load/run zImage address
 		.word	_edata			@ zImage end address
 1:		mov	r7, r1			@ save architecture ID
 		mov	r8, r2			@ save atags pointer
-- 
1.7.1

  parent reply	other threads:[~2010-11-16 13:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 13:14 [PATCH 1/7] ARM: kexec: Correct data alignment for CONFIG_THUMB2_KERNEL Dave Martin
2010-11-16 13:14 ` [PATCH 2/7] ARM: vfp: " Dave Martin
2010-11-16 13:14 ` [PATCH 3/7] ARM: Thumb-2: Correct data alignment for CONFIG_THUMB2_KERNEL in bootp/init.S Dave Martin
2010-11-16 13:14 ` [PATCH 4/7] ARM: Thumb-2: Correct data alignment for CONFIG_THUMB2_KERNEL in kernel/head.S Dave Martin
2010-11-16 18:22   ` Russell King - ARM Linux
2010-11-17 10:16     ` Catalin Marinas
2010-11-17 10:16     ` Dave Martin
2010-11-16 13:14 ` [PATCH 5/7] ARM: Thumb-2: Correct data alignment for CONFIG_THUMB2_KERNEL in mm/proc-v7.S Dave Martin
2010-11-16 13:14 ` [PATCH 6/7] ARM: Thumb-2: Fix CONFIG_THUMB2_KERNEL breakage in compressed/head.S Dave Martin
2010-11-16 13:14 ` Dave Martin [this message]
2010-11-16 18:26   ` [PATCH 7/7] ARM: Thumb-2: Restore sensible zImage header layout for CONFIG_THUMB2_KERNEL Russell King - ARM Linux
2010-11-16 20:28     ` Nicolas Pitre
2010-11-16 20:35       ` Russell King - ARM Linux
2010-11-16 20:58         ` Uwe Kleine-König
2010-11-17  9:16         ` Dave Martin
2010-11-17  9:19           ` Dave Martin
2010-11-17 10:21           ` Catalin Marinas
2010-11-17 11:11   ` [PATCH 7/7 v1.1] " Dave Martin
2010-11-17 16:17     ` Nicolas Pitre
2010-11-17 16:46       ` Dave Martin

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=1289913277-8822-7-git-send-email-dave.martin@linaro.org \
    --to=dave.martin@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.