Skip to content

Commit 06a4b6d

Browse files
Ard BiesheuvelRussell King
authored andcommitted
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: Patrice CHOTARD <[email protected]> Acked-by: Nicolas Pitre <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 7ef4783 commit 06a4b6d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

arch/arm/boot/compressed/efi-header.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
@ there.
1818
.inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000
1919
#else
20-
mov r0, r0
20+
W(mov) r0, r0
2121
#endif
2222
.endm
2323

2424
.macro __EFI_HEADER
2525
#ifdef CONFIG_EFI_STUB
26-
b __efi_start
27-
2826
.set start_offset, __efi_start - start
2927
.org start + 0x3c
3028
@

arch/arm/boot/compressed/head.S

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,22 @@ start:
130130
.rept 7
131131
__nop
132132
.endr
133-
ARM( mov r0, r0 )
134-
ARM( b 1f )
135-
THUMB( badr r12, 1f )
136-
THUMB( bx r12 )
133+
#ifndef CONFIG_THUMB2_KERNEL
134+
mov r0, r0
135+
#else
136+
AR_CLASS( sub pc, pc, #3 ) @ A/R: switch to Thumb2 mode
137+
M_CLASS( nop.w ) @ M: already in Thumb2 mode
138+
.thumb
139+
#endif
140+
W(b) 1f
137141

138142
.word _magic_sig @ Magic numbers to help the loader
139143
.word _magic_start @ absolute load/run zImage address
140144
.word _magic_end @ zImage end address
141145
.word 0x04030201 @ endianness flag
142146

143-
THUMB( .thumb )
144-
1: __EFI_HEADER
145-
147+
__EFI_HEADER
148+
1:
146149
ARM_BE8( setend be ) @ go BE8 if compiled for BE8
147150
AR_CLASS( mrs r9, cpsr )
148151
#ifdef CONFIG_ARM_VIRT_EXT

0 commit comments

Comments
 (0)