From 51d50267929eef9d435be3f94163437b659c7ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 26 Sep 2023 19:39:48 +0200 Subject: [PATCH 1/2] WriteExit: Assert on bad exit numbers --- Core/MIPS/ARM/ArmJit.cpp | 2 ++ Core/MIPS/ARM64/Arm64Jit.cpp | 3 +++ Core/MIPS/x86/Jit.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index eab53366291f..f7df325ace88 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -746,6 +746,8 @@ void ArmJit::UpdateRoundingMode(u32 fcr31) { void ArmJit::WriteExit(u32 destination, int exit_num) { // TODO: Check destination is valid and trigger exception. + _assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination); + WriteDownCount(); //If nobody has taken care of this yet (this can be removed when all branches are done) JitBlock *b = js.curBlock; diff --git a/Core/MIPS/ARM64/Arm64Jit.cpp b/Core/MIPS/ARM64/Arm64Jit.cpp index b8e8b6f560f9..727c24412ef5 100644 --- a/Core/MIPS/ARM64/Arm64Jit.cpp +++ b/Core/MIPS/ARM64/Arm64Jit.cpp @@ -725,6 +725,9 @@ void Arm64Jit::UpdateRoundingMode(u32 fcr31) { // though, as we need to have the SUBS flag set in the end. So with block linking in the mix, // I don't think this gives us that much benefit. void Arm64Jit::WriteExit(u32 destination, int exit_num) { + // TODO: Check destination is valid and trigger exception. + _assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination); + // TODO: Check destination is valid and trigger exception. WriteDownCount(); //If nobody has taken care of this yet (this can be removed when all branches are done) diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index 62225275e504..2f561a2cd05a 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -708,7 +708,7 @@ static void HitInvalidBranch(uint32_t dest) { } void Jit::WriteExit(u32 destination, int exit_num) { - _dbg_assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num"); + _assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination); if (!Memory::IsValidAddress(destination) || (destination & 3) != 0) { ERROR_LOG_REPORT(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc); From dd2b1ace884664bd64ed2a1ad179a5b6f7b404f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 26 Sep 2023 19:44:05 +0200 Subject: [PATCH 2/2] BlockCache on ARM/ARM64: Allow two more exits --- Core/MIPS/JitCommon/JitBlockCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/MIPS/JitCommon/JitBlockCache.h b/Core/MIPS/JitCommon/JitBlockCache.h index 3049300f9aa7..09eae3cc2138 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.h +++ b/Core/MIPS/JitCommon/JitBlockCache.h @@ -29,7 +29,7 @@ #include "Core/MIPS/MIPS.h" #if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) -const int MAX_JIT_BLOCK_EXITS = 2; +const int MAX_JIT_BLOCK_EXITS = 4; #else const int MAX_JIT_BLOCK_EXITS = 8; #endif