fix(agc): reject inaccessible speculative mapped-copy sources #15487

Merged
JJenkx merged 5 commits from upstream-pr/15487 into main 2026-11-10 05:08:32 +00:00
JJenkx commented 2026-11-03 14:56:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-03T14:56:33Z.


What

CopyMapped trusts cached access flags before memcpy. Arena pages can already be reset to no-access before that cache is invalidated, so speculative draw-cache key reads can segfault instead of returning a miss.

Add libc's internal GuestCopyInUnsynced_nid_no_patch, sharing the existing checked native-copy backend but skipping host-read preparation. CopyMapped uses it and preserves errno on normal returns. Ordinary GuestCopyIn and path reads still run their existing read guard/GPU-flush hook. Empty/null/overflow handling remains explicit; inaccessible or short copies return Unmapped. Other hosts retain the existing walk. The debt note distinguishes checked copying from pinning or an atomic snapshot. Linux retains the existing backend policy: EFAULT/short reads return a miss; other process_vm_readv errors (such as a denied or unavailable host facility) still throw. This intentionally exposes unsupported host facilities, with no unsafe memcpy fallback. That failure-policy limitation is not exercised by the title measurements below.

Six host fixtures cover valid data, full/partial arena resets after access-cache priming, recommit, range boundaries, and hook behavior. The hook fixture checks both that speculative copies skip preparation and that ordinary checked copies still prepare.

Overlap: the original audit scanned 1,714 open PRs,141 shared-file candidates; all 67 failed-closed heads/sharedpatches were reviewed. No same correction was found. Keep #6188's requireNotSpeculative precondition if combined; this PR does not depend on it. The new internal helper name is absent from2,945 pinned PR refs checked locally. #13664 changes errno handling in the shared libc backend; preserve that independent change when combining.

Tested

Linux 7.2.11, GCC 16.2.1, Release, Ryzen 9 7950X (16 cores/32 threads).

  • Original main negative control: main 4f41f4c375 plus the original five fixtures (73cc4f7aaecd6365e46820eb15f86b90010db89e) segfaults on full/partial reset; valid/reuse/boundary cases pass. Original controls and qualification, SHA-256 d97729c86e4c4dcd5ea3b59dc3ef078122da51901fadeb1a6d8e2eae9655ee33.
  • Read-preparation negative control: published 46941c1c37a plus the exact new hook fixture fails only agc_mapped_copy_hooks: a speculative mapped copy ran read guards or flushed GPU writes. The other five cases pass.
  • Latest revision beed64fa73ba7446c9a00fd07059b478d8d0b068: all six host cases pass three repetitions each (18 passes, zero skips), ICD disabled. Public-header audit, conventions and whitespace checks pass.
  • Matched GPU/host regression group: latest revision passes the same seven shader-memory/draw-cache/user-value relocation tests as the original main-production control 73cc4f7aaec: 7/7 each, zero skips and zero VUIDs, actual Khronos layer insertion in both verbose logs. Same RX 6650 XT / RADV NAVI23, Mesa 26.2.6, Linux 7.2.11 and required ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Control GuestMemory/General sources are byte-identical to main 4f41f4c375; that unchanged control was reused, not rerun.
  • Newer-main integration (1e658521a0a, after the depth/DCC/pool merges): main + common #15436 (de31b5b25c4) and the same base + this PR (91842997246) each pass the same 15/15 focused tests on RX 6650 XT / Mesa 26.2.6 / Linux 7.2.11, actual VVL, zero VUIDs/skips, unchanged source/library hashes. The revised six host-only cases also pass with ICD disabled. No source changes were needed to integrate the five PR commits. Fresh matrix, verbose logs, build/host results and provenance, SHA-256 3f3bf172ce441c9c726bca26f850d394579c3bbe6bfbc2bdc5a9fa8cec506d72 (GitHub digest verified). The frame-time table below remains explicitly for the earlier pinned 4f41f4c375 base.
  • Fixture creation remains guarded by BUILD_TESTING; ON/OFF configuration checks are documented in the preceding CMake-only follow-up.
  • The earlier prepared-copy variant plus common main-stack fix #15436 (4199ddb20550) completed one 603.3-second cold OuterWilds run with normal native/GDB exit and reviewed outdoor night/daylight captures. That is not a title result for the new unsynchronized revision.
  • Windows exact-head check: Windows 11 / MinGW GCC 15.2 report: all six host cases pass on beed64fa73; the identical-fixture negative control a2b477f661 fails only hooks. The worker verified the new helper is exported from libc and imported by AGC. Host-only; no Windows GPU/title claim.
  • Native cost and call counts: measured below. The earlier ~0.9 µs extra/256-byte microbenchmark was for the prepared variant; it is not a cost measurement for this revision. macOS has not been run. No speedup or zero-cost claim.

Latest hook negative control,18 host passes,7/7 regression logs,source hashes and revision patch — SHA-256 75f74a5c093be979d34ffcd2465e0b21e33e28d6640cb75a0d38ec2d7f0d0ea1 (GitHub digest verified). No game assets, requests, shaders or saves are included.

Native title cost and speculative-copy traffic

Outer Wilds PPSA08102 01.000.000, same Ryzen 9 7950X / RX 6650 XT RADV Mesa 26.2.6 / Linux 7.2.11, 3840×2160. Both arms include the same adopted-main-stack prerequisite #15436 (4199ddb20550) over main 4f41f4c375; the change adds only this PR (beed64fa73, integration fa835ef16fe8). These are not vanilla-main results. Same fresh seed including memory saves, scripted wake at 180 s, warm separate caches with the same shader SourceVersion, same camera and 270:20 trace window, ordinary close at 440 s. Production arms contain no copy counter, draw profiler or CPU sampler.

Production attempt Presents Window ms FPS Mean ms/present p50 ms GPU busy ms/present
a1-control 266 20058.402 13.261 75.408 75.389 67.932
b1-nosync 243 20063.766 12.111 82.567 82.305 77.409
b2-nosync 240 20047.406 11.972 83.531 82.972 77.239
a3-control-retry 246 20076.227 12.253 81.611 81.455 76.243

