fix(agc): load each REWIND control once with acquire in copySegment #17411
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17411"
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-08T19:08:07Z.
What
Driver::copySegmentcopied every packet from guest memory with a plaininsert, including a REWIND packet and its control dword. A title releases one gate and then writes the next gate's control throughsceAgcRewindPatchSetRewindState(a release store) while the queue worker copies the tail holding that next REWIND, so the plain copy raced the atomic store.A REWIND is exactly two dwords (
Pm4.cppsizes it withsize(2),sceAgcDcbRewindGetSizereturns 8 bytes), socopySegmentnow requires that and takes the control with oneatomic_refacquire load, the pair of the release store and the orderexecuteRewindTailandnoteReleasedTailsalready use. Other packets are copied as before. The replay tool writes controls inrestoreGroupwith a plain copy instead; that is fixed separately in #17338.Tests in
tests/Pm4.cpp:agc_driver_pm4_rewind_copy(a writer releases gates while the queue copies the tails behind them) andagc_driver_pm4_rewind_size(a REWIND that is not two dwords throws incopySegment;mainalready rejected it later, in validation, withinvalid packet size). The race is only visible to TSan, which upstream CI does not run (sanitizers.ymlruns ASan and UBSan), so the TSan runs below are the evidence; without TSanrewind_copypasses onmaintoo.Tested
rewind_copymain 0/32 pass (run 42510041542) (data racecopySegmentread vsSetRewindStatestore, 32 reports), this change 32/32 and 0 reports (run 42510039286), mutant (plain copy of the control restored) 0/32 (run 42510043667).rewind_sizemain 0/32 (different message), change 32/32, mutant 32/32.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R agc_driver_pm4: change 28/28 pass, main 27/28 (only the newrewind_size); neither log containswas not found but was requested, neither containsVUID-.agc_driver_pm4_rewind_tracealso fails under TSan on main; it is a different race (a plain label read inPm4::WaitSatisfiedUncheckedagainst the test's atomic store) and is not changed here.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)🤖 Generated with Claude Code