Skip to content

Commit 540b573

Browse files
Dave MartinRussell King
authored andcommitted
ARM: 6999/1: head, zImage: Always Enter the kernel in ARM state
Currently, the documented kernel entry requirements are not explicit about whether the kernel should be entered in ARM or Thumb, leading to an ambiguitity about how to enter Thumb-2 kernels. As a result, the kernel is reliant on the zImage decompressor to enter the kernel proper in the correct instruction set state. This patch changes the boot entry protocol for head.S and Image to be the same as for zImage: in all cases, the kernel is now entered in ARM. Documentation/arm/Booting is updated to reflect this new policy. A different rule will be needed for Cortex-M class CPUs as and when support for those lands in mainline, since these CPUs don't support the ARM instruction set at all: a note is added to the effect that the kernel must be entered in Thumb on such systems. Signed-off-by: Dave Martin <dave.martin@linaro.org> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent c7e89b1 commit 540b573

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎Documentation/arm/Booting‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,8 @@ In either case, the following conditions must be met:
164164
- The boot loader is expected to call the kernel image by jumping
165165
directly to the first instruction of the kernel image.
166166

167+
On CPUs supporting the ARM instruction set, the entry must be
168+
made in ARM state, even for a Thumb-2 kernel.
169+
170+
On CPUs supporting only the Thumb instruction set such as
171+
Cortex-M class CPUs, the entry must be made in Thumb state.

‎arch/arm/boot/compressed/head.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ not_relocated: mov r0, #0
353353
mov r0, #0 @ must be zero
354354
mov r1, r7 @ restore architecture number
355355
mov r2, r8 @ restore atags pointer
356-
mov pc, r4 @ call kernel
356+
ARM( mov pc, r4 ) @ call kernel
357+
THUMB( bx r4 ) @ entry point is always ARM
357358

358359
.align 2
359360
.type LC0, #object

‎arch/arm/kernel/head-nommu.S‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@
3232
* numbers for r1.
3333
*
3434
*/
35+
.arm
36+
3537
__HEAD
3638
ENTRY(stext)
39+
40+
THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.
41+
THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
42+
THUMB( .thumb ) @ switch to Thumb now.
43+
THUMB(1: )
44+
3745
setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
3846
@ and irqs disabled
3947
#ifndef CONFIG_CPU_CP15

‎arch/arm/kernel/head.S‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,16 @@
7171
* crap here - that's what the boot loader (or in extreme, well justified
7272
* circumstances, zImage) is for.
7373
*/
74+
.arm
75+
7476
__HEAD
7577
ENTRY(stext)
78+
79+
THUMB( adr r9, BSYM(1f) ) @ Kernel is always entered in ARM.
80+
THUMB( bx r9 ) @ If this is a Thumb-2 kernel,
81+
THUMB( .thumb ) @ switch to Thumb now.
82+
THUMB(1: )
83+
7684
setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode
7785
@ and irqs disabled
7886
mrc p15, 0, r9, c0, c0 @ get processor id

0 commit comments

Comments
 (0)