From e0e1c729cd7c422eab55d55cc3bd79824498b31f Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:29:19 +0300 Subject: [PATCH 1/2] Fix sys_spu_thread_group_disconnect_event --- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index d9aa0c53f3..9fd5c3145c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -1919,17 +1919,15 @@ error_code sys_spu_thread_group_disconnect_event(ppu_thread& ppu, u32 id, u32 et if (!ep) { sys_spu.error("sys_spu_thread_group_disconnect_event(): unknown event type (%d)", et); - return CELL_EINVAL; + return CELL_OK; } + // No error checking is performed + std::lock_guard lock(group->mutex); - if (!lv2_obj::check(*ep)) - { - return CELL_EINVAL; - } - ep->reset(); + return CELL_OK; } From e58a3ab7e02172279d0ccc2e5a40c3ae1050d482 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:43:39 +0300 Subject: [PATCH 2/2] sys_spu: Fix order of some checks --- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 9fd5c3145c..51b6721048 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -1831,6 +1831,11 @@ error_code sys_spu_thread_write_snr(ppu_thread& ppu, u32 id, u32 number, u32 val sys_spu.trace("sys_spu_thread_write_snr(id=0x%x, number=%d, value=0x%x)", id, number, value); + if (number > 1) + { + return CELL_EINVAL; + } + const auto [thread, group] = lv2_spu_group::get_thread(id); if (!thread) [[unlikely]] @@ -1838,11 +1843,6 @@ error_code sys_spu_thread_write_snr(ppu_thread& ppu, u32 id, u32 number, u32 val return CELL_ESRCH; } - if (number > 1) - { - return CELL_EINVAL; - } - thread->push_snr(number, value); return CELL_OK; @@ -2090,6 +2090,11 @@ error_code sys_spu_thread_group_connect_event_all_threads(ppu_thread& ppu, u32 i sys_spu.warning("sys_spu_thread_group_connect_event_all_threads(id=0x%x, eq=0x%x, req=0x%llx, spup=*0x%x)", id, eq, req, spup); + if (!req) + { + return CELL_EINVAL; + } + const auto group = idm::get(id); const auto queue = idm::get(eq); @@ -2098,11 +2103,6 @@ error_code sys_spu_thread_group_connect_event_all_threads(ppu_thread& ppu, u32 i return CELL_ESRCH; } - if (!req) - { - return CELL_EINVAL; - } - std::unique_lock lock(group->mutex); if (auto state = +group->run_state; @@ -2172,6 +2172,11 @@ error_code sys_spu_thread_group_disconnect_event_all_threads(ppu_thread& ppu, u3 sys_spu.warning("sys_spu_thread_group_disconnect_event_all_threads(id=0x%x, spup=%d)", id, spup); + if (spup > 63) + { + return CELL_EINVAL; + } + const auto group = idm::get(id); if (!group) @@ -2179,11 +2184,6 @@ error_code sys_spu_thread_group_disconnect_event_all_threads(ppu_thread& ppu, u3 return CELL_ESRCH; } - if (spup > 63) - { - return CELL_EINVAL; - } - std::lock_guard lock(group->mutex); for (auto& t : group->threads)