From: Kohei Tokunaga Date: Mon, 28 Apr 2025 06:39:00 +0000 (+0900) Subject: util/cacheflush.c: Update cache flushing mechanism for Emscripten X-Git-Tag: v10.1.0-rc0~101^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c7c05171902d2da678f85c035efdf412ce91c4f;p=thirdparty%2Fqemu.git util/cacheflush.c: Update cache flushing mechanism for Emscripten Although __builtin___clear_cache is used to flush the instruction cache for a specified memory region, this operation doesn't apply to wasm, as its memory isn't executable. Moreover, Emscripten does not support this builtin and fails to compile it with the following error. > fatal error: error in backend: llvm.clear_cache is not supported on wasm To resolve this, this commit removes the call to __builtin___clear_cache for Emscripten build. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/r/2926a798fa52a3a5b11c3df4edd1643d2b7cdcb9.1745820062.git.ktokunaga.mail@gmail.com Signed-off-by: Paolo Bonzini --- diff --git a/include/qemu/cacheflush.h b/include/qemu/cacheflush.h index ae20bcda733..76eb55d818d 100644 --- a/include/qemu/cacheflush.h +++ b/include/qemu/cacheflush.h @@ -26,6 +26,13 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) /* icache is coherent and does not require flushing. */ } +#elif defined(EMSCRIPTEN) + +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) +{ + /* Wasm doesn't have executable region of memory. */ +} + #else void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); diff --git a/util/cacheflush.c b/util/cacheflush.c index 1d12899a392..17c58918de6 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -229,6 +229,10 @@ static void __attribute__((constructor)) init_cache_info(void) /* Caches are coherent and do not require flushing; symbol inline. */ +#elif defined(EMSCRIPTEN) + +/* Wasm doesn't have executable region of memory. */ + #elif defined(__aarch64__) && !defined(CONFIG_WIN32) /* * For Windows, we use generic implementation of flush_idcache_range, that