libkernel: sysctl throws for kern.proc.pathname, machdep.cacheline_size and hw.physmem (XPSemu, PS5MC); fix branch ready #3722

Closed
opened 2026-10-11 15:59:59 +00:00 by screamm · 0 comments
screamm commented 2026-10-11 15:59:59 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T15:59:59Z.


libkernel's sysctl/sysctlbyname answer only hw.ncpu and kern.rng_pseudo and throw for every other name. XPSemu (PPSA97358) calls sysctlbyname("machdep.cacheline_size") from a constructor before main and sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}) in qemu_init; PS5MC (PPSA99420) also queries sysctl. Both tolerate a failure but need a return rather than the throw (predicted lines: what(): sysctlbyname_nid_postfix: unsupported name machdep.cacheline_size).

Fix branch ready: screamm:feat/libkernel-sysctl-names (fd017757, one commit on main a11c8f7f). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. It touches the end of sysctlbyname like the open #2902 (kern.sdk_version) does; the resolution is to keep both blocks before the final throw.

  • kern.proc.pathname (MIB {1,14,12,pid}): /app0/eboot.bin for pid -1 and the caller's own pid, ESRCH for any other pid, EINVAL for a MIB without exactly one pid argument or for the by-name form, following FreeBSD 11.4 sys/kern/kern_proc.c sysctl_kern_proc_pathname (8c639945); the path is relative to the process root as vn_fullpath builds it, which for a title is its sandbox (ps5-payload-dev samples/list_files), consistent with __progname and the /app0 mount model. Console confirmation of the exact string is recorded as open.
  • machdep.cacheline_size: ENOENT, because no FreeBSD amd64/x86 code defines that name (it exists only under sys/powerpc); XPSemu then keeps its own fallback.
  • hw.physmem (name and MIB {6,5}): the same physical memory sysconf(_SC_PHYS_PAGES) already reports, so the two stay consistent (FreeBSD derives both from physmem, kern_mib.c).
  • Buffer protocol as sysctl_root: size query for a null oldp, truncated copy with ENOMEM for a short buffer, EPERM for newp on these read-only names before the handler runs. Unknown names still throw, as before.
  • guest_system_configuration covers each name over the size query, exact copy, short buffer, ESRCH, EPERM, the EINVAL cases and the untouched caller buffer for ENOENT.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_system_configuration 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" ran under heavy host load (six other builds): the failures beyond the known windows_exceptions (#3411, fixed by #3415), guest_kernel_sys (#3510), guest_filesystem (#3518) and the guest_ampr_markers flake (#3371) were timeouts of guest_sce_net, guest_pthread_start and guest_pthread_rwlock, which pass when rerun serially. With main's SystemConfiguration.cpp the extended test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5802704336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3722). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T15:59:59Z. --- libkernel's `sysctl`/`sysctlbyname` answer only `hw.ncpu` and `kern.rng_pseudo` and throw for every other name. XPSemu (PPSA97358) calls `sysctlbyname("machdep.cacheline_size")` from a constructor before `main` and `sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1})` in `qemu_init`; PS5MC (PPSA99420) also queries `sysctl`. Both tolerate a failure but need a return rather than the throw (predicted lines: `what(): sysctlbyname_nid_postfix: unsupported name machdep.cacheline_size`). **Fix branch ready:** [`screamm:feat/libkernel-sysctl-names`](https://github.com/screamm/AnyPS5/tree/feat/libkernel-sysctl-names) (`fd017757`, one commit on `main` `a11c8f7f`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. It touches the end of `sysctlbyname` like the open #2902 (`kern.sdk_version`) does; the resolution is to keep both blocks before the final throw. - `kern.proc.pathname` (MIB `{1,14,12,pid}`): `/app0/eboot.bin` for pid -1 and the caller's own pid, `ESRCH` for any other pid, `EINVAL` for a MIB without exactly one pid argument or for the by-name form, following FreeBSD 11.4 `sys/kern/kern_proc.c` `sysctl_kern_proc_pathname` (`8c639945`); the path is relative to the process root as `vn_fullpath` builds it, which for a title is its sandbox (ps5-payload-dev `samples/list_files`), consistent with `__progname` and the `/app0` mount model. Console confirmation of the exact string is recorded as open. - `machdep.cacheline_size`: `ENOENT`, because no FreeBSD amd64/x86 code defines that name (it exists only under `sys/powerpc`); XPSemu then keeps its own fallback. - `hw.physmem` (name and MIB `{6,5}`): the same physical memory `sysconf(_SC_PHYS_PAGES)` already reports, so the two stay consistent (FreeBSD derives both from `physmem`, `kern_mib.c`). - Buffer protocol as `sysctl_root`: size query for a null `oldp`, truncated copy with `ENOMEM` for a short buffer, `EPERM` for `newp` on these read-only names before the handler runs. Unknown names still throw, as before. - `guest_system_configuration` covers each name over the size query, exact copy, short buffer, `ESRCH`, `EPERM`, the `EINVAL` cases and the untouched caller buffer for `ENOENT`. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_system_configuration` 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` ran under heavy host load (six other builds): the failures beyond the known `windows_exceptions` (#3411, fixed by #3415), `guest_kernel_sys` (#3510), `guest_filesystem` (#3518) and the `guest_ampr_markers` flake (#3371) were timeouts of `guest_sce_net`, `guest_pthread_start` and `guest_pthread_rwlock`, which pass when rerun serially. With `main`'s `SystemConfiguration.cpp` the extended test fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
Sign in to join this conversation.
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#3722
No description provided.