fix(libkernel): read compiled SDK version from process parameters #3643

Closed
oguzhanozfe wants to merge 2 commits from upstream-pr/3643 into main
oguzhanozfe commented 2026-10-11 14:40:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oguzhanozfe on 2026-10-11T14:40:27Z.


What

Implement ordinary sceKernelGetCompiledSdkVersion using the executable's Orbis process parameters. Null output returns EINVAL before metadata access. The unchanged bounded reader supplies the mapped prefix; the query validates minimum size and ORBI magic, then writes the low 32 bits of the actual SDK field. Missing/malformed metadata follows explicit emulator refusal and preserves output.

Community shadPS4 evidence supports this ordinary subset; it is not a Sony specification. Implementation is original. Size/magic refusal is an emulator policy. Prospero behavior remains unchanged.

Tested

Windows, MinGW GCC 15.2.0, Release: fresh libs-only builds of libc, libkernel and NID patcher, plus two focused tests. Tests cover zero/high SDK bits, guaranteed unaligned pointers/canaries, null and refusal paths, u64 size width/exact magic, and the actual .procpar reader with malformed RVA. Static provider exports changed from 900 to 901; the ordinary NID binds the same function RVA as the named export. One tools-disabled public-source Claude audit reported no material query bug; scoped fixture additions passed affected checks. The PE fixture uses GNU named-section attributes in double-bracket syntax; that syntax-only correction was separately compiled and tested against unchanged candidate providers.

Independent verification reran both focused executables and the static export checks successfully. A process-test PATH setup failure before test entry was preserved, then the exact registered CTest environment passed. Full default builds, Linux reader integration, other compiler/unwind configurations and game applicability are untested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819851831 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643). Originally posted by [oguzhanozfe](https://github.com/oguzhanozfe) on 2026-10-11T14:40:27Z. --- ### What Implement ordinary `sceKernelGetCompiledSdkVersion` using the executable's Orbis process parameters. Null output returns EINVAL before metadata access. The unchanged bounded reader supplies the mapped prefix; the query validates minimum size and ORBI magic, then writes the low 32 bits of the actual SDK field. Missing/malformed metadata follows explicit emulator refusal and preserves output. [Community shadPS4 evidence](https://github.com/shadps4-emu/shadPS4/blob/3a9f57265d28975658f1ca941daa5c879c7a74bd/src/core/libraries/kernel/process.cpp) supports this ordinary subset; it is not a Sony specification. Implementation is original. Size/magic refusal is an emulator policy. Prospero behavior remains unchanged. ### Tested Windows, MinGW GCC 15.2.0, Release: fresh libs-only builds of libc, libkernel and NID patcher, plus two focused tests. Tests cover zero/high SDK bits, guaranteed unaligned pointers/canaries, null and refusal paths, u64 size width/exact magic, and the actual `.procpar` reader with malformed RVA. Static provider exports changed from 900 to 901; the ordinary NID binds the same function RVA as the named export. One tools-disabled public-source Claude audit reported no material query bug; scoped fixture additions passed affected checks. The PE fixture uses GNU named-section attributes in double-bracket syntax; that syntax-only correction was separately compiled and tested against unchanged candidate providers. Independent verification reran both focused executables and the static export checks successfully. A process-test PATH setup failure before test entry was preserved, then the exact registered CTest environment passed. Full default builds, Linux reader integration, other compiler/unwind configurations and game applicability are untested. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-11 14:40:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:40:49Z.


Progress report (43e3a70 → 6eb81da)

➖ System libraries: 87.87% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetCompiledSdkVersion_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110165024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6110165024). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:40:49Z. --- <!-- progress-report --> ### Progress report (43e3a70 → 6eb81da) ➖ **System libraries**: 87.87% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetCompiledSdkVersion_nid_postfix` | </details>
blawesom commented 2026-10-11 15:19:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:19:49Z.


Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 833/833 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110518175 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6110518175). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:19:49Z. --- Independent pre-review on **Linux** (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Builds; `tools/check_conventions.py --base origin/main` passes. - Full suite: **833/833 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
oneandonlydean commented 2026-10-11 23:16:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:16:03Z.


Which title calls sceKernelGetCompiledSdkVersion? With the title ID and the log line where it stops on main this can go in; otherwise I'll close it until one does. It throws unless the process parameters carry the ORBI magic, so please check it against that title's block too.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114996701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6114996701). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:16:03Z. --- Which title calls `sceKernelGetCompiledSdkVersion`? With the title ID and the log line where it stops on main this can go in; otherwise I'll close it until one does. It throws unless the process parameters carry the `ORBI` magic, so please check it against that title's block too.
adriadam10 commented 2026-10-12 20:46:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:46:36Z.

Review: CHANGES_REQUESTED