Failed attempt retained: A2 control crashed with SIGSEGV in describePages<CopyMapped> → CopyMapped → relocatedContentKey → drawRegisterKey at 137.6 s, before its trace. Its observer exits 86; it has no timing result. Actual order was A1, B1, B2, failed A2, separate private count diagnostic, then one bounded A3 control retry. This is not a completed original ABBA sequence. All four successful production runs and the separate diagnostic have verified normal native exit, scheduled close, no remaining native PID, unchanged SDK/generated hashes and restored kernel setting.

Pooled successful production windows: control 12.757 FPS / 78.388 ms per present, change 12.042 FPS / 83.046 ms per present. The observed change is +5.94% ms/present / -5.61% FPS. These slower measurements are retained. Controls vary substantially, the sky/lighting/celestial positions animate, and GPU busy time differs; this small dataset does not isolate a causal CopyMapped cost or establish statistical significance. No zero-overhead claim.

All successful traces report no dropped events. Sampled build/profiler process lists were empty during the measurement windows; this does not exclude all desktop/background load. Direct review confirms the pre-wake prompt and same outdoor camera/trees/tower/tutorial. Primary and X11 post-trace captures are attached; flagged small differences and animated-world limitations remain in the scene reviews.

Separate count diagnostic: private 79d494c7ca98 adds only a window-gated counter over the production integration; its patch and 3-copies/28-bytes CPU self-check are attached. While trace recording is active, 1,606 attempts / 321,792 requested bytes / 242 presents = 6.636 attempts and 1329.719 requested bytes per present. These are attempted requests, not successful-copy bytes. Diagnostic timing is excluded from every production comparison.

Current native backend microbenchmark: exact production libc, valid 256-byte GuestCopyInUnsynced, five × 200,000 calls with data/checksum verification: median 843.353 ns/call. This measures only the native helper, not the full CopyMapped wrapper, a main/change difference, or game frame cost.

Traces, full summaries/digests, captures, success/failure receipts, count patch/self-check, SDK hashes, helper benchmark and Windows/CI references — SHA-256 cfd4860f6813ee33d25e3f48ff23ba31ce8c1290787c48af7f066da696199c2a (internal manifest verified; no game assets, binaries, shaders, requests or saves).

