feat(libkernel): implement sceKernelIsStack #702
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/702"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-05T17:10:31Z.
What
sceKernelIsStack(addr, start, end)threwnot implemented.Thread.cppkeeps the stack range of every running guest thread: registered inRunThread(the guest range on Windows, the host range on Linux, wherestackAddressis not set) and removed infinishThread.GuestThreadStackanswers from the calling thread's stack first (its guest range, or the host limits for an adopted thread such as the main thread), then from the registry.sceKernelIsStack: an address in a stack returns its bounds; a mapped address outside every stack succeeds with null bounds; an addresssceKernelVirtualQueryrejects returnsSCE_KERNEL_ERROR_EACCES. Nullstart/endare allowed. The non-stack and unmapped results follow shadPS4'sMemoryManager::IsStack.guest_kernel_is_stack: main thread stack, a running worker's stack queried from the worker and from the main thread (disjoint from the main stack), a global, null outputs, a mapped and then unmapped flexible page.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Ryzen 7 9800X3D, Radeon RX 9070 XT.
ctest: 288/290 passed, includingguest_kernel_is_stack.agc_driver_lds_atomics64andagc_driver_vopc_compare_tablefail on this machine onmainas well (Vulkan device tests).sceKernelIsStackafter readingRuntimeInitializeOnLoads.json, then continues toScriptingAssemblies.jsonand VideoOut setup.Not tested on Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:34:22Z.
Thanks for this. It needs a rebase now that #761 has landed. Both change the same part of
core/libs/prx/libkernel/Pthread/src/Thread.cpp: #761 addedSetStackFromHost(), which queries the host stack withGetCurrentThreadStackLimits/pthread_getattr_np, and this PR addsNativeStackLimits(), which does the same query. Rather than keeping two copies,sceKernelIsStackcould build on #761's query (or both could share one helper) when you resolve it.Imported from boykopovar/AnyPS5. Originally posted by merwie on 2026-10-06T07:58:33Z.
Merged
main(no rebase, to keep the review history).NativeStackLimitsand #761's query are now one helper,HostStackLimits:SetStackFromHostthrows when it fails, andsceKernelIsStackuses it only for a host thread that has noPthreadPrivateyet. Non-GPU tests pass.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T07:58:54Z.
Progress report (
481c85e→17332ed)📈 System libraries: 82.34% (+0.03%, +1 implemented functions)
✅ 1 implemented
sceKernelIsStack