From: Ard Biesheuvel Date: Mon, 18 Apr 2016 15:09:42 +0000 (+0200) Subject: arm64: kernel: use literal for relocated address of __secondary_switched X-Git-Tag: firefly_0821_release~176^2~4^2~35^2~8 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f7e45d9a0a4d0e5e1ef8581a106f2c891939249d;p=firefly-linux-kernel-4.4.55.git arm64: kernel: use literal for relocated address of __secondary_switched We can simply use a relocated 64-bit literal to store the address of __secondary_switched(), and the relocation code will ensure that it holds the correct value at secondary entry time, as long as we make sure that the literal is not dereferenced until after we have enabled the MMU. So jump via a small __secondary_switch() function covered by the ID map that performs the literal load and branch-to-register. Acked-by: Catalin Marinas Acked-by: Mark Rutland Signed-off-by: Ard Biesheuvel Signed-off-by: Will Deacon (cherry picked from commit e5ebeec879b726c755af0c1c15f3699b53268cd5) Signed-off-by: Ard Biesheuvel --- diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index b417de3c36f9..9e6f5ebbde8d 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -466,9 +466,7 @@ __mmap_switched: str x15, [x11, x23] b 0b -2: adr_l x8, kimage_vaddr // make relocated kimage_vaddr - dc cvac, x8 // value visible to secondaries - dsb sy // with MMU off +2: #endif adr_l sp, initial_sp, x4 @@ -672,12 +670,9 @@ secondary_startup: adrp x26, swapper_pg_dir bl __cpu_setup // initialise processor - ldr x8, kimage_vaddr - ldr w9, 0f - sub x27, x8, w9, sxtw // address to jump to after enabling the MMU + adr_l x27, __secondary_switch // address to jump to after enabling the MMU b __enable_mmu ENDPROC(secondary_startup) -0: .long (_text - TEXT_OFFSET) - __secondary_switched __secondary_switched: adr_l x5, vectors @@ -750,3 +745,8 @@ __no_granule_support: wfe b __no_granule_support ENDPROC(__no_granule_support) + +__secondary_switch: + ldr x8, =__secondary_switched + br x8 +ENDPROC(__secondary_switch)