All four production summary lines (diagnostic excluded)
{"commit":"4199ddb20550","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4621,"ms":20058.402},"presents":266,"frame_ms":{"p50":75.389,"p90":80.406,"p99":113.465,"max":133.097},"gpu_busy_ms_per_present":67.932,"worker_busy_pct":{"queue worker 0x0":47.973},"top_phases_ms_per_frame":{"Driver.Packet":35.209,"Driver.Present":34.842,"VideoOut.Flip":34.77,"VideoOut.Flip.present":34.707,"Driver.Present.render_fence_wait":34.393,"Vulkan.Retire":34.393,"Vulkan.Retire.wait":34.378,"Driver.Packet.draw":25.398},"trace_dropped":false,"trace":"aps5-trace-4199ddb20550-2040365.json.gz"}
{"commit":"fa835ef16fe8","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4130,"ms":20063.766},"presents":243,"frame_ms":{"p50":82.305,"p90":86.78,"p99":118.91,"max":126.477},"gpu_busy_ms_per_present":77.409,"worker_busy_pct":{"queue worker 0x0":37.298},"top_phases_ms_per_frame":{"Driver.Present":46.119,"VideoOut.Flip":45.982,"VideoOut.Flip.present":45.922,"Driver.Present.render_fence_wait":45.715,"Vulkan.Retire":45.715,"Vulkan.Retire.wait":45.696,"Driver.Packet":29.922,"Driver.DrawFinish":22.576},"trace_dropped":false,"trace":"aps5-trace-fa835ef16fe8-2214384.json.gz"}
{"commit":"fa835ef16fe8","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4222,"ms":20047.406},"presents":240,"frame_ms":{"p50":82.972,"p90":88.873,"p99":120.119,"max":142.976},"gpu_busy_ms_per_present":77.239,"worker_busy_pct":{"queue worker 0x0":38.476},"top_phases_ms_per_frame":{"Driver.Present":45.831,"VideoOut.Flip":45.7,"VideoOut.Flip.present":45.629,"Driver.Present.render_fence_wait":45.427,"Vulkan.Retire":45.427,"Vulkan.Retire.wait":45.41,"Driver.Packet":31.224,"Driver.DrawFinish":23.0},"trace_dropped":false,"trace":"aps5-trace-fa835ef16fe8-2382514.json.gz"}
{"commit":"4199ddb20550","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4330,"ms":20076.227},"presents":246,"frame_ms":{"p50":81.455,"p90":85.841,"p99":118.635,"max":123.274},"gpu_busy_ms_per_present":76.243,"worker_busy_pct":{"queue worker 0x0":38.652},"top_phases_ms_per_frame":{"Driver.Present":44.544,"VideoOut.Flip":44.431,"VideoOut.Flip.present":44.368,"Driver.Present.render_fence_wait":44.111,"Vulkan.Retire":44.111,"Vulkan.Retire.wait":44.093,"Driver.Packet":30.564,"Driver.DrawFinish":22.623},"trace_dropped":false,"trace":"aps5-trace-4199ddb20550-2829800.json.gz"}

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: AMD RX 6650 XT / RADV NAVI23, Mesa 26.2.6, Linux 7.2.11
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5139407516 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15487). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-03T14:56:33Z. --- ### What `CopyMapped` trusts cached access flags before `memcpy`. Arena pages can already be reset to no-access before that cache is invalidated, so speculative draw-cache key reads can segfault instead of returning a miss. Add libc's internal `GuestCopyInUnsynced_nid_no_patch`, sharing the existing checked native-copy backend but skipping host-read preparation. `CopyMapped` uses it and preserves `errno` on normal returns. Ordinary `GuestCopyIn` and path reads still run their existing read guard/GPU-flush hook. Empty/null/overflow handling remains explicit; inaccessible or short copies return `Unmapped`. Other hosts retain the existing walk. The debt note distinguishes checked copying from pinning or an atomic snapshot. Linux retains the existing backend policy: `EFAULT`/short reads return a miss; other `process_vm_readv` errors (such as a denied or unavailable host facility) still throw. This intentionally exposes unsupported host facilities, with no unsafe `memcpy` fallback. That failure-policy limitation is not exercised by the title measurements below. Six host fixtures cover valid data, full/partial arena resets after access-cache priming, recommit, range boundaries, and hook behavior. The hook fixture checks both that speculative copies skip preparation and that ordinary checked copies still prepare. Overlap: the original audit scanned 1,714 open PRs,141 shared-file candidates; all 67 failed-closed heads/sharedpatches were reviewed. No same correction was found. Keep #6188's `requireNotSpeculative` precondition if combined; this PR does not depend on it. The new internal helper name is absent from2,945 pinned PR refs checked locally. #13664 changes errno handling in the shared libc backend; preserve that independent change when combining. ### Tested Linux 7.2.11, GCC 16.2.1, Release, Ryzen 9 7950X (16 cores/32 threads). - **Original main negative control:** main `4f41f4c375` plus the original five fixtures (`73cc4f7aaecd6365e46820eb15f86b90010db89e`) segfaults on full/partial reset; valid/reuse/boundary cases pass. [Original controls and qualification](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/agc-checked-mapped-copy-5f5c592c-20261103.tar.gz), SHA-256 `d97729c86e4c4dcd5ea3b59dc3ef078122da51901fadeb1a6d8e2eae9655ee33`. - **Read-preparation negative control:** published `46941c1c37a` plus the exact new hook fixture fails only `agc_mapped_copy_hooks`: `a speculative mapped copy ran read guards or flushed GPU writes`. The other five cases pass. - **Latest revision `beed64fa73ba7446c9a00fd07059b478d8d0b068`:** all six host cases pass three repetitions each (**18 passes, zero skips**), ICD disabled. Public-header audit, conventions and whitespace checks pass. - **Matched GPU/host regression group:** latest revision passes the same seven shader-memory/draw-cache/user-value relocation tests as the original main-production control `73cc4f7aaec`: **7/7 each**, zero skips and zero VUIDs, actual Khronos layer insertion in both verbose logs. Same RX 6650 XT / RADV NAVI23, Mesa 26.2.6, Linux 7.2.11 and required `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. Control GuestMemory/General sources are byte-identical to main `4f41f4c375`; that unchanged control was reused, not rerun. - **Newer-main integration** (`1e658521a0a`, after the depth/DCC/pool merges): main + common #15436 (`de31b5b25c4`) and the same base + this PR (`91842997246`) each pass the same **15/15** focused tests on RX 6650 XT / Mesa 26.2.6 / Linux 7.2.11, actual VVL, zero VUIDs/skips, unchanged source/library hashes. The revised six host-only cases also pass with ICD disabled. No source changes were needed to integrate the five PR commits. [Fresh matrix, verbose logs, build/host results and provenance](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/agc-main1e-nosync-vertex-matrix-20261103.tar.gz), SHA-256 `3f3bf172ce441c9c726bca26f850d394579c3bbe6bfbc2bdc5a9fa8cec506d72` (GitHub digest verified). The frame-time table below remains explicitly for the earlier pinned `4f41f4c375` base. - Fixture creation remains guarded by `BUILD_TESTING`; ON/OFF configuration checks are documented in the preceding CMake-only follow-up. - The earlier prepared-copy variant plus common main-stack fix #15436 (`4199ddb20550`) completed one 603.3-second cold OuterWilds run with normal native/GDB exit and reviewed outdoor night/daylight captures. That is **not** a title result for the new unsynchronized revision. - **Windows exact-head check:** [Windows 11 / MinGW GCC 15.2 report](https://github.com/boykopovar/AnyPS5/pull/15487#issuecomment-6609993276): all six host cases pass on `beed64fa73`; the identical-fixture negative control `a2b477f661` fails only hooks. The worker verified the new helper is exported from libc and imported by AGC. Host-only; no Windows GPU/title claim. - **Native cost and call counts:** measured below. The earlier ~0.9 µs extra/256-byte microbenchmark was for the prepared variant; it is not a cost measurement for this revision. macOS has not been run. No speedup or zero-cost claim. [Latest hook negative control,18 host passes,7/7 regression logs,source hashes and revision patch](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/agc-mapped-copy-nosync-beed64fa-20261103.tar.gz) — SHA-256 `75f74a5c093be979d34ffcd2465e0b21e33e28d6640cb75a0d38ec2d7f0d0ea1` (GitHub digest verified). No game assets, requests, shaders or saves are included. <!-- 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. --> #### Native title cost and speculative-copy traffic Outer Wilds PPSA08102 01.000.000, same Ryzen 9 7950X / RX 6650 XT RADV Mesa 26.2.6 / Linux 7.2.11, 3840×2160. Both arms include the same adopted-main-stack prerequisite #15436 (`4199ddb20550`) over main `4f41f4c375`; the change adds only this PR (`beed64fa73`, integration `fa835ef16fe8`). These are not vanilla-main results. Same fresh seed including memory saves, scripted wake at 180 s, warm separate caches with the same shader SourceVersion, same camera and 270:20 trace window, ordinary close at 440 s. Production arms contain no copy counter, draw profiler or CPU sampler. | Production attempt | Presents | Window ms | FPS | Mean ms/present | p50 ms | GPU busy ms/present | |---|---:|---:|---:|---:|---:|---:| | a1-control | 266 | 20058.402 | 13.261 | 75.408 | 75.389 | 67.932 | | b1-nosync | 243 | 20063.766 | 12.111 | 82.567 | 82.305 | 77.409 | | b2-nosync | 240 | 20047.406 | 11.972 | 83.531 | 82.972 | 77.239 | | a3-control-retry | 246 | 20076.227 | 12.253 | 81.611 | 81.455 | 76.243 | **Failed attempt retained:** A2 control crashed with SIGSEGV in `describePages<CopyMapped> → CopyMapped → relocatedContentKey → drawRegisterKey` at 137.6 s, before its trace. Its observer exits 86; it has no timing result. Actual order was A1, B1, B2, failed A2, separate private count diagnostic, then one bounded A3 control retry. This is not a completed original ABBA sequence. All four successful production runs and the separate diagnostic have verified normal native exit, scheduled close, no remaining native PID, unchanged SDK/generated hashes and restored kernel setting. Pooled successful production windows: control **12.757 FPS / 78.388 ms per present**, change **12.042 FPS / 83.046 ms per present**. The observed change is **+5.94% ms/present / -5.61% FPS**. These slower measurements are retained. Controls vary substantially, the sky/lighting/celestial positions animate, and GPU busy time differs; this small dataset does **not isolate a causal CopyMapped cost or establish statistical significance**. No zero-overhead claim. All successful traces report no dropped events. Sampled build/profiler process lists were empty during the measurement windows; this does not exclude all desktop/background load. Direct review confirms the pre-wake prompt and same outdoor camera/trees/tower/tutorial. Primary and X11 post-trace captures are attached; flagged small differences and animated-world limitations remain in the scene reviews. **Separate count diagnostic:** private `79d494c7ca98` adds only a window-gated counter over the production integration; its patch and 3-copies/28-bytes CPU self-check are attached. While trace recording is active, **1,606 attempts / 321,792 requested bytes / 242 presents = 6.636 attempts and 1329.719 requested bytes per present**. These are attempted requests, not successful-copy bytes. Diagnostic timing is excluded from every production comparison. **Current native backend microbenchmark:** exact production libc, valid 256-byte `GuestCopyInUnsynced`, five × 200,000 calls with data/checksum verification: median **843.353 ns/call**. This measures only the native helper, not the full CopyMapped wrapper, a main/change difference, or game frame cost. [Traces, full summaries/digests, captures, success/failure receipts, count patch/self-check, SDK hashes, helper benchmark and Windows/CI references](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/agc-nosync-beed64fa-native-cost-count-20261103.tar.gz) — SHA-256 `cfd4860f6813ee33d25e3f48ff23ba31ce8c1290787c48af7f066da696199c2a` (internal manifest verified; no game assets, binaries, shaders, requests or saves). <details> <summary>All four production summary lines (diagnostic excluded)</summary> ```json {"commit":"4199ddb20550","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4621,"ms":20058.402},"presents":266,"frame_ms":{"p50":75.389,"p90":80.406,"p99":113.465,"max":133.097},"gpu_busy_ms_per_present":67.932,"worker_busy_pct":{"queue worker 0x0":47.973},"top_phases_ms_per_frame":{"Driver.Packet":35.209,"Driver.Present":34.842,"VideoOut.Flip":34.77,"VideoOut.Flip.present":34.707,"Driver.Present.render_fence_wait":34.393,"Vulkan.Retire":34.393,"Vulkan.Retire.wait":34.378,"Driver.Packet.draw":25.398},"trace_dropped":false,"trace":"aps5-trace-4199ddb20550-2040365.json.gz"} {"commit":"fa835ef16fe8","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4130,"ms":20063.766},"presents":243,"frame_ms":{"p50":82.305,"p90":86.78,"p99":118.91,"max":126.477},"gpu_busy_ms_per_present":77.409,"worker_busy_pct":{"queue worker 0x0":37.298},"top_phases_ms_per_frame":{"Driver.Present":46.119,"VideoOut.Flip":45.982,"VideoOut.Flip.present":45.922,"Driver.Present.render_fence_wait":45.715,"Vulkan.Retire":45.715,"Vulkan.Retire.wait":45.696,"Driver.Packet":29.922,"Driver.DrawFinish":22.576},"trace_dropped":false,"trace":"aps5-trace-fa835ef16fe8-2214384.json.gz"} {"commit":"fa835ef16fe8","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4222,"ms":20047.406},"presents":240,"frame_ms":{"p50":82.972,"p90":88.873,"p99":120.119,"max":142.976},"gpu_busy_ms_per_present":77.239,"worker_busy_pct":{"queue worker 0x0":38.476},"top_phases_ms_per_frame":{"Driver.Present":45.831,"VideoOut.Flip":45.7,"VideoOut.Flip.present":45.629,"Driver.Present.render_fence_wait":45.427,"Vulkan.Retire":45.427,"Vulkan.Retire.wait":45.41,"Driver.Packet":31.224,"Driver.DrawFinish":23.0},"trace_dropped":false,"trace":"aps5-trace-fa835ef16fe8-2382514.json.gz"} {"commit":"4199ddb20550","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_SECONDS":"270:20"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA08102","title":"Outer Wilds","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 270:20","first_present":4330,"ms":20076.227},"presents":246,"frame_ms":{"p50":81.455,"p90":85.841,"p99":118.635,"max":123.274},"gpu_busy_ms_per_present":76.243,"worker_busy_pct":{"queue worker 0x0":38.652},"top_phases_ms_per_frame":{"Driver.Present":44.544,"VideoOut.Flip":44.431,"VideoOut.Flip.present":44.368,"Driver.Present.render_fence_wait":44.111,"Vulkan.Retire":44.111,"Vulkan.Retire.wait":44.093,"Driver.Packet":30.564,"Driver.DrawFinish":22.623},"trace_dropped":false,"trace":"aps5-trace-4199ddb20550-2829800.json.gz"} ``` </details> ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- 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: AMD RX 6650 XT / RADV NAVI23, Mesa 26.2.6, Linux 7.2.11 <!-- 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 (Codex) <!-- yes / no -->
XairRrR commented 2026-11-03 15:22:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:22:45Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The checked native copy stops the CopyMapped SIGSEGV on reset arena pages, and the negative control confirms it. But at this head, every speculative CopyMapped read now goes through the AGC host-read hook. That hook runs a read guard that can throw and a GPU-write flush, and the old path did neither.

What I ran

Head 46941c1c37a9de3d8d719b769bc8741c2de61a25, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 203ccfa893ab7dd1a4f857a179bb9f0b750b65ea (Release, GCC 14.2.0, Ninja, Debian 13 VM, lavapipe).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...46941c1c37a9de3d8d719b769bc8741c2de61a25
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure
# negative control
git show 4f41f4c375f5abb487dbd184fbc150f31994d762:core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp > core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp
git show 4f41f4c375f5abb487dbd184fbc150f31994d762:core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp > core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp
ninja -C build -j32 -l32 agc_mapped_copy_tests
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure
# restore
git show 203ccfa893ab7dd1a4f857a179bb9f0b750b65ea:<both paths> > <both paths>
ninja -C build -j32 -l32
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_"
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (script) ok
Selected tests (script) 2218 ran, no new failures, no timeouts; 7 known failures that also fail on main; agc_driver_alpha_to_coverage_sample_mask_export passed after a rerun
Validation layer (script) 770 tests, layer loaded in 769, none missing, 0 tests with new VUID- lines
agc_mapped_copy_{valid,reset,partial,reuse,boundaries} on merged tree 5/5 pass
Same tests with main's GuestMemory.cpp/.hpp reset and partial SegFault; the other 3 pass
Worktree after restore git status --porcelain empty; 5/5 pass again
Negative control output
1/5 Test #2101: agc_mapped_copy_reset ............***Exception: SegFault  0.01 sec
2/5 Test #2104: agc_mapped_copy_boundaries .......   Passed    0.01 sec
3/5 Test #2103: agc_mapped_copy_reuse ............   Passed    0.01 sec
4/5 Test #2102: agc_mapped_copy_partial ..........***Exception: SegFault  0.01 sec
5/5 Test #2100: agc_mapped_copy_valid ............   Passed    0.01 sec
60% tests passed, 2 tests failed out of 5

Negative control

I restored only the production files (Execution/src/GuestMemory.cpp, Execution/include/GuestMemory.hpp) from main and rebuilt agc_mapped_copy_tests. reset and partial crash with SIGSEGV, as the description says, and valid, reuse and boundaries pass on both arms. Then I restored the merged files, rebuilt, and the tests passed again with a clean worktree.

Findings

Blocking

1. Speculative CopyMapped reads now run the host-read hook, which can throw and flushes GPU writes.

core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:2988-2992 calls GuestCopyIn_nid_no_patch. That leads to CopyGuestBytes (core/libs/prx/libc/src/General.cpp:86-87), then to GuestArenaPrepareHostRead_nid_no_patch, and then to the AGC hook PrepareHostRead (GuestMemory.cpp:2806-2808). The hook runs:

  • The read guard. It is installed as guardReads (core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp:911-912), which calls RequireNoMultisampleTarget, and that throws std::runtime_error when the range overlaps a guarded multisampled color target or FMASK (MultisampleTarget.cpp:1676-1686). Two calls are affected:

    • DrawRelocate.cpp:101 copies 4 KiB from any user-data pair that looks like a callee pointer, to test whether it holds code.
    • DrawRelocate.cpp:54 reads relocation content for the draw key. That read runs from drawRegisterKey (Draw.cpp:418) before the cache lookup.

    Both are guesses: the old walk just read the bytes or answered Unmapped. Now a guess that lands on a host-only multisample target aborts the draw with an exception. That is a new failure mode, a throw in place of the old SIGSEGV for this class of address. Nobody has raised this part before.

  • FlushGpuWrites. oneandonlydean already raised this. I confirm it on the merged tree: the hook is installed by Recorder.cpp:1308 (FlushForAccess), and it also now runs inside validateCaptured's masked re-read (Execution/src/Driver/Memory/CaptureValidation.cpp:85). The author agreed in the discussion that this was not intended and said a revision is coming. This head does not contain it yet.

Suggested fix: as the author proposed, split the checked native copy from the host-read preparation. For example, add a libc helper that does only the process_vm_readv/ReadProcessMemory/mach_vm_read_overwrite step, and use it from CopyMapped. Then add a fixture that installs a throwing read guard and a counting flush hook, and checks that CopyMapped calls neither while Read still calls both.

Non-blocking

2. A non-EFAULT failure in process_vm_readv now throws from a speculative read. core/libs/prx/libc/src/General.cpp:95 throws for any errno other than EFAULT, for example EPERM or ENOSYS under a restrictive seccomp or ptrace policy. Before this PR, CopyMapped never made that syscall. A checked-copy helper for speculative use could map those errors to Unmapped, or the PR could state that throwing is intended.

3. Cost on the draw path is unmeasured. oneandonlydean already raised this. The description's own microbenchmark goes from about 11 ns to about 911 ns per 256-byte copy, and relocatedContentKey makes one copy per chunk of up to 64 words on every productive-relocation draw, cache hits included. No title frame-time comparison is attached. The author has said those numbers are coming. This PR claims no speedup, so it is not a perf PR, but the cost should be known before merge.

Not verified

  • Windows (ReadProcessMemory) and macOS (mach_vm_read_overwrite): I only built and ran on Linux.
  • I did not trigger the read-guard throw in a running test. Finding 1 rests on reading the call chain in the merged tree.
  • The author's RX 6650 XT / RADV results and the attached archives: I have no network access and did not check them.
  • Title behaviour and frame time (PPSA08102): no title was launched.

To get this to a good state

  1. Make the speculative CopyMapped path skip GuestArenaPrepareHostRead (no read guard, no FlushGpuWrites), keeping the checked native copy and the reset and partial-reset fixtures.
  2. Add a fixture showing that CopyMapped calls neither the read guard nor the flush hook. Ideally, also show that a throwing guard does not escape from it.
  3. Decide how non-EFAULT errors from the native copy are handled on the speculative path.
  4. Attach the call/byte counts and the matched main/change frame-time comparison that were requested in the discussion.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5754806869 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15487#pullrequestreview-5754806869). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T15:22:45Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The checked native copy stops the `CopyMapped` SIGSEGV on reset arena pages, and the negative control confirms it. But at this head, every speculative `CopyMapped` read now goes through the AGC host-read hook. That hook runs a read guard that can throw and a GPU-write flush, and the old path did neither. ## What I ran Head `46941c1c37a9de3d8d719b769bc8741c2de61a25`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `203ccfa893ab7dd1a4f857a179bb9f0b750b65ea` (Release, GCC 14.2.0, Ninja, Debian 13 VM, lavapipe). ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...46941c1c37a9de3d8d719b769bc8741c2de61a25 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure # negative control git show 4f41f4c375f5abb487dbd184fbc150f31994d762:core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp > core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp git show 4f41f4c375f5abb487dbd184fbc150f31994d762:core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp > core/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hpp ninja -C build -j32 -l32 agc_mapped_copy_tests ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure # restore git show 203ccfa893ab7dd1a4f857a179bb9f0b750b65ea:<both paths> > <both paths> ninja -C build -j32 -l32 ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (script) | ok | | Selected tests (script) | 2218 ran, no new failures, no timeouts; 7 known failures that also fail on `main`; `agc_driver_alpha_to_coverage_sample_mask_export` passed after a rerun | | Validation layer (script) | 770 tests, layer loaded in 769, none missing, 0 tests with new `VUID-` lines | | `agc_mapped_copy_{valid,reset,partial,reuse,boundaries}` on merged tree | 5/5 pass | | Same tests with `main`'s `GuestMemory.cpp/.hpp` | `reset` and `partial` SegFault; the other 3 pass | | Worktree after restore | `git status --porcelain` empty; 5/5 pass again | <details><summary>Negative control output</summary> ``` 1/5 Test #2101: agc_mapped_copy_reset ............***Exception: SegFault 0.01 sec 2/5 Test #2104: agc_mapped_copy_boundaries ....... Passed 0.01 sec 3/5 Test #2103: agc_mapped_copy_reuse ............ Passed 0.01 sec 4/5 Test #2102: agc_mapped_copy_partial ..........***Exception: SegFault 0.01 sec 5/5 Test #2100: agc_mapped_copy_valid ............ Passed 0.01 sec 60% tests passed, 2 tests failed out of 5 ``` </details> ## Negative control I restored only the production files (`Execution/src/GuestMemory.cpp`, `Execution/include/GuestMemory.hpp`) from `main` and rebuilt `agc_mapped_copy_tests`. `reset` and `partial` crash with SIGSEGV, as the description says, and `valid`, `reuse` and `boundaries` pass on both arms. Then I restored the merged files, rebuilt, and the tests passed again with a clean worktree. ## Findings ### Blocking **1. Speculative `CopyMapped` reads now run the host-read hook, which can throw and flushes GPU writes.** `core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:2988-2992` calls `GuestCopyIn_nid_no_patch`. That leads to `CopyGuestBytes` (`core/libs/prx/libc/src/General.cpp:86-87`), then to `GuestArenaPrepareHostRead_nid_no_patch`, and then to the AGC hook `PrepareHostRead` (`GuestMemory.cpp:2806-2808`). The hook runs: - **The read guard.** It is installed as `guardReads` (`core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp:911-912`), which calls `RequireNoMultisampleTarget`, and that throws `std::runtime_error` when the range overlaps a guarded multisampled color target or FMASK (`MultisampleTarget.cpp:1676-1686`). Two calls are affected: - `DrawRelocate.cpp:101` copies 4 KiB from any user-data pair that looks like a callee pointer, to test whether it holds code. - `DrawRelocate.cpp:54` reads relocation content for the draw key. That read runs from `drawRegisterKey` (`Draw.cpp:418`) before the cache lookup. Both are guesses: the old walk just read the bytes or answered `Unmapped`. Now a guess that lands on a host-only multisample target aborts the draw with an exception. That is a new failure mode, a throw in place of the old SIGSEGV for this class of address. Nobody has raised this part before. - **`FlushGpuWrites`.** `oneandonlydean` already raised this. I confirm it on the merged tree: the hook is installed by `Recorder.cpp:1308` (`FlushForAccess`), and it also now runs inside `validateCaptured`'s masked re-read (`Execution/src/Driver/Memory/CaptureValidation.cpp:85`). The author agreed in the discussion that this was not intended and said a revision is coming. This head does not contain it yet. Suggested fix: as the author proposed, split the checked native copy from the host-read preparation. For example, add a libc helper that does only the `process_vm_readv`/`ReadProcessMemory`/`mach_vm_read_overwrite` step, and use it from `CopyMapped`. Then add a fixture that installs a throwing read guard and a counting flush hook, and checks that `CopyMapped` calls neither while `Read` still calls both. ### Non-blocking **2. A non-`EFAULT` failure in `process_vm_readv` now throws from a speculative read.** `core/libs/prx/libc/src/General.cpp:95` throws for any errno other than `EFAULT`, for example `EPERM` or `ENOSYS` under a restrictive seccomp or ptrace policy. Before this PR, `CopyMapped` never made that syscall. A checked-copy helper for speculative use could map those errors to `Unmapped`, or the PR could state that throwing is intended. **3. Cost on the draw path is unmeasured.** `oneandonlydean` already raised this. The description's own microbenchmark goes from about 11 ns to about 911 ns per 256-byte copy, and `relocatedContentKey` makes one copy per chunk of up to 64 words on every productive-relocation draw, cache hits included. No title frame-time comparison is attached. The author has said those numbers are coming. This PR claims no speedup, so it is not a perf PR, but the cost should be known before merge. ## Not verified - Windows (`ReadProcessMemory`) and macOS (`mach_vm_read_overwrite`): I only built and ran on Linux. - I did not trigger the read-guard throw in a running test. Finding 1 rests on reading the call chain in the merged tree. - The author's RX 6650 XT / RADV results and the attached archives: I have no network access and did not check them. - Title behaviour and frame time (PPSA08102): no title was launched. ## To get this to a good state 1. Make the speculative `CopyMapped` path skip `GuestArenaPrepareHostRead` (no read guard, no `FlushGpuWrites`), keeping the checked native copy and the reset and partial-reset fixtures. 2. Add a fixture showing that `CopyMapped` calls neither the read guard nor the flush hook. Ideally, also show that a throwing guard does not escape from it. 3. Decide how non-`EFAULT` errors from the native copy are handled on the speculative path. 4. Attach the call/byte counts and the matched `main`/change frame-time comparison that were requested in the discussion. <!-- anyps5-bots job=3405 head=46941c1c37a9de3d8d719b769bc8741c2de61a25 -->
XairRrR commented 2026-11-03 16:29:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T16:29:43Z.

Review: APPROVED


Re-checked — approved

Since my last review, a2b477f661 adds a hook fixture and beed64fa73 switches CopyMapped to a new libc helper, GuestCopyInUnsynced_nid_no_patch. The helper makes the checked native copy without GuestArenaPrepareHostRead, so the blocking finding is resolved.

What changed since my last review

  • core/libs/prx/libc/src/General.cpp:86-87: CopyGuestBytes now takes a prepare flag. The new GuestCopyInUnsynced_nid_no_patch (General.cpp:856) has the same empty, null and overflow checks as GuestCopyIn_nid_no_patch and passes prepare = false. It is declared in core/libs/prx/libc/include/General.hpp.
  • core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:2990: CopyMapped calls the unsynced helper instead of GuestCopyIn_nid_no_patch.
  • tests/MappedCopy.cpp: a new hooks mode installs counting read-guard and flush hooks. It checks that CopyMapped calls neither hook and that GuestCopyIn_nid_no_patch still calls each hook once. The CMake fragment registers this sixth mode.
  • The debt entry now says the copy runs "without host-read synchronization".
  • In the discussion, the author agreed that the flush was not intended. They say the title call/byte counts and the frame-time comparison are still pending.

What I ran

Head beed64fa73ba7446c9a00fd07059b478d8d0b068, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 4bcca7692fa617f50d931caf5ced9d00be98d1ef. Release build with GCC 14.2.0 and Ninja, on a Debian 13 VM with lavapipe.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...beed64fa73ba7446c9a00fd07059b478d8d0b068
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure
# negative control A: main's production files
git show 4f41f4c375f5abb487dbd184fbc150f31994d762:<path> > <path>   # GuestMemory.cpp/.hpp, libc General.cpp/.hpp
ninja -C build -j32 -l32 agc_mapped_copy_tests
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_"
# negative control B: previously reviewed head's production files
git show 46941c1c37a9de3d8d719b769bc8741c2de61a25:<path> > <path>   # same four files
ninja -C build -j32 -l32 agc_mapped_copy_tests
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure
# restore
git show 4bcca7692fa617f50d931caf5ced9d00be98d1ef:<path> > <path>
ninja -C build -j32 -l32
ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_"
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (script) ok
Selected tests (script) 3728 ran, no new failures or timeouts; 9 known failures that also fail on main
Validation layer (script) 770 tests, layer loaded in 769, none missing, 0 tests with new VUID- lines
agc_mapped_copy_* on the merged tree 6/6 pass
Control A (main production files) reset and partial SegFault; the other 4 pass
Control B (46941c1c37 production files) only hooks fails: a speculative mapped copy ran read guards or flushed GPU writes
After restoring the merged files 6/6 pass; git status --porcelain empty

The script's check also reports guest_net_ctl as an unexpected skip, but main has the same skip, so it is not from this PR.

Negative control B output
1/6 Test #2101: agc_mapped_copy_reset ............   Passed    0.01 sec
2/6 Test #2102: agc_mapped_copy_partial ..........   Passed    0.01 sec
3/6 Test #2103: agc_mapped_copy_reuse ............   Passed    0.01 sec
4/6 Test #2105: agc_mapped_copy_hooks ............***Failed    0.01 sec
a speculative mapped copy ran read guards or flushed GPU writes
5/6 Test #2100: agc_mapped_copy_valid ............   Passed    0.01 sec
6/6 Test #2104: agc_mapped_copy_boundaries .......   Passed    0.00 sec
83% tests passed, 1 tests failed out of 6

Control A confirms that the reset fixtures still catch the original crash. Control B confirms that the new hooks fixture catches the read preparation this revision removes. Both results match the author's description.

Previous findings

  1. Speculative CopyMapped runs the host-read hook (read guard that can throw, FlushGpuWrites). Resolved. CopyMapped now calls CopyGuestBytes(..., false), which skips GuestArenaPrepareHostRead. The hooks fixture shows the speculative path calls neither hook while the ordinary path still calls both, and it fails on the previous head (control B). Because the guard is never called, a throwing guard cannot escape CopyMapped, so I don't need a separate throwing-guard fixture. The masked re-read in CaptureValidation.cpp returns to main's behaviour: no flush.
  2. A non-EFAULT process_vm_readv failure throws from a speculative read (non-blocking). Still open. core/libs/prx/libc/src/General.cpp:95 still throws for any errno other than EFAULT, and the unsynced helper inherits that throw. On main, CopyMapped never made this syscall. This only matters under a seccomp or ptrace policy that denies the syscall, so I'm not blocking on it. Mapping those errors to false in the unsynced path, or stating that the throw is intended, would settle it.
  3. Cost on the draw path is unmeasured (non-blocking). Still open, and the author says it is pending. The prepared-variant microbenchmark no longer applies, because the flush and guard are gone. But each chunk read is still one syscall instead of a cached walk. No title numbers are attached, and the PR claims no speedup.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • Windows (ReadProcessMemory) and macOS (mach_vm_read_overwrite) behaviour of the unsynced path. I only built and ran on Linux. The author has asked for a Windows run, and no result is posted yet.
  • The author's RX 6650 XT / RADV results and the attached archives. I have no network access and did not check them.
  • Title behaviour and frame time. No title was launched.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5755881962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15487#pullrequestreview-5755881962). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T16:29:43Z. **Review:** APPROVED --- # Re-checked — approved Since my last review, `a2b477f661` adds a hook fixture and `beed64fa73` switches `CopyMapped` to a new libc helper, `GuestCopyInUnsynced_nid_no_patch`. The helper makes the checked native copy without `GuestArenaPrepareHostRead`, so the blocking finding is resolved. ## What changed since my last review - `core/libs/prx/libc/src/General.cpp:86-87`: `CopyGuestBytes` now takes a `prepare` flag. The new `GuestCopyInUnsynced_nid_no_patch` (`General.cpp:856`) has the same empty, null and overflow checks as `GuestCopyIn_nid_no_patch` and passes `prepare = false`. It is declared in `core/libs/prx/libc/include/General.hpp`. - `core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:2990`: `CopyMapped` calls the unsynced helper instead of `GuestCopyIn_nid_no_patch`. - `tests/MappedCopy.cpp`: a new `hooks` mode installs counting read-guard and flush hooks. It checks that `CopyMapped` calls neither hook and that `GuestCopyIn_nid_no_patch` still calls each hook once. The CMake fragment registers this sixth mode. - The debt entry now says the copy runs "without host-read synchronization". - In the discussion, the author agreed that the flush was not intended. They say the title call/byte counts and the frame-time comparison are still pending. ## What I ran Head `beed64fa73ba7446c9a00fd07059b478d8d0b068`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `4bcca7692fa617f50d931caf5ced9d00be98d1ef`. Release build with GCC 14.2.0 and Ninja, on a Debian 13 VM with lavapipe. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...beed64fa73ba7446c9a00fd07059b478d8d0b068 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure # negative control A: main's production files git show 4f41f4c375f5abb487dbd184fbc150f31994d762:<path> > <path> # GuestMemory.cpp/.hpp, libc General.cpp/.hpp ninja -C build -j32 -l32 agc_mapped_copy_tests ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" # negative control B: previously reviewed head's production files git show 46941c1c37a9de3d8d719b769bc8741c2de61a25:<path> > <path> # same four files ninja -C build -j32 -l32 agc_mapped_copy_tests ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" --output-on-failure # restore git show 4bcca7692fa617f50d931caf5ced9d00be98d1ef:<path> > <path> ninja -C build -j32 -l32 ctest --test-dir build -j8 --test-load 32 -R "agc_mapped_copy_" git status --porcelain ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (script) | ok | | Selected tests (script) | 3728 ran, no new failures or timeouts; 9 known failures that also fail on `main` | | Validation layer (script) | 770 tests, layer loaded in 769, none missing, 0 tests with new `VUID-` lines | | `agc_mapped_copy_*` on the merged tree | 6/6 pass | | Control A (`main` production files) | `reset` and `partial` SegFault; the other 4 pass | | Control B (`46941c1c37` production files) | only `hooks` fails: `a speculative mapped copy ran read guards or flushed GPU writes` | | After restoring the merged files | 6/6 pass; `git status --porcelain` empty | The script's check also reports `guest_net_ctl` as an unexpected skip, but `main` has the same skip, so it is not from this PR. <details><summary>Negative control B output</summary> ``` 1/6 Test #2101: agc_mapped_copy_reset ............ Passed 0.01 sec 2/6 Test #2102: agc_mapped_copy_partial .......... Passed 0.01 sec 3/6 Test #2103: agc_mapped_copy_reuse ............ Passed 0.01 sec 4/6 Test #2105: agc_mapped_copy_hooks ............***Failed 0.01 sec a speculative mapped copy ran read guards or flushed GPU writes 5/6 Test #2100: agc_mapped_copy_valid ............ Passed 0.01 sec 6/6 Test #2104: agc_mapped_copy_boundaries ....... Passed 0.00 sec 83% tests passed, 1 tests failed out of 6 ``` </details> Control A confirms that the reset fixtures still catch the original crash. Control B confirms that the new `hooks` fixture catches the read preparation this revision removes. Both results match the author's description. ## Previous findings 1. **Speculative `CopyMapped` runs the host-read hook (read guard that can throw, `FlushGpuWrites`).** Resolved. `CopyMapped` now calls `CopyGuestBytes(..., false)`, which skips `GuestArenaPrepareHostRead`. The `hooks` fixture shows the speculative path calls neither hook while the ordinary path still calls both, and it fails on the previous head (control B). Because the guard is never called, a throwing guard cannot escape `CopyMapped`, so I don't need a separate throwing-guard fixture. The masked re-read in `CaptureValidation.cpp` returns to `main`'s behaviour: no flush. 2. **A non-`EFAULT` `process_vm_readv` failure throws from a speculative read** (non-blocking). Still open. `core/libs/prx/libc/src/General.cpp:95` still throws for any errno other than `EFAULT`, and the unsynced helper inherits that throw. On `main`, `CopyMapped` never made this syscall. This only matters under a seccomp or ptrace policy that denies the syscall, so I'm not blocking on it. Mapping those errors to `false` in the unsynced path, or stating that the throw is intended, would settle it. 3. **Cost on the draw path is unmeasured** (non-blocking). Still open, and the author says it is pending. The prepared-variant microbenchmark no longer applies, because the flush and guard are gone. But each chunk read is still one syscall instead of a cached walk. No title numbers are attached, and the PR claims no speedup. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - Windows (`ReadProcessMemory`) and macOS (`mach_vm_read_overwrite`) behaviour of the unsynced path. I only built and ran on Linux. The author has asked for a Windows run, and no result is posted yet. - The author's RX 6650 XT / RADV results and the attached archives. I have no network access and did not check them. - Title behaviour and frame time. No title was launched. <!-- anyps5-bots job=3434 head=beed64fa73ba7446c9a00fd07059b478d8d0b068 -->
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!15487
No description provided.