feat(libkernel): implement sysKernel update version and mode queries #10671

Merged
pushkarreddyy merged 6 commits from upstream-pr/10671 into main 2026-10-26 21:31:01 +00:00
pushkarreddyy commented 2026-10-24 16:38:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-24T16:38:38Z.


What

Four sysKernel system queries (sysKernelGetUpdVersion, sysKernelGetManufacturingMode, sysKernelGetIntdevModeForInternalLibc, and sysKernelGetIntdevModeForRcmgr) were discovery stubs that threw NotImplemented in libkernel_sys. They are now implemented in libkernel, alongside sysKernelGetLowerLimitSysexVersion and sysKernelGetLowerLimitUpdVersion in core/libs/prx/libkernel/System/src/SystemConfiguration.cpp, and the libkernel_sys stubs are removed.

Following firmware 13.42 libkernel.sprx and libkernel_sys.sprx disassembly measured by BunnyFl, these wrapper functions delegate to sysctlbyname:

  • sysKernelGetUpdVersion(uint32_t* version) validates null output (returning SCE_KERNEL_ERROR_EINVAL), delegates to sysctlbyname("machdep.upd_version", ...), and returns the sysctl status.
  • sysKernelGetManufacturingMode(void) returns int from sysctlbyname("machdep.curr_manumode", ...).
  • sysKernelGetIntdevModeForInternalLibc(void) returns int from sysctlbyname("machdep.rcmgr_intdev_for_internal_libc", ...).
  • sysKernelGetIntdevModeForRcmgr(void) returns int from sysctlbyname("machdep.rcmgr_intdev", ...).

The underlying machdep sysctls (machdep.upd_version, machdep.curr_manumode, machdep.rcmgr_intdev_for_internal_libc, machdep.rcmgr_intdev) return 0 as assumed defaults chosen by AnyPS5, and reject writes with EPERM. Neither routine alters guest errno (*__error_nid_postfix()). Technical debt documentation is updated in docs/dev/debt/libkernel.md.

Tested

  • Run python tools/check_conventions.py --base origin/main (passed with 0 errors).
  • Extended CheckVersionLimits in core/libs/tests/GuestSystemConfiguration.cpp:
    • verified sysKernelGetUpdVersion writes 0 into the destination buffer and rejects null output with SCE_KERNEL_ERROR_EINVAL;
    • verified sysKernelGetManufacturingMode, sysKernelGetIntdevModeForInternalLibc, and sysKernelGetIntdevModeForRcmgr return 0;
    • verified trailing canary bytes (0xaaaaaaaau) remain untampered;
    • verified guest errno remains untouched across calls.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4997183893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10671). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-24T16:38:38Z. --- ### What Four `sysKernel` system queries (`sysKernelGetUpdVersion`, `sysKernelGetManufacturingMode`, `sysKernelGetIntdevModeForInternalLibc`, and `sysKernelGetIntdevModeForRcmgr`) were discovery stubs that threw `NotImplemented` in `libkernel_sys`. They are now implemented in `libkernel`, alongside `sysKernelGetLowerLimitSysexVersion` and `sysKernelGetLowerLimitUpdVersion` in `core/libs/prx/libkernel/System/src/SystemConfiguration.cpp`, and the `libkernel_sys` stubs are removed. Following firmware 13.42 `libkernel.sprx` and `libkernel_sys.sprx` disassembly measured by BunnyFl, these wrapper functions delegate to `sysctlbyname`: - `sysKernelGetUpdVersion(uint32_t* version)` validates null output (returning `SCE_KERNEL_ERROR_EINVAL`), delegates to `sysctlbyname("machdep.upd_version", ...)`, and returns the sysctl status. - `sysKernelGetManufacturingMode(void)` returns `int` from `sysctlbyname("machdep.curr_manumode", ...)`. - `sysKernelGetIntdevModeForInternalLibc(void)` returns `int` from `sysctlbyname("machdep.rcmgr_intdev_for_internal_libc", ...)`. - `sysKernelGetIntdevModeForRcmgr(void)` returns `int` from `sysctlbyname("machdep.rcmgr_intdev", ...)`. The underlying `machdep` sysctls (`machdep.upd_version`, `machdep.curr_manumode`, `machdep.rcmgr_intdev_for_internal_libc`, `machdep.rcmgr_intdev`) return 0 as assumed defaults chosen by AnyPS5, and reject writes with `EPERM`. Neither routine alters guest errno (`*__error_nid_postfix()`). Technical debt documentation is updated in `docs/dev/debt/libkernel.md`. ### Tested - Run `python tools/check_conventions.py --base origin/main` (passed with 0 errors). - Extended `CheckVersionLimits` in `core/libs/tests/GuestSystemConfiguration.cpp`: - verified `sysKernelGetUpdVersion` writes 0 into the destination buffer and rejects null output with `SCE_KERNEL_ERROR_EINVAL`; - verified `sysKernelGetManufacturingMode`, `sysKernelGetIntdevModeForInternalLibc`, and `sysKernelGetIntdevModeForRcmgr` return 0; - verified trailing canary bytes (`0xaaaaaaaau`) remain untampered; - verified guest errno remains untouched across calls. ### Checklist - [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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 16:43:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:43:35Z.

Review: APPROVED


Reviewed exact head 4b4ceb48935474d15deec74e9f03064f9db7b9bf. The four wrappers consistently validate null outputs, write exactly one 32-bit zero, and return success without touching errno; the adjacent canary and errno assertions cover those boundaries. The prior discovery stubs are removed, and the debt entry now records the added queries and their still-unknown output meaning. git diff --check, conventions, and the merge-tree check with current upstream/main pass. I also compiled the changed SystemConfiguration.cpp and GuestSystemConfiguration.cpp translation units with the repository’s CMake-generated GCC 12 build flags. I did not run the linked runtime test locally; the PR reports the new assertions in CheckVersionLimits, while hosted product/platform build jobs are skipped by path policy. The reported firmware 13.42 behavior remains author-supplied evidence, not independently checked against a console or binary here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639007406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10671#pullrequestreview-5639007406). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T16:43:35Z. **Review:** APPROVED --- Reviewed exact head `4b4ceb48935474d15deec74e9f03064f9db7b9bf`. The four wrappers consistently validate null outputs, write exactly one 32-bit zero, and return success without touching errno; the adjacent canary and errno assertions cover those boundaries. The prior discovery stubs are removed, and the debt entry now records the added queries and their still-unknown output meaning. `git diff --check`, conventions, and the merge-tree check with current `upstream/main` pass. I also compiled the changed `SystemConfiguration.cpp` and `GuestSystemConfiguration.cpp` translation units with the repository’s CMake-generated GCC 12 build flags. I did not run the linked runtime test locally; the PR reports the new assertions in `CheckVersionLimits`, while hosted product/platform build jobs are skipped by path policy. The reported firmware 13.42 behavior remains author-supplied evidence, not independently checked against a console or binary here.
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!10671
No description provided.