refactor(libs): share the remaining compiled SDK version reads #26370

Open
Buraddomoon wants to merge 1 commit from upstream-pr/26370 into main
Buraddomoon commented 2026-11-23 20:58:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Buraddomoon on 2026-11-23T20:58:00Z.


What

Route the six remaining read sites enumerated in #26276 through the helper introduced by #26296. AppContent, GnmDriverForNeoMode, Hmd2, Http and Http2 now use ApplicationCompiledSdkVersion() for the 32-bit process-parameter field at offset 0x10. Http2 uses the host helper instead of a guest export, removing its 0x99900000 fallback and unused kernel API include.

Keep the existing local helper names as forwarding functions: in-flight changes such as #24528 call them too. This centralizes the read without renaming their call sites or requiring those PRs first. The SDK field and normal SDK-dependent results are preserved.

Http2 previously substituted 0x99900000 when sceKernelGetCompiledSdkVersion(&version) returned an error, although its destination was a local host-stack variable. The direct helper returns the actual field without that guest-output fallback policy. Parameter discovery can throw for missing or invalid process metadata in both implementations; the helper is not a fabricated-success fallback.

Together with #26296, this completes the 16 readers listed in #26276. The additional readers identified in review in Json2, Ngs2.native, Rtc, Ssl, UsbStorageDialog and kernel Coredump are follow-up scope.

Tested

Linux x86-64, Debian 13 container on Fedora 44, GCC 14.2.0, CMake 3.31.6, Ninja, Release with -O1 -DNDEBUG. Full runtime configuration (BUILD_TESTING=ON), all five affected libraries and the selected test executables built successfully.

  • Exact head 3aec109413b7a30a3db672cc09e90dd71dfb74f0: 74/74 CTests passed, zero skips, in 23.58 s. Selection: guest_appcontent|guest_hmd2|guest_gnm_neo|^guest_http|application_?heap|process_?param.
  • Existing tests exercise AppContent SDK-dependent checks, GNM Neo context-state sizes before/from SDK 4.00, Hmd2 initialization/error paths, HTTP URI rules before/from SDK 1.00, the HTTP socket callback boundary at SDK 1.50, and HTTP/2 gzip content lengths on older/newer SDKs. The HTTP transports use local loopback servers.
  • Coverage limit confirmed in review: the two Hmd2 SDK branches are unreachable at this head. sceHmd2Initialize always returns UnsupportedFeature, and initialized is never set to true. The passing Hmd2 tests validate the available error paths, not those SDK branches.
  • Optimization review: rebuilt the changed C++ paths with -O3, including the Http2 transport archive, while leaving unchanged dependency builds at -O1. The same 74/74 CTests passed with zero skips on the unchanged head.
  • Compiled all six changed translation units with GCC 14.2.0 at -O3 and compared them with a variant removing the local forwarding functions and calling ApplicationCompiledSdkVersion() directly. objdump -drC instruction and relocation listings match for all six, after normalizing only the temporary object filename and the generated initializer filename. The forwarding functions disappear at this optimization level; retaining their names adds no extra call in this compiler/configuration.
  • The shared reader caches the process-parameter pointer and still loads the SDK field on each call. Caching the SDK value itself would change the existing behavior exercised by the version-switching tests. This code inspection is not a frame-rate measurement.
  • python3 tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD passed.
  • The author's local runs did not include native Windows/macOS, a console, a GPU or a title. No performance claim.
  • Independent validation reported by Helldiverr: Windows 11 Pro 26300, WinLibs GCC 15.2, Release; 73 selected tests passed on main f784587f30 and on three runs of merge 5952756a06. The reviewer also checked SDK changes between calls and used negative-control/mutation cases for the reachable readers. These are the reviewer's runs, separate from the author's Linux results.

