Skip to content

Commit f7e45d9

Browse files
author
Ard Biesheuvel
committed
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 <catalin.marinas@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com> (cherry picked from commit e5ebeec879b726c755af0c1c15f3699b53268cd5) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
1 parent 7a28120 commit f7e45d9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

arch/arm64/kernel/head.S

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,7 @@ __mmap_switched:
466466
str x15, [x11, x23]
467467
b 0b
468468

469-
2: adr_l x8, kimage_vaddr // make relocated kimage_vaddr
470-
dc cvac, x8 // value visible to secondaries
471-
dsb sy // with MMU off
469+
2:
472470
#endif
473471

474472
adr_l sp, initial_sp, x4
@@ -672,12 +670,9 @@ secondary_startup:
672670
adrp x26, swapper_pg_dir
673671
bl __cpu_setup // initialise processor
674672

675-
ldr x8, kimage_vaddr
676-
ldr w9, 0f
677-
sub x27, x8, w9, sxtw // address to jump to after enabling the MMU
673+
adr_l x27, __secondary_switch // address to jump to after enabling the MMU
678674
b __enable_mmu
679675
ENDPROC(secondary_startup)
680-
0: .long (_text - TEXT_OFFSET) - __secondary_switched
681676

682677
__secondary_switched:
683678
adr_l x5, vectors
@@ -750,3 +745,8 @@ __no_granule_support:
750745
wfe
751746
b __no_granule_support
752747
ENDPROC(__no_granule_support)
748+
749+
__secondary_switch:
750+
ldr x8, =__secondary_switched
751+
br x8
752+
ENDPROC(__secondary_switch)

0 commit comments

Comments
 (0)