feat(libkernel): export cpuset_getid, rfork_thread and sceKernelRdup #16270

Merged
NevesHenry merged 2 commits from upstream-pr/16270 into main 2026-11-07 02:54:54 +00:00
NevesHenry commented 2026-11-06 02:32:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NevesHenry on 2026-11-06T02:32:11Z.


What

ProsperoWeb (PRWB00001) 0.2.1, a web browser in the homebrew catalog, imports cpuset_getid (DGY7qWLcHGA), rfork_thread (bSDxEpGzmUE) and sceKernelRdup (LxIacrWiJ3w) from libkernel. On main only libkernel_sys exports them, and nothing this title loads on Linux needs libkernel_sys.prx, so the dynamic loader stops before the entry point:

./PRWB00001: symbol lookup error: ./PRWB00001: undefined symbol: LxIacrWiJ3w

tools/audit_dump.py lists these three as the title's only imports that another library exports, which "resolve on Linux"; that holds only when something else loads libkernel_sys.prx. On Windows the kernel-family search from #12430 should find them. I didn't run it there. No other catalog title imports any of the three, or cpuset and cpuset_setid, from libkernel_sys (import audit of 139 catalog packages).

Change:

  • Cpuset.cpp moves from libkernel_sys to libkernel/System/src unchanged except for its include. cpuset and cpuset_setid move with cpuset_getid because the three share its set table. Their declarations move to libkernel's Api.hpp, guest_kernel_sys_cpuset now links libkernel and libc only, and their debt entry moves to docs/dev/debt/libkernel.md.
  • rfork_thread and sceKernelRdup move to libkernel/Unimplemented.cpp with the prototypes the title uses, FreeBSD's rfork_thread(int flags, void *stack, int (*func)(void *), void *arg) and int sceKernelRdup(int pid, int fd), and still throw. The title calls sceKernelRdup only when dup is refused with EPERM and dup2 onto a reserved number fails (native_trace.c#L157-L188), and rfork_thread only from a fork probe that is off by default (native_fork_probe.c#L1-L40). Neither is reached in the run below. A debt entry records this. #12826 did the same for MihawkOS's sceKernelProtectDirectMemoryForPID.
  • New test guest_kernel_process_exports: it loads libkernel.prx from the unpatched and the patched library directories, resolves the five exports by name and by NID, and calls cpuset_getid through the resolved pointer (root set 0, process set 1).

Tested

Linux: Ubuntu 24.04 container on WSL2, Ryzen 9 7900, GCC 13.3, Release, llvmpipe (the only Vulkan device here).

Title: ProsperoWeb 0.2.1, PRWB00001.zip from kvaps/ProsperoWeb, SHA-256 687652cbc05c01db60410c357bc4322f05170de4829ace174d1d5628ba63b0b0, the same as in the homebrew catalog. I converted it with the relinker's default flags (as tools/title_run.py does) and ran it for 40 s under Xvfb in a container with no network, without input, 3 runs each. The main column uses libkernel.prx and libkernel_sys.prx built from main's sources and the same converted executable.

main c36ab99c74 This PR
Stop undefined symbol: LxIacrWiJ3w, exit 127, before the entry point (3/3) what(): sysctl_nid_postfix: unsupported MIB 1.14.17.14, exit 134, about 6 s in (3/3)
Title log nothing its file and socket self-tests, then cpu: ... cpuset 0-12 (0x1fff), root set, set for the process | probe 8:ok and main: starting the UI

