Commit 06a4b6d0 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Russell King

ARM: 8677/1: boot/compressed: fix decompressor header layout for v7-M

As reported by Patrice, the header layout of the decompressor is
incorrect when building for v7-M. In this case, the __nop macro
resolves to 'mov r0, r0', which is emitted as a narrow encoding,
resulting in the header data fields to end up at lower offsets than
required.

Given the variety of targets we need to support with the same code,
the startup sequence is a bit of a jumble, and uses instructions
and macros whose encoding widths cannot be specified (badr), or only
exist in a narrow encoding (bx)

So force the use of a wide encoding in __nop, and replace the start
sequence with a simple jump to the label marking the start of code,
preceded by a Thumb2 mode switch if required (using explicit wide
encodings where appropriate). The label itself can be moved to the
start of code [where it belongs] due to the larger range of branch
instructions as compared to adr instructions.
Reported-by: default avatarPatrice CHOTARD <patrice.chotard@st.com>
Acked-by: default avatarNicolas Pitre <nico@linaro.org>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent 7ef4783e
...@@ -17,14 +17,12 @@ ...@@ -17,14 +17,12 @@
@ there. @ there.
.inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000 .inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000
#else #else
mov r0, r0 W(mov) r0, r0
#endif #endif
.endm .endm
.macro __EFI_HEADER .macro __EFI_HEADER
#ifdef CONFIG_EFI_STUB #ifdef CONFIG_EFI_STUB
b __efi_start
.set start_offset, __efi_start - start .set start_offset, __efi_start - start
.org start + 0x3c .org start + 0x3c
@ @
......
...@@ -130,19 +130,22 @@ start: ...@@ -130,19 +130,22 @@ start:
.rept 7 .rept 7
__nop __nop
.endr .endr
ARM( mov r0, r0 ) #ifndef CONFIG_THUMB2_KERNEL
ARM( b 1f ) mov r0, r0
THUMB( badr r12, 1f ) #else
THUMB( bx r12 ) AR_CLASS( sub pc, pc, #3 ) @ A/R: switch to Thumb2 mode
M_CLASS( nop.w ) @ M: already in Thumb2 mode
.thumb
#endif
W(b) 1f
.word _magic_sig @ Magic numbers to help the loader .word _magic_sig @ Magic numbers to help the loader
.word _magic_start @ absolute load/run zImage address .word _magic_start @ absolute load/run zImage address
.word _magic_end @ zImage end address .word _magic_end @ zImage end address
.word 0x04030201 @ endianness flag .word 0x04030201 @ endianness flag
THUMB( .thumb ) __EFI_HEADER
1: __EFI_HEADER 1:
ARM_BE8( setend be ) @ go BE8 if compiled for BE8 ARM_BE8( setend be ) @ go BE8 if compiled for BE8
AR_CLASS( mrs r9, cpsr ) AR_CLASS( mrs r9, cpsr )
#ifdef CONFIG_ARM_VIRT_EXT #ifdef CONFIG_ARM_VIRT_EXT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment