From 84d42ecb655ef7ed302e7522db29050b613d30e5 Mon Sep 17 00:00:00 2001 From: eladash Date: Sat, 9 Feb 2019 18:58:54 +0200 Subject: [PATCH] Add EFAULT checks to spu_thread_group_join, ppu_thread_join Order of checks is based on firmware --- rpcs3/Emu/Cell/Modules/cellSpurs.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 18 ++++++++++-------- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 11 +++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index a7245ec9090d..3d13726aa450 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -574,7 +574,7 @@ void _spurs::handler_entry(ppu_thread& ppu, vm::ptr spurs) CHECK_SUCCESS(sys_spu_thread_group_start(ppu, spurs->spuTG)); - if (s32 rc = sys_spu_thread_group_join(ppu, spurs->spuTG, vm::null, vm::null)) + if (s32 rc = sys_spu_thread_group_join(ppu, spurs->spuTG, vm::var{}, vm::var{})) { if (rc == CELL_ESTAT) { diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index da1fbcba4439..fadc02d7cbd1 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -120,19 +120,21 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr vptr // Wait for cleanup (*thread.ptr)(); - // Get the exit status from the register - if (vptr) + if (ppu.test_stopped()) { - if (ppu.test_stopped()) - { - return 0; - } - - *vptr = thread->gpr[3]; + return 0; } // Cleanup idm::remove>(thread->id); + + if (!vptr) + { + return CELL_EFAULT; + } + + // Get the exit status from the register + *vptr = thread->gpr[3]; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index d1361437be5f..ada4b421ee6e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -683,16 +683,19 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr cause return 0; } - if (cause) + if (!cause) { - *cause = static_cast(ppu.gpr[4]); + return CELL_EFAULT; } - if (status) + *cause = static_cast(ppu.gpr[4]); + + if (!status) { - *status = static_cast(ppu.gpr[5]); + return CELL_EFAULT; } + *status = static_cast(ppu.gpr[5]); return CELL_OK; }