The new stop is kern.proc with KERN_PROC_PID \| KERN_PROC_INC_THREAD (17) for its own pid. No open PR handles it.

  • ctest -R "guest_kernel_process_exports|guest_kernel_sys_cpuset|available_cpumask|sched_priority": 5/5 pass. With core/libs/prx from main and the test kept, both new tests fail: libkernel.prx does not export cpuset_getid_nid_postfix (and the other four names), libkernel.prx does not export DGY7qWLcHGA (and the other four NIDs).
  • ctest -R "kernel|resident|direct_memory|public_headers|progress_|conventions_|patched_libraries|tools_headers|nid_|cpuset|process_exports" -E "^agc_": 203/203 pass.
  • With #16243 merged on top, guest_kernel_process_exports, guest_kernel_resident_fmem_export, both _patched variants, guest_kernel_sys_cpuset and guest_kernel_sys pass (6/6). #16243 merges into main plus this branch, and this branch into main plus #16243, with no conflict, and both orders give the same tree.
  • tools/progress.py --module: libkernel 705 of 763 (from 703 of 758) and libkernel_sys 158 of 821 (from 160 of 826); the five exports moved.
  • tools/check_conventions.py passes, with one warning: the moved cpuset debt entry is 1,247 characters, as it already was in libkernel_sys.md; I moved it without rewording it.
  • 2026-11-07: merged main cdf371df68 into the branch as c3747080fa. The only conflict was in docs/dev/debt/libkernel_sys.md, where #15035 rewrote the sceKernelSettimeofday entry next to the moved cpuset entry; I kept main's line. Full Linux build (GCC 13, Release): the 5 tests above pass, the regex above now runs 206/206, and guest_kernel|libkernel 49/49. check_conventions.py gives the same single warning.
  • Windows and macOS: not built.
  • Overlap: no open PR mentions these functions, their NIDs or the title. tools/pr_overlap.py needs git 2.38 and this host has 2.34, so I merged the heads of the 197 open PRs that change these files into this branch and into main one by one: all merge or conflict the same way with both, except #16215, which edits the libkernel_sys.md line just above the moved cpuset entry and needs a one-line rebase. #15973 changes one line of Cpuset.cpp that is already on main and merges cleanly across the move.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PRWB00001 #16268
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

