fix(libkernel_sys): return what the firmware returns from 20 calls it does not implement #9172

Merged
hypermoist merged 6 commits from upstream-pr/9172 into main 2026-10-25 12:31:31 +00:00
hypermoist commented 2026-10-21 14:13:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-21T14:13:04Z.


What

These 20 libkernel_sys exports were NotImplemented stubs. In libkernel_sys.sprx (firmware 13.60, read from disassembly, not measured on a console) each is a single constant return. None makes a syscall or reads its arguments, so the exports now return the same value. This follows #8303, #8305 and #8307.

Export NID Offset in libkernel_sys.sprx Firmware body Now
pthread_switch_add_np Q9DhUQxNCwI 0xfb40 mov eax, 0x2d; ret 45 (ENOTSUP)
pthread_switch_delete_np neZ60m-+Baw 0xfb50 mov eax, 0x2d; ret 45 (ENOTSUP)
sceKernelAddResource uqJlNd9XIrA 0x46ca0 xor eax, eax; ret 0
sceKernelEventLogInit c7noapHDHWU 0x28f90 xor eax, eax; ret 0
sceKernelIsGenuineKratosCex H54cSDvjryI 0x1f160 xor eax, eax; ret 0
sceKernelReleaseTraceDirectMemory Alqa9RE0Y5k 0x1aaf0 xor eax, eax; ret 0
sceKernelHasNeoMode rNRtm1uioyY 0x20af0 mov eax, 1; ret 1
sceKernelIsAuthenticNeo cbn9Di01j0k 0x20b00 mov eax, 1; ret 1
sceKernelIsGenuineN u3h77G+tFVc 0x1f540 mov eax, 1; ret 1
sceKernelCreateEport KF25CDxFn48 0x2bd80 mov eax, 0x80020001; ret 0x80020001 (EPERM)
sceKernelDeleteEport HhGAQ+ffliw 0x2bd90 mov eax, 0x80020001; ret 0x80020001 (EPERM)
sceKernelTriggerEport is-XQhYPRaQ 0x2bda0 mov eax, 0x80020001; ret 0x80020001 (EPERM)
sceKernelOpenEport wibWed78GyY 0x2bdb0 mov eax, 0x80020001; ret 0x80020001 (EPERM)
sceKernelCloseEport J5RqzZ7nMVc 0x2bdc0 mov eax, 0x80020001; ret 0x80020001 (EPERM)
sceKernelQueryTraceMemory +8GCeq43o7c 0x1a710 mov eax, 0x80020002; ret 0x80020002 (ENOENT)
sceKernelIccGetCPMode 1NlbNxWzn7U 0x26d90 mov eax, 0x8002002d; ret 0x8002002d (ENOTSUP)
sceKernelIccSetCPMode hc0GFWwSrR4 0x26da0 mov eax, 0x8002002d; ret 0x8002002d (ENOTSUP)
sceKernelClearGameDirectMemory EgJqC+9VmvM 0x19b40 mov eax, 0x8002004e; ret 0x8002004e (ENOSYS)
sceKernelMapTraceMemory DpDnfM6StzA 0x1a6f0 mov eax, 0x8002004e; ret 0x8002004e (ENOSYS)
sceKernelTraceMemoryTypeProtect eESTogkCMPE 0x1a720 mov eax, 0x8002004e; ret 0x8002004e (ENOSYS)

Left out: get_module_info_list, which returns the address of module data rather than a constant.

Tested

