feat(libkernel): add mlockall export #4386
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4386"
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 MarcZX10 on 2026-10-12T08:33:45Z.
What
Adds the
mlockallexport as a single focused change. Zero and unknown flags returnEINVAL; validMCL_CURRENTandMCL_FUTURErequests throw because safely locking guest memory would require excluding host stacks, heaps, modules and driver mappings, and tracking later mappings.On main
7e181fcc, XPSemu (PPSA97358, catalog release) stops loading at unresolved importx7g7Ebeo8-U(mlockall). The reported call sites requestMCL_CURRENT | MCL_FUTURE, and run only with-overcommit mem-lock=on; the title's default is off. This supplies the missing export. It does not claim a successful title run with mem-lock enabled, where valid calls remain unsupported.Tested
guest_getrlimit/guest_mlockpassing 2/2 on earlier head61b12b9e1.git diff --check upstream/main...HEADpassed. No build or runtime tests were run after the latest rebase ontomainfc1f063f5.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-12T08:43:37Z.
Title evidence for the
getdtablesizehalf (#3650 was closed because "no title gets further with this"). VLC (PPSA85300) does get further with a throwinggetdtablesize, because it never calls it:maine013f8c9plus areaddir_r(#3635 doesn't merge ontomainright now, so I used screamm's branch from #3556), VLC stops atFAIL: unresolved ELF import sZuwaDPATKs from libkernel.prx(getdtablesize). Windows 11, catalog build.0x16FA11D) is aclosefrom-style loop:n = getdtablesize(); for (fd = max(low, 0); fd < n; ++fd) close(fd);. It is called once, withlow = 3, from a spawn helper's child path (0x16f6380..0x16f6520):pipe/dup, thendup2(in, 0),dup2(out, 1),closefrom(3),execvp,_exit.0x141ee3ca0, which sets errno 78 (ENOSYS) and returns -1. That'sxemu_ps5_forkin libc_missing.c, the same reason the mergedexecvpTechnicalDebt entry gives.getdtablesizeadded, VLC's next stop isYKT49TOLQWs(sceKernelJitMapSharedMemory, #3787).XPSemu (PPSA97358) also imports it, from a different call site (
0x3603DD, afterpipeand fourfcntlcalls). I haven't traced whether that one is reachable.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T09:02:50Z.
Progress report (
fc1f063→a7ea2bd)➖ System libraries: 87.83% (+0.0%, +1 implemented functions)
✅ 1 implemented
mlockall_nid_postfixImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T11:22:25Z.
Windows test: head
61b12b9e1merged onto currentmain5a031d49e(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j4: full build 0 errors; ctest (guest_getrlimit, guest_mlock): 2/2 passed;python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T14:02:08Z.
Rebase handoff — rebased onto current
main, authorship unchanged (both commits).Conflicts resolved:
TechnicalDebt.md: union, both entries kept (both commits).GuestGetrlimit.cpp: main had expanded the unsupported-resources loop while this PR added its checks. The merge keeps main's loop plus this PR'sRequireTableSizeUnsupported(); the PR'sRequireUnsupported(GUEST_RLIMIT_AS)was dropped because main has since madeRLIMIT_ASa supported resource (it is now in the supported loop), so that expectation no longer holds against currentmain.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesTo pick it up:
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:58:03Z.
Please drop the
mlockallcommit and rebase (docs/dev/debt/libkernel.mdconflicts): no title stops atmlockall.getdtablesizecan go in after #3635, since PPSA85300 stops atsZuwaDPATKsoncereaddir_ris in.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-13T06:28:04Z.
A title that stops at
mlockallonmain: XPSemu (PPSA97358, catalog release). Onmain7e181fcc, both Linux and Windows 11 stop it at the unresolved importx7g7Ebeo8-U(mlockall) fromlibkernel.prx. This PR's throwing behaviour for valid flags would be enough for it. XPSemu is QEMU, and its two calls are QEMU's mem-lock path:mlockall(MCL_CURRENT | MCL_FUTURE)at guest 0xD2033B and inos_mlockat 0xF504B4. Both run only with-overcommit mem-lock=on, and its help text says the default is off.It isn't the last import it needs.
import_audit.pyonmainea2bbefbalso listsgetdtablesize(this PR),pthread_atfork(#4377),execveand theposix_spawnfamily (#3651), all absent.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:12:00Z.
Thanks for raising the scope and rebase issues. The new XPSemu report in this thread changes the mlockall part: on main, XPSemu fails to load at the unresolved mlockall import, and the reported call sites use valid MCL_CURRENT | MCL_FUTURE flags. That makes the throwing implementation relevant to a real import stop, although the call is exercised only with -overcommit mem-lock=on. getdtablesize still has no demonstrated runtime call, so I agree it should not be bundled without title evidence. The PR head remains conflicted; I have not yet updated it.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:47:43Z.
The new XPSemu evidence resolves the earlier “no title stops at mlockall” concern: PPSA97358 on main
7e181fccstops at unresolved importx7g7Ebeo8-U, with its validMCL_CURRENT | MCL_FUTUREcalls gated behind-overcommit mem-lock=on.I narrowed this PR to
mlockallonly, droppedgetdtablesize, rebased onto current maina24da902, retained the current debt entries, and updated the title and description. The evidence shows an import stop, not a successful patched title run; with mem-lock enabled, valid calls still throw because full locking is unsupported. Prior build results are labeled as pre-rebase, and no tests were run on the new head. The rebased diff passesgit diff --check.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:51:50Z.
Follow-up: main advanced again while I was resolving this thread. The single-
mlockallbranch is now rebased onfc1f063f5; the debt entry and scope are unchanged. The description identifies all runtime results as pre-rebase.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-13T09:20:14Z.
Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs): head80b04706merged ontomain5f426f94(one textual conflict indocs/dev/debt/libkernel.mdwith the newsceKernelGetPageTableStatsbullet, both kept). Code and tests are identical to myfeat/libkernel-xpsemu-processcommits; only the debt bullets moved.guest_mlockandguest_getrlimit3/3;ctest -j8 -E "^agc_driver_|^video_out_flip"684/686 plus one skip, the only failure beingpatched_libraries, which fails onmainitself since #4877 (libkernel_sys.prximportsrename_nid_postfixthat the patched libkernel does not export; fix in #5025); conventions andgit diff --checkpass.XPSemu (PPSA97358) relinked against this build: on
mainit stops atFAIL: unresolved ELF import x7g7Ebeo8-U from libkernel.prx(mlockall); with this PR it moves on toFAIL: unresolved ELF import U9t5kJAWPnA from libkernel.prx(pthread_atfork, #4377). Somlockallis the title's current stop onmain, which supports keeping it in this PR as babyhuey reported; the valid-flag throw is not reached because XPSemu only callsmlockallwith-overcommit mem-lock=on.