Thanks for the PR. Not merging yet:

  • @oneandonlydean asked which title calls sceKernelGetCompiledSdkVersion and where it stops on main. That is still unanswered. Please give the title ID (PPSAxxxxx) and the log line from main, and say whether that title's process parameters carry the ORBI magic, since the function throws otherwise.
  • The 0x10 SDK field offset and the size >= 0x40 / ORBI check come only from shadPS4 (PS4). Please say what supports them for PS5 process parameters (a title's block, or another source), and add that to the PR.
  • compiled_sdk_version_process is Windows-only, so Linux CI only runs the test with a replaced reader. A Linux-reachable test of the real reader path would cover the Linux behaviour.

Happy to re-review once the title evidence is in.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5495788552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#pullrequestreview-5495788552). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T20:46:36Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. Not merging yet: - @oneandonlydean asked which title calls `sceKernelGetCompiledSdkVersion` and where it stops on `main`. That is still unanswered. Please give the title ID (PPSAxxxxx) and the log line from `main`, and say whether that title's process parameters carry the `ORBI` magic, since the function throws otherwise. - The `0x10` SDK field offset and the `size >= 0x40` / `ORBI` check come only from shadPS4 (PS4). Please say what supports them for PS5 process parameters (a title's block, or another source), and add that to the PR. - `compiled_sdk_version_process` is Windows-only, so Linux CI only runs the test with a replaced reader. A Linux-reachable test of the real reader path would cover the Linux behaviour. Happy to re-review once the title evidence is in.
adriadam10 commented 2026-10-13 07:41:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T07:41:32Z.

Review: CHANGES_REQUESTED


Thanks for the Linux reader test in 6eb81da; that covers the last point of the previous review. Two points are still open and block the merge:

  • @oneandonlydean's question is unanswered: which title (PPSAxxxxx) calls sceKernelGetCompiledSdkVersion, and what is the log line where it stops on main? Does that title's process parameters block carry the ORBI magic? The function throws otherwise.
  • The 0x10 SDK field offset and the size >= 0x40 / ORBI checks are sourced only from shadPS4 (PS4). Please add what supports them for PS5 process parameters (a title's block or another source) to the PR body.

Without a title that needs it, this will likely be closed as unneeded; happy to re-review once the evidence is in.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5500283611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#pullrequestreview-5500283611). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T07:41:32Z. **Review:** CHANGES_REQUESTED --- Thanks for the Linux reader test in 6eb81da; that covers the last point of the previous review. Two points are still open and block the merge: - @oneandonlydean's question is unanswered: which title (PPSAxxxxx) calls `sceKernelGetCompiledSdkVersion`, and what is the log line where it stops on `main`? Does that title's process parameters block carry the `ORBI` magic? The function throws otherwise. - The `0x10` SDK field offset and the `size >= 0x40` / `ORBI` checks are sourced only from shadPS4 (PS4). Please add what supports them for PS5 process parameters (a title's block or another source) to the PR body. Without a title that needs it, this will likely be closed as unneeded; happy to re-review once the evidence is in.
xXPBSXx commented 2026-10-13 08:07:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:07:32Z.


Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: this PR merged onto main c080fc2d5 (no conflict).

  • compiled_sdk_version and compiled_sdk_version_process build and pass with the PR (0.02 s and 0.03 s).
  • CompiledSdkVersion.cpp is a new file, so there is no main version to take it back to; the tests call sceKernelGetCompiledSdkVersion_nid_postfix, which the PR adds.

Not tested: Linux, a console, a title run, the ELF fixture script (CompiledSdkVersionElfFixture.py; I did not run Python fixtures here).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141176456 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6141176456). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:07:32Z. --- Tested on Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: this PR merged onto `main` `c080fc2d5` (no conflict). - `compiled_sdk_version` and `compiled_sdk_version_process` build and pass with the PR (0.02 s and 0.03 s). - `CompiledSdkVersion.cpp` is a new file, so there is no `main` version to take it back to; the tests call `sceKernelGetCompiledSdkVersion_nid_postfix`, which the PR adds. Not tested: Linux, a console, a title run, the ELF fixture script (`CompiledSdkVersionElfFixture.py`; I did not run Python fixtures here). AI-assisted (Claude Code).
coltken95 commented 2026-10-13 11:11:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T11:11:09Z.


Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commits on main at 77b9f7270: compiled_sdk_version and compiled_sdk_version_process both pass, the latter exercising the Linux process reader. A run against main's sources is not applicable here, since the tests build CompiledSdkVersion.cpp, which this PR adds.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144245381 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6144245381). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T11:11:09Z. --- Linux validation (Ubuntu 24.04, GCC 13.3, Release), this PR's commits on `main` at 77b9f7270: `compiled_sdk_version` and `compiled_sdk_version_process` both pass, the latter exercising the Linux process reader. A run against `main`'s sources is not applicable here, since the tests build `CompiledSdkVersion.cpp`, which this PR adds. AI-assisted: yes
oneandonlydean commented 2026-10-14 02:39:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:39:45Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159666778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3643#issuecomment-6159666778). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:39:45Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!3643
No description provided.