Repository navigation
GPU: fail closed on unresolved control flow and errored FSSMs in effects - #2352
Conversation
`gpu::effects::of` previously stopped scanning on the first undecodable dword after any `S_ENDPGM`, accepted programs without a terminator or whose decoded tail could fall through into undecoded bytes, and ignored indirect jumps and out-of-range branches. If a live branch jumped past an early `S_ENDPGM` and undecodable gap (or an indirect/out-of-range transfer targeted code outside the decoded slice), memory writes beyond the stopped decode point were missed and `big_and_image_only` could misclassify a memory-writing compute shader as image-only. `compute_code` also accepted hardware-CS FSSM entries whose `f.error` was populated (e.g. XBCH `rsize` mismatch, where `xbox::parse_xbch` records `f.error` and still populates `f.programs`). Resolve static far jumps (`rdna2::resolve_far_jumps`), require a decoded `F_TERMINATOR` and a non-fallthrough tail, fail closed (`None`) on any unresolved indirect transfer or branch targeting outside the decoded instruction PCs, treat trailing `S_CODE_END` after a terminator as padding, and reject `f.error.is_some()` in `compute_code`. Part of xcl-dev#2088 Part of xcl-dev#1452 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Tested: current PR head merged onto current No Linux/Wine report in the thread yet; adding one.
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
|
Test report on an NVIDIA card (Windows, retail title). Tested
Not tested
AI use MiniMax Code (MiniMax-M3.1-Flash) built the commits, ran the test suite and the smoke runs, and wrote this report from the real output. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Part of #2088
Part of #1452
Follow-up to #2176 (
crates/xcl/src/gpu/effects.rs).gpu::effects::big_and_image_onlyallowshle::d3d12x::pso_asyncto skip waiting on a big compute pipeline while the driver compiles it only wheneffects::ofproves the shader writes nothing outside images. This PR closes three fail-open gaps ineffects::ofandeffects::compute_codeso unrecognized or incomplete control flow and errored FSSM containers never misclassify a memory-writing compute shader as image-only.What is in it
gpu::effects::of(crates/xcl/src/gpu/effects.rs): decode intoVec<Decoded>, track anyrdna2::F_TERMINATOR(S_ENDPGM,S_ENDPGM_SAVED,S_ENDPGM_ORDERED_PS_DONE), stop on trailing decode errors orS_CODE_ENDpadding only after a terminator, require both a decoded terminator and a non-fallthrough tail (F_TERMINATOR,S_BRANCH, or resolvedfar_target), runrdna2::resolve_far_jumps(&mut insts), and returnNoneif anyF_BRANCH | F_INDIRECTinstruction lacks a resolvedrdna2::branch_targetpointing to a decoded instruction PC.gpu::effects::compute_code(crates/xcl/src/gpu/effects.rs): fail closed (None) when the matched hardware-CS (hw == 6) FSSM hasf.error.is_some()(e.g. XBCHrsizemismatch wherexbox::parse_xbchstill callsanalyze_fssmand populatesf.programs).gpu::effects::tests(crates/xcl/src/gpu/effects.rs): 3 pure-CPU unit tests covering early-S_ENDPGMundecodable-gap branch targets, tail fallthrough into undecoded bytes, missing terminators,S_ENDPGM_SAVED+ trailing data, unresolvedS_SETPC_B64/S_SWAPPC_B64, out-of-rangeS_BRANCH/S_CALL_B64, valid and out-of-range resolved far jumps with trailingS_CODE_ENDpadding, and XBCHrsize-errored FSSMs inbig_and_image_only.Tested
rustc 1.100.0, DXC1.9.2609.5, release profile (--release).cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture: 4 passed, 3 failed (all 3 new tests failed onorigin/main).cargo test --release -p xcl --lib gpu::effects::tests:: -- --nocapture: 7 passed, 0 failed, 0 ignored (0.01 s).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1275 passed, 0 failed, 46 ignored across 23 test binaries (28 pre-existingSKIPPEDlines: 21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 2 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped ingpu::effects::tests).Regression run
main:
PR:
Not tested
gpu::effectsis pure-CPU static RDNA2/FSSM analysis).title: 29640639or wild XBCH containers with mismatchedrsizeheaders (covered synthetically viaxbox::tests::sample/xbox::tests::fssm).AI use
gpu/effects.rs,gpu/rdna2.rs, andgpu/xbox.rs, wrote the fail-closed logic and failing-first unit tests, and ran the workspace and paired smoke tests.