diff --git a/src/core/arm/nce/interpreter_visitor.cpp b/src/core/arm/nce/interpreter_visitor.cpp index be6fee8613..b5f89510ca 100644 --- a/src/core/arm/nce/interpreter_visitor.cpp +++ b/src/core/arm/nce/interpreter_visitor.cpp @@ -765,8 +765,8 @@ std::optional MatchAndExecuteOneInstruction(Core::Memory::Memory& memory, m fpsimd_context* fpsimd_context) { std::span regs(reinterpret_cast(context->regs), 31); std::span vregs(reinterpret_cast(fpsimd_context->vregs), 32); - u64& sp = *reinterpret_cast(&context->sp); - const u64& pc = *reinterpret_cast(&context->pc); + u64 sp = context->sp; + const u64 pc = context->pc; InterpreterVisitor visitor(memory, regs, vregs, sp, pc); u32 instruction = memory.Read32(pc); @@ -774,6 +774,7 @@ std::optional MatchAndExecuteOneInstruction(Core::Memory::Memory& memory, m auto decoder = Dynarmic::A64::Decode(instruction); was_executed = decoder.get().call(visitor, instruction); + context->sp = sp; return was_executed ? std::optional(pc + 4) : std::nullopt; } diff --git a/src/core/arm/nce/patcher.cpp b/src/core/arm/nce/patcher.cpp index b72e0f4e51..d4c0023ed5 100644 --- a/src/core/arm/nce/patcher.cpp +++ b/src/core/arm/nce/patcher.cpp @@ -26,6 +26,8 @@ using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters; constexpr size_t MaxRelativeBranch = 128_MiB; constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32); +namespace { + [[nodiscard]] std::optional DecodeCacheOperation(u32 inst) { switch (inst & ~u32{0x1F}) { case 0xD5087620: @@ -42,6 +44,8 @@ constexpr u32 ModuleCodeIndex = 0x24 / sizeof(u32); } } +} // namespace + Patcher::Patcher() : c(m_patch_instructions), c_pre(m_patch_instructions_pre) { // The first word of the patch section is always a branch to the first instruction of the // module.