fix(agc): keep a rewatched import's memory compared once it is shared #9159

Merged
EagleBearerYS merged 13 commits from upstream-pr/9159 into main 2026-10-24 18:26:38 +00:00
EagleBearerYS commented 2026-10-21 14:02:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T14:02:16Z.


What

On Windows, a fault that AnyPS5 resumes in guest code can overwrite the guest's red zone, [rsp-0x80, rsp-0x10) (#361). Since #6678 this happens again in Grand Theft Auto V (PPSA04264)'s open world, in every run. @tibzejoker's report in #9136:

FATAL: unhandled exception 0xc0000005 on thread '[RAGE] HDD Streamer'
  rip gtav.exe+0x28baa50   (eboot 0x28aaa50)
  read of 0x000000000000774f

At eboot 0x28aaa50 the game's zlib inflate_fast reloads two pointers from its red zone, then reads through a garbage one. Their bisect counts the faults AnyPS5 resumes over 60 s of Story (Windows 11 26200, RTX 4090 with NVIDIA 616.92, i9-13900K):

tree (from #9136) resumed faults open world
main 47a266cf9, and the merge before #6678 0 no crash
#6678's merge 755fecb33 134
main f6ce8e34a 400+, ~60 of them in zlib, all MEM_MAPPED crash, 7 of 7 runs
main 7280a17ec with APS5_NO_DEFERRED_SETTLES=1 133 (85 MEM_MAPPED, 44 MEM_PRIVATE), 0 in zlib no crash in 150 s

Why #6678 brings the faults back:

  • When a small import's deferred settle completes, rewatchSettledImports returns its range to the write watch through GuestMemory::Rewatch.
  • At that point Grand Theft Auto V's buffers are resident direct memory: private pages that GetWriteWatch tracks without faults.
  • Later, a second mapping of the same direct memory turns the run into 16 KiB shared views (WindowsMappings::demote). From then on every clearing collect over the range makes all its aliases read-only, so each guest store faults and is resumed.
  • Before #6678 the import kept the range out of the write watch for good, so it was compared and never armed.
  • A check at rewatch time can't see this, because the memory only turns shared afterwards.

A second source of the same faults, from @tibzejoker's next bisect (#9136 comment). These are MEM_MAPPED faults over 60 s of Story with APS5_NO_DEFERRED_SETTLES=1, so #6678's path is out:

tree (from #9136) MEM_MAPPED resumed faults
e9cc4a8ef, the merge before #8172 0
d9df34d08, #8172's merge 6
28f126650, #6598's merge 134
28f126650 with #8172 reverted 1
  • #8172 keeps resident DCC targets in the write watch when an aligned block import spans them, which #8103 needs. To do that, ImportWatched keeps each watched run of such an import in the watch, instead of taking the whole import out.
  • In Grand Theft Auto V, those runs are resident direct memory that a second mapping later turns into shared views, which are then armed the same way (eboot 0x162b9e4 among their stores).
  • This change keeps them watched while they're private, as #8103's DCC targets need, and compared once they're shared.

The change, in seven commits, plus two test-only commits and a debt entry:

  1. libc (98adb5f205): WindowsMappings::CompareWhenShared marks the pages of a range, and makes writable again any alias of them that is already armed.
    • Once a marked page is shared, collectable() and the fresh-collect pre-check refuse a clearing collect over it before anything is made read-only. Its aliases are never armed, and the caller gets no write record, so it compares the range.
    • While a marked page is still a resident run, it's collected through GetWriteWatch as before.
  2. agc (d98ee15162): Rewatch marks each range with GuestArenaCompareWhenShared before it returns the range to the watch.
    • The gain #6678 wants is kept while the memory stays private.
    • Once it is shared, the range is compared again, as before #6678.
  3. test (ead292e2e5): CheckComparedWhenShared forgets its section's handle value before it maps. WindowsMappings keys its physical pages by that value, so a value that an earlier case closed without ForgetSection could come back with that case's stored pages. Test-only.
  4. agc (81aec58343): ImportWatched marks the resident pages of each run it keeps in the watch, with GuestArenaCompareResidentWhenShared, a resident-only variant of the same mark.
    • This covers the runs #8172's path keeps watched.
    • Memory that is already shared when it's imported isn't marked, and keeps today's tracking.
  5. libc (47c8df4950): the mark survives a full unmap and remap.
    • It lived only on the shared page, which WindowsMappings holds weakly. Once every view of that memory was unmapped, the next Map made a fresh, unmarked page, and the next clearing collect armed its views again.
    • CompareWhenShared now also marks the physical page, and a shared page made for it starts marked. ForgetSection still drops the mark, so a reused section handle starts unmarked.
  6. libc (1ad5f29e20): the resident runs an import's read-write alias turns into shared views are marked too.
    • An import over a range that isn't all writable private memory maps a read-write alias first, and MapAlias turns every resident run in the range into shared views before ImportWatched runs. The import's resident-only mark skipped those views, so the import's walk and every later clearing collect armed them.
    • MapAlias now records the views it turns shared, and the resident-only mark includes them. A second guest mapping of the page clears the record, so memory the guest itself shares keeps today's tracking.
  7. libc (37a5d9495d): a compared shared page is reported once.
    • When a page this change marks turns into a shared view while it's compared, WindowsMappings flags it unreported.
    • The first refused collect over it takes the flag and reports the page as a CPU write, once, as main reports the pages at the first collect after the sharing.
  8. agc (1712336477): compared shared memory is never read as unchanged since before a refused collect.
    • The stale read @embersas's GPU fixture found (comment): a texture cached before the sharing, then shared, then written with no lookup in between, came back from the first lookup unchanged, with no comparison.
    • A refused walk now records its generation for each 64 KiB block that holds compared shared pages. UnchangedSince, UnchangedSinceAll and UnchangedCommittedSince answer false against an older generation there, so a cache compares bytes instead of trusting stamps that never came.
    • The report alone wasn't enough: the dispatch cache takes the newest of several spans' collects, so a refused span's 0 hid behind another span's generation.
    • WrittenSince, ChangedBlocks, StoredOver and NewestStamp stay stamp-only, so storage textures and depth surfaces don't reload or drop at every epoch. Stamping the whole range at every refused collect would make depth surfaces reload from guest memory at every bind, dropping depth the GPU drew but hasn't stored.
    • Cost: one std::map::lower_bound per UnchangedSince* call (the map is empty on Linux), and on Windows two WindowsMappings listings per refused walk. Analytical, not timed.
  9. test (388f5f13e6): agc_driver_compared_shared_snapshot takes embersas's ordering through the production CachedSampledTexture.
  10. docs (cb9de8049c): a debt entry for depth surfaces over compared shared memory (below).

Scope:

  • Only memory that a rewatch returned to the watch, or that an import kept watched while it was resident or that its alias turned shared, is affected. Other shared views are armed and collected as before, including direct memory that was never imported and is mapped twice.
  • Linux and macOS are unchanged: WindowsMappings, Rewatch's Windows branch and the new mark in ImportWatched are Windows-only.
  • Behaviour change: native multisampled depth over compared shared memory now throws "guest writes over native multisample depth are not implemented" at the first check after a refused collect, as main throws it at the sharing. Before the eighth commit, this PR trusted the missing stamps there.
  • A gap left as it is: a depth surface over such memory doesn't see CPU stores made after the sharing, as over unwatched memory. The new debt entry says so.

Overlap:

  • @Dripl1x's #9181 (d6e270ea9f, first posted in #9136) stops arming resident runs, which is #7473's part of the faults (the MEM_PRIVATE ones). This change covers memory that turns shared. The two touch different code and merge cleanly. @tibzejoker's run with both is in Tested.
  • Our open #8926 returns retired imports to the watch through the same Rewatch, so this change covers it too. #8926 depends on this PR.
  • Our open #9505 conflicts with 1ad5f29e20 in WindowsMappings::Map's shared path, where #9505 restructures the loop that turns a page's resident aliases shared. The resolution keeps #9505's structure and clears aliasDemoted after each demote in both of its loops. They already conflicted in WindowsWriteWatch.cpp's main() list, where both sides stay.
  • git merge-tree of the head against every open PR touching the changed files: no conflicts. Of the PRs that already conflict with main, 21 touch these files, and none touches the changed functions.

Tested

  • Grand Theft Auto V (PPSA04264), by @tibzejoker (#9136 comment): main 663de1ab2 + Dripl1x's d6e270ea9 (#9181) + 81aec58343, 150 s of Story with deferred settles on.
    • Their verdict: "the crash is fixed with the two fixes together". 0 MEM_PRIVATE, 0 faults in zlib, 0x162b9e4 gone, no crash.
    • 105 MEM_MAPPED faults remain, at eboot 0x28f413a (a store in a loop, not a red-zone leaf) and in a system DLL's host code. Both write 16 KiB views that were shared when written. As they read it, that is direct memory that was never imported and is mapped twice, which this change leaves armed.
  • Grand Theft Auto V (PPSA04264) on a second machine, by @dantdmdarealguy (#9136 comment): Windows 11 Pro, i9-14900K, RTX 5080 (NVIDIA 32.0.16.1742), WinLibs GCC 15.2.0, Release, game 01.005.000, warm caches, the same scripted pad input in alternating runs of 600-900 s. Their tree needed #9730's sceVoiceSetThreadsParams fix to reach gameplay.
    • main 7e2ba73e4 + #9730: the [RAGE] HDD Streamer crash, the game's int 0x41 assert after inflate returned Z_DATA_ERROR, in 4 of 4 runs, 236-253 s after launch. One earlier manual run of that tree survived 900 s.
    • The same + #9181 (d6e270ea9) + this PR (99aeb0ac5): 0 of 3 runs, up to about 12 min of gameplay.
    • As they note, they didn't count resumed faults, so this shows only that the two PRs together remove the crash on a second machine and GPU.
  • Grand Theft Auto V (PPSA04264), the faults that remain, by @tibzejoker (#9159 comment, #9136 comment): main 3bbd2321d + #9181 + this PR up to 81aec5834 + #9730 + #9445, Windows 11, RTX 4090, APS5_MIMALLOC=1, 7-minute open-world runs with every resumed write fault logged.
    • Across about 15 runs with both PRs, 2 ended in the HDD Streamer crash.
    • In the 8 logged runs, 4 still had 1 to 4 resumed writes from zlib's inflate_fast, one per 4 KiB subpage of a fresh 16 KiB MEM_MAPPED view. One of those runs crashed, on the thread of its only zlib fault. The other 4 runs had none.
    • Their local version of the remap commit (the mark kept on the physical page) still saw resumed zlib writes in its 4 runs, with 1 crash. So the remaining faults come from another path, which this PR doesn't cover.
    • Their tree has neither 47c8df4950 nor 1ad5f29e20. 1ad5f29e20 closes one path that arms such views, and this PR doesn't claim to fix these faults.
    • Two more paths that turn resident memory into unmarked shared views are being checked: breakRun, where unmapping part of a resident run turns the whole run shared, and the demotion of a whole resident run when a second mapping shares one of its pages. A diagnostic that names the path behind each armed view would tell them apart in their runs.
  • Independent CPU-only validation, by @embersas (#9136 comment; Ryzen 9 3900X, Windows 11 26300.9711, WinLibs GCC 15.2.0, Release; no game was run). This PR's head 1ad5f29e20 and #9181's d6e270ea9f, on main 0a0ed72167 alone and together, plus test/9159-9181-together (d7cec80e8c):
    • The focused tests pass on every tree, 3 runs each: guest_memory, windows_write_watch, agc_write_tracking, agc_write_tracking_metadata_commit, agc_resident_direct_remap, agc_rewatched_direct_shared, agc_import_alias_shared, agc_host_import_retire and more.
    • The probe: 16 known qwords in [rsp-0x80, rsp), one 32-byte store per case, any fault resumed by GuestArenaHandleWrite; 90 executions. With this PR, the four shared cases no longer fault and keep all 16 qwords: rewatched, then a second mapping; a watched import, then a second mapping; rewatched, every view unmapped, mapped twice; an import alias over resident memory. On main, each faults and loses 13.
    • Not this PR's cases: the resident 2 MiB case is #9181's, and is fixed by it, not by this PR. Unmarked shared views still fault on every tree, which is the class #5640 (now merged) is for.
    • Failing controls: each piece of this PR reverted on its own (the two refusal checks, the Rewatch mark, the ImportWatched mark, the physical-page mark, demote(..., true)) makes its test fail and the store fault again. With only the refusal checks reverted, the alias store didn't fault in that sequence, but agc_import_alias_shared failed on the refusal.
    • Not covered there: the comparison callers use after a refused collect, breakRun and the whole-run demotion paths, the GPU tests, and any game.
  • windows_write_watch:
    • CheckComparedWhenShared: a marked resident range stays collected. A second mapping then makes it shared. From then on its collects fail, neither mapping is read-only, and stores into it raise no fault (the test's vectored handler counts them). The unmarked half of the same mapping is still collected.
    • CheckResidentOnlyComparedWhenShared: a resident-only mark leaves a shared view armed and collected, and still keeps a resident page compared once a second mapping makes it shared.
    • CheckComparedWhenSharedRemapped: a marked resident page is unmapped, then mapped into two views. A clearing collect through either view refuses, neither is made read-only, and a store raises no fault. After ForgetSection the same mapping is collected and armed again.
  • New ctest agc_import_alias_shared (WIN32, a process mode of agc_write_tracking_tests, next to agc_rewatched_direct_shared): it imports direct memory whose range needs a read-write alias, the way an import maps one, and requires that the pages the alias turned shared are compared and not armed. Memory the guest itself mapped twice before the alias is still armed, as before.
  • New ctest agc_rewatched_direct_shared (WIN32, its own process mode of agc_write_tracking_tests, in the PATH list), with two cases:
    • Rewatched: it maps direct memory resident, takes a block out of the watch and rewatches it as a settle does, then maps the same memory a second time. The block must collect while resident, then collect as 0 through either mapping, stay writable, and show a store through both mappings. A block that never left the watch must still be collected.
    • Imported: resident direct memory imported with the watch kept, then mapped a second time, must collect as 0 through either mapping, stay writable and show a store through both. Unimported shared direct memory must still be collected.
  • The stale read through the sampled cache, on a GPU (agc_driver_compared_shared_snapshot, this PC, Windows 11). The test runs on its first Vulkan device, which on this PC is the AMD Radeon integrated GPU (driver 31.0.21923.1000), not the RTX 3070. It checks the CPU-side cache logic; the GPU only reads the texels back.
    • Red on 1ad5f29e20 plus the test, 3 of 3: "the first lookup after a CPU store into shared compared memory returned the snapshot cached before the sharing".
    • Green at 388f5f13e6, 3 of 3, with agc_driver_partially_resident_snapshot and _pending_stores.
    • #9181 alone (c442afa5d1) plus the test passes 3 of 3, so #9181 isn't affected.
  • The stale read on an NVIDIA GPU, by @embersas (comment): their external fixture, unchanged from their first report, on Windows 11 26300, Ryzen 9 3900X, RTX 3080 Ti (NVIDIA 610.88), WinLibs GCC 15.2.0, Release, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and the Khronos validation layer; no game was run. Four orderings, three repetitions per tree:
    • main ef0d8ae3b5: 12 of 12 pass. Their earlier branch of this PR with #9181 (d7cec80e8c): the two orderings that write from the CPU after the sharing, with no lookup in between, still return the stale first lookup, 3 of 3 each; the other two pass.
    • This head, cb9de8049c, without #9181: 12 of 12 pass. In the two affected orderings the first lookup makes one TextureCompare read, replaces the texture, and the GPU reads the new texel (0xa0001234, against 0x10001234 before); the other texels match, and the store raises no write fault.
    • agc_driver_compared_shared_snapshot passes 3 of 3 on this head on the RTX 3080 Ti, none skipped.
    • The layer loaded in every execution, with no VUID-, validation or synchronization message.
    • Their scope: a synthetic fixture that calls Unwatch/Rewatch directly and reads through a compute texelFetch. It doesn't cover host-import settling, draws, other caches or orderings, other GPUs, or any game.
  • GitHub's runners:
    • df89dd1041, merged with main dab0113e06 (run). The merge's one conflict was docs/dev/debt/libSceAgcDriver.md, where main added its "Unmapped depth planes" entry at the same place as this PR's "Depth surfaces over compared shared memory" entry; both are kept. The PR's own added and removed lines are unchanged.
      • on Windows, the same 12 tests run ×10: 11 pass, 1 skips, 0 fail. agc_driver_compared_shared_snapshot skips, as the runner has no Vulkan device;
      • on Linux, agc_write_tracking, agc_write_watch_coverage, guest_memory, guest_shm_open and guest_jit_shared_memory pass ×10: 5 run, 5 pass, 0 skip, 0 fail;
      • the libc and libkernel suites pass on both (169 and 217 tests on Windows, 142 and 204 on Linux), run with APS5_SKIP_TIMING_TESTS=1.
    • 719a048a1f, merged with main 1e20650e84 (run). The merge's one conflict was the list of cases in WindowsWriteWatch.cpp's main(), where main added three private-commit cases next to this PR's four; all seven run. The PR's own added and removed lines are unchanged.
      • on Windows, windows_write_watch, agc_rewatched_direct_shared, agc_import_alias_shared, agc_compared_shared_generations, agc_resident_direct_remap, agc_write_tracking, agc_write_tracking_metadata_commit, agc_write_watch_coverage, guest_memory, guest_shm_open and guest_jit_shared_memory pass ×10: 12 run, 11 pass, 1 skip, 0 fail. agc_driver_compared_shared_snapshot skips, as the runner has no Vulkan device;
      • on Linux, agc_write_tracking, agc_write_watch_coverage, guest_memory, guest_shm_open and guest_jit_shared_memory pass ×10: 5 run, 5 pass, 0 skip, 0 fail;
      • the libc and libkernel suites pass on both (147 and 213 tests on Windows, 120 and 203 on Linux), run with APS5_SKIP_TIMING_TESTS=1.
    • The report commit, 37a5d9495d (run): its only red is a build failure: its new windows_write_watch case uses the call the commit adds, so it doesn't build with 1ad5f29e20's code. The next commit's red covers the behaviour. At 37a5d9495d, on Windows, windows_write_watch, agc_rewatched_direct_shared, agc_import_alias_shared, agc_resident_direct_remap, agc_write_tracking and agc_write_tracking_metadata_commit pass 10 runs in a row, 6 of 6, none skipped; on Linux, agc_write_tracking passes 10 runs in a row. The libc suite passes on both and the libkernel suite on Linux; on Windows, guest_raise_in_system_call timed out once at the end of the libkernel suite, the runner timeout above.
    • The refusal-mark commit, 1712336477 (run): red with 37a5d9495d's code, 3 of 3 on Windows: agc_compared_shared_generations fails with "write tracking test failed: a store into rewatched direct memory once shared reads as unchanged since a generation before the sharing", and the other 6 pass. Green at 1712336477: on Windows those 7 pass 10 runs in a row, none skipped; on Linux, agc_write_tracking passes 10 runs in a row. The libc and libkernel suites pass on both.
    • The head, 388f5f13e6 (run): on Windows the same 7 pass 10 runs in a row, none skipped.
    • The alias commit, 1ad5f29e20 (run):
      • red on Windows with the head before it (47c8df4950), 3/3: agc_import_alias_shared fails with "memory an import's alias demoted was armed by the import";
      • green at 1ad5f29e20: on Windows, agc_import_alias_shared, windows_write_watch, agc_rewatched_direct_shared, agc_resident_direct_remap, agc_write_tracking and agc_write_tracking_metadata_commit pass ×10; on Linux, agc_write_tracking passes ×10;
      • the libc suite passes on both (142 on Windows, 115 on Linux) and the libkernel suite on Linux (197). On Windows, guest_raise_in_system_call timed out at 30 s on both arms, 47c8df4950 and 1ad5f29e20, so 206 of 207 pass; this commit changes nothing in libkernel. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners;
      • under Wine, the new case is red 10/10 on 47c8df4950 and green 10/10 at 1ad5f29e20, with two control cases, and a mutant without the line that clears the record fails.
    • The remap commit, 47c8df4950 (run):
      • red on Windows with the head before it (99aeb0ac56), 3/3: "a page to be compared when shared was collected after every view was unmapped and it was mapped again";
      • green at 47c8df4950: on Windows, windows_write_watch, guest_shm_open, guest_jit_shared_memory and guest_memory pass ×10, and the libc (142) and libkernel (207) suites pass; on Linux, the last three pass ×10, and the libc (115) and libkernel (197) suites pass;
      • the suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners;
      • under Wine 9.0, a build of the new case alone is red 10/10 on 99aeb0ac56 and green 10/10 at 47c8df4950. The full windows_write_watch stops earlier under Wine 9.0 on both trees, so the GitHub run is the check for the rest.
    • 99aeb0ac56, merged with main df2569d2c5 (run), with the PR's own diff unchanged by the merge:
      • on Windows, windows_write_watch, agc_rewatched_direct_shared, agc_write_tracking, agc_write_tracking_metadata_commit, agc_resident_direct_remap, agc_write_watch_coverage and guest_memory pass ×10, and the libc (142) and libkernel (207) suites pass;
      • on Linux, agc_write_tracking, agc_write_watch_coverage and guest_memory pass ×10, and the libkernel suite passes (197). libc's only failure is precise_wait, a timing test that fails there with main's code too.
    • Red for the first two commits, with only the two checks in collectable() and the fresh pre-check reverted (run): "a page to be compared when shared was collected once shared" and "rewatched direct memory was collected once shared".
    • Red for the import commit, with only its mark reverted on 81aec58343 (run): only agc_rewatched_direct_shared fails, with "imported direct memory was collected once shared".
    • Green at 81aec58343 (run):
      • on Windows, windows_write_watch, agc_rewatched_direct_shared, agc_write_tracking, agc_write_tracking_metadata_commit and agc_resident_direct_remap pass ×10, and the libc suite passes;
      • in the libkernel suite, guest_raise_in_system_call hit its 30 s timeout once; this change doesn't touch libkernel;
      • on Linux, agc_write_tracking and the suites pass.
    • ead292e2e5 on its own (run): green on both runners.
    • With main's code, the new cases don't build, because they use the new calls.
    • With #8926 on top (test/9136-guard-8926-v3, run): 33 Windows tests pass, including agc_driver_graphics with #8926's retired-import case. The same libkernel timeout appeared there once.
  • #8103's DCC tests on Linux (lavapipe, CI's flags), on 79cae21875, which has the same patch as 81aec58343:
    • agc_driver_msaa_dcc_clear_4 and agc_driver_msaa_dcc_state pass 10/10;
    • agc_driver_msaa_dcc_clear_2 and _clear_8 skip, because lavapipe has only 1 and 4 color samples; main skips them the same way;
    • ^agc passes 862/862 on the head and on main.
    • The change is Windows-only, so this shows the Linux side is unchanged. The Windows runner has no Vulkan device for these tests; the GPU run is below.
  • The same DCC tests on a GPU: NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, the only device selected, Windows 11; GPU clocks weren't held, pass/fail only), on 5e8db4e8f7, a Windows tree of main 27bcd6a29e with #8926 and this PR's three code commits (all but the test-only ead292e2e5), from before the merge with main. ctest -R '^agc_driver_msaa_dcc_(clear_[248]|state)$' --repeat until-fail:10 passes all four 10 of 10, _clear_2 and _clear_8 included.
  • Resident Evil Village (PPSA01556) on that tree and GPU, the intro check for #9136's guard: a 12-minute run from a cold shader cache reached the VR question with no "an address-based build copies … past 64 MiB" line, no abort and no FATAL. The largest guest upload was 63.8 MiB.
  • Validation layer, main against cb9de8049c, on GitHub's Linux runner (llvmpipe, LLVM 20.1.2) (run): agc_write_tracking, agc_driver_partially_resident_snapshot and the three agc_driver_host_import_* tests, 5 of 5 passing on both trees. The layer loaded 4 times on each, and neither log has a VUID- message, so the change adds none. The new GPU test, agc_driver_compared_shared_snapshot, runs only on Windows, so this comparison doesn't cover it. On the Windows runner, without a Vulkan device, 7 of the 11 tests pass and the 4 device tests skip.
  • check_conventions.py passes, with no comment lines added.

Checklist

  • Based on main dab0113e06, merged in df89dd1041; 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none. Part of #9136 (the MEM_MAPPED side; Dripl1x's #9181 is the resident side)
  • Unblocks: none claimed
  • GPUs tested: none needed (CPU-side write tracking); Windows tests on GitHub's runner, #8103's DCC tests on lavapipe; the DCC tests and a Resident Evil Village (PPSA01556) run on an NVIDIA GeForce RTX 3070 Laptop GPU (617.42), Windows 11, on a tree from before the merge with main; the compared-shared snapshot test on this PC's AMD Radeon integrated GPU (31.0.21923.1000), Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4952867970 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9159). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T14:02:16Z. --- ### What On Windows, a fault that AnyPS5 resumes in guest code can overwrite the guest's red zone, `[rsp-0x80, rsp-0x10)` (#361). Since #6678 this happens again in Grand Theft Auto V (PPSA04264)'s open world, in every run. @tibzejoker's report in #9136: ``` FATAL: unhandled exception 0xc0000005 on thread '[RAGE] HDD Streamer' rip gtav.exe+0x28baa50 (eboot 0x28aaa50) read of 0x000000000000774f ``` At eboot `0x28aaa50` the game's zlib `inflate_fast` reloads two pointers from its red zone, then reads through a garbage one. Their bisect counts the faults AnyPS5 resumes over 60 s of Story (Windows 11 26200, RTX 4090 with NVIDIA 616.92, i9-13900K): | tree (from #9136) | resumed faults | open world | |---|---|---| | `main` 47a266cf9, and the merge before #6678 | 0 | no crash | | #6678's merge 755fecb33 | 134 | | | `main` f6ce8e34a | 400+, ~60 of them in zlib, all `MEM_MAPPED` | crash, 7 of 7 runs | | `main` 7280a17ec with `APS5_NO_DEFERRED_SETTLES=1` | 133 (85 `MEM_MAPPED`, 44 `MEM_PRIVATE`), 0 in zlib | no crash in 150 s | **Why #6678 brings the faults back:** - When a small import's deferred settle completes, `rewatchSettledImports` returns its range to the write watch through `GuestMemory::Rewatch`. - At that point Grand Theft Auto V's buffers are resident direct memory: private pages that `GetWriteWatch` tracks without faults. - Later, a second mapping of the same direct memory turns the run into 16 KiB shared views (`WindowsMappings::demote`). From then on every clearing collect over the range makes all its aliases read-only, so each guest store faults and is resumed. - Before #6678 the import kept the range out of the write watch for good, so it was compared and never armed. - A check at rewatch time can't see this, because the memory only turns shared afterwards. **A second source of the same faults,** from @tibzejoker's next bisect ([#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6318105853)). These are `MEM_MAPPED` faults over 60 s of Story with `APS5_NO_DEFERRED_SETTLES=1`, so #6678's path is out: | tree (from #9136) | `MEM_MAPPED` resumed faults | |---|---| | e9cc4a8ef, the merge before #8172 | 0 | | d9df34d08, #8172's merge | 6 | | 28f126650, #6598's merge | 134 | | 28f126650 with #8172 reverted | 1 | - #8172 keeps resident DCC targets in the write watch when an aligned block import spans them, which #8103 needs. To do that, `ImportWatched` keeps each watched run of such an import in the watch, instead of taking the whole import out. - In Grand Theft Auto V, those runs are resident direct memory that a second mapping later turns into shared views, which are then armed the same way (eboot `0x162b9e4` among their stores). - This change keeps them watched while they're private, as #8103's DCC targets need, and compared once they're shared. **The change, in seven commits, plus two test-only commits and a debt entry:** 1. **libc** (98adb5f205): `WindowsMappings::CompareWhenShared` marks the pages of a range, and makes writable again any alias of them that is already armed. - Once a marked page is shared, `collectable()` and the fresh-collect pre-check refuse a clearing collect over it before anything is made read-only. Its aliases are never armed, and the caller gets no write record, so it compares the range. - While a marked page is still a resident run, it's collected through `GetWriteWatch` as before. 2. **agc** (d98ee15162): `Rewatch` marks each range with `GuestArenaCompareWhenShared` before it returns the range to the watch. - The gain #6678 wants is kept while the memory stays private. - Once it is shared, the range is compared again, as before #6678. 3. **test** (ead292e2e5): `CheckComparedWhenShared` forgets its section's handle value before it maps. `WindowsMappings` keys its physical pages by that value, so a value that an earlier case closed without `ForgetSection` could come back with that case's stored pages. Test-only. 4. **agc** (81aec58343): `ImportWatched` marks the resident pages of each run it keeps in the watch, with `GuestArenaCompareResidentWhenShared`, a resident-only variant of the same mark. - This covers the runs #8172's path keeps watched. - Memory that is already shared when it's imported isn't marked, and keeps today's tracking. 5. **libc** (47c8df4950): the mark survives a full unmap and remap. - It lived only on the shared page, which `WindowsMappings` holds weakly. Once every view of that memory was unmapped, the next `Map` made a fresh, unmarked page, and the next clearing collect armed its views again. - `CompareWhenShared` now also marks the physical page, and a shared page made for it starts marked. `ForgetSection` still drops the mark, so a reused section handle starts unmarked. 6. **libc** (1ad5f29e20): the resident runs an import's read-write alias turns into shared views are marked too. - An import over a range that isn't all writable private memory maps a read-write alias first, and `MapAlias` turns every resident run in the range into shared views before `ImportWatched` runs. The import's resident-only mark skipped those views, so the import's walk and every later clearing collect armed them. - `MapAlias` now records the views it turns shared, and the resident-only mark includes them. A second guest mapping of the page clears the record, so memory the guest itself shares keeps today's tracking. 7. **libc** (37a5d9495d): a compared shared page is reported once. - When a page this change marks turns into a shared view while it's compared, `WindowsMappings` flags it unreported. - The first refused collect over it takes the flag and reports the page as a CPU write, once, as `main` reports the pages at the first collect after the sharing. 8. **agc** (1712336477): compared shared memory is never read as unchanged since before a refused collect. - The stale read @embersas's GPU fixture found ([comment](https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6363081974)): a texture cached before the sharing, then shared, then written with no lookup in between, came back from the first lookup unchanged, with no comparison. - A refused walk now records its generation for each 64 KiB block that holds compared shared pages. `UnchangedSince`, `UnchangedSinceAll` and `UnchangedCommittedSince` answer false against an older generation there, so a cache compares bytes instead of trusting stamps that never came. - The report alone wasn't enough: the dispatch cache takes the newest of several spans' collects, so a refused span's 0 hid behind another span's generation. - `WrittenSince`, `ChangedBlocks`, `StoredOver` and `NewestStamp` stay stamp-only, so storage textures and depth surfaces don't reload or drop at every epoch. Stamping the whole range at every refused collect would make depth surfaces reload from guest memory at every bind, dropping depth the GPU drew but hasn't stored. - **Cost:** one `std::map::lower_bound` per `UnchangedSince*` call (the map is empty on Linux), and on Windows two `WindowsMappings` listings per refused walk. Analytical, not timed. 9. **test** (388f5f13e6): `agc_driver_compared_shared_snapshot` takes embersas's ordering through the production `CachedSampledTexture`. 10. **docs** (cb9de8049c): a debt entry for depth surfaces over compared shared memory (below). **Scope:** - Only memory that a rewatch returned to the watch, or that an import kept watched while it was resident or that its alias turned shared, is affected. Other shared views are armed and collected as before, including direct memory that was never imported and is mapped twice. - Linux and macOS are unchanged: `WindowsMappings`, `Rewatch`'s Windows branch and the new mark in `ImportWatched` are Windows-only. - **Behaviour change:** native multisampled depth over compared shared memory now throws "guest writes over native multisample depth are not implemented" at the first check after a refused collect, as `main` throws it at the sharing. Before the eighth commit, this PR trusted the missing stamps there. - **A gap left as it is:** a depth surface over such memory doesn't see CPU stores made after the sharing, as over unwatched memory. The new debt entry says so. **Overlap:** - @Dripl1x's #9181 (d6e270ea9f, first posted in #9136) stops arming resident runs, which is #7473's part of the faults (the `MEM_PRIVATE` ones). This change covers memory that turns shared. The two touch different code and merge cleanly. @tibzejoker's run with both is in Tested. - Our open #8926 returns retired imports to the watch through the same `Rewatch`, so this change covers it too. #8926 depends on this PR. - Our open #9505 conflicts with 1ad5f29e20 in `WindowsMappings::Map`'s shared path, where #9505 restructures the loop that turns a page's resident aliases shared. The resolution keeps #9505's structure and clears `aliasDemoted` after each `demote` in both of its loops. They already conflicted in `WindowsWriteWatch.cpp`'s `main()` list, where both sides stay. - `git merge-tree` of the head against every open PR touching the changed files: no conflicts. Of the PRs that already conflict with `main`, 21 touch these files, and none touches the changed functions. ### Tested - **Grand Theft Auto V (PPSA04264), by @tibzejoker** ([#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6319072267)): `main` 663de1ab2 + Dripl1x's d6e270ea9 (#9181) + 81aec58343, 150 s of Story with deferred settles on. - Their verdict: "the crash is fixed with the two fixes together". 0 `MEM_PRIVATE`, 0 faults in zlib, `0x162b9e4` gone, no crash. - 105 `MEM_MAPPED` faults remain, at eboot `0x28f413a` (a store in a loop, not a red-zone leaf) and in a system DLL's host code. Both write 16 KiB views that were shared when written. As they read it, that is direct memory that was never imported and is mapped twice, which this change leaves armed. - **Grand Theft Auto V (PPSA04264) on a second machine, by @dantdmdarealguy** ([#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6338355911)): Windows 11 Pro, i9-14900K, RTX 5080 (NVIDIA 32.0.16.1742), WinLibs GCC 15.2.0, Release, game 01.005.000, warm caches, the same scripted pad input in alternating runs of 600-900 s. Their tree needed #9730's `sceVoiceSetThreadsParams` fix to reach gameplay. - `main` 7e2ba73e4 + #9730: the `[RAGE] HDD Streamer` crash, the game's `int 0x41` assert after `inflate` returned `Z_DATA_ERROR`, in 4 of 4 runs, 236-253 s after launch. One earlier manual run of that tree survived 900 s. - The same + #9181 (d6e270ea9) + this PR (99aeb0ac5): 0 of 3 runs, up to about 12 min of gameplay. - As they note, they didn't count resumed faults, so this shows only that the two PRs together remove the crash on a second machine and GPU. - **Grand Theft Auto V (PPSA04264), the faults that remain, by @tibzejoker** ([#9159 comment](https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6355849767), [#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6356302049)): `main` 3bbd2321d + #9181 + this PR up to 81aec5834 + #9730 + #9445, Windows 11, RTX 4090, `APS5_MIMALLOC=1`, 7-minute open-world runs with every resumed write fault logged. - Across about 15 runs with both PRs, 2 ended in the HDD Streamer crash. - In the 8 logged runs, 4 still had 1 to 4 resumed writes from zlib's `inflate_fast`, one per 4 KiB subpage of a fresh 16 KiB `MEM_MAPPED` view. One of those runs crashed, on the thread of its only zlib fault. The other 4 runs had none. - Their local version of the remap commit (the mark kept on the physical page) still saw resumed zlib writes in its 4 runs, with 1 crash. So the remaining faults come from another path, which this PR doesn't cover. - Their tree has neither 47c8df4950 nor 1ad5f29e20. 1ad5f29e20 closes one path that arms such views, and this PR doesn't claim to fix these faults. - Two more paths that turn resident memory into unmarked shared views are being checked: `breakRun`, where unmapping part of a resident run turns the whole run shared, and the demotion of a whole resident run when a second mapping shares one of its pages. A diagnostic that names the path behind each armed view would tell them apart in their runs. - **Independent CPU-only validation, by @embersas** ([#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6361307981); Ryzen 9 3900X, Windows 11 26300.9711, WinLibs GCC 15.2.0, Release; no game was run). This PR's head 1ad5f29e20 and #9181's d6e270ea9f, on `main` 0a0ed72167 alone and together, plus `test/9159-9181-together` (d7cec80e8c): - **The focused tests pass** on every tree, 3 runs each: `guest_memory`, `windows_write_watch`, `agc_write_tracking`, `agc_write_tracking_metadata_commit`, `agc_resident_direct_remap`, `agc_rewatched_direct_shared`, `agc_import_alias_shared`, `agc_host_import_retire` and more. - **The probe:** 16 known qwords in `[rsp-0x80, rsp)`, one 32-byte store per case, any fault resumed by `GuestArenaHandleWrite`; 90 executions. With this PR, the four shared cases no longer fault and keep all 16 qwords: rewatched, then a second mapping; a watched import, then a second mapping; rewatched, every view unmapped, mapped twice; an import alias over resident memory. On `main`, each faults and loses 13. - **Not this PR's cases:** the resident 2 MiB case is #9181's, and is fixed by it, not by this PR. Unmarked shared views still fault on every tree, which is the class #5640 (now merged) is for. - **Failing controls:** each piece of this PR reverted on its own (the two refusal checks, the `Rewatch` mark, the `ImportWatched` mark, the physical-page mark, `demote(..., true)`) makes its test fail and the store fault again. With only the refusal checks reverted, the alias store didn't fault in that sequence, but `agc_import_alias_shared` failed on the refusal. - **Not covered there:** the comparison callers use after a refused collect, `breakRun` and the whole-run demotion paths, the GPU tests, and any game. - **`windows_write_watch`:** - `CheckComparedWhenShared`: a marked resident range stays collected. A second mapping then makes it shared. From then on its collects fail, neither mapping is read-only, and stores into it raise no fault (the test's vectored handler counts them). The unmarked half of the same mapping is still collected. - `CheckResidentOnlyComparedWhenShared`: a resident-only mark leaves a shared view armed and collected, and still keeps a resident page compared once a second mapping makes it shared. - `CheckComparedWhenSharedRemapped`: a marked resident page is unmapped, then mapped into two views. A clearing collect through either view refuses, neither is made read-only, and a store raises no fault. After `ForgetSection` the same mapping is collected and armed again. - **New ctest `agc_import_alias_shared`** (WIN32, a process mode of `agc_write_tracking_tests`, next to `agc_rewatched_direct_shared`): it imports direct memory whose range needs a read-write alias, the way an import maps one, and requires that the pages the alias turned shared are compared and not armed. Memory the guest itself mapped twice before the alias is still armed, as before. - **New ctest `agc_rewatched_direct_shared`** (WIN32, its own process mode of `agc_write_tracking_tests`, in the `PATH` list), with two cases: - **Rewatched:** it maps direct memory resident, takes a block out of the watch and rewatches it as a settle does, then maps the same memory a second time. The block must collect while resident, then collect as 0 through either mapping, stay writable, and show a store through both mappings. A block that never left the watch must still be collected. - **Imported:** resident direct memory imported with the watch kept, then mapped a second time, must collect as 0 through either mapping, stay writable and show a store through both. Unimported shared direct memory must still be collected. - **The stale read through the sampled cache, on a GPU** (`agc_driver_compared_shared_snapshot`, this PC, Windows 11). The test runs on its first Vulkan device, which on this PC is the AMD Radeon integrated GPU (driver 31.0.21923.1000), not the RTX 3070. It checks the CPU-side cache logic; the GPU only reads the texels back. - **Red** on 1ad5f29e20 plus the test, 3 of 3: "the first lookup after a CPU store into shared compared memory returned the snapshot cached before the sharing". - **Green** at 388f5f13e6, 3 of 3, with `agc_driver_partially_resident_snapshot` and `_pending_stores`. - **#9181 alone** (c442afa5d1) plus the test passes 3 of 3, so #9181 isn't affected. - **The stale read on an NVIDIA GPU, by @embersas** ([comment](https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6374118786)): their external fixture, unchanged from their first report, on Windows 11 26300, Ryzen 9 3900X, RTX 3080 Ti (NVIDIA 610.88), WinLibs GCC 15.2.0, Release, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and the Khronos validation layer; no game was run. Four orderings, three repetitions per tree: - `main` ef0d8ae3b5: 12 of 12 pass. Their earlier branch of this PR with #9181 (d7cec80e8c): the two orderings that write from the CPU after the sharing, with no lookup in between, still return the stale first lookup, 3 of 3 each; the other two pass. - This head, cb9de8049c, without #9181: 12 of 12 pass. In the two affected orderings the first lookup makes one `TextureCompare` read, replaces the texture, and the GPU reads the new texel (`0xa0001234`, against `0x10001234` before); the other texels match, and the store raises no write fault. - `agc_driver_compared_shared_snapshot` passes 3 of 3 on this head on the RTX 3080 Ti, none skipped. - The layer loaded in every execution, with no `VUID-`, validation or synchronization message. - Their scope: a synthetic fixture that calls `Unwatch`/`Rewatch` directly and reads through a compute `texelFetch`. It doesn't cover host-import settling, draws, other caches or orderings, other GPUs, or any game. - **GitHub's runners:** - **df89dd1041, merged with `main` dab0113e06** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40113599047)). The merge's one conflict was `docs/dev/debt/libSceAgcDriver.md`, where `main` added its "Unmapped depth planes" entry at the same place as this PR's "Depth surfaces over compared shared memory" entry; both are kept. The PR's own added and removed lines are unchanged. - on Windows, the same 12 tests run ×10: 11 pass, 1 skips, 0 fail. `agc_driver_compared_shared_snapshot` skips, as the runner has no Vulkan device; - on Linux, `agc_write_tracking`, `agc_write_watch_coverage`, `guest_memory`, `guest_shm_open` and `guest_jit_shared_memory` pass ×10: 5 run, 5 pass, 0 skip, 0 fail; - the libc and libkernel suites pass on both (169 and 217 tests on Windows, 142 and 204 on Linux), run with `APS5_SKIP_TIMING_TESTS=1`. - **719a048a1f, merged with `main` 1e20650e84** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40072370223)). The merge's one conflict was the list of cases in `WindowsWriteWatch.cpp`'s `main()`, where `main` added three private-commit cases next to this PR's four; all seven run. The PR's own added and removed lines are unchanged. - on Windows, `windows_write_watch`, `agc_rewatched_direct_shared`, `agc_import_alias_shared`, `agc_compared_shared_generations`, `agc_resident_direct_remap`, `agc_write_tracking`, `agc_write_tracking_metadata_commit`, `agc_write_watch_coverage`, `guest_memory`, `guest_shm_open` and `guest_jit_shared_memory` pass ×10: 12 run, 11 pass, 1 skip, 0 fail. `agc_driver_compared_shared_snapshot` skips, as the runner has no Vulkan device; - on Linux, `agc_write_tracking`, `agc_write_watch_coverage`, `guest_memory`, `guest_shm_open` and `guest_jit_shared_memory` pass ×10: 5 run, 5 pass, 0 skip, 0 fail; - the libc and libkernel suites pass on both (147 and 213 tests on Windows, 120 and 203 on Linux), run with `APS5_SKIP_TIMING_TESTS=1`. - **The report commit, 37a5d9495d** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39958812606)): its only red is a build failure: its new `windows_write_watch` case uses the call the commit adds, so it doesn't build with 1ad5f29e20's code. The next commit's red covers the behaviour. At 37a5d9495d, on Windows, `windows_write_watch`, `agc_rewatched_direct_shared`, `agc_import_alias_shared`, `agc_resident_direct_remap`, `agc_write_tracking` and `agc_write_tracking_metadata_commit` pass 10 runs in a row, 6 of 6, none skipped; on Linux, `agc_write_tracking` passes 10 runs in a row. The libc suite passes on both and the libkernel suite on Linux; on Windows, `guest_raise_in_system_call` timed out once at the end of the libkernel suite, the runner timeout above. - **The refusal-mark commit, 1712336477** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39958882591)): **red** with 37a5d9495d's code, 3 of 3 on Windows: `agc_compared_shared_generations` fails with "write tracking test failed: a store into rewatched direct memory once shared reads as unchanged since a generation before the sharing", and the other 6 pass. **Green** at 1712336477: on Windows those 7 pass 10 runs in a row, none skipped; on Linux, `agc_write_tracking` passes 10 runs in a row. The libc and libkernel suites pass on both. - **The head, 388f5f13e6** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39950359679)): on Windows the same 7 pass 10 runs in a row, none skipped. - **The alias commit, 1ad5f29e20** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39897171612)): - **red** on Windows with the head before it (47c8df4950), 3/3: `agc_import_alias_shared` fails with "memory an import's alias demoted was armed by the import"; - **green** at 1ad5f29e20: on Windows, `agc_import_alias_shared`, `windows_write_watch`, `agc_rewatched_direct_shared`, `agc_resident_direct_remap`, `agc_write_tracking` and `agc_write_tracking_metadata_commit` pass ×10; on Linux, `agc_write_tracking` passes ×10; - the libc suite passes on both (142 on Windows, 115 on Linux) and the libkernel suite on Linux (197). On Windows, `guest_raise_in_system_call` timed out at 30 s on both arms, 47c8df4950 and 1ad5f29e20, so 206 of 207 pass; this commit changes nothing in libkernel. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners; - under Wine, the new case is red 10/10 on 47c8df4950 and green 10/10 at 1ad5f29e20, with two control cases, and a mutant without the line that clears the record fails. - **The remap commit, 47c8df4950** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39892006921)): - **red** on Windows with the head before it (99aeb0ac56), 3/3: "a page to be compared when shared was collected after every view was unmapped and it was mapped again"; - **green** at 47c8df4950: on Windows, `windows_write_watch`, `guest_shm_open`, `guest_jit_shared_memory` and `guest_memory` pass ×10, and the libc (142) and libkernel (207) suites pass; on Linux, the last three pass ×10, and the libc (115) and libkernel (197) suites pass; - the suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners; - under Wine 9.0, a build of the new case alone is red 10/10 on 99aeb0ac56 and green 10/10 at 47c8df4950. The full `windows_write_watch` stops earlier under Wine 9.0 on both trees, so the GitHub run is the check for the rest. - **99aeb0ac56, merged with `main` df2569d2c5** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39708223042)), with the PR's own diff unchanged by the merge: - on Windows, `windows_write_watch`, `agc_rewatched_direct_shared`, `agc_write_tracking`, `agc_write_tracking_metadata_commit`, `agc_resident_direct_remap`, `agc_write_watch_coverage` and `guest_memory` pass ×10, and the libc (142) and libkernel (207) suites pass; - on Linux, `agc_write_tracking`, `agc_write_watch_coverage` and `guest_memory` pass ×10, and the libkernel suite passes (197). libc's only failure is `precise_wait`, a timing test that fails there with `main`'s code too. - **Red for the first two commits,** with only the two checks in `collectable()` and the fresh pre-check reverted ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39608522649)): "a page to be compared when shared was collected once shared" and "rewatched direct memory was collected once shared". - **Red for the import commit,** with only its mark reverted on 81aec58343 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39622170106)): only `agc_rewatched_direct_shared` fails, with "imported direct memory was collected once shared". - **Green at 81aec58343** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39620216522)): - on Windows, `windows_write_watch`, `agc_rewatched_direct_shared`, `agc_write_tracking`, `agc_write_tracking_metadata_commit` and `agc_resident_direct_remap` pass ×10, and the libc suite passes; - in the libkernel suite, `guest_raise_in_system_call` hit its 30 s timeout once; this change doesn't touch libkernel; - on Linux, `agc_write_tracking` and the suites pass. - **ead292e2e5 on its own** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39618439578)): green on both runners. - With `main`'s code, the new cases don't build, because they use the new calls. - **With #8926 on top** (`test/9136-guard-8926-v3`, [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39619852795)): 33 Windows tests pass, including `agc_driver_graphics` with #8926's retired-import case. The same libkernel timeout appeared there once. - **#8103's DCC tests on Linux** (lavapipe, CI's flags), on 79cae21875, which has the same patch as 81aec58343: - `agc_driver_msaa_dcc_clear_4` and `agc_driver_msaa_dcc_state` pass 10/10; - `agc_driver_msaa_dcc_clear_2` and `_clear_8` skip, because lavapipe has only 1 and 4 color samples; `main` skips them the same way; - `^agc` passes 862/862 on the head and on `main`. - The change is Windows-only, so this shows the Linux side is unchanged. The Windows runner has no Vulkan device for these tests; the GPU run is below. - **The same DCC tests on a GPU:** NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42, the only device selected, Windows 11; GPU clocks weren't held, pass/fail only), on 5e8db4e8f7, a Windows tree of `main` 27bcd6a29e with #8926 and this PR's three code commits (all but the test-only ead292e2e5), from before the merge with `main`. `ctest -R '^agc_driver_msaa_dcc_(clear_[248]|state)$' --repeat until-fail:10` passes all four 10 of 10, `_clear_2` and `_clear_8` included. - **Resident Evil Village (PPSA01556)** on that tree and GPU, the intro check for #9136's guard: a 12-minute run from a cold shader cache reached the VR question with no "an address-based build copies … past 64 MiB" line, no abort and no FATAL. The largest guest upload was 63.8 MiB. - **Validation layer, `main` against cb9de8049c,** on GitHub's Linux runner (llvmpipe, LLVM 20.1.2) ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39969717075)): `agc_write_tracking`, `agc_driver_partially_resident_snapshot` and the three `agc_driver_host_import_*` tests, 5 of 5 passing on both trees. The layer loaded 4 times on each, and neither log has a `VUID-` message, so the change adds none. The new GPU test, `agc_driver_compared_shared_snapshot`, runs only on Windows, so this comparison doesn't cover it. On the Windows runner, without a Vulkan device, 7 of the 11 tests pass and the 4 device tests skip. - `check_conventions.py` passes, with no comment lines added. ### Checklist - [x] Based on `main` dab0113e06, merged in df89dd1041; 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none. Part of #9136 (the `MEM_MAPPED` side; Dripl1x's #9181 is the resident side) - [x] Unblocks: none claimed - [x] GPUs tested: none needed (CPU-side write tracking); Windows tests on GitHub's runner, #8103's DCC tests on lavapipe; the DCC tests and a Resident Evil Village (PPSA01556) run on an NVIDIA GeForce RTX 3070 Laptop GPU (617.42), Windows 11, on a tree from before the merge with `main`; the compared-shared snapshot test on this PC's AMD Radeon integrated GPU (31.0.21923.1000), Windows 11 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-22 01:42:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:42:54Z.

Review: DISMISSED


I reviewed the Windows shared-page comparison changes, the resident-only call path and the added write-watch regressions against the issue evidence. The latest PR body reports zero zlib/resident faults for the combined fix; hosted conventions, relinker, register-context and write-watch checks pass. Platform Windows/Linux product jobs were skipped, and I did not run a local Windows test. I found no code-level blocker in the submitted changes.

Approval is blocked on the repository freshness rule: this head is based on 27bcd6a29e2fd69aba0626610b2350eb8f2847f6, while current main is 94fbb8cea80af91db62ab6ee7e4da23341675c40; current main is not an ancestor of the PR head. Please rebase/update to current main and rerun the relevant focused Windows/write-watch validation on the updated branch. #9181 is an independent, complementary half of #9136; the two PR heads merge cleanly together, so I found no required dependency ordering between them.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608309191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9159#pullrequestreview-5608309191). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:42:54Z. **Review:** DISMISSED --- I reviewed the Windows shared-page comparison changes, the resident-only call path and the added write-watch regressions against the issue evidence. The latest PR body reports zero zlib/resident faults for the combined fix; hosted conventions, relinker, register-context and write-watch checks pass. Platform Windows/Linux product jobs were skipped, and I did not run a local Windows test. I found no code-level blocker in the submitted changes. Approval is blocked on the repository freshness rule: this head is based on `27bcd6a29e2fd69aba0626610b2350eb8f2847f6`, while current `main` is `94fbb8cea80af91db62ab6ee7e4da23341675c40`; current main is not an ancestor of the PR head. Please rebase/update to current main and rerun the relevant focused Windows/write-watch validation on the updated branch. #9181 is an independent, complementary half of #9136; the two PR heads merge cleanly together, so I found no required dependency ordering between them.
EagleBearerYS commented 2026-10-22 02:09:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T02:09:18Z.


Thanks, @MarcZX10. 99aeb0ac56 merges current main (df2569d2c5) into this branch with no conflicts, and the PR's own diff is unchanged by it. On GitHub's runners (run), the write-watch and resident tests pass 10 runs in a row on Windows, with the libc and libkernel suites, and the focused tests pass on Linux too. Tested has the details. Thanks for checking #9181 as well.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330981185 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6330981185). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T02:09:18Z. --- Thanks, @MarcZX10. 99aeb0ac56 merges current `main` (df2569d2c5) into this branch with no conflicts, and the PR's own diff is unchanged by it. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39708223042)), the write-watch and resident tests pass 10 runs in a row on Windows, with the libc and libkernel suites, and the focused tests pass on Linux too. Tested has the details. Thanks for checking #9181 as well.
EagleBearerYS commented 2026-10-22 10:25:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T10:25:38Z.


@dantdmdarealguy thanks for the alternating runs of Grand Theft Auto V on the RTX 5080 (#9136 comment): the HDD Streamer crash in 4 of 4 runs without #9181 and this PR, and in none of 3 with them. It's in Tested as a second machine, with your note that the runs didn't count resumed faults.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6338496776 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6338496776). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T10:25:38Z. --- @dantdmdarealguy thanks for the alternating runs of Grand Theft Auto V on the RTX 5080 ([#9136 comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6338355911)): the HDD Streamer crash in 4 of 4 runs without #9181 and this PR, and in none of 3 with them. It's in Tested as a second machine, with your note that the runs didn't count resumed faults.
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!9159
No description provided.