diff --git a/util/cacheflush.c b/util/cacheflush.c index de35616718..a08906155a 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -241,7 +241,14 @@ static void __attribute__((constructor)) init_cache_info(void) void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - sys_dcache_flush((void *)rw, len); + if (rx == rw) { + /* + * sys_icache_invalidate() syncs the dcache and icache, + * so no need to call sys_dcache_flush(). + */ + } else { + sys_dcache_flush((void *)rw, len); + } sys_icache_invalidate((void *)rx, len); } #else