Skip to content

Commit bae0ca2

Browse files
wildea01Russell King
authored andcommitted
ARM: 7953/1: mm: ensure TLB invalidation is complete before enabling MMU
During __v{6,7}_setup, we invalidate the TLBs since we are about to enable the MMU on return to head.S. Unfortunately, without a subsequent dsb instruction, the invalidation is not guaranteed to have completed by the time we write to the sctlr, potentially exposing us to junk/stale translations cached in the TLB. This patch reworks the init functions so that the dsb used to ensure completion of cache/predictor maintenance is also used to ensure completion of the TLB invalidation. Cc: <[email protected]> Reported-by: Albin Tonnerre <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent ca47440 commit bae0ca2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/arm/mm/proc-v6.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ __v6_setup:
208208
mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
209209
mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
210210
mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
211-
mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
212211
#ifdef CONFIG_MMU
213212
mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
214213
mcr p15, 0, r0, c2, c0, 2 @ TTB control register
@@ -218,6 +217,8 @@ __v6_setup:
218217
ALT_UP(orr r8, r8, #TTB_FLAGS_UP)
219218
mcr p15, 0, r8, c2, c0, 1 @ load TTB1
220219
#endif /* CONFIG_MMU */
220+
mcr p15, 0, r0, c7, c10, 4 @ drain write buffer and
221+
@ complete invalidations
221222
adr r5, v6_crval
222223
ldmia r5, {r5, r6}
223224
ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables

arch/arm/mm/proc-v7.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ __v7_setup:
351351

352352
4: mov r10, #0
353353
mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
354-
dsb
355354
#ifdef CONFIG_MMU
356355
mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
357356
v7_ttb_setup r10, r4, r8, r5 @ TTBCR, TTBRx setup
@@ -360,6 +359,7 @@ __v7_setup:
360359
mcr p15, 0, r5, c10, c2, 0 @ write PRRR
361360
mcr p15, 0, r6, c10, c2, 1 @ write NMRR
362361
#endif
362+
dsb @ Complete invalidations
363363
#ifndef CONFIG_ARM_THUMBEE
364364
mrc p15, 0, r0, c0, c1, 0 @ read ID_PFR0 for ThumbEE
365365
and r0, r0, #(0xf << 12) @ ThumbEE enabled field

0 commit comments

Comments
 (0)