AI disclosure: this change and description were written with Claude Code.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5181940396 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16270). Originally posted by [NevesHenry](https://github.com/NevesHenry) on 2026-11-06T02:32:11Z. --- ### What ProsperoWeb (PRWB00001) 0.2.1, a web browser in the homebrew catalog, imports `cpuset_getid` (`DGY7qWLcHGA`), `rfork_thread` (`bSDxEpGzmUE`) and `sceKernelRdup` (`LxIacrWiJ3w`) from `libkernel`. On `main` only `libkernel_sys` exports them, and nothing this title loads on Linux needs `libkernel_sys.prx`, so the dynamic loader stops before the entry point: ``` ./PRWB00001: symbol lookup error: ./PRWB00001: undefined symbol: LxIacrWiJ3w ``` `tools/audit_dump.py` lists these three as the title's only imports that another library exports, which "resolve on Linux"; that holds only when something else loads `libkernel_sys.prx`. On Windows the kernel-family search from #12430 should find them. I didn't run it there. No other catalog title imports any of the three, or `cpuset` and `cpuset_setid`, from `libkernel_sys` (import audit of 139 catalog packages). Change: - `Cpuset.cpp` moves from `libkernel_sys` to `libkernel/System/src` unchanged except for its include. `cpuset` and `cpuset_setid` move with `cpuset_getid` because the three share its set table. Their declarations move to `libkernel`'s `Api.hpp`, `guest_kernel_sys_cpuset` now links `libkernel` and `libc` only, and their debt entry moves to `docs/dev/debt/libkernel.md`. - `rfork_thread` and `sceKernelRdup` move to `libkernel/Unimplemented.cpp` with the prototypes the title uses, FreeBSD's `rfork_thread(int flags, void *stack, int (*func)(void *), void *arg)` and `int sceKernelRdup(int pid, int fd)`, and still throw. The title calls `sceKernelRdup` only when `dup` is refused with `EPERM` and `dup2` onto a reserved number fails ([`native_trace.c#L157-L188`](https://github.com/kvaps/ProsperoWeb/blob/8cfe29c3cbd763c8c832f414f902b68b7d9a09bb/src/frontend/ps5/native/native_trace.c#L157-L188)), and `rfork_thread` only from a fork probe that is off by default ([`native_fork_probe.c#L1-L40`](https://github.com/kvaps/ProsperoWeb/blob/8cfe29c3cbd763c8c832f414f902b68b7d9a09bb/src/frontend/ps5/native/native_fork_probe.c#L1-L40)). Neither is reached in the run below. A debt entry records this. #12826 did the same for MihawkOS's `sceKernelProtectDirectMemoryForPID`. - New test `guest_kernel_process_exports`: it loads `libkernel.prx` from the unpatched and the patched library directories, resolves the five exports by name and by NID, and calls `cpuset_getid` through the resolved pointer (root set 0, process set 1). ### Tested Linux: Ubuntu 24.04 container on WSL2, Ryzen 9 7900, GCC 13.3, Release, llvmpipe (the only Vulkan device here). Title: ProsperoWeb 0.2.1, `PRWB00001.zip` from [kvaps/ProsperoWeb](https://github.com/kvaps/ProsperoWeb/releases/tag/v0.2.1), SHA-256 `687652cbc05c01db60410c357bc4322f05170de4829ace174d1d5628ba63b0b0`, the same as in the homebrew catalog. I converted it with the relinker's default flags (as `tools/title_run.py` does) and ran it for 40 s under Xvfb in a container with no network, without input, 3 runs each. The `main` column uses `libkernel.prx` and `libkernel_sys.prx` built from `main`'s sources and the same converted executable. | | `main` c36ab99c74 | This PR | |---|---|---| | Stop | `undefined symbol: LxIacrWiJ3w`, exit 127, before the entry point (3/3) | `what(): sysctl_nid_postfix: unsupported MIB 1.14.17.14`, exit 134, about 6 s in (3/3) | | Title log | nothing | its file and socket self-tests, then `cpu: ... cpuset 0-12 (0x1fff), root set, set for the process \| probe 8:ok` and `main: starting the UI` | The new stop is `kern.proc` with `KERN_PROC_PID \| KERN_PROC_INC_THREAD` (17) for its own pid. No open PR handles it. - `ctest -R "guest_kernel_process_exports|guest_kernel_sys_cpuset|available_cpumask|sched_priority"`: 5/5 pass. With `core/libs/prx` from `main` and the test kept, both new tests fail: `libkernel.prx does not export cpuset_getid_nid_postfix` (and the other four names), `libkernel.prx does not export DGY7qWLcHGA` (and the other four NIDs). - `ctest -R "kernel|resident|direct_memory|public_headers|progress_|conventions_|patched_libraries|tools_headers|nid_|cpuset|process_exports" -E "^agc_"`: 203/203 pass. - With #16243 merged on top, `guest_kernel_process_exports`, `guest_kernel_resident_fmem_export`, both `_patched` variants, `guest_kernel_sys_cpuset` and `guest_kernel_sys` pass (6/6). #16243 merges into `main` plus this branch, and this branch into `main` plus #16243, with no conflict, and both orders give the same tree. - `tools/progress.py --module`: `libkernel` 705 of 763 (from 703 of 758) and `libkernel_sys` 158 of 821 (from 160 of 826); the five exports moved. - `tools/check_conventions.py` passes, with one warning: the moved cpuset debt entry is 1,247 characters, as it already was in `libkernel_sys.md`; I moved it without rewording it. - 2026-11-07: merged `main` cdf371df68 into the branch as c3747080fa. The only conflict was in `docs/dev/debt/libkernel_sys.md`, where #15035 rewrote the `sceKernelSettimeofday` entry next to the moved cpuset entry; I kept `main`'s line. Full Linux build (GCC 13, Release): the 5 tests above pass, the regex above now runs 206/206, and `guest_kernel|libkernel` 49/49. `check_conventions.py` gives the same single warning. - Windows and macOS: not built. - Overlap: no open PR mentions these functions, their NIDs or the title. `tools/pr_overlap.py` needs git 2.38 and this host has 2.34, so I merged the heads of the 197 open PRs that change these files into this branch and into `main` one by one: all merge or conflict the same way with both, except #16215, which edits the `libkernel_sys.md` line just above the moved cpuset entry and needs a one-line rebase. #15973 changes one line of `Cpuset.cpp` that is already on `main` and merges cleanly across the move. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PRWB00001 #16268 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) AI disclosure: this change and description were written with Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16270
No description provided.