AGC: SRT walker statically evaluates a scalar load behind a per-lane exec guard and fails on a NULL pointer #479
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 ThisIsAkill on 2026-10-03T20:10:09Z.
Summary
A compute shader fails at record time with
AGC driver: guest memory is not readable at 0x30 (range 0x30+0x4). The SRT walker statically evaluates a scalar load that sits on a branch it cannot evaluate (a per-laneexecguard), follows a NULL pointer, and throws. On hardware the block would page-fault if it ran, so it is presumably not executed while the pointer is NULL.Seen with PPSA21567 on Linux (GCC 16.2),
maind3ec1f15plus #285, compute shader at0x5005f6100(16x16, wave64).Pointer chain
The table that
s[0:1]points to is mapped and all zero, soPis NULL.Why this is not a bounds-check case
s_load_*reads a raw 64-bit address. There is no V#, so nonum_recordsclamp (onlys_buffer_load_*is range-checked). If this block ran withP = 0, real hardware would raise a VM fault rather than return 0. The title does not fault on the console, so the block is presumably not executed whilePis NULL.Where the driver fails
SrtDescriptorEvaluation.cpp(EvaluateRuntimeSourcesImpl) marks descriptor sources inactive only on paths whose block condition the clean evaluator can compute from uniform memory. The guard here isexecfrom a per-lane compare, which it cannot evaluate, so both successors stay active. The load throughPis then evaluated when the dispatch is recorded, andGuestMemory::CheckRangethrows.Options (not choosing)
FaultBufferpath, or a trap), and throw when the fault is read back. A block that never runs costs nothing; one that does run still fails loudly.Assumptions and limits
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-03T20:12:54Z.
Note for option 1:
IrResourcePlan::controlFlow(theResourceBlocklist thatEvaluateRuntimeSourcesImpluses to mark sources inactive) is never populated outside a test (libSceAgcDriver/tests/ShaderMemory.cpp).ExtractPlancopies it from the program's plan, and nothing in the recompiler fills it. So today the walker evaluates every descriptor source unconditionally, including sources on branches with a uniform, evaluable condition. Deferring only sources "on a branch the walker cannot evaluate" would first need the analysis that produces these blocks (sources per block, branch condition, successors).Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-03T20:34:33Z.
Local experiment for option 1 (not proposed as code). PPSA21567, Linux,
maind3ec1f15with #285 and #290 applied:ReadConstof a poisoned slot records aBdaAbiUnmappedfault in its original block (the slot read is emitted where the originals_loadwas).0x5005f6100twice, plus0x50064fc00,0x5006b0300,0x500715700), each with the same 5 reads: P+0x18, P+0x30, P+0x34, P+0x58, P+0x5c.So the guarded block did not execute in these dispatches while P was invalid. P was NULL in most runs and
0x3f800000in one, which looks like non-pointer data in that table entry.Limits: there is no positive control showing this fault path fires when such a block does run (it reuses
RecordBdaFault). The mapping of the 4 checks to the 4 variants is inferred from ordering. Without #290 the same dispatch failed earlier withvkAllocateMemory-2, so the result depends on that PR as well.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T05:25:26Z.
For whoever follows this: #759 (Celegans12, stacked on #757 and #758, open) implements option 1 from this issue. In the flat SRT walk, a read whose base comes from memory and whose dword isn't accessible is not made. The slot reads 0 and is recorded, the record becomes part of the variant and disk-cache key, and each
ReadConstof a recorded slot raises a BDAUnmappedfault through the fault buffer at the original pc. A guarded block that never runs costs nothing, and one that does run still fails loudly. It also fills the gap noted in the first comment, since it doesn't rely onIrResourcePlan::controlFlow.One thing to check against this shader: #759 still throws when a branch condition needs such a value. Here P+0x18 feeds
s_bitcmp1_b32 vcc_lo, 18and thens_trap. @ThisIsAkill, if you have time, a run of #759 on PPSA21567 (0x5005f6100, plus0x50064fc00,0x5006b0300and0x500715700) would show whether that path is covered, and the result would help the review there.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:26:39Z.
#759 is on main now: a read through a null SRT pointer on a branch that doesn't run no longer throws at capture, and faults at run time if it does run. Branch conditions that need such a value still throw, which may cover the P+0x18
s_bitcmp1/s_traphere. Does0x5005f6100still fail on current main?Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:45:56Z.
Partly addressed by #759: a read through a NULL/unmapped SRT pointer no longer throws at capture and raises a deferred
Unmappedfault at the original pc if the guarded block runs (covered byGuardedNullPointer), on top of #285 (driver-owned global data share); still open: branch conditions that need such a value (theP+0x18s_bitcmp1/s_traphere) still throw, and nobody has confirmed0x5005f6100on current main.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:08:40Z.
Closing: no answer on whether
0x5005f6100still fails since #759. Reopen with the log line from current main if it does.