diff --git a/Common/ExceptionHandlerSetup.cpp b/Common/ExceptionHandlerSetup.cpp index 7c8d64b1eb..6cdbefede4 100644 --- a/Common/ExceptionHandlerSetup.cpp +++ b/Common/ExceptionHandlerSetup.cpp @@ -36,7 +36,8 @@ static BadAccessHandler g_badAccessHandler; -#ifdef _WIN32 +// We cannot handle exceptions in UWP builds. Bleh. +#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP) static PVOID g_vectoredExceptionHandle; diff --git a/Core/Core.cpp b/Core/Core.cpp index ecc3d08259..dfb28a6fc8 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -395,6 +395,7 @@ const char *ExceptionTypeAsString(ExceptionType type) { const char *MemoryExceptionTypeAsString(MemoryExceptionType type) { switch (type) { + case MemoryExceptionType::UNKNOWN: return "Unknown"; case MemoryExceptionType::READ_WORD: return "Read Word"; case MemoryExceptionType::WRITE_WORD: return "Write Word"; case MemoryExceptionType::READ_BLOCK: return "Read Block"; diff --git a/Core/Core.h b/Core/Core.h index e7bdb5a462..314a2823a1 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -81,6 +81,7 @@ bool Core_GetPowerSaving(); enum class MemoryExceptionType { NONE, + UNKNOWN, READ_WORD, WRITE_WORD, READ_BLOCK, diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 2f0016d511..251a2c0f9e 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -97,6 +97,11 @@ void FireMhzChange() { } void SetClockFrequencyHz(int cpuHz) { + if (cpuHz <= 0) { + // Paranoid check, protecting against division by zero and similar nonsense. + return; + } + // When the mhz changes, we keep track of what "time" it was before hand. // This way, time always moves forward, even if mhz is changed. lastGlobalTimeUs = GetGlobalTimeUs(); diff --git a/Core/MIPS/ARM/ArmAsm.cpp b/Core/MIPS/ARM/ArmAsm.cpp index fa5a10195d..44176dc293 100644 --- a/Core/MIPS/ARM/ArmAsm.cpp +++ b/Core/MIPS/ARM/ArmAsm.cpp @@ -254,7 +254,7 @@ void ArmJit::GenerateFixedCode() { crashHandler = GetCodePtr(); MOVP2R(R0, &coreState); - MOVI2R(R1, CORE_ERROR); + MOVI2R(R1, CORE_RUNTIME_ERROR); STR(R1, R0, 0); B(quitLoop); diff --git a/Core/MIPS/ARM64/Arm64Asm.cpp b/Core/MIPS/ARM64/Arm64Asm.cpp index a884f6ac4e..81f67fa3a3 100644 --- a/Core/MIPS/ARM64/Arm64Asm.cpp +++ b/Core/MIPS/ARM64/Arm64Asm.cpp @@ -289,7 +289,7 @@ void Arm64Jit::GenerateFixedCode(const JitOptions &jo) { crashHandler = GetCodePtr(); MOVP2R(SCRATCH1_64, &coreState); - MOVI2R(SCRATCH2, CORE_ERROR); + MOVI2R(SCRATCH2, CORE_RUNTIME_ERROR); STR(INDEX_UNSIGNED, SCRATCH2, SCRATCH1_64, 0); B(quitLoop); diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 9e8968fd8c..34d2b5f76d 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -542,6 +542,8 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) { } else { type = MemoryExceptionType::READ_WORD; } + } else { + type = MemoryExceptionType::UNKNOWN; } if (success && g_Config.bIgnoreBadMemAccess) { diff --git a/Core/Util/DisArm64.cpp b/Core/Util/DisArm64.cpp index c891b5eb05..e6c983be55 100644 --- a/Core/Util/DisArm64.cpp +++ b/Core/Util/DisArm64.cpp @@ -265,17 +265,15 @@ static void BranchExceptionAndSystem(uint32_t w, uint64_t addr, Instruction *ins } } -void Arm64AnalyzeLoadStore(uint64_t addr, uint32_t w, Arm64LSInstructionInfo *info) { +bool Arm64AnalyzeLoadStore(uint64_t addr, uint32_t w, Arm64LSInstructionInfo *info) { *info = {}; info->instructionSize = 4; int id = (w >> 25) & 0xF; switch (id) { case 4: case 6: case 0xC: case 0xE: - info->isLoadOrStore = true; break; default: - ERROR_LOG(CPU, "Tried to disassemble %08x at %p as a load/store instruction", w, (void *)addr); - return; // not the expected instruction + return false; // not the expected instruction } info->size = w >> 30; @@ -298,6 +296,7 @@ void Arm64AnalyzeLoadStore(uint64_t addr, uint32_t w, Arm64LSInstructionInfo *in info->isPairLoadStore = true; // TODO } + return true; } static void LoadStore(uint32_t w, uint64_t addr, Instruction *instr) { diff --git a/Core/Util/DisArm64.h b/Core/Util/DisArm64.h index 73b22db4bd..ced77f2cc2 100644 --- a/Core/Util/DisArm64.h +++ b/Core/Util/DisArm64.h @@ -18,7 +18,7 @@ // Basic ARM64 disassembler. // No promises of accuracy, mostly just made to debug JIT code. -#include +#include typedef bool (*SymbolCallback)(char *buffer, int bufsize, uint8_t *address); @@ -28,8 +28,6 @@ void Arm64Dis(uint64_t addr, uint32_t w, char *output, int bufsize, bool include struct Arm64LSInstructionInfo { int instructionSize; - bool isLoadOrStore; - bool isIntegerLoadStore; bool isFPLoadStore; bool isPairLoadStore; @@ -44,4 +42,4 @@ struct Arm64LSInstructionInfo { // TODO: more. }; -void Arm64AnalyzeLoadStore(uint64_t addr, uint32_t op, Arm64LSInstructionInfo *info); +bool Arm64AnalyzeLoadStore(uint64_t addr, uint32_t op, Arm64LSInstructionInfo *info); diff --git a/ext/disarm.cpp b/ext/disarm.cpp index c3d0662f3f..ece10410f4 100644 --- a/ext/disarm.cpp +++ b/ext/disarm.cpp @@ -760,11 +760,13 @@ static bool DisasmNeon(uint32_t op, char *text) { return false; } -void ArmAnalyzeLoadStore(uint32_t addr, uint32_t op, ArmLSInstructionInfo *info) { +bool ArmAnalyzeLoadStore(uint32_t addr, uint32_t op, ArmLSInstructionInfo *info) { *info = {}; info->instructionSize = 4; // TODO + + return false; } diff --git a/ext/disarm.h b/ext/disarm.h index 138f3e3e69..901e74cd4f 100644 --- a/ext/disarm.h +++ b/ext/disarm.h @@ -47,4 +47,4 @@ struct ArmLSInstructionInfo { // TODO: more. }; -void ArmAnalyzeLoadStore(uint32_t addr, uint32_t op, ArmLSInstructionInfo *info); +bool ArmAnalyzeLoadStore(uint32_t addr, uint32_t op, ArmLSInstructionInfo *info);