diff --git a/Core/MIPS/x86/CompBranch.cpp b/Core/MIPS/x86/CompBranch.cpp index 7d3a52091a..c18d9ae5d5 100644 --- a/Core/MIPS/x86/CompBranch.cpp +++ b/Core/MIPS/x86/CompBranch.cpp @@ -20,8 +20,9 @@ #include "profiler/profiler.h" -#include "Core/Reporting.h" #include "Core/Config.h" +#include "Core/Core.h" +#include "Core/Reporting.h" #include "Core/HLE/HLE.h" #include "Core/HLE/HLETables.h" #include "Core/Host.h" @@ -591,6 +592,10 @@ void Jit::Comp_VBranch(MIPSOpcode op) } } +static void HitInvalidJump(uint32_t dest) { + Core_ExecException(dest, currentMIPS->pc - 8, ExecExceptionType::JUMP); +} + void Jit::Comp_Jump(MIPSOpcode op) { CONDITIONAL_LOG; if (js.inDelaySlot) { @@ -608,6 +613,12 @@ void Jit::Comp_Jump(MIPSOpcode op) { js.compiling = false; } // TODO: Mark this block dirty or something? May be indication it will be changed by imports. + + CompileDelaySlot(DELAYSLOT_NICE); + FlushAll(); + MOV(32, MIPSSTATE_VAR(pc), Imm32(GetCompilerPC() + 8)); + ABI_CallFunctionC((const void *)&HitInvalidJump, targetAddr); + WriteSyscallExit(); return; } diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index a9b24fa8a2..4629d57f3d 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -705,6 +705,11 @@ void Jit::WriteExit(u32 destination, int exit_num) { } } +static void HitInvalidJumpReg(uint32_t source) { + Core_ExecException(currentMIPS->pc, source, ExecExceptionType::JUMP); + currentMIPS->pc = source + 8; +} + void Jit::WriteExitDestInReg(X64Reg reg) { // If we need to verify coreState and rewind, we may not jump yet. if (js.afterOp & (JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE)) { @@ -741,15 +746,13 @@ void Jit::WriteExitDestInReg(X64Reg reg) { SetJumpTarget(tooLow); SetJumpTarget(tooHigh); - ABI_CallFunctionA((const void *)&Memory::GetPointer, R(reg)); + ABI_CallFunctionA((const void *)&Memory::IsValidAddress, R(reg)); // If we're ignoring, coreState didn't trip - so trip it now. - if (g_Config.bIgnoreBadMemAccess) { - CMP(32, R(EAX), Imm32(0)); - FixupBranch skip = J_CC(CC_NE); - ABI_CallFunctionA((const void *)&Core_UpdateState, Imm32(CORE_RUNTIME_ERROR)); - SetJumpTarget(skip); - } + CMP(32, R(EAX), Imm32(0)); + FixupBranch skip = J_CC(CC_NE); + ABI_CallFunctionC((const void *)&HitInvalidJumpReg, GetCompilerPC()); + SetJumpTarget(skip); SUB(32, MIPSSTATE_VAR(downcount), Imm8(0)); JMP(dispatcherCheckCoreState, true);