Skip to content

Commit 238962a

Browse files
wildea01Russell King
authored andcommitted
ARM: 8191/1: decompressor: ensure I-side picks up relocated code
To speed up decompression, the decompressor sets up a flat, cacheable mapping of memory. However, when there is insufficient space to hold the page tables for this mapping, we don't bother to enable the caches and subsequently skip all the cache maintenance hooks. Skipping the cache maintenance before jumping to the relocated code allows the processor to predict the branch and populate the I-cache with stale data before the relocation loop has completed (since a bootloader may have SCTLR.I set, which permits normal, cacheable instruction fetches regardless of SCTLR.M). This patch moves the cache maintenance check into the maintenance routines themselves, allowing the v6/v7 versions to invalidate the I-cache regardless of the MMU state. Cc: <[email protected]> Reported-by: Marc Carino <[email protected]> Tested-by: Julien Grall <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 9ff0bb5 commit 238962a

File tree

1 file changed

+16
-4
lines changed
  • arch/arm/boot/compressed

1 file changed

+16
-4
lines changed

arch/arm/boot/compressed/head.S

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ dtb_check_done:
397397
add sp, sp, r6
398398
#endif
399399

400-
tst r4, #1
401-
bleq cache_clean_flush
400+
bl cache_clean_flush
402401

403402
adr r0, BSYM(restart)
404403
add r0, r0, r6
@@ -1047,6 +1046,8 @@ cache_clean_flush:
10471046
b call_cache_fn
10481047

10491048
__armv4_mpu_cache_flush:
1049+
tst r4, #1
1050+
movne pc, lr
10501051
mov r2, #1
10511052
mov r3, #0
10521053
mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -1064,6 +1065,8 @@ __armv4_mpu_cache_flush:
10641065
mov pc, lr
10651066
10661067
__fa526_cache_flush:
1068+
tst r4, #1
1069+
movne pc, lr
10671070
mov r1, #0
10681071
mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
10691072
mcr p15, 0, r1, c7, c5, 0 @ flush I cache
@@ -1072,13 +1075,16 @@ __fa526_cache_flush:
10721075

10731076
__armv6_mmu_cache_flush:
10741077
mov r1, #0
1075-
mcr p15, 0, r1, c7, c14, 0 @ clean+invalidate D
1078+
tst r4, #1
1079+
mcreq p15, 0, r1, c7, c14, 0 @ clean+invalidate D
10761080
mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB
1077-
mcr p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
1081+
mcreq p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
10781082
mcr p15, 0, r1, c7, c10, 4 @ drain WB
10791083
mov pc, lr
10801084

10811085
__armv7_mmu_cache_flush:
1086+
tst r4, #1
1087+
bne iflush
10821088
mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
10831089
tst r10, #0xf << 16 @ hierarchical cache (ARMv7)
10841090
mov r10, #0
@@ -1139,13 +1145,17 @@ iflush:
11391145
mov pc, lr
11401146

11411147
__armv5tej_mmu_cache_flush:
1148+
tst r4, #1
1149+
movne pc, lr
11421150
1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate D cache
11431151
bne 1b
11441152
mcr p15, 0, r0, c7, c5, 0 @ flush I cache
11451153
mcr p15, 0, r0, c7, c10, 4 @ drain WB
11461154
mov pc, lr
11471155

11481156
__armv4_mmu_cache_flush:
1157+
tst r4, #1
1158+
movne pc, lr
11491159
mov r2, #64*1024 @ default: 32K dcache size (*2)
11501160
mov r11, #32 @ default: 32 byte line size
11511161
mrc p15, 0, r3, c0, c0, 1 @ read cache type
@@ -1179,6 +1189,8 @@ no_cache_id:
11791189

11801190
__armv3_mmu_cache_flush:
11811191
__armv3_mpu_cache_flush:
1192+
tst r4, #1
1193+
movne pc, lr
11821194
mov r1, #0
11831195
mcr p15, 0, r1, c7, c0, 0 @ invalidate whole cache v3
11841196
mov pc, lr

0 commit comments

Comments
 (0)