The pre-submission branch overlap check examined 2,541 open PRs and 13 shared-file candidates. It returned exit 2 for #17711, #19525 and the then-current #24528 because they already conflicted with the checked base. After the bot listed 13 unverified comparisons, I manually compared the current heads of all 13 reported PRs against base 2b09db6f11 and this head 3aec109413: #11630, #12056, #16231, #17711, #18954, #19525, #20805, #24528, #24634, #25677, #25731, #25756 and #26229. Eleven merge cleanly with this head. #17711 and #19525 have exactly the same conflict paths and conflict blocks on the base and on this branch. The updated #24528 (81b4bc374f) merges cleanly; retaining the local helper names preserves its added calls. This records manual comparison of the bot warnings, not a clean checker exit or combined runtime qualification of the other PRs.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: Fixes #26276
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5461109134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26370). Originally posted by [Buraddomoon](https://github.com/Buraddomoon) on 2026-11-23T20:58:00Z. --- ### What Route the six remaining read sites enumerated in #26276 through the helper introduced by #26296. AppContent, GnmDriverForNeoMode, Hmd2, Http and Http2 now use `ApplicationCompiledSdkVersion()` for the 32-bit process-parameter field at offset `0x10`. Http2 uses the host helper instead of a guest export, removing its `0x99900000` fallback and unused kernel API include. Keep the existing local helper names as forwarding functions: in-flight changes such as #24528 call them too. This centralizes the read without renaming their call sites or requiring those PRs first. The SDK field and normal SDK-dependent results are preserved. Http2 previously substituted `0x99900000` when `sceKernelGetCompiledSdkVersion(&version)` returned an error, although its destination was a local host-stack variable. The direct helper returns the actual field without that guest-output fallback policy. Parameter discovery can throw for missing or invalid process metadata in both implementations; the helper is not a fabricated-success fallback. Together with #26296, this completes the 16 readers listed in #26276. The additional readers identified in review in Json2, Ngs2.native, Rtc, Ssl, UsbStorageDialog and kernel Coredump are follow-up scope. ### Tested Linux x86-64, Debian 13 container on Fedora 44, GCC 14.2.0, CMake 3.31.6, Ninja, Release with `-O1 -DNDEBUG`. Full runtime configuration (`BUILD_TESTING=ON`), all five affected libraries and the selected test executables built successfully. - Exact head `3aec109413b7a30a3db672cc09e90dd71dfb74f0`: **74/74 CTests passed, zero skips**, in 23.58 s. Selection: `guest_appcontent|guest_hmd2|guest_gnm_neo|^guest_http|application_?heap|process_?param`. - Existing tests exercise AppContent SDK-dependent checks, GNM Neo context-state sizes before/from SDK 4.00, Hmd2 initialization/error paths, HTTP URI rules before/from SDK 1.00, the HTTP socket callback boundary at SDK 1.50, and HTTP/2 gzip content lengths on older/newer SDKs. The HTTP transports use local loopback servers. - Coverage limit confirmed in review: the two Hmd2 SDK branches are unreachable at this head. `sceHmd2Initialize` always returns `UnsupportedFeature`, and `initialized` is never set to true. The passing Hmd2 tests validate the available error paths, not those SDK branches. - Optimization review: rebuilt the changed C++ paths with `-O3`, including the Http2 transport archive, while leaving unchanged dependency builds at `-O1`. The same **74/74 CTests passed with zero skips** on the unchanged head. - Compiled all six changed translation units with GCC 14.2.0 at `-O3` and compared them with a variant removing the local forwarding functions and calling `ApplicationCompiledSdkVersion()` directly. `objdump -drC` instruction and relocation listings match for all six, after normalizing only the temporary object filename and the generated initializer filename. The forwarding functions disappear at this optimization level; retaining their names adds no extra call in this compiler/configuration. - The shared reader caches the process-parameter pointer and still loads the SDK field on each call. Caching the SDK value itself would change the existing behavior exercised by the version-switching tests. This code inspection is not a frame-rate measurement. - `python3 tools/check_conventions.py --base origin/main` and `git diff --check origin/main...HEAD` passed. - The author's local runs did not include native Windows/macOS, a console, a GPU or a title. No performance claim. - Independent validation reported by [Helldiverr](https://github.com/boykopovar/AnyPS5/pull/26370#issuecomment-7115167841): Windows 11 Pro 26300, WinLibs GCC 15.2, Release; 73 selected tests passed on `main` `f784587f30` and on three runs of merge `5952756a06`. The reviewer also checked SDK changes between calls and used negative-control/mutation cases for the reachable readers. These are the reviewer's runs, separate from the author's Linux results. The pre-submission branch overlap check examined 2,541 open PRs and 13 shared-file candidates. It returned exit 2 for #17711, #19525 and the then-current #24528 because they already conflicted with the checked base. After the bot listed 13 unverified comparisons, I manually compared the current heads of all 13 reported PRs against base `2b09db6f11` and this head `3aec109413`: #11630, #12056, #16231, #17711, #18954, #19525, #20805, #24528, #24634, #25677, #25731, #25756 and #26229. Eleven merge cleanly with this head. #17711 and #19525 have exactly the same conflict paths and conflict blocks on the base and on this branch. The updated #24528 (`81b4bc374f`) merges cleanly; retaining the local helper names preserves its added calls. This records manual comparison of the bot warnings, not a clean checker exit or combined runtime qualification of the other PRs. <!-- 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. --> ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- #PR, or none --> - [x] Fixes: Fixes #26276 <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
catminou4 commented 2026-11-23 22:08:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-23T22:08:29Z.

Review: COMMENTED


Verified locally (Linux x86-64, GCC 11): libSceAppContent and libSceHttp build cleanly from this branch.

The change replaces six local copies of "read the compiled SDK version from the process parameters at +0x10" with the existing shared helper ApplicationCompiledSdkVersion() from prx/libc/include/ApplicationHeap.hpp, which does exactly the same read. Five of the six sites are behavior-neutral.

One note on libSceHttp2/Transport.cpp: the old code went through sceKernelGetCompiledSdkVersion and fell back to 0x99900000 on error; the new code reads the process parameters directly and has no fallback. Since ApplicationCompiledSdkVersion() is the same source of truth and cannot fail, this is arguably more consistent, but it is a small behavioral difference worth being aware of (the 0x99900000 sentinel path is gone). Not a blocker.

Deduplicating onto the shared helper is the right direction. LGTM from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6030301756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26370#pullrequestreview-6030301756). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-23T22:08:29Z. **Review:** COMMENTED --- Verified locally (Linux x86-64, GCC 11): `libSceAppContent` and `libSceHttp` build cleanly from this branch. The change replaces six local copies of "read the compiled SDK version from the process parameters at +0x10" with the existing shared helper `ApplicationCompiledSdkVersion()` from `prx/libc/include/ApplicationHeap.hpp`, which does exactly the same read. Five of the six sites are behavior-neutral. One note on `libSceHttp2/Transport.cpp`: the old code went through `sceKernelGetCompiledSdkVersion` and fell back to `0x99900000` on error; the new code reads the process parameters directly and has no fallback. Since `ApplicationCompiledSdkVersion()` is the same source of truth and cannot fail, this is arguably more consistent, but it is a small behavioral difference worth being aware of (the `0x99900000` sentinel path is gone). Not a blocker. Deduplicating onto the shared helper is the right direction. LGTM from my side.
MarcZX10 commented 2026-11-25 08:05:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:05:55Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; its six reader paths now delegate to the shared SDK-version helper while preserving the existing helper names and SDK-dependent call sites.

What I ran

Reviewed head 3aec109413b7a30a3db672cc09e90dd71dfb74f0 using the prepared diff and pinned repository reader. No build or test commands were run by me; the test results below are author-reported.

Files read: description.md, commits.md, manifest.json, diff.patch, ApplicationHeap.hpp, and the changed source ranges in Export.cpp, Options.cpp, Uri.cpp, and Transport.cpp for all six changed files. All six changed files are listed as included in the manifest. No files were excluded by the manifest.

Results

Check Result Note
Diff and source review passed Six changed files inspected
Author-reported Linux tests not run 74/74 CTests reported passed
Author-reported Windows validation not run Reported separately in the description
Build, native console, and performance measurement not run No local execution

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the reported tests or builds, verify native Windows/macOS behavior, or measure behavior on a console, GPU, or title. The description reports Hmd2 SDK branches are currently unreachable; I did not independently verify that coverage claim. The description also reports the other reviewers' test runs; those were not run by me.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6053871051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26370#pullrequestreview-6053871051). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T08:05:55Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; its six reader paths now delegate to the shared SDK-version helper while preserving the existing helper names and SDK-dependent call sites. ## What I ran Reviewed head `3aec109413b7a30a3db672cc09e90dd71dfb74f0` using the prepared diff and pinned repository reader. No build or test commands were run by me; the test results below are author-reported. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `ApplicationHeap.hpp`, and the changed source ranges in `Export.cpp`, `Options.cpp`, `Uri.cpp`, and `Transport.cpp` for all six changed files. All six changed files are listed as included in the manifest. No files were excluded by the manifest. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | Six changed files inspected | | Author-reported Linux tests | not run | 74/74 CTests reported passed | | Author-reported Windows validation | not run | Reported separately in the description | | Build, native console, and performance measurement | not run | No local execution | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the reported tests or builds, verify native Windows/macOS behavior, or measure behavior on a console, GPU, or title. The description reports Hmd2 SDK branches are currently unreachable; I did not independently verify that coverage claim. The description also reports the other reviewers' test runs; those were not run by me. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 12:18:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:18:39Z.

Review: COMMENTED


Compiled the exact shared SDK helper into a Linux fixture. It read the compiled SDK field while ignoring the adjacent Prospero field, and a second call saw a value change without redoing the process-parameter lookup. I checked the call sites against the previously used offset. This run covered the shared helper.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169646592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26370#pullrequestreview-6169646592). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:18:39Z. **Review:** COMMENTED --- Compiled the exact shared SDK helper into a Linux fixture. It read the compiled SDK field while ignoring the adjacent Prospero field, and a second call saw a value change without redoing the process-parameter lookup. I checked the call sites against the previously used offset. This run covered the shared helper. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/26370:upstream-pr/26370'
git switch 'upstream-pr/26370'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/26370'
git switch 'upstream-pr/26370'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/26370'
git switch 'upstream-pr/26370'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/26370'
git switch 'main'
git merge --squash 'upstream-pr/26370'
git switch 'main'
git merge --ff-only 'upstream-pr/26370'
git switch 'main'
git merge 'upstream-pr/26370'
git push origin 'main'
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!26370
No description provided.