ARM: head.S: use PC-relative insn sequence for secondary_data
authorArd Biesheuvel <ardb@kernel.org>
Mon, 14 Sep 2020 08:25:23 +0000 (11:25 +0300)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 28 Oct 2020 16:05:39 +0000 (17:05 +0100)
Replace the open coded PC relative offset calculations with adr_l
and ldr_l invocations. This removes some open coded arithmetic
involving virtual addresses, avoids literal pools on v7+, and slightly
reduces the footprint of the code.

Note that it also removes a stale comment about the contents of r6.

Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
arch/arm/kernel/head.S

index f5a636f..478506b 100644 (file)
@@ -383,10 +383,8 @@ ENTRY(secondary_startup)
        /*
         * Use the page tables supplied from  __cpu_up.
         */
-       adr     r4, __secondary_data
-       ldmia   r4, {r5, r7, r12}               @ address to jump to after
-       sub     lr, r4, r5                      @ mmu has been enabled
-       add     r3, r7, lr
+       adr_l   r3, secondary_data
+       mov_l   r12, __secondary_switched
        ldrd    r4, r5, [r3, #0]                @ get secondary_data.pgdir
 ARM_BE8(eor    r4, r4, r5)                     @ Swap r5 and r4 in BE:
 ARM_BE8(eor    r5, r4, r5)                     @ it can be done in 3 steps
@@ -401,22 +399,13 @@ ARM_BE8(eor       r4, r4, r5)                     @ without using a temp reg.
 ENDPROC(secondary_startup)
 ENDPROC(secondary_startup_arm)
 
-       /*
-        * r6  = &secondary_data
-        */
 ENTRY(__secondary_switched)
-       ldr     sp, [r7, #12]                   @ get secondary_data.stack
+       ldr_l   r7, secondary_data + 12         @ get secondary_data.stack
+       mov     sp, r7
        mov     fp, #0
        b       secondary_start_kernel
 ENDPROC(__secondary_switched)
 
-       .align
-
-       .type   __secondary_data, %object
-__secondary_data:
-       .long   .
-       .long   secondary_data
-       .long   __secondary_switched
 #endif /* defined(CONFIG_SMP) */