Skip to content

Commit f2971e0

Browse files
mrutland-armAlex Shi
authored andcommitted
arm64: fix KASLR boot-time I-cache maintenance
Commit f80fb3a3d50843a4 ("arm64: add support for kernel ASLR") missed a DSB necessary to complete I-cache maintenance in the primary boot path, and hence stale instructions may still be present in the I-cache and may be executed until the I-cache maintenance naturally completes. Since commit 8ec4198 ("arm64: mm: ensure patched kernel text is fetched from PoU"), all CPUs invalidate their I-caches after their MMU is enabled. Prior a CPU's MMU having been enabled, arbitrary lines may have been fetched from the PoC into I-caches. We never patch text expected to be executed with the MMU off. Thus, it is unnecessary to perform broadcast I-cache maintenance in the primary boot path. This patch reduces the scope of the I-cache maintenance to the local CPU, and adds the missing DSB with similar scope, matching prior maintenance in the primary boot path. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Ard Biesehvuel <ard.biesheuvel@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> (cherry picked from commit b90b4a608ea2401cc491828f7a385edd2e236e37) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 37829fd commit f2971e0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

arch/arm64/kernel/head.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,9 @@ __enable_mmu:
740740

741741
msr sctlr_el1, x19 // re-enable the MMU
742742
isb
743-
ic ialluis // flush instructions fetched
744-
isb // via old mapping
743+
ic iallu // flush instructions fetched
744+
dsb nsh // via old mapping
745+
isb
745746
add x27, x27, x23 // relocated __mmap_switched
746747
#endif
747748
br x27

0 commit comments

Comments
 (0)