Skip to content

Commit

Permalink
Add EFAULT checks to spu_thread_group_join, ppu_thread_join
Browse files Browse the repository at this point in the history
Order of checks is based on firmware
  • Loading branch information
elad335 authored and Nekotekina committed Feb 9, 2019
1 parent 0861226 commit 84d42ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellSpurs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ void _spurs::handler_entry(ppu_thread& ppu, vm::ptr<CellSpurs> 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<u32>{}, vm::var<u32>{}))
{
if (rc == CELL_ESTAT)
{
Expand Down
18 changes: 10 additions & 8 deletions rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,21 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr<u64> 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<named_thread<ppu_thread>>(thread->id);

if (!vptr)
{
return CELL_EFAULT;
}

// Get the exit status from the register
*vptr = thread->gpr[3];
return CELL_OK;
}

Expand Down
11 changes: 7 additions & 4 deletions rpcs3/Emu/Cell/lv2/sys_spu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,19 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr<u32> cause
return 0;
}

if (cause)
if (!cause)
{
*cause = static_cast<u32>(ppu.gpr[4]);
return CELL_EFAULT;
}

if (status)
*cause = static_cast<u32>(ppu.gpr[4]);

if (!status)
{
*status = static_cast<s32>(ppu.gpr[5]);
return CELL_EFAULT;
}

*status = static_cast<s32>(ppu.gpr[5]);
return CELL_OK;
}

Expand Down

0 comments on commit 84d42ec

Please sign in to comment.