Skip to content

Commit e6c38d2

Browse files
jkomlodipm215
authored andcommitted
util/cacheflush: Make first DSB unconditional on aarch64
On ARM hosts with CTR_EL0.DIC and CTR_EL0.IDC set, this would only cause an ISB to be executed during cache maintenance, which could lead to QEMU executing TBs containing garbage instructions. This seems to be because the ISB finishes executing instructions and flushes the pipeline, but the ISB doesn't guarantee that writes from the executed instructions are committed. If a small enough TB is created, it's possible that the writes setting up the TB aren't committed by the time the TB is executed. This function is intended to be a port of the gcc implementation (https://github.com/gcc-mirror/gcc/blob/85b46d0795ac76bc192cb8f88b646a647acf98c1/libgcc/config/aarch64/sync-cache.c#L67) which makes the first DSB unconditional, so we can fix the synchronization issue by doing that as well. Cc: [email protected] Fixes: 664a797 ("util: Specialize flush_idcache_range for aarch64") Signed-off-by: Joe Komlodi <[email protected]> Message-id: [email protected] Reviewed-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 5b14454 commit e6c38d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

util/cacheflush.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,11 @@ void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
279279
for (p = rw & -dcache_lsize; p < rw + len; p += dcache_lsize) {
280280
asm volatile("dc\tcvau, %0" : : "r" (p) : "memory");
281281
}
282-
asm volatile("dsb\tish" : : : "memory");
283282
}
284283

284+
/* DSB unconditionally to ensure any outstanding writes are committed. */
285+
asm volatile("dsb\tish" : : : "memory");
286+
285287
/*
286288
* If CTR_EL0.DIC is enabled, Instruction cache cleaning to the Point
287289
* of Unification is not required for instruction to data coherence.

0 commit comments

Comments
 (0)