aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-08-17 11:54:41 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2016-08-17 12:37:37 -0400
commitbc9f3d7788a88d080a30599bde68f383daf8f8a5 (patch)
tree31bb9bddbf43207842221dff70d83a21389e4e1f
parentbfe6c8a89e03f52bccf922f74ced8fe959e7fd36 (diff)
arm64: kernel: avoid literal load of virtual address with MMU off
Literal loads of virtual addresses are subject to runtime relocation when CONFIG_RELOCATABLE=y, and given that the relocation routines run with the MMU and caches enabled, literal loads of relocated values performed with the MMU off are not guaranteed to return the latest value unless the memory covering the literal is cleaned to the PoC explicitly. So defer the literal load until after the MMU has been enabled, just like we do for primary_switch() and secondary_switch() in head.S. Fixes: 1e48ef7fcc37 ("arm64: add support for building vmlinux as a relocatable PIE binary") Cc: <stable@vger.kernel.org> # 4.6+ Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/kernel/sleep.S10
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/arm64/kernel/sleep.S b/arch/arm64/kernel/sleep.S
index 9a3aec97ac09..ccf79d849e0a 100644
--- a/arch/arm64/kernel/sleep.S
+++ b/arch/arm64/kernel/sleep.S
@@ -101,12 +101,20 @@ ENTRY(cpu_resume)
101 bl el2_setup // if in EL2 drop to EL1 cleanly 101 bl el2_setup // if in EL2 drop to EL1 cleanly
102 /* enable the MMU early - so we can access sleep_save_stash by va */ 102 /* enable the MMU early - so we can access sleep_save_stash by va */
103 adr_l lr, __enable_mmu /* __cpu_setup will return here */ 103 adr_l lr, __enable_mmu /* __cpu_setup will return here */
104 ldr x27, =_cpu_resume /* __enable_mmu will branch here */ 104 adr_l x27, _resume_switched /* __enable_mmu will branch here */
105 adrp x25, idmap_pg_dir 105 adrp x25, idmap_pg_dir
106 adrp x26, swapper_pg_dir 106 adrp x26, swapper_pg_dir
107 b __cpu_setup 107 b __cpu_setup
108ENDPROC(cpu_resume) 108ENDPROC(cpu_resume)
109 109
110 .pushsection ".idmap.text", "ax"
111_resume_switched:
112 ldr x8, =_cpu_resume
113 br x8
114ENDPROC(_resume_switched)
115 .ltorg
116 .popsection
117
110ENTRY(_cpu_resume) 118ENTRY(_cpu_resume)
111 mrs x1, mpidr_el1 119 mrs x1, mpidr_el1
112 adrp x8, mpidr_hash 120 adrp x8, mpidr_hash