feat(libkernel): implement sceKernelMlock #359
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/359"
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 DotDebian on 2026-10-02T13:28:10Z.
What
Implements
sceKernelMlock, which threwNotImplemented.mlock(2): the range is widened to guest page boundaries, a zero length returns 0, a range that wraps returnsSCE_KERNEL_ERROR_EINVAL, a range that is not entirely mapped and accessible returnsSCE_KERNEL_ERROR_ENOMEM.VirtualLock. The number of pages a process may lock is bounded by its minimum working set, so onERROR_WORKING_SET_QUOTAthe working set minimum and maximum are both raised by the size of the range (current limits and flags read first, not overwritten) and the lock is retried once. If the limits cannot be raised the call returnsSCE_KERNEL_ERROR_EAGAIN. Any other host failure throws.mlock. OnENOMEM,EPERMorEAGAINthe softRLIMIT_MEMLOCKis raised to the hard limit and the lock is retried once; the remaining error is returned as the matchingSCE_KERNEL_ERROR_*.Caller found: the
libc.prx(SDK 9) shipped with Astro Bot (PPSA21564) imports it (3k6kx-zOOSQ) and calls it as(address, length)on its heap right aftersceKernelMapNamedFlexibleMemoryInternal(libc.prx+0xb0e3) when one of its internal flags is set. A nonzero return takes its error path.Tested
Windows 11, Intel Core Ultra 9 285K, MinGW-w64 GCC 15.2.0.
ctest: 107 of 107 pass.CheckMlockcase inguest_memory: locks 4 MiB of flexible memory from an unaligned address (above the default 200 KiB minimum working set, so the quota path runs), checks that the working set minimum now covers it and thatVirtualUnlockfinds every page locked, locks again, then checks the zero length, the wrapping range, a reserved range (ENOMEM), unmapping a locked range, and the unmapped range (ENOMEM).VmLckin/proc/self/status.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🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T05:33:17Z.
Progress report (
8387b4d→774b349)📈 System libraries: 79.17% (+0.03%, +1 implemented functions)
✅ 1 implemented
sceKernelMlock_nid_postfixImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:43:05Z.
Thanks, the semantics look right to me (I checked here that Linux
mlockon a PROT_NONE reservation fails with ENOMEM, as your test expects). It now conflicts with main incore/libs/tests/GuestMemory.cpp; could you rebase?Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:37:55Z.
Thanks for the rebase. It conflicts with main again in
core/libs/tests/GuestMemory.cpp, this time with #347'sCheckNoOverwriteRejectsHostOccupiedMapping(the_WIN32include block and the new test function sit where yours go); keeping both sides works. With both kept,guest_memorypasses here. The only red CI job on this head is Windowsguest_audio_in_no_device(0xc0000409), the flake #532 fixed, so a rebase also clears that. After that it's ready to merge from my side.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T01:18:03Z.
Thanks for the rebase.
CheckMlocknow sits after #347's test and reuses main's_WIN32include block, the code is unchanged,guest_memorypasses here, and CI is green on both jobs. Ready to merge from my side.