feat(agc): implement deferred faults for reads through null SRT pointers #759
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/759"
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 Celegans12 on 2026-10-05T21:12:34Z.
What
Capturing a shader throws
AGC driver: null or misaligned addresswhen the flat SRT walk reads through a pointer loaded from memory that is null or unmapped, even if the program skips thats_load; the console faults only when a wave runs it. Following boykopovar's guidance, this is a pure runtime check: shaders still compile at registration and nothing per capture enters a key.ReadConstof a flat slot that can depend on such a read (ComputeGuardedFlatSlots) checks a flag word in the flattened SRT. A set flag raises anUnmappedBDA fault with the recorded pc and address and stops the invocation like an unmapped BDA read. These programs get the fault buffer (ShaderInfo::usesFaultBuffer).SrtRuntime::accessible) is not made; the slot reads 0 and the capture appends the flags and{pc, address}records.s_cbranch_execz.EvaluateRawReadandEvaluateRuntimeSourcesImpl.Tested
main1be6f9f1: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 485/485 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_guarded_null_pointer(GPU): skipped null reads (SCC branch,s_cbranch_execz) don't fault; executed ones fault at their pc and address, even with one lane or an empty EXEC; all runs of a program share one pipeline variant.agc_shader_memory: null, unmapped and chained records, one variant, specialization and module for poisoned and clean captures, replay, and the remaining throws. Neither test builds onmain; both pass with-DANYPS5_ENABLE_SPIRV_TOOLS=ON.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T15:13:30Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1527, L1549-1550core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppL456core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppL90-108core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTableCache.cppcore/shader/recompiler/ImageTableAbi.hppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppL627-629, L968-971core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL197, L2458core/libs/prx/libSceAgcDriver/Graphics/include/Context.hppL137core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppL92core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL521core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppL126, L495, L511core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL197, L2458core/libs/prx/libSceAgcDriver/Graphics/include/Context.hppL137core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppL92core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL521core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppL126, L256, L495, L511Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T16:09:43Z.
A second title for this one: @orbz22 tested Astro's Playroom (PPSA01325) with #759 (a3de45b1) on top of #285, and the
guest memory is not readable at 0x28stop in compute shader 0x5001c6a00 (an SRT walk through a null user-data pointer) is gone (their report). The only conflict they hit was the role list inShaderValidation.cpp, which needs bothGdsandImageTableMap.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-07T16:46:50Z.
Run of this PR on PPSA21567, as asked in #479.
Setup: Linux (CachyOS, kernel 7.2.8, GCC 16.2.1), Ryzen 7 7800X3D, RX 9070 XT (RADV GFX1201, Mesa 26.2.3).
main1e5bb880+ #285 (c7eac179) + this PR (a3de45b1). One conflict inShaderValidation.cpp: the role allow-list gets bothGds(#285) andImageTableMap(this PR). Default settings, one 180 s run.maincompute shader 0x50082b700: AGC graphics: unsupported descriptor role Gdsmain+ #285compute shader 0x5005f6100: AGC driver: guest memory is not readable at 0x30 (range 0x30+0x4)main+ #285 + this PR0x5005f6100; the next stop is unrelated:FATAL: an address-based build copies 12403 MiB of 35 registered ranges, past 64 MiB(every host import fails on RADV, the case #943 addresses)Not checked: whether the
s_bitcmp1_b32/s_trappath you pointed at in #479 executed. stderr has no fault report and no message naming0x5005f6100, but I did not inspect the fault buffer.AI-assisted: yes (Claude Code ran the builds and wrote this report; the runs are on my machine).
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T17:02:48Z.
Thanks for running it on RDNA4. A third title, and the first on RADV, is a big help for this one.
On the part you didn't check: you don't need to read the fault buffer for that. If the guarded
s_loadhad actually executed, the deferred fault would surface on stderr asBDA access failed: address=0x30 instruction=0x… bytes=4 … reason=1for that dispatch, like any other BDA fault. So no such line for0x5005f6100means the read behind the branch never ran, which is the case this PR is for.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-07T17:36:41Z.
Checked: that run's stdout and stderr have no
BDA access failedline, so the guarded read in0x5005f6100did not execute.AI-assisted: yes (Claude Code checked the log; the run is on my machine).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T11:01:11Z.
@boykopovar this one needs your call, because it's in the #639 area. The last commit (c838c1673) adds
srtPoison(slot, pc, address of each read through a null SRT pointer) toResourceSpecialization, and throughBuildKeyto the variant and the disk-cache key. #639 replaces specialization by resource with runtime descriptors. It's also stacked on #757/#758, which are already waiting on your ordering against #639.Why it matters: it removes the
guest memory is not readable at 0x28/0x30stop on three titles. PPSA26344 (author), Astro's Playroom PPSA01325 (orbz22, on top of #285) and PPSA21567 (EdouardSence, RADV RDNA4, on top of #285; noBDA access failedline, so the guarded read really is skipped). Dean also sees this stop blocking a title onmain.Should it land before #639, or wait and get redone on runtime descriptors?
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-08T14:56:20Z.
A title that needs this: Ghost of Yōtei (PPSA26344 v01.008.000, retail). Headless runs on Linux, RX 9070 XT, Mesa 26.2.4 RADV.
Current
main(29e533ac) stops before its first present:The image descriptor is read from a buffer, at an offset computed in a loop.
main+ #1274 stops at the same line.mainat6b573862+ this PR at c838c167 gets past it. Shader 0x80003aa700 no longer fails, 96 resource builds run instead of 43, and the next stop is a different shader:That is the case #822 covers.
Caveats on that build:
main.main, it gives 8 conflicts in the recompiler (DescriptorBindingBuilder,ResourceMaterializer,SpirvImageEmitter,ShaderDiskCache). I did not try to resolve those myself.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T16:30:22Z.
Thanks for the RADV run, it's good to see 0x80003aa700 get through on AMD too. The conflict with
maincame from today's cache format bump. 6fb7f68e is rebased onto it and merges cleanly now. For the #759 + #822 combination, I put a merged branch on my fork and described it on #822: https://github.com/Celegans12/AnyPS5/tree/test/yotei-759-822Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-09T02:31:24Z.
I've rebuilt this as a pure runtime check, following boykopovar's guidance. It now sits directly on
maininstead of on #758 and #757, so it doesn't depend on either of them any more. This is the redo after #639 that adriadam10 asked about.At registration, every flat SRT slot that can depend on a read through a pointer loaded from memory gets a guard: its
ReadConstloads one flag word from the flattened SRT and branches on it. When a capture finds such a read null or unmapped, it skips the read, the slot reads 0, and the flag points at a{pc, address}record. If a wave actually executes the read, the shader raises anUnmappedBDA fault at that pc and stops the invocation. Nothing per capture goes into any key, so poisoned and clean captures share one variant, specialization and pipeline.oneandonlydean mentioned this is the next fix Astro Bot needs. I haven't run Astro Bot on the new head myself, so a run from someone with the title would be very welcome. Otherwise it's ready for review.
Details
56f8a62428onmain1be6f9f1. Disk cache format 21, becauseusesFaultBufferis encoded now; #822 also takes 21.ReadConst: one extra 32-bit load from a buffer the shader already reads, plus a uniform branch.CacheableResultand #757's fault-completion check.agc_shader_memoryand the GPU testagc_driver_guarded_null_pointer. A skipped null read doesn't fault, an executed one faults at its pc and address, and every run of a program uses one pipeline variant. Neither test builds onmain.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T08:05:45Z.
Astro Bot (PPSA21567, retail) run on the new head
56f8a624. No regression from this PR, but the run doesn't reach its code yet.Setup: RX 9070 XT (RDNA4), RADV / Mesa 26.2.4, Linux 7.2.9. Scripted input, headless gamescope, from boot. All stacks are on
maina8b032b2and merged cleanly.shader image heap capacity exceeded(#1789)prepared shader artifact is missing for the requested static ABI ... stage=5 wave=64(the null pixel program, #1901)prepared rectangle artifacts are missing(details on #1902)Unmappedfault came from the guarded reads.astrobotbranch is never reached. I'll run it again once the walls above are fixed.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T12:43:59Z.
Astro Bot (PPSA21567) now reaches this PR's code, and it gets past the stop. Tested on head
56f8a624, Linux, RX 9070 XT (RADV), scripted and headless.Base:
main43972e69+ #1836, #1837, #2105, #1893, #1902, #1928 and CouchRiv's #1789 branch (bd5f22c9).compute shader 0x5005f6100: AGC driver: guest memory is not readable at 0x30 (range 0x30+0x4). That is a read through a null SRT pointer.Unmappedfault is reported, so the guarded read is skipped and never executed.No frame is presented yet in these runs.
Tested and written by Claude (AI assistant) on a contributor's machine.