diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 2c7165065a..2e7df11562 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1003,9 +1003,17 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) { g_tls_fault_all++; + const auto cpu = get_current_cpu_thread(); + if (rsx::g_access_violation_handler && rsx::g_access_violation_handler(addr, is_writing)) { g_tls_fault_rsx++; + + if (cpu) + { + cpu->test_state(); + } + return true; } @@ -1142,11 +1150,16 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) if (vm::check_addr(addr, d_size)) { + if (cpu) + { + cpu->test_state(); + } + return true; } // TODO: allow recovering from a page fault as a feature of PS3 virtual memory - if (const auto cpu = get_current_cpu_thread()) + if (cpu) { LOG_FATAL(MEMORY, "Access violation %s location 0x%x", is_writing ? "writing" : "reading", addr); cpu->state += cpu_flag::dbg_pause; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 9563723820..2124cedbe0 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -107,6 +107,14 @@ namespace vm } } + void temporary_unlock() noexcept + { + if (auto cpu = get_current_cpu_thread()) + { + temporary_unlock(*cpu); + } + } + reader_lock::reader_lock() : locked(true) { diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index bfc88c7323..ee97809a80 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -70,6 +70,7 @@ namespace vm // Optimization (set cpu_flag::memory) void temporary_unlock(cpu_thread& cpu) noexcept; + void temporary_unlock() noexcept; constexpr struct try_to_lock_t{} try_to_lock{}; diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp index 5c523bcfa4..6e338ffccc 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp @@ -51,6 +51,7 @@ namespace gl //LOG_WARNING(RSX, "Cache access not from worker thread! address = 0x%X", address); work_item &task = m_renderer->post_flush_request(address, section_to_post); + vm::temporary_unlock(); { std::unique_lock lock(task.guard_mutex); task.cv.wait(lock, [&task] { return task.processed; }); @@ -62,4 +63,4 @@ namespace gl return false; } -} \ No newline at end of file +}