From 1ec33ddc04df8dee74583de5b95da473d5083b2e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 14 Feb 2023 19:59:42 -0800 Subject: [PATCH] riscv: Use __riscv_flush_icache() on Linux. This seems to perhaps clear icache on all harts. Otherwise crashing is seen. Not sure what to do on other platforms. --- Common/RiscVEmitter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Common/RiscVEmitter.cpp b/Common/RiscVEmitter.cpp index b061486f37..9c99961656 100644 --- a/Common/RiscVEmitter.cpp +++ b/Common/RiscVEmitter.cpp @@ -18,6 +18,9 @@ #include "ppsspp_config.h" #include #include +#if PPSSPP_ARCH(RISCV64) && PPSSPP_PLATFORM(LINUX) +#include +#endif #include "Common/BitScan.h" #include "Common/CPUDetect.h" #include "Common/RiscVEmitter.h" @@ -1051,8 +1054,13 @@ void RiscVEmitter::FlushIcache() { void RiscVEmitter::FlushIcacheSection(const u8 *start, const u8 *end) { #if PPSSPP_ARCH(RISCV64) +#if PPSSPP_PLATFORM(LINUX) + __riscv_flush_icache((char *)start, (char *)end, 0); +#else + // TODO: This might only correspond to a local hart icache clear, which is no good. __builtin___clear_cache((char *)start, (char *)end); #endif +#endif } FixupBranch::~FixupBranch() {