feat(libkernel_sys): implement sceKernelIsCEX, sceKernelIsDevKit, get_authinfo and sceKernelGetOpenPsIdForSystem #10524

Merged
YossiYad merged 7 commits from upstream-pr/10524 into main 2026-10-26 04:37:52 +00:00
YossiYad commented 2026-10-24 07:57:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-24T07:57:06Z.


What

Four libkernel_sys exports threw. They now describe a retail console running the guest:

  • sceKernelIsCEX returns 1 and sceKernelIsDevKit 0, as shadPS4's process.cpp does with its devkit option off.
  • get_authinfo(pid, info) follows shadPS4's kernel.cpp: -1 with EPERM for a null result, -1 with ESRCH for a process other than 0 or the guest's own pid, otherwise the 0x88-byte structure cleared except the first capability word, 0x2000000000000000. fpPS4 gives the same 0x88-byte size.
  • sceKernelGetOpenPsIdForSystem returns positive 22 for null, following the firmware 13.42 module report, and otherwise returns sceKernelGetOpenPsId's value. The module reads a separate sysctl, whose value is not known here.

The stubs leave Export.Discovery.cpp; the implementations sit in Export.cpp after umask, away from the end of the file where other open PRs append and from the spot before fork where #10421 adds is_in_sandbox.

Not measured on a PS5.

Tested

Current validation (2026-10-25): rebased onto main 16ff208dc3; rebuilt and passed all 14 guest_kernel_sys tests on Bazzite 44, including null system-ID and unchanged-output regressions. Conventions pass against upstream/main.

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main 1e20650e84, rebased on 5d3ab7791d afterwards (every commit builds, the kernel_sys tests pass):

  • New guest_kernel_sys_console_identity (core/libs/tests/GuestKernelSysConsoleIdentity.cpp): the console kind; get_authinfo errno for a null result and for another pid, with the result left alone; for pid 0 and the guest pid the authority ID, the capability word, the cleared remainder and nothing written past 0x88 bytes; both OpenPSID queries agree and the system one writes 16 bytes. Dropping the pid check and moving the capability bit to the next word each made it fail.
  • Full ctest on a merge of this branch with the other four from the same day (camera, NpParty, SharePlay, libkernel_sys): 2021 of 2024 pass. The 3 failures, application_heap_scripting, application_heap_lazy and agc_driver_tessellation, fail the same way on main on this machine and do not use these exports. Tests that need the GPU skipped themselves.
  • tools/progress.py --compare: libraries +0.03%, 4 functions implemented, none lost.
  • tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py: no open PR implements these four. Several open libkernel_sys PRs (#9156, #9160, #9161, #9187, #9284, #9293, #9297, #9302, #9693) conflict with main and could not be compared by the tool; none of them names these exports.

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:4993661134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10524). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-24T07:57:06Z. --- ### What Four libkernel_sys exports threw. They now describe a retail console running the guest: - `sceKernelIsCEX` returns 1 and `sceKernelIsDevKit` 0, as [shadPS4's process.cpp](https://github.com/shadps4-emu/shadPS4/blob/396c2a09a38d22eaa02aab32c1967263dceab95f/src/core/libraries/kernel/process.cpp) does with its devkit option off. - `get_authinfo(pid, info)` follows [shadPS4's kernel.cpp](https://github.com/shadps4-emu/shadPS4/blob/396c2a09a38d22eaa02aab32c1967263dceab95f/src/core/libraries/kernel/kernel.cpp): -1 with `EPERM` for a null result, -1 with `ESRCH` for a process other than 0 or the guest's own pid, otherwise the 0x88-byte structure cleared except the first capability word, `0x2000000000000000`. [fpPS4](https://github.com/red-prig/fpPS4/blob/04cefd43e6fddd1ab033e7980cd356d14c964905/kernel/ps4_libkernel.pas) gives the same 0x88-byte size. - `sceKernelGetOpenPsIdForSystem` returns positive 22 for null, following the firmware 13.42 module report, and otherwise returns `sceKernelGetOpenPsId`'s value. The module reads a separate sysctl, whose value is not known here. The stubs leave `Export.Discovery.cpp`; the implementations sit in `Export.cpp` after `umask`, away from the end of the file where other open PRs append and from the spot before `fork` where #10421 adds `is_in_sandbox`. Not measured on a PS5. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Current validation (2026-10-25): rebased onto main `16ff208dc3`; rebuilt and passed all 14 `guest_kernel_sys` tests on Bazzite 44, including null system-ID and unchanged-output regressions. Conventions pass against upstream/main. Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `1e20650e84`, rebased on `5d3ab7791d` afterwards (every commit builds, the `kernel_sys` tests pass): - New `guest_kernel_sys_console_identity` (`core/libs/tests/GuestKernelSysConsoleIdentity.cpp`): the console kind; `get_authinfo` errno for a null result and for another pid, with the result left alone; for pid 0 and the guest pid the authority ID, the capability word, the cleared remainder and nothing written past 0x88 bytes; both OpenPSID queries agree and the system one writes 16 bytes. Dropping the pid check and moving the capability bit to the next word each made it fail. - Full `ctest` on a merge of this branch with the other four from the same day (camera, NpParty, SharePlay, libkernel_sys): 2021 of 2024 pass. The 3 failures, `application_heap_scripting`, `application_heap_lazy` and `agc_driver_tessellation`, fail the same way on `main` on this machine and do not use these exports. Tests that need the GPU skipped themselves. - `tools/progress.py --compare`: libraries +0.03%, 4 functions implemented, none lost. - `tools/check_conventions.py --base upstream/main` passes. - `tools/pr_overlap.py`: no open PR implements these four. Several open libkernel_sys PRs (#9156, #9160, #9161, #9187, #9284, #9293, #9297, #9302, #9693) conflict with `main` and could not be compared by the tool; none of them names these exports. ### 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
MarcZX10 commented 2026-10-24 11:12:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T11:12:06Z.

Review: APPROVED


Reviewed the exact PR implementation and the focused console-identity tests. The output struct has the asserted 0x88-byte layout; get_authinfo checks null and pid before writing, uses guest errno values, and the test verifies sentinel preservation on errors plus the exact cleared/capability fields on success. The PS4 emulator sources support the behavior, but this is not PS5-measured and the PR records that limit. The reported Linux test/conventions checks pass; hosted build jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638039401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10524#pullrequestreview-5638039401). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T11:12:06Z. **Review:** APPROVED --- Reviewed the exact PR implementation and the focused console-identity tests. The output struct has the asserted 0x88-byte layout; `get_authinfo` checks null and pid before writing, uses guest errno values, and the test verifies sentinel preservation on errors plus the exact cleared/capability fields on success. The PS4 emulator sources support the behavior, but this is not PS5-measured and the PR records that limit. The reported Linux test/conventions checks pass; hosted build jobs are skipped.
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!10524
No description provided.