fix(agc): keep the driver's reads of known-zero guest pages out of Windows write-watch #20084
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20084"
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 oneandonlydean on 2026-11-14T15:25:05Z.
What
On Windows the driver's own reads of never-written guest pages were collected as CPU writes. JJenkx found the cause in #18281:
GetWriteWatchreports a read that faults in a demand-zero page of privateMEM_WRITE_WATCHmemory as a write.DepthSurface::CapturePublicationcollects the plane's generation and then reads the plane withCopyGuestBytes; when the plane was only drawn on the GPU, that read stamped its 2048 pages as CPU writes and the nextUnchangedSinceAllcheck aborted with "guest writes over native multisample depth are not implemented".The guest arena already tracks which watched pages are known to be zero (
GuestArenaKnownZero, used by the heap mirror since #15967/#18144). On Windows,CopyGuestBytes(and soRead),ReadCommitted,EqualsCommittedandCompareMappednow ask it for the range first, take the known-zero spans as zeros without touching them, and read only the rest. A page is known zero only while write-watch has not reported it since its last reset, or it was reported and still reads all zero, both decided under the arena's mapping lock, so the zeros are the page's bytes at that moment. Nothing resets or drops a write-watch report: a guest store after that moment, including a zero store over a never-written page (#18144), is still collected. Linux and macOS are unchanged (the new path is compiled only on Windows; reads never report there).The reads this does not cover (the guest's own reads, host reads outside these functions, pages that left the known-zero set and were trimmed back to demand-zero) are listed in docs/dev/debt/libSceAgcDriver.md.
Tests:
agc_guest_read_known_zero(new, Windows only, skips elsewhere): reads 8 MiB of never-written guest memory through every primitive, then requires that a collect leaves the range unchanged; a zero store and a nonzero store after the reads must be collected; 200 rounds of a guest zero store and a nonzero store racing a 2 MiBCopyGuestBytesover fresh memory must be collected.windows_write_watch:CheckKnownZeroReadsSkipFirstReadReportsrecords whether first reads of demand-zero pages are reported on the running system, then checks that a read that takes known-zero spans as zeros is not collected and that a later zero store is.Tested
Linux (CachyOS, GCC, Release): built
libSceAgcDriver,libcand the touched tests; ctest results below.agc_guest_read_known_zeroand the Windows write-watch test do not run on Linux.ctest -R 'agc_guest_read_known_zero|guest_memory|collect_memo|collect_coverage|known_zero|write_watch|resident_mirror|resident_heap|depth|copy_guest': "100% tests passed out of 107", withagc_guest_read_known_zeroskipped (Windows only). This set includesagc_collect_memo_generation,agc_driver_resident_heap_mirror,agc_driver_native_depth_publicationand the other depth tests.Windows: not built or run by me. It needs a Windows build,
windows_write_watchandagc_guest_read_known_zero(the latter should fail on main and pass here), and runs of PPSA13934 on the island past 300 s.Perf on Windows is unmeasured: each of these reads now takes the arena's mapping lock once per 2 MiB chunk and, where a chunk has known-zero pages, a
GetWriteWatchquery without reset. A paired before and after run of PPSA21564 on Windows would show whether the smallCopyGuestBytescalls from shader memory cost anything.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T15:50:44Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the Windows-specific build and tests were not run, so the inspected evidence supports only a non-blocking review.
What I ran
Reviewed head
3b634af403be18275c6b7b1c72777631cd6af5d9usingrepo_read.pyto inspect the prepared diff, changed files, and targeted callers and APIs. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
windows_write_watch, andagc_guest_read_known_zerobefore merging. The changed behavior is under_WIN32; the description reports no Windows build or test run, and this review did not run them either.Not verified
Windows compilation and runtime behavior, including the new race test and performance impact, were not verified. The Linux test results in the PR description are author-reported, not run in this review. The prepared review folder listed five changed files, all included and read; no excluded changed files were listed.
To get this to a good state
Nothing is required. Optional: run the Windows build and the two Windows tests noted above.
Continued review (pass 2)
The added test registration and documentation lines are consistent with the described Windows-only regression coverage; no defect was found in the specified additions.
What I ran
Reviewed head
3b634af403be18275c6b7b1c72777631cd6af5d9; no commands or tests were run. Read the specified additions inagc_guest_read_known_zero_tests.cmake,WindowsWriteWatch.cpp, andlibSceAgcDriver.md, plus their diff context and relevant CMake registration location.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The Windows test executables were not built or run. The review covers only the specified added lines and their local context; it does not reassess the rest of the pull request.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T16:29:13Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes implement the described Windows known-zero read path; I found no verified blocking defect, but could not run the checks or verify behavior on Windows.
What I ran
Reviewed head
8c090909547ad5629865b86bf78bbce975db7a61using the prepared diff and pinned-head reader. No tests or build commands were run.Results
Negative control
Not run. I did not change the code under test or run the new tests.
Findings
Blocking
None.
Non-blocking
The change is Windows-specific, and the author reports that Windows build and tests have not run. Verify the new tests on Windows, including the reported failure on main and pass on this head, before relying on the fix for the affected workload.
Sources
Not verified
windows_write_watch,agc_guest_read_known_zero, and PPSA13934 behavior were not verified.GuestMemory.cpp,GuestReadKnownZero.cpp,agc_guest_read_known_zero_tests.cmake,WindowsWriteWatch.cpp, anddocs/dev/debt/libSceAgcDriver.md. Related context read:WindowsMappings.hppandGuestArena.cpp. All five changed files listed in the manifest were included and read; no changed files were excluded.To get this to a good state
Nothing is required. Optional: build and run the Windows tests on this head, then validate the affected workload on Windows.
Continued review (pass 2)
Nothing blocks this continuation review; the specified added lines and their surrounding code show no verified defect.
What I ran
Read the continuation lines and surrounding code at head
8c090909547ad5629865b86bf78bbce975db7a61; no commands or tests were run. The inspected files werecore/libs/tests/WindowsWriteWatch.cppanddocs/dev/debt/libSceAgcDriver.md.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The rest of the PR and all other added lines were not reviewed in this continuation pass; the broader review is covered by the earlier pass. Windows tests were not run.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:13:37Z.
Review: COMMENTED
Reviewed — no blocking findings
Windows-only behavior is the central change, and the prepared description reports Linux checks but no Windows build or run; I found no concrete defect in the changed code I inspected.
What I ran
Reviewed head
3296b40a0172bfabb28827183b0a24d0c66bd450. No build or tests were run in this session. I readdescription.md,commits.md,manifest.json,diff.patch, and the full text of all five changed files listed in the manifest. No files were excluded by the manifest.Results
Findings
Blocking
None.
Non-blocking
The core behavior and its new regression tests have not been built or run on Windows. Please run the Windows build,
windows_write_watch, andagc_guest_read_known_zerobefore relying on the reported fix.Sources
The changed implementation is in
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp(lines 3661–3686, 3701–3712, 3748–3794, and 3850–3866). The new Windows regression is incore/libs/prx/libSceAgcDriver/tests/GuestReadKnownZero.cpp; related write-watch coverage is incore/libs/tests/WindowsWriteWatch.cpp.Not verified
No compilation or tests were performed in this session. Windows behavior, including the new tests, remains unverified here. The author reports Linux checks in the PR description; those results were not independently verified.
To get this to a good state
Nothing is required. Optional: run the Windows build and the two Windows tests listed above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T05:32:34Z.
Review: COMMENTED
Reviewed — no blocking findings
The patch is structurally consistent with the stated Windows write-watch fix, but its Windows-only implementation was not built or run by the author or reviewer.
What I ran
Reviewed head
d772094c8b2a2c1a0f43cf1ba89cb8a533a7270a; no merged-preview check was run. I inspected the prepared diff and usedrepo_read.pyto read relevant pinned-head context. I ran no build or tests. The Linux test results below are author-reported.Results
Negative control
Not run. No Windows test or build was available to verify that this change fails on the base revision and passes on the PR head.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The Windows-only code and tests were not built or run. The author reports Linux build and test results, but I did not independently run them. I reviewed the changed diff content for all five files in
manifest.json:GuestMemory.cpp,GuestReadKnownZero.cpp,agc_guest_read_known_zero_tests.cmake,WindowsWriteWatch.cpp, andlibSceAgcDriver.md. The manifest lists no excluded files. For repository context, I read relevant ranges fromGuestMemory.cpp,WindowsMappings.hpp, andCMakeLists.txt; I did not read the full text of every changed file.To get this to a good state
Nothing is required. Optional: run a Windows build,
windows_write_watch,agc_guest_read_known_zero, and the reported PPSA13934 scenario; record the results and Windows performance impact.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T05:35:18Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
💬 Code review
Actionable comments posted (1)
bef6b1cf-db6a-4e9a-a04a-85efff476faeReviewing files that changed from the base of the PR and between
2af8e79edfandd772094c8b.core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/GuestReadKnownZero.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_guest_read_known_zero_tests.cmakecore/libs/tests/WindowsWriteWatch.cppdocs/dev/debt/libSceAgcDriver.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-12-01T10:16:05Z.
Review: APPROVED
Approved after exact-head Windows validation of
d772094c8b2a2c1a0f43cf1ba89cb8a533a7270a.Environment: Windows 11, GCC 16.2 (UCRT64), Release,
BUILD_TESTING=ON, NVIDIA RTX 4070 SUPER.Built:
windows_write_watch_testsagc_guest_read_known_zero_testsagc_driver_committed_read_mapping_testsResults:
windows_write_watch: passwindows_write_watch_verify_direct: passagc_guest_read_known_zero: pass, plus 5/5 consecutive repeat runsagc_driver_committed_read_mapping: pass, plus 20/20 consecutive repeat runsgit diff --checkagainst the PR base: passThe repeated committed-read mapping result specifically covers the regression reported on the earlier head; I found no new correctness defect in the complete five-file diff. I did not run PPSA13934 or measure the Windows performance impact. I also did not duplicate the existing debt-fragment convention comment.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T13:30:56Z.
Review: COMMENTED
Reviewed — no blocking findings
The source review found no verified blocking defect, but Windows-only behavior remains unvalidated on this head.
What I ran
Reviewed head
103564dd643acb06df8b2c787d4660bdb5deb012using the pinnedrepo_read.pyreader and the prepared diff. No tests or builds were run; the author’s reported Linux test results were not independently verified.Results
Negative control
Not run; the Windows-only negative control requires a Windows runtime.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Windows execution, including
windows_write_watchandagc_guest_read_known_zero, and the proposed Windows performance comparison were not verified. All 5 files listed underreviewedinfiles.jsonwere read; no files were excluded.To get this to a good state
Nothing is required. For additional confidence, run the two Windows-only tests and collect the proposed before-and-after Windows performance comparison.