feat(libs): general system-library fixes from PS4 title bring-up #27937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27937"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by kleinergoo7 on 2026-11-27T21:03:44Z.
What
This branch makes AnyPS5's system libraries behave correctly for PS4 titles relinked through the shared pipeline. It is one topic: PS4 guest compatibility in the general-purpose library implementations, uncovered while bringing up CUSA51664 (Heretic + Hexen). No per-game IDs, addresses, paths or NIDs are used in the implementation; title IDs appear only in the debt notes.
Grouped by area (23 commits):
abortand__stack_chk_failwithAPS5_VABI, declare them once inApi.hpp(redundant locals inBoundsChecking.cpp,Threads.cpp,InventoryExports.cppandChecks.cppremoved); implement thebad_alloc/system_error_Doraisehandlers andstd::_Random_device_entropy.sceGnmDrawInitToDefaultContextStateto the normal provider, with a base-hardware init table derived from the existing Neo table. The init write goes through the checked guest-output path (GuestArena::HostWrite+GuestWritable+GuestCopyOut) like the 400-word variant, propagating a failed write as an error instead of copying directly into guest memory.SET_CONFIG_REGwrites in a config bank, keepINDEX_TYPElow two bits as the uconfig path and shadPS4 do, and reject its byte-swap modifier bits instead of silently dropping them.sceKernelMapDirectMemoryplacements the alignment argument is normalized to the guest page size; fixed no-overwrite placements keep the requested alignment (the previous code forwarded it unchanged). This preserves the guest-pointer-safe hint path from current main.Removed per Dec 3 review: the throwing-only stub libraries
libSceNpToolkitandlibJavaScriptCore(and their tests, CMake entries and debt files) are dropped from this PR. Those stubs were only needed to progress further into Battlefield 1 (CUSA02429) by resolving missing imports and were never required for Heretic + Hexen; BF1 remains an investigation sidenote with a separate unresolved entitlement-object runtime failure, not a compatibility claim here. The stub work is preserved separately for a future PR that gives a function real behaviour.All new and changed behavior is generic. Unmeasured console semantics are documented in the debt fragment folded into the per-library debt files (
tools/debt_fold.py --checkpasses).Tested
Fedora Linux 45, GCC 16, AMD RX 580 (POLARIS10), RADV Mesa 26.2.7, Vulkan 1.4.350, Khronos validation layer 1.4.350. Branch rebased onto current
origin/main(700fae9438).python3 tools/check_conventions.py --base main --head ps4/bringup: pass (new head).python3 tools/debt_fold.py --check: pass (new head).git diff --check: clean;range-diffvs the previous head: 17 identical, 5 context adaptations to upstream refactors, plus the stub removals, the GNM checked-write fix and the debt corrections.b4461c9dfc, for reference):test_public_headers.py: 415 libraries / 35098 exports; 71/71 focused tests inbuilds/full;agc_driver_pm4*31/31 including replay tools; GPU validation comparison attempted withtools/vulkan_validation_gate.py(both sides 0 VUID diagnostics; gate exited 1 only because the host-side unit test creates no Vulkan instance, so layer insertion is unconfirmed and reviewers may ask for a hardware validation run). Windows (reviewer-reported, RX 6700 XT / MinGW-w64 GCC 15.2): 42/42 CTests, 3/3 runs.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T21:24:31Z.
Review: COMMENTED
Actionable comments posted: 5
4689a8bd-8f9a-4099-ba1c-ff0ae2bf1cd9Reviewing files that changed from the base of the PR and between
335fd4626fandd9b8c0b19e.core/libs/prx/libJavaScriptCore/CMakeLists.txtcore/libs/prx/libJavaScriptCore/Export.cppcore/libs/prx/libJavaScriptCore/include/Api.hppcore/libs/prx/libJavaScriptCore/libJavaScriptCore.hppcore/libs/prx/libSceAgcDriver/Execution/include/QueueState.hppcore/libs/prx/libSceAgcDriver/Execution/src/Pm4.cppcore/libs/prx/libSceAgcDriver/tests/Pm4.cppcore/libs/prx/libSceGnmDriver/Export.cppcore/libs/prx/libSceGnmDriver/include/Api.hppcore/libs/prx/libSceGnmDriver/tests/InitModes.cppcore/libs/prx/libSceNgs2.native/include/Ngs2Types.hppcore/libs/prx/libSceNgs2.native/src/Rack.cppcore/libs/prx/libSceNgs2.native/src/Voice.cppcore/libs/prx/libSceNgs2.native/tests/Ngs2Routing.cppcore/libs/prx/libSceNpToolkit/CMakeLists.txtcore/libs/prx/libSceNpToolkit/Export.cppcore/libs/prx/libSceNpToolkit/include/Api.hppcore/libs/prx/libSceNpToolkit/libSceNpToolkit.hppcore/libs/prx/libc/include/Api.hppcore/libs/prx/libc/src/BoundsChecking.cppcore/libs/prx/libc/src/Process.cppcore/libs/prx/libc/src/Random.cppcore/libs/prx/libc/src/exception/StandardExceptions.cppcore/libs/prx/libc/tests/cmake/guest_libc_abort.cmakecore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/tests/GuestFlexibleMemoryBudget.cppcore/libs/tests/GuestJavaScriptCore.cppcore/libs/tests/GuestLibcAbort.cppcore/libs/tests/GuestLibcAbort.pycore/libs/tests/GuestLibcDoraiseSystemError.cppcore/libs/tests/GuestLibcxxRandomDevice.cppcore/libs/tests/GuestNpToolkit.cppdocs/dev/debt/changes/ps4-bringup.mddocs/dev/debt/libJavaScriptCore.mddocs/dev/debt/libSceNpToolkit.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T21:32:44Z.
Review: COMMENTED
Actionable comments posted: 2
876071fb-c83f-464b-af9a-118d1b536fc5Reviewing files that changed from the base of the PR and between
d9b8c0b19eandf90862cf76.core/libs/prx/libSceNgs2.native/src/Rack.cppcore/libs/prx/libSceNgs2.native/src/Voice.cppcore/libs/prx/libSceNgs2.native/tests/Ngs2Routing.cppcore/libs/tests/GuestLibcDoraiseSystemError.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:34:14Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: preserve the requested alignment for fixed no-overwrite mappings while normalizing ordinary fixed placements.
What I ran
45caf878748835e0bc654490cd1f713275ca7feeand the prepared diff; I did not run build or tests.description.md,commits.md,manifest.json,diff.patch, andREADME.md. All 34 changed files are marked included in the manifest; I read changed hunks and targeted repository context for the behavior-heavy changes. No excluded changed files are listed.Results
Findings
Blocking
core/libs/prx/libkernel/DirectMemory/Export.cpp:382: the new condition normalizes alignment wheneverMAP_FIXEDis set, includingMAP_FIXED | MAP_FIXED_NOREPLACE. The existing mapping code validates that the requested address satisfies the supplied alignment, and the flexible-map logic distinguishes no-overwrite mappings. With a page-aligned address that does not meet the caller’s larger alignment, this change accepts a placement that should fail alignment validation. Normalize only when the no-overwrite flag is absent; add coverage for the combined flags and a misaligned fixed address.Non-blocking
None.
Not verified
To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T22:03:46Z.
Review: COMMENTED
Actionable comments posted: 1
50017f0e-3794-4cec-ae91-2ed76586c751Reviewing files that changed from the base of the PR and between
45caf87874and1b7775dfe4.core/libs/prx/libSceNgs2.native/src/Voice.cppcore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/tests/GuestFlexibleMemoryBudget.cppdocs/dev/debt/changes/ps4-bringup.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T22:24:24Z.
Review: COMMENTED
Actionable comments posted: 1
e10bfdcf-1204-4a7e-aed7-221007464151Reviewing files that changed from the base of the PR and between
1b7775dfe4and53ba6bbf4e.core/libs/prx/libSceNgs2.native/src/Voice.cppdocs/dev/debt/changes/ps4-bringup.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T06:34:02Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
b7697fb66494ae223761f58f67e4a1eff9eabef9using the prepared description, commits, manifest, diff, and changed-file contents. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceGnmDriver/Export.cpp:207,core/libs/prx/libSceNgs2.native/src/Rack.cpp:412,core/libs/prx/libSceNgs2.native/src/Voice.cpp:448).Not verified
No tests were run. Author-reported test results and console behavior were not independently verified. All changed files listed in the manifest were read through the prepared diff; repository context beyond the diff was not read. No files were excluded from review in the manifest.
To get this to a good state
Nothing is required. Optional: confirm the documented unmeasured console behavior when hardware access is available.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T17:49:43Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the review found no verified defects in the inspected code.
What I ran
Reviewed head
bd3a63b06742969cb9de7b0b141c110a761a694bfrom the prepared diff and the pinned repository reader. No commands or tests were run; test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The review bundle lists 36 changed files, all marked included. I inspected the description, commits, manifest, full diff, and targeted source ranges in the NGS2 voice and rack logic, direct memory mapping, AGC PM4 handling, GNM context-state construction, and libc exception handling. I did not read every changed file or run tests, so the rest of the changed code and the reported platform and guest runs are not independently verified. The bundle listing did not include a
files.jsondocument.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T19:24:44Z.
Review: COMMENTED
Reviewed — comments
The change covers broad PS4 library compatibility work; this review did not verify every changed file or run the reported checks.
What I ran
Inspected the prepared description, commit list, manifest, and diff for head
b4461c9dfc1acb20ce0ff4a634bbf88a62b55c59. No commands or tests were run.Results
Findings
Blocking
None identified in the inspected diff.
Non-blocking
None.
Not verified
The complete source and behavior of the changed files were not independently verified, and no tests were run. The bundle lists 35 changed files, all included in
files/; I read the description, commits, manifest and diff, but did not read the full text of every changed file. The reported Linux, Windows, guest-runtime, and GPU validation results were not run by this review.To get this to a good state
Nothing is required. The review remains a comment because the full change and its reported checks were not independently verified.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T09:16:07Z.
Review: COMMENTED
Reviewed — comments
The reviewed changes contain substantial PS4 compatibility behavior whose console semantics remain unmeasured, and this review did not inspect every changed line or run checks.
What I ran
Read the prepared description, commits, README, manifest excerpt, and portions of the diff for head
341cf83594683d96703f66706bbb72fdd3498c3b; no commands or tests were run.Results
Findings
Blocking
None identified in the portions inspected.
Non-blocking
The description and debt notes identify multiple newly modeled PS4 behaviors as unmeasured on-console, including NGS2 layouts/events, GNM initialization bytes, and fixed-placement memory alignment. These are material compatibility assumptions; confirm them against console behavior as part of follow-up validation.
Not verified
The review did not inspect every changed line or the full text of every changed file, and did not run tests or build checks. The manifest was read only in part; the review README lists 40 changed files, and the full list of excluded files was not available. No claim is made about uninspected code.
To get this to a good state
Nothing is required. Optional: validate the documented PS4 behavior assumptions on-console and complete review of the remaining changed lines.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:41:40Z.
Review: COMMENTED
The new PS4
sceGnmDrawInitToDefaultContextStateimplementation checks the pointer for null and then copies the packet directly into guest memory. A valid command buffer can be under a guest write watch or a GPU read trap, so a plain host copy bypasses the preparation used by the adjacent command-buffer writers onmain. Please send the selected Base or Neo packet through the checked guest-output path and propagate a failed write through the export's error return. The packet-content tests can keep checking both modes.Source review of the GNM change at
341cf83594.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T22:02:59Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
8b51962cd85daebb4e88e0564b4e2ebbc6fb288awith the pinnedrepo_read.pyreader and prepared diff; no tests or build commands were run.Results
Negative control
Not run; no negative-control procedure was performed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Behavior reviewed in NGS2 voice handling, NGS2 rack options, AGC PM4 handling, and direct-memory mapping.
Not verified
The prepared manifest lists 28 changed files, all with full text available; all 28 changed-file diffs were reviewed, with no files excluded by preparation. The description reports that current-head build and focused tests could not run and remote CI is pending; those results were not independently verified. Console-specific semantics documented as unmeasured were not independently checked.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T14:57:51Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code shows no verified blocking defect, but the build and focused tests were not run on this head.
What I ran
Reviewed head
73dc63056af73ed89e6c2ce2bbdfd5066a0df669against the prepared patch; no merged preview was run. I inspected the review bundle with shell searches and reads and checked targeted changed-file context. The repository reader returned search matches but could not complete its read because it attempted to write a log in the read-only workspace. No build or test command was run.Results
Negative control
Not run; no tests were run.
Findings
Blocking
None.
Non-blocking
No code-level defect was verified. The new-head build and focused test results remain unverified.
Sources
Not verified
The full build, focused test suite, Vulkan validation comparison, and physical-console behavior were not verified on this head. The prepared manifest lists 28 changed files, all included in the diff;
files.jsonlists no excluded files. The reader did not complete source-context reads because its logging write was blocked by the read-only workspace.To get this to a good state
Nothing is required. Optional: run the pending full build and focused tests on this head before merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.