fix(agc): tolerate mapping changes during committed snapshots #10498

Merged
dotaku22 merged 2 commits from upstream-pr/10498 into main 2026-10-28 08:25:30 +00:00
dotaku22 commented 2026-10-24 04:30:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dotaku22 on 2026-10-24T04:30:56Z.


What

Build on merged #10575's shared visitReadablePages helper rather than adding a second checked-read implementation. A failed Windows committed read now invalidates cached page states and re-queries each page before retrying, excluding guard/no-access pages. Expected mapping-race errors recover; unexpected errors throw. Copies zero inaccessible bytes and comparisons ignore them, retaining #10575's semantics. Linux is unchanged.

The Windows-only regression covers no-access/guard pages, surrounding readable bytes, stale-cache invalidation, both copy and comparison paths, guard preservation, and 500 snapshots during concurrent protection changes. Snapshots are not atomic with respect to guest writes.

Tested

Rebased onto cccdaa2734 after #10575 merged. Windows 11 build 26200; NVIDIA GeForce RTX 5070 Ti, NVIDIA 610.88; GCC 15.2 Release.

ctest --test-dir build -R '^(agc_driver_committed_read_mapping|agc_driver_graphics)$' -V

  • Current main's implementation, with this PR's regression retained: agc_driver_graphics passes (including #10575's released-page copy/comparison regression); agc_driver_committed_read_mapping fails with failed snapshot retained stale readable page states.
  • Rebased PR: both pass, including the protection-change concurrency regression and comparison checks.
  • Same machine/GPU and focused tests, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, SDK 1.4.363.0 via VK_LAYER_PATH, implicit layers disabled. Both verbose logs confirm the validation layer loaded; neither has missing-layer messages or VUID- errors.
  • python tools/check_conventions.py --base origin/main: passes.

Linux, macOS, other GPUs and gameplay on this rebased head were not tested. Earlier combined Demon's Souls runs are not evidence for this exact revision.

The local overlap check lists only this PR itself as confirmed overlap. Several other branches conflict with main and could not be compared automatically; this is not a guarantee that those branches have no overlap.

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: #10575 (merged; agreed order completed)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti; NVIDIA 610.88; Windows 11 build 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4992482350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10498). Originally posted by [dotaku22](https://github.com/dotaku22) on 2026-10-24T04:30:56Z. --- ### What Build on merged #10575's shared `visitReadablePages` helper rather than adding a second checked-read implementation. A failed Windows committed read now invalidates cached page states and re-queries each page before retrying, excluding guard/no-access pages. Expected mapping-race errors recover; unexpected errors throw. Copies zero inaccessible bytes and comparisons ignore them, retaining #10575's semantics. Linux is unchanged. The Windows-only regression covers no-access/guard pages, surrounding readable bytes, stale-cache invalidation, both copy and comparison paths, guard preservation, and 500 snapshots during concurrent protection changes. Snapshots are not atomic with respect to guest writes. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Rebased onto `cccdaa2734` after #10575 merged. Windows 11 build 26200; NVIDIA GeForce RTX 5070 Ti, NVIDIA 610.88; GCC 15.2 Release. `ctest --test-dir build -R '^(agc_driver_committed_read_mapping|agc_driver_graphics)$' -V` - Current main's implementation, with this PR's regression retained: `agc_driver_graphics` passes (including #10575's released-page copy/comparison regression); `agc_driver_committed_read_mapping` fails with `failed snapshot retained stale readable page states`. - Rebased PR: both pass, including the protection-change concurrency regression and comparison checks. - Same machine/GPU and focused tests, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, SDK 1.4.363.0 via `VK_LAYER_PATH`, implicit layers disabled. Both verbose logs confirm the validation layer loaded; neither has missing-layer messages or `VUID-` errors. - `python tools/check_conventions.py --base origin/main`: passes. Linux, macOS, other GPUs and gameplay on this rebased head were not tested. Earlier combined Demon's Souls runs are not evidence for this exact revision. The local overlap check lists only this PR itself as confirmed overlap. Several other branches conflict with main and could not be compared automatically; this is not a guarantee that those branches have no overlap. ### 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: #10575 (merged; agreed order completed) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5070 Ti; NVIDIA 610.88; Windows 11 build 26200 - [x] AI-assisted: yes
adriadam10 commented 2026-10-24 04:42:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T04:42:52Z.

Review: CHANGES_REQUESTED


Thanks, the Windows fix looks right and the test targets the crash. One thing blocks it:

  • core/libs/prx/libSceAgcDriver/tests/execution/CommittedReadMapping.cpp:96-98: on Linux the test returns VulkanTestSkipped without printing a reason. The Linux job runs tools/check_skips.py on the junit and fails any skip whose reason doesn't match DEVICE_LIMITATION, so this would turn the Linux Build red ("skipped for a reason that is not expected"). Print a skipped, ... line for the Windows-only case and make check_skips.py accept that reason for the linux job (or register the test only on Windows), so the Linux job doesn't lose coverage silently.

Everything else in the diff checked out (no comments in code, registered through the tests/execution glob, unexpected errors still throw).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636871490 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10498#pullrequestreview-5636871490). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-24T04:42:52Z. **Review:** CHANGES_REQUESTED --- Thanks, the Windows fix looks right and the test targets the crash. One thing blocks it: - `core/libs/prx/libSceAgcDriver/tests/execution/CommittedReadMapping.cpp:96-98`: on Linux the test returns `VulkanTestSkipped` without printing a reason. The Linux job runs `tools/check_skips.py` on the junit and fails any skip whose reason doesn't match `DEVICE_LIMITATION`, so this would turn the Linux Build red ("skipped for a reason that is not expected"). Print a `skipped, ...` line for the Windows-only case and make `check_skips.py` accept that reason for the linux job (or register the test only on Windows), so the Linux job doesn't lose coverage silently. Everything else in the diff checked out (no comments in code, registered through the `tests/execution` glob, unexpected errors still throw).
MarcZX10 commented 2026-10-24 11:21:45 +00:00 (Migrated from github.com)

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

Review: DISMISSED


The Windows recovery path is carefully bounded: it invalidates stale page-state entries, zeros the destination, then re-queries and reads each page so stable readable bytes survive while guard/no-access bytes remain zero. The new test covers both no-access and guard pages, surrounding bytes, and concurrent protection changes. I also confirmed the current CMake change registers this GPU regression only on Windows, addressing the Linux skip concern from the earlier review. The author reports focused Windows validation-layer tests passing; hosted build jobs skipped, and I did not rerun them locally.

One merge-order blocker remains: #10575 is open and changes the same GuestMemory read path with ReadProcessMemory for released-page races. The overlap bot identifies exact shared lines, and this PR currently says Depends on: none. Please coordinate with #10575's author on whether this mapping/protection fix is layered after their released-page fix, then declare the agreed order here. The two regressions cover different failure modes, but the implementation overlap needs an explicit merge sequence under CONTRIBUTING.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638062716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10498#pullrequestreview-5638062716). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T11:21:45Z. **Review:** DISMISSED --- The Windows recovery path is carefully bounded: it invalidates stale page-state entries, zeros the destination, then re-queries and reads each page so stable readable bytes survive while guard/no-access bytes remain zero. The new test covers both no-access and guard pages, surrounding bytes, and concurrent protection changes. I also confirmed the current CMake change registers this GPU regression only on Windows, addressing the Linux skip concern from the earlier review. The author reports focused Windows validation-layer tests passing; hosted build jobs skipped, and I did not rerun them locally. One merge-order blocker remains: #10575 is open and changes the same GuestMemory read path with ReadProcessMemory for released-page races. The overlap bot identifies exact shared lines, and this PR currently says Depends on: none. Please coordinate with #10575's author on whether this mapping/protection fix is layered after their released-page fix, then declare the agreed order here. The two regressions cover different failure modes, but the implementation overlap needs an explicit merge sequence under CONTRIBUTING.
adriadam10 commented 2026-10-26 18:31:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-26T18:31:35Z.

Review: CHANGES_REQUESTED


The Linux skip point is resolved: CommittedReadMapping is now only registered on Windows (core/libs/prx/libSceAgcDriver/CMakeLists.txt:2178), so the Linux job loses nothing and check_skips.py is not involved.

One blocker left, the one @MarcZX10 raised:

  • #10575 changes the same GuestMemory.cpp committed-read path (ReadProcessMemory, released-page races) and this PR still says Depends on: none. You and @Mouhand-Kaddo agreed on #10575 first, then this PR rebased onto it with the shared checked-read helper consolidated. Please set Depends on: #10575 in the body, and once #10575 merges, rebase and fold copyCommittedRun into its helper, keeping the protection-change regression and the unexpected-error handling.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5657092037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10498#pullrequestreview-5657092037). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-26T18:31:35Z. **Review:** CHANGES_REQUESTED --- The Linux skip point is resolved: `CommittedReadMapping` is now only registered on Windows (`core/libs/prx/libSceAgcDriver/CMakeLists.txt:2178`), so the Linux job loses nothing and `check_skips.py` is not involved. One blocker left, the one @MarcZX10 raised: - #10575 changes the same `GuestMemory.cpp` committed-read path (`ReadProcessMemory`, released-page races) and this PR still says `Depends on: none`. You and @Mouhand-Kaddo agreed on #10575 first, then this PR rebased onto it with the shared checked-read helper consolidated. Please set `Depends on: #10575` in the body, and once #10575 merges, rebase and fold `copyCommittedRun` into its helper, keeping the protection-change regression and the unexpected-error handling.
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!10498
No description provided.