From 25f45fbd23f9e7c88d5d126073cf4bbc9e01086b Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 20 Sep 2020 01:36:44 +1000 Subject: [PATCH] CPU: Add hack for stale icache reads in interpreter --- src/core/cpu_core.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index b4947af09..30d7e1e3f 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -467,6 +467,7 @@ void DisassembleAndPrint(u32 addr, u32 instructions_before /* = 0 */, u32 instru template ALWAYS_INLINE_RELEASE static void ExecuteInstruction() { +restart_instruction: const Instruction inst = g_state.current_instruction; #if 0 @@ -1348,6 +1349,16 @@ ALWAYS_INLINE_RELEASE static void ExecuteInstruction() // everything else is reserved/invalid default: { + u32 ram_value; + if (SafeReadInstruction(g_state.current_instruction_pc, &ram_value) && + ram_value != g_state.current_instruction.bits) + { + Log_ErrorPrintf("Stale icache at 0x%08X - ICache: %08X RAM: %08X", g_state.current_instruction_pc, + g_state.current_instruction.bits, ram_value); + g_state.current_instruction.bits = ram_value; + goto restart_instruction; + } + RaiseException(Exception::RI); } break;