fix(libc): report writes consumed before an alias at both of its views #23976
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23976"
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 chitters2004 on 2026-11-19T23:48:37Z.
What
On Linux,
DirectMemory.cppWatchMappingregisters a new mapping withGuestWriteWatchRegisterand then aliases it to every mapping sharing its backing with separateGuestWriteWatchAliascalls.Watch::AliasinGuestWriteWatch.cpponly linked the two views. A collect that walked either view between those calls, from any thread (for example a tracked range of an earlier mapping at that address), consumed a write's dirty bit with a plan that had no link yet. The write was reported at that view only, and once the views were linked the other view never learned of it: a stale read through the new alias. The two views have separate userfaultfd write-protect bits, so a write through one never marks the other.Aliasnow marks both linked ranges fresh, asRegisteralready does for a new range. The next collect of either view reports the linked range whole and fans it out through the new link. Both sides are marked so the report survives either side being unregistered before it is collected. The cost is one whole report of the aliased overlap perAliascall. The window is narrow (a collect from another thread between those calls), and no title is known to show it. +4 lines inGuestWriteWatch.cpp, plusCheckAliasAfterConsumedWriteinlibSceAgcDriver/tests/WriteTracking.cppand the CTestagc_write_tracking_alias_after_consume(Linux only, skipped elsewhere): it maps one memfd at two views, registers and collects both, writes through one view, collects that view, aliases, and requires the other view to report the page and neither view to report it again afterwards, in both directions.Tested
agc_write_trackingand its neighbours: Linux 4 passed (main: 3), no new VUIDs; Windows 11 passed, 1 skipped (the new test, Linux only), same results as main otherwise: https://github.com/chitters2004/AnyPS5/actions/runs/44637479711 (run on a commit with the same tree as this head; only the message differs)draft/ci-mf11-control: the new test on mainc3a823624fwithout theAliaschange):agc_write_tracking_alias_after_consumefails on Linux ("a write consumed at one view before an alias was never reported at the other view"), main's tests pass: https://github.com/chitters2004/AnyPS5/actions/runs/44637494214userfaultfdwrite-protect async andPAGEMAP_SCAN(kernel 6.7+), as on the CI runners.Checklist
main(c3a823624f); no other open PR implements the same functions (#20580, #20126, #19557, #19054, #12792 touchGuestWriteWatch.cppand #23613, #23770, #20349 touchDirectMemory.cpp, none changesAliasorWatchMapping)NotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:57:55Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
bb328c92a21f5d33c0d93ce43e19242f959ca66aagainstmain. I did not run commands or tests. The author reports Linux and Windows CI results and a failing negative control in the PR description; I did not independently verify those runs.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the test suite or verify the reported CI runs, physical GPU behavior, or console behavior. All files listed as reviewed in the manifest were read:
core/libs/prx/libSceAgcDriver/tests/WriteTracking.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_write_tracking_tests.cmake, andcore/libs/prx/libc/src/GuestWriteWatch.cpp. No files were excluded by the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:10:34Z.
Review: APPROVED
I read the diff at
bb328c92a2. Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged intomainat6c6b29320fetogether with other open PRs (so not an isolated build).agc_write_tracking_alias_after_consumeand the otheragc_write_trackingtests: pass.Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:55:30Z.
Review: COMMENTED
On Linux,
agc_write_tracking_alias_after_consumepassed atbb328c92a2. It exercises a write consumed before the alias is registered in both view orders, then checks that the next collection after reporting is quiet. The generation-wrap, mark-order, and Vulkan scalar-buffer controls passed on the same baseline and change. Both scalar runs loaded the Khronos validation layer and had no missing-layer warnings or VUID messages.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.