Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dave Martin and committed by
Russell King
540b5738 c7e89b16

+23 -1
+5
Documentation/arm/Booting
··· 164 164 - The boot loader is expected to call the kernel image by jumping 165 165 directly to the first instruction of the kernel image. 166 166 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.
+2 -1
arch/arm/boot/compressed/head.S
··· 353 353 mov r0, #0 @ must be zero 354 354 mov r1, r7 @ restore architecture number 355 355 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 357 358 358 359 .align 2 359 360 .type LC0, #object
+8
arch/arm/kernel/head-nommu.S
··· 32 32 * numbers for r1. 33 33 * 34 34 */ 35 + .arm 36 + 35 37 __HEAD 36 38 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 + 37 45 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode 38 46 @ and irqs disabled 39 47 #ifndef CONFIG_CPU_CP15
+8
arch/arm/kernel/head.S
··· 71 71 * crap here - that's what the boot loader (or in extreme, well justified 72 72 * circumstances, zImage) is for. 73 73 */ 74 + .arm 75 + 74 76 __HEAD 75 77 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 + 76 84 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode 77 85 @ and irqs disabled 78 86 mrc p15, 0, r9, c0, c0 @ get processor id