Windows: agc_write_tracking fails since #3594, StoredOver still trusts block stamps for arena host holes #4087
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T22:59:09Z.
Environment: Windows 11 Pro 10.0.26220, WinLibs GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON;main1a7b96b5bplus #4021 (needed forlibkernelto compile).Reproduction
First bad merge:
8a13a1b8e, #3594 "fix(agc): exclude host arena holes from write-watch proofs" by @Scramblrrrr. Its parent07eacac68passes; the merge fails.Failure
This comes from
core/libs/prx/libSceAgcDriver/tests/WriteTracking.cpp:95(inCheckSharedBlock):Analysis
unwatchedsits on the main thread's host stack. On Windows that address lies inside the guest arena's address interval but in a host hole the arena was reserved around, soWriteTracker::covers()(coverage.Covers) returns true for it.Watched()returned true for the host hole, so the test skipped theStoredOvercheck.Watched,collectWrites,UnchangedSinceandUnchangedSinceAllreturn "not watched" whenGuestArenaHostRegionOverlaps_nid_postfixis true. It did not changeStoredOver(core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:1305).StoredOverstill passes itscovers()check, finds no newer stamps on the block, and returnsfalse("not stored over").This only affects Windows. The host-hole exclusion is
#ifdef _WIN32. On other platformscovers()goes throughGuestWriteWatchCovers_nid_postfix, which does not cover an unregistered stack, soStoredOverreturns true early.The test is not the only thing affected.
StoredOveris used as a proof byGraphics/src/Draw.cpp:210(CMASK proofs) andGraphics/src/Texture.cpp:1725and:4023, so a host-hole range can still be treated as not stored over in production. The other stamp readers that #3594 left without the exclusion areUnchangedSinceCollected,WrittenSince,ChangedBlocks,MarkWrittenandImportWatched. Each should be checked for the same inconsistency.Minimal fix (verified locally, not committed)
In
StoredOver, treat host holes as unwatched, the same way #3594 does inWatched:I rebuilt
agc_write_tracking_testswith only this change against the1a7b96b5bbuild. It printedwrite tracking tests passed3/3; the unmodified exe fails.A broader option is to do the host-region exclusion once inside
WriteTracker::covers()on Windows. Then every caller gives the same answer, including the five functions listed above.Found and bisected with Claude Code assistance (five full Windows builds, each with #4021 applied to make
libkernelcompile); reviewed before posting.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T00:21:34Z.
Fix branch ready:
screamm:fix/write-tracking-host-holes(03860b02, one commit onmainbab7b328). I cannot open it as a PR under the intake rule while #4081 is open; anyone eligible is welcome to carry it, keeping the commit as is.WriteTracker::covers()now returns false for any range overlapping an arena host hole, so every query (Watched,StoredOver,UnchangedSince*,WrittenSince,ChangedBlocks,MarkWritten,StoreOwnBytes,ImportWatched,collectWrites) gives a hole the answer an unwatched range always got; the five separate#ifdef _WIN32checks from #3594 are removed, their range-overflow early returns stay. Each query's "not covered" answer is already the safe one for its callers (Draw.cppCMASK proofs,Texture.cppkeep checks,VulkanDevice.cpp). Ranges outside holes behave as before: the arena is reserved in allocation-granularity pieces around the holes and tracker blocks are 64 KiB from the arena base, so no block is shared between a hole and arena memory.CheckHostHole()inWriteTracking.cpp(Windows only) finds a hole withVirtualQuerythe wayBdaResources.cppdoes and checks all twelve queries against it; againstmaintheStoredOver,MarkWritten,StoreOwnBytes,WrittenSinceandChangedBlockschecks fail, and with only thecovers()change reverted it fails at the first check. Like #3594's own test it assumes the arena contains a host hole.StoredOver/WrittenSincebut not on the same lines.Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs:agc_write_tracking,agc_write_watch_coverage,guest_memory3/3 (alsoagc_shared_write*);ctest -j8 -E "^agc_driver_|^video_out_flip"582/583, the one failure being #4088;tools/check_conventions.py --base mainandgit diff --checkpass. Not run on Linux (the change is inside#ifdef _WIN32).Written with Claude Code assistance (fix by a subagent, reviewed and validated in this session).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T00:34:50Z.
Thanks for catching the missing StoredOver exclusion, and for the Windows bisection/negative control. #3594's focused checks did not cover that existing assertion; I should have included agc_write_tracking. I see #4131 is now merged and will include that check in my next Windows current-main build. I am reviewing the remaining stamp readers listed in #4087 before proposing any further change, rather than duplicating the merged fix. AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T00:37:12Z.
I have picked up screamm's public 03860b02 for a Windows current-main cross-test, preserving author/commit attribution. It applies cleanly on
7a84b222with #4131 already merged (local integration1b4baaee2). The arena's host-region list is fixed during reservation and OverlapsHostRegion does not take the allocation mutex, so moving the exclusion into covers does not introduce that lock acquisition under the tracker lock.I will run the existing write-tracking/coverage/guest-memory checks plus the new twelve-query fixture after my current bounded 007 measurement ends. No competing implementation; I have not claimed a tested result or opened a carry PR yet. AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T00:56:31Z.
The canonical carry is now #4186, preserving screamm's author/commit content on main
7a84b222. Windows current-main integration 27c134117 passed write tracking (including the twelve-query fixture), write-watch coverage, guest memory, graphics and BDA device 5/5 in8.53s. Description distinguishes the standalone carry head from that profiling-only integration; no full-suite/Linux claim. Thanks for the correction and explicit carry offer. AI-assisted: yes (Codex).