Linux (CachyOS, GCC), merged with current main: libkernel_sys builds. The new guest_kernel_sys_constants test (core/libs/tests/GuestKernelSysConstants.cpp) calls all 20 exports and checks each exact return; it passes, as do guest_kernel_sys and guest_kernel_sys_thread_defaults. check_conventions and pr_overlap pass. #9134 removes the stub after sceKernelCloseEport; the two hunks are separated by unchanged lines, so both merge cleanly. No title was run.

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4953028571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9172). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-21T14:13:04Z. --- ### What These 20 libkernel_sys exports were `NotImplemented` stubs. In `libkernel_sys.sprx` (firmware 13.60, read from disassembly, not measured on a console) each is a single constant return. None makes a syscall or reads its arguments, so the exports now return the same value. This follows #8303, #8305 and #8307. | Export | NID | Offset in `libkernel_sys.sprx` | Firmware body | Now | |---|---|---|---|---| | `pthread_switch_add_np` | `Q9DhUQxNCwI` | `0xfb40` | `mov eax, 0x2d; ret` | 45 (`ENOTSUP`) | | `pthread_switch_delete_np` | `neZ60m-+Baw` | `0xfb50` | `mov eax, 0x2d; ret` | 45 (`ENOTSUP`) | | `sceKernelAddResource` | `uqJlNd9XIrA` | `0x46ca0` | `xor eax, eax; ret` | 0 | | `sceKernelEventLogInit` | `c7noapHDHWU` | `0x28f90` | `xor eax, eax; ret` | 0 | | `sceKernelIsGenuineKratosCex` | `H54cSDvjryI` | `0x1f160` | `xor eax, eax; ret` | 0 | | `sceKernelReleaseTraceDirectMemory` | `Alqa9RE0Y5k` | `0x1aaf0` | `xor eax, eax; ret` | 0 | | `sceKernelHasNeoMode` | `rNRtm1uioyY` | `0x20af0` | `mov eax, 1; ret` | 1 | | `sceKernelIsAuthenticNeo` | `cbn9Di01j0k` | `0x20b00` | `mov eax, 1; ret` | 1 | | `sceKernelIsGenuineN` | `u3h77G+tFVc` | `0x1f540` | `mov eax, 1; ret` | 1 | | `sceKernelCreateEport` | `KF25CDxFn48` | `0x2bd80` | `mov eax, 0x80020001; ret` | `0x80020001` (EPERM) | | `sceKernelDeleteEport` | `HhGAQ+ffliw` | `0x2bd90` | `mov eax, 0x80020001; ret` | `0x80020001` (EPERM) | | `sceKernelTriggerEport` | `is-XQhYPRaQ` | `0x2bda0` | `mov eax, 0x80020001; ret` | `0x80020001` (EPERM) | | `sceKernelOpenEport` | `wibWed78GyY` | `0x2bdb0` | `mov eax, 0x80020001; ret` | `0x80020001` (EPERM) | | `sceKernelCloseEport` | `J5RqzZ7nMVc` | `0x2bdc0` | `mov eax, 0x80020001; ret` | `0x80020001` (EPERM) | | `sceKernelQueryTraceMemory` | `+8GCeq43o7c` | `0x1a710` | `mov eax, 0x80020002; ret` | `0x80020002` (ENOENT) | | `sceKernelIccGetCPMode` | `1NlbNxWzn7U` | `0x26d90` | `mov eax, 0x8002002d; ret` | `0x8002002d` (ENOTSUP) | | `sceKernelIccSetCPMode` | `hc0GFWwSrR4` | `0x26da0` | `mov eax, 0x8002002d; ret` | `0x8002002d` (ENOTSUP) | | `sceKernelClearGameDirectMemory` | `EgJqC+9VmvM` | `0x19b40` | `mov eax, 0x8002004e; ret` | `0x8002004e` (ENOSYS) | | `sceKernelMapTraceMemory` | `DpDnfM6StzA` | `0x1a6f0` | `mov eax, 0x8002004e; ret` | `0x8002004e` (ENOSYS) | | `sceKernelTraceMemoryTypeProtect` | `eESTogkCMPE` | `0x1a720` | `mov eax, 0x8002004e; ret` | `0x8002004e` (ENOSYS) | Left out: `get_module_info_list`, which returns the address of module data rather than a constant. ### Tested Linux (CachyOS, GCC), merged with current `main`: libkernel_sys builds. The new `guest_kernel_sys_constants` test (`core/libs/tests/GuestKernelSysConstants.cpp`) calls all 20 exports and checks each exact return; it passes, as do `guest_kernel_sys` and `guest_kernel_sys_thread_defaults`. `check_conventions` and `pr_overlap` pass. #9134 removes the stub after `sceKernelCloseEport`; the two hunks are separated by unchanged lines, so both merge cleanly. No title was run. ### 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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
MarcZX10 commented 2026-10-22 08:28:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:28:29Z.

Review: DISMISSED


Review

The changed wrappers are still argumentless and return the constants shown in the description. I did not find a source-level defect in the edited bodies. I’m requesting changes for missing direct regression coverage and reviewable firmware evidence.

Tests for the new returns

I searched core/libs/tests for all 20 export names in this PR and found no references. The reported guest_kernel_sys pass is useful for the library, but the current tests do not check these new return values.

Please add focused checks that call the 20 exports and assert their exact returns (grouping by constant is fine), then rerun guest_kernel_sys. This protects the newly implemented behavior and ensures the changed symbols are linked by a test.

Firmware evidence

The table identifies firmware 12.00 and the instruction pattern for each return group, but does not give a module offset or attached listing. Please include the libkernel_sys.sprx function offsets or a concise disassembly excerpt for each group so reviewers can verify the constants. Keep the note that console behavior has not been measured.

Base and overlaps

The head is 608 commits behind current main (merge base 663de1ab21, from 2026-10-21 13:56 UTC). Please update it to current main and rerun the focused test as CONTRIBUTING requires branches to stay current.

I checked the generated file-level overlap list against the changed exports. #8987, #9019, #9040, #9103, #9141, #9294, and #9382 touch other exports in the same source file; I found no duplicate export or shared changed hunk. #9134 removes the adjacent sceKernelCloseEventFlag stub, not sceKernelCloseEport, so that is separate too. I found no dependency that needs adding.

Checks

  • git diff --check against current main: passed.
  • tools/check_conventions.py against current main: passed.
  • Hosted eligibility, intake, conventions, labels, and report jobs passed; Linux, Windows, register-context, relinker, ASan relinker, and write-watch jobs were skipped.
  • I did not run a local build/test in this session. The reported Linux guest_kernel_sys pass is author-reported on the older base.

The firmware-derived values look consistent as implemented; direct assertions and reviewable source evidence are needed before approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611328432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9172#pullrequestreview-5611328432). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T08:28:29Z. **Review:** DISMISSED --- ## Review The changed wrappers are still argumentless and return the constants shown in the description. I did not find a source-level defect in the edited bodies. I’m requesting changes for missing direct regression coverage and reviewable firmware evidence. ### Tests for the new returns I searched `core/libs/tests` for all 20 export names in this PR and found no references. The reported `guest_kernel_sys` pass is useful for the library, but the current tests do not check these new return values. Please add focused checks that call the 20 exports and assert their exact returns (grouping by constant is fine), then rerun `guest_kernel_sys`. This protects the newly implemented behavior and ensures the changed symbols are linked by a test. ### Firmware evidence The table identifies firmware 12.00 and the instruction pattern for each return group, but does not give a module offset or attached listing. Please include the `libkernel_sys.sprx` function offsets or a concise disassembly excerpt for each group so reviewers can verify the constants. Keep the note that console behavior has not been measured. ### Base and overlaps The head is 608 commits behind current `main` (merge base `663de1ab21`, from 2026-10-21 13:56 UTC). Please update it to current `main` and rerun the focused test as CONTRIBUTING requires branches to stay current. I checked the generated file-level overlap list against the changed exports. #8987, #9019, #9040, #9103, #9141, #9294, and #9382 touch other exports in the same source file; I found no duplicate export or shared changed hunk. #9134 removes the adjacent `sceKernelCloseEventFlag` stub, not `sceKernelCloseEport`, so that is separate too. I found no dependency that needs adding. ### Checks - `git diff --check` against current `main`: passed. - `tools/check_conventions.py` against current `main`: passed. - Hosted eligibility, intake, conventions, labels, and report jobs passed; Linux, Windows, register-context, relinker, ASan relinker, and write-watch jobs were skipped. - I did not run a local build/test in this session. The reported Linux `guest_kernel_sys` pass is author-reported on the older base. The firmware-derived values look consistent as implemented; direct assertions and reviewable source evidence are needed before approval.
hypermoist commented 2026-10-22 08:47:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-22T08:47:05Z.


@MarcZX10 thanks, all three addressed:

  • Tests: guest_kernel_sys_constants (core/libs/tests/GuestKernelSysConstants.cpp) calls each of the 20 exports and checks its exact return. It passes on Linux together with guest_kernel_sys and guest_kernel_sys_thread_defaults.
  • Evidence: the description now lists every export's NID and function offset in libkernel_sys.sprx (firmware 12.00) next to its two-instruction body. It still says the values are read from disassembly and not measured on a console.
  • Base: I merged current main (928094e49d) before running the tests.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336657585 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9172#issuecomment-6336657585). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-22T08:47:05Z. --- @MarcZX10 thanks, all three addressed: - **Tests:** `guest_kernel_sys_constants` (`core/libs/tests/GuestKernelSysConstants.cpp`) calls each of the 20 exports and checks its exact return. It passes on Linux together with `guest_kernel_sys` and `guest_kernel_sys_thread_defaults`. - **Evidence:** the description now lists every export's NID and function offset in `libkernel_sys.sprx` (firmware 12.00) next to its two-instruction body. It still says the values are read from disassembly and not measured on a console. - **Base:** I merged current `main` (928094e49d) before running the tests.
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!9172
No description provided.