From 0bb84b374e59ec212a3c66be73e41702298a4692 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:28:11 +0200 Subject: [PATCH] sys_ppu_thread: Fix u64 stack size argument --- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 7 ++++--- rpcs3/Emu/Cell/lv2/sys_ppu_thread.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 1aa9409f46..250cd99431 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -468,11 +468,11 @@ error_code sys_ppu_thread_restart(ppu_thread& ppu) return CELL_OK; } -error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 unk, s32 prio, u32 _stacksz, u64 flags, vm::cptr threadname) +error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 unk, s32 prio, u64 _stacksz, u64 flags, vm::cptr threadname) { ppu.state += cpu_flag::wait; - sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=*0x%x)", + sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%llx, flags=0x%llx, threadname=*0x%x)", thread_id, param, arg, unk, prio, _stacksz, flags, threadname); // thread_id is checked for null in stub -> CELL_ENOMEM @@ -497,7 +497,8 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::p const u32 tls = param->tls; // Compute actual stack size and allocate - const u32 stack_size = utils::align(std::max(_stacksz, 4096), 4096); + // 0 and UINT64_MAX both convert to 4096 + const u64 stack_size = FN(x ? x : 4096)(utils::align(_stacksz, 4096)); auto& dct = g_fxo->get(); diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h index 81598288ea..2e3f8c524e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.h @@ -53,7 +53,7 @@ error_code sys_ppu_thread_get_priority(ppu_thread& ppu, u32 thread_id, vm::ptr sp); error_code sys_ppu_thread_stop(ppu_thread& ppu, u32 thread_id); error_code sys_ppu_thread_restart(ppu_thread& ppu); -error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 arg4, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname); +error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr thread_id, vm::ptr param, u64 arg, u64 arg4, s32 prio, u64 stacksize, u64 flags, vm::cptr threadname); error_code sys_ppu_thread_start(ppu_thread& ppu, u32 thread_id); error_code sys_ppu_thread_rename(ppu_thread& ppu, u32 thread_id, vm::cptr name); error_code sys_ppu_thread_recover_page_fault(ppu_thread& ppu, u32 thread_id);