diff --git a/include/dynarmic/callbacks.h b/include/dynarmic/callbacks.h index 09f7d40f..9e127717 100644 --- a/include/dynarmic/callbacks.h +++ b/include/dynarmic/callbacks.h @@ -29,7 +29,8 @@ struct UserCallbacks { bool (*IsReadOnlyMemory)(std::uint32_t vaddr); /// The intrepreter must execute only one instruction at PC. - void (*InterpreterFallback)(std::uint32_t pc, Jit* jit); + void (*InterpreterFallback)(std::uint32_t pc, Jit* jit, void* user_arg); + void* user_arg = nullptr; bool (*CallSVC)(std::uint32_t swi); diff --git a/src/backend_x64/emit_x64.cpp b/src/backend_x64/emit_x64.cpp index e79b0a7a..fbd669f9 100644 --- a/src/backend_x64/emit_x64.cpp +++ b/src/backend_x64/emit_x64.cpp @@ -2188,6 +2188,7 @@ void EmitX64::EmitTerminalInterpret(IR::Term::Interpret terminal, Arm::LocationD code->mov(code->ABI_PARAM1.cvt32(), terminal.next.PC()); code->mov(code->ABI_PARAM2, reinterpret_cast(jit_interface)); + code->mov(code->ABI_PARAM3, reinterpret_cast(cb.user_arg)); code->mov(MJitStateReg(Arm::Reg::PC), code->ABI_PARAM1.cvt32()); code->SwitchMxcsrOnExit(); code->CallFunction(cb.InterpreterFallback); diff --git a/tests/arm/fuzz_arm.cpp b/tests/arm/fuzz_arm.cpp index 7a6a4854..e4ded4ca 100644 --- a/tests/arm/fuzz_arm.cpp +++ b/tests/arm/fuzz_arm.cpp @@ -56,7 +56,7 @@ static void MemoryWrite8(u32 vaddr, u8 value); static void MemoryWrite16(u32 vaddr, u16 value); static void MemoryWrite32(u32 vaddr, u32 value); static void MemoryWrite64(u32 vaddr, u64 value); -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit); +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*); static Dynarmic::UserCallbacks GetUserCallbacks(); static bool IsReadOnlyMemory(u32 vaddr) { @@ -92,7 +92,7 @@ static void MemoryWrite64(u32 vaddr, u64 value){ write_records.push_back({64, vaddr, value}); } -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit) { +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*) { ARMul_State interp_state{USER32MODE}; interp_state.user_callbacks = GetUserCallbacks(); interp_state.NumInstrsToExecute = 1; diff --git a/tests/arm/fuzz_thumb.cpp b/tests/arm/fuzz_thumb.cpp index df07df54..2231dc00 100644 --- a/tests/arm/fuzz_thumb.cpp +++ b/tests/arm/fuzz_thumb.cpp @@ -48,7 +48,7 @@ static void MemoryWrite8(u32 vaddr, u8 value); static void MemoryWrite16(u32 vaddr, u16 value); static void MemoryWrite32(u32 vaddr, u32 value); static void MemoryWrite64(u32 vaddr, u64 value); -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit); +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*); static Dynarmic::UserCallbacks GetUserCallbacks(); static bool IsReadOnlyMemory(u32 vaddr) { @@ -84,7 +84,7 @@ static void MemoryWrite64(u32 vaddr, u64 value){ write_records.push_back({64, vaddr, value}); } -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit) { +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*) { ARMul_State interp_state{USER32MODE}; interp_state.user_callbacks = GetUserCallbacks(); interp_state.NumInstrsToExecute = 1; diff --git a/tests/arm/test_thumb_instructions.cpp b/tests/arm/test_thumb_instructions.cpp index 5c96a688..8a238ff4 100644 --- a/tests/arm/test_thumb_instructions.cpp +++ b/tests/arm/test_thumb_instructions.cpp @@ -15,7 +15,7 @@ static std::array code_mem{}; static u32 MemoryRead32(u32 vaddr); -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit); +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*); static Dynarmic::UserCallbacks GetUserCallbacks(); static u32 MemoryRead32(u32 vaddr) { @@ -26,7 +26,7 @@ static u32 MemoryRead32(u32 vaddr) { return vaddr; } -static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit) { +static void InterpreterFallback(u32 pc, Dynarmic::Jit* jit, void*) { ARMul_State interp_state{USER32MODE}; interp_state.user_callbacks = GetUserCallbacks(); interp_state.NumInstrsToExecute = 1;