Core: Do not fail on checking delay slot, if it is invalid memory

This commit is contained in:
zilmar 2022-08-22 13:02:25 +09:30
parent 9b16d29792
commit f3a392489a
2 changed files with 11 additions and 34 deletions

View File

@ -597,11 +597,9 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t &
ContinuePC = PC + 8; ContinuePC = PC + 8;
} }
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(PC + 4, DelaySlot.Value)) if (TargetPC == PC &&
{ g_MMU->MemoryValue32(PC + 4, DelaySlot.Value) &&
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD)); !R4300iInstruction(PC, Command.Value).DelaySlotEffectsCompare(DelaySlot.Value))
}
if (TargetPC == PC && !R4300iInstruction(PC, Command.Value).DelaySlotEffectsCompare(DelaySlot.Value))
{ {
PermLoop = true; PermLoop = true;
} }

View File

@ -477,11 +477,7 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool
if ((m_CompilePC & 0xFFC) != 0xFFC) if ((m_CompilePC & 0xFFC) != 0xFFC)
{ {
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) m_EffectDelaySlot = g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value);
{
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
m_EffectDelaySlot = R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value);
} }
else else
{ {
@ -4325,12 +4321,8 @@ void CX86RecompilerOps::SPECIAL_JR()
m_Section->m_Cont.LinkLocation2 = nullptr; m_Section->m_Cont.LinkLocation2 = nullptr;
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) &&
{ R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
if (R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
{ {
if (IsConst(m_Opcode.rs)) if (IsConst(m_Opcode.rs))
{ {
@ -4350,12 +4342,7 @@ void CX86RecompilerOps::SPECIAL_JR()
else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
{
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
if (R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
{ {
CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, nullptr); CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, nullptr);
} }
@ -4393,12 +4380,8 @@ void CX86RecompilerOps::SPECIAL_JALR()
if (m_PipelineStage == PIPELINE_STAGE_NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) &&
{ R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value) && (m_CompilePC & 0xFFC) != 0xFFC)
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
if (R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value) && (m_CompilePC & 0xFFC) != 0xFFC)
{ {
if (IsConst(m_Opcode.rs)) if (IsConst(m_Opcode.rs))
{ {
@ -4444,12 +4427,8 @@ void CX86RecompilerOps::SPECIAL_JALR()
else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
R4300iOpcode DelaySlot; R4300iOpcode DelaySlot;
if (!g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value)) if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) &&
{ R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
if (R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value))
{ {
CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, nullptr); CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, nullptr);
} }