Skip to contentSkip to conversation

arm: section split in boot/compressed/head.S

RFC In review Leif Lindholm 2 participants 3 messages Jul 21, 2014 – Jul 22, 2014 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

RFC 1/1 arm: section split in boot/compressed/head.S

The current code in boot/compressed/head.S executes pretty much sequentially from "start", all the way until the end of "dtb_check_done". However, shortly after the "not_angel" symbol, there is a section change, in the form of a ".text" directive.

This means any literal pools in .start end up getting inserted into the middle of the instruction stream.

Would something like the below (pardon the semantic silliness) be an acceptable fix?

arch/arm/boot/compressed/head.S +4 -2
index 3a8b32d..8ee05e9 100644
@@ -149,6 +149,10 @@ start:
 		mov	r0, #0x17		@ angel_SWIreason_EnterSVC
  ARM(		swi	0x123456	)	@ angel_SWI_ARM
  THUMB(		svc	0xab		)	@ angel_SWI_THUMB
+		b	angel
+
+		.text
+angel:
 not_angel:
 		safe_svcmode_maskall r0
 		msr	spsr_cxsf, r9		@ Save the CPU boot mode in
@@ -163,8 +167,6 @@ not_angel:
 		 * by the linker here, but it should preserve r7, r8, and r9.
 		 */
 
-		.text
-
 #ifdef CONFIG_AUTO_ZRELADDR
 		@ determine final kernel image address
 		mov	r4, pc
#1 lore raw
Quoted 18 lines · Leif Lindholm

The current code in boot/compressed/head.S executes pretty much sequentially from "start", all the way until the end of "dtb_check_done". However, shortly after the "not_angel" symbol, there is a section change, in the form of a ".text" directive.

This means any literal pools in .start end up getting inserted into the middle of the instruction stream.

Would something like the below (pardon the semantic silliness) be an acceptable fix?

arch/arm/boot/compressed/head.S +0 -0
index 3a8b32d..8ee05e9 100644

arch/arm/boot/compressed/head.S start: · line 152

Quoted 4 lines
arch/arm/boot/compressed/head.S +1 -0
@@ -149,6 +149,10 @@ start:
                mov     r0, #0x17               @ angel_SWIreason_EnterSVC
  ARM(          swi     0x123456        )       @ angel_SWI_ARM
  THUMB(                svc     0xab            )       @ angel_SWI_THUMB
+               b       angel

The idea appears to be that code in .start sections from other platform specific object files gets put there, so it gets executed extremely early.
Jumping over it kind of defeats the purpose here.

Instead, adding an explicit .ltorg and jumping over /that/ should do the trick, I think, but perhaps it's better just to open code the literal pool in this case.

Signature · 1 line
Ard.
Quoted 20 lines
arch/arm/boot/compressed/head.S +3 -2
+
+               .text
+angel:
 not_angel:
                safe_svcmode_maskall r0
                msr     spsr_cxsf, r9           @ Save the CPU boot mode in
@@ -163,8 +167,6 @@ not_angel:
                 * by the linker here, but it should preserve r7, r8, and r9.
                 */
 
-               .text
-
 #ifdef CONFIG_AUTO_ZRELADDR
                @ determine final kernel image address
                mov     r4, pc

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw

RFC 1/1 arm: section split in boot/compressed/head.S

Quoted 14 lines · Ard Biesheuvel
Quoted 13 lines · Leif Lindholm

The current code in boot/compressed/head.S executes pretty much sequentially from "start", all the way until the end of "dtb_check_done". However, shortly after the "not_angel" symbol, there is a section change, in the form of a ".text" directive.

This means any literal pools in .start end up getting inserted into the middle of the instruction stream.

Would something like the below (pardon the semantic silliness) be an acceptable fix?

Quoted 15 lines

arch/arm/boot/compressed/head.S start: · line 152

Quoted 9 lines
arch/arm/boot/compressed/head.S +1 -0
index 3a8b32d..8ee05e9 100644
@@ -149,6 +149,10 @@ start:
                mov     r0, #0x17               @ angel_SWIreason_EnterSVC
  ARM(          swi     0x123456        )       @ angel_SWI_ARM
  THUMB(                svc     0xab            )       @ angel_SWI_THUMB
+               b       angel

The idea appears to be that code in .start sections from other platform specific object files gets put there, so it gets executed extremely early.
Jumping over it kind of defeats the purpose here.

Ah, I got the impression something magic was going on, but failed to spot that bit...

Quoted 3 lines

Instead, adding an explicit .ltorg and jumping over /that/ should do the trick, I think, but perhaps it's better just to open code the literal pool in this case.

The current state seems fragile, so:

arch/arm/boot/compressed/head.S +5 -0
index 3a8b32d..8fded53 100644
@@ -149,6 +149,11 @@ start:
 		mov	r0, #0x17		@ angel_SWIreason_EnterSVC
  ARM(		swi	0x123456	)	@ angel_SWI_ARM
  THUMB(		svc	0xab		)	@ angel_SWI_THUMB
+		b	angel
+
+		.ltorg
+
+angel:
 not_angel:
 		safe_svcmode_maskall r0
 		msr	spsr_cxsf, r9		@ Save the CPU boot mode in

?

/
Leif