fix(agc): exclude host arena holes from write-watch proofs #3594

Merged
Scramblrrrr merged 1 commit from upstream-pr/3594 into main 2026-10-11 21:39:35 +00:00
Scramblrrrr commented 2026-10-11 13:56:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T13:56:14Z.


What

Windows reserves the guest arena around existing host mappings. WriteTracker initializes coverage for the arena address interval, including those excluded host regions. A range inside a host-owned hole can therefore be reported as write-watched and sent to GetWriteWatch even though it was not allocated with MEM_WRITE_WATCH. Native copied-read reuse testing exposed error 87; debugger address layouts did not reproduce it.

Reject host-region overlaps before collecting or accepting write-watch proofs, including bulk unchanged queries. Collection returns zero (tracking unavailable), and eligibility/unchanged proofs return false, so callers take their existing fresh-copy or comparison path. The existing store path already excludes these regions. No exception suppression or assumption that untracked memory is unchanged is introduced.

The Windows regression enumerates an actual host exclusion inside the arena rather than depending on ASLR placement of a heap allocation. It checks eligibility, collection and both unchanged-query APIs, plus ordinary host-heap rejection and unchanged bytes. Guest memory is not dereferenced during arena enumeration. Related #2863 optimizes queue-worker write-watch walks; this correction addresses excluded-region eligibility. Depends on: none.

Tested

Head 56d08f2547, base main a11c8f7f70. Windows 11, Ryzen 7800X3D, Release MinGW GCC 15.2, SPIRV-Tools OFF.

  • Fresh build and agc_driver_graphics: PASS, final run 4.81 seconds.
  • Negative control: kept the new regression, rebuilt main's GuestMemory.cpp; fails with an arena host hole was reported as write-watched (0.36 seconds). Restored the fix, explicitly rebuilt, and repeated the passing test.
  • Conventions and diff checks pass. Linux/macOS were not run locally; host exclusions are Windows-only.

The correction was also tested in the separate 007 performance integration: six selected Vulkan checks passed. That experimental stack and its title data are not part of this PR. Its game runs still hit a host-memory guard and no visible frame was verified; this fix does not establish playability or solve memory pressure.

Checklist

  • Based on current main; no equivalent excluded-region proof fix found in open PRs
  • One topic per PR
  • No new code comments
  • Unimplemented paths retain errors; unavailable proofs are rejected
  • No investigation files, title data or images added
  • No new third-party code
  • Generic behavior
  • Depends on: none
  • AI-assisted: yes, Codex; author responsible for review
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819575808 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3594). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T13:56:14Z. --- ### What Windows reserves the guest arena around existing host mappings. WriteTracker initializes coverage for the arena address interval, including those excluded host regions. A range inside a host-owned hole can therefore be reported as write-watched and sent to GetWriteWatch even though it was not allocated with MEM_WRITE_WATCH. Native copied-read reuse testing exposed error 87; debugger address layouts did not reproduce it. Reject host-region overlaps before collecting or accepting write-watch proofs, including bulk unchanged queries. Collection returns zero (tracking unavailable), and eligibility/unchanged proofs return false, so callers take their existing fresh-copy or comparison path. The existing store path already excludes these regions. No exception suppression or assumption that untracked memory is unchanged is introduced. The Windows regression enumerates an actual host exclusion inside the arena rather than depending on ASLR placement of a heap allocation. It checks eligibility, collection and both unchanged-query APIs, plus ordinary host-heap rejection and unchanged bytes. Guest memory is not dereferenced during arena enumeration. Related #2863 optimizes queue-worker write-watch walks; this correction addresses excluded-region eligibility. Depends on: none. ### Tested Head 56d08f254737bfe921bc5122439c240bf63bedb3, base main a11c8f7f70a0ed4e71504a89de69e8cdae687817. Windows 11, Ryzen 7800X3D, Release MinGW GCC 15.2, SPIRV-Tools OFF. - Fresh build and `agc_driver_graphics`: PASS, final run 4.81 seconds. - Negative control: kept the new regression, rebuilt main's GuestMemory.cpp; fails with `an arena host hole was reported as write-watched` (0.36 seconds). Restored the fix, explicitly rebuilt, and repeated the passing test. - Conventions and diff checks pass. Linux/macOS were not run locally; host exclusions are Windows-only. The correction was also tested in the separate 007 performance integration: six selected Vulkan checks passed. That experimental stack and its title data are not part of this PR. Its game runs still hit a host-memory guard and no visible frame was verified; this fix does not establish playability or solve memory pressure. ### Checklist - [x] Based on current main; no equivalent excluded-region proof fix found in open PRs - [x] One topic per PR - [x] No new code comments - [x] Unimplemented paths retain errors; unavailable proofs are rejected - [x] No investigation files, title data or images added - [x] No new third-party code - [x] Generic behavior - [x] Depends on: none - [x] AI-assisted: yes, Codex; author responsible for review
adriadam10 commented 2026-10-11 21:39:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:39:31Z.


Checked on Linux merged onto current main: libSceAgcDriver build and ctest (390/390, agc_driver_graphics passes). The fix and its test are _WIN32-only; reviewed the code: the overlap check runs before the collect memo path and before the tracker lock, and Watched/UnchangedSince/UnchangedSinceAll now reject the excluded ranges, matching the existing store path. The Windows run with the negative control in the description covers the runtime behaviour. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114073502 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3594#issuecomment-6114073502). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:39:31Z. --- Checked on Linux merged onto current main: libSceAgcDriver build and ctest (390/390, `agc_driver_graphics` passes). The fix and its test are `_WIN32`-only; reviewed the code: the overlap check runs before the collect memo path and before the tracker lock, and `Watched`/`UnchangedSince`/`UnchangedSinceAll` now reject the excluded ranges, matching the existing store path. The Windows run with the negative control in the description covers the runtime behaviour. Merging once CI is green.
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!3594
No description provided.