From 492c9e3c7c778ce88995c54d13efbfca1832baed Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 21 Jul 2019 01:26:49 +0400 Subject: [PATCH] Fix sys_rsx_context_iounmap partial unmapping --- rpcs3/Emu/Cell/lv2/sys_rsx.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index 3002200909..e70e338870 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -219,10 +219,11 @@ error_code sys_rsx_context_iounmap(u32 context_id, u32 io, u32 size) } const u32 end = (io >>= 20) + (size >>= 20); - for (u32 ea = RSXIOMem.ea[io]; io < end;) + + while (io < end) { - RSXIOMem.io[ea++].raw() = 0xFFFF; - RSXIOMem.ea[io++].raw() = 0xFFFF; + const u32 ea_entry = std::exchange(RSXIOMem.ea[io++].raw(), 0xFFFF); + if (ea_entry < 512) RSXIOMem.io[ea_entry].raw() = 0xFFFF; } std::atomic_thread_fence(std::memory_order_seq_cst);