Recompiler: close four mask-taint soundness holes in mesh_wave::transfer #2137
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2147"
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 ivall/xcl. Originally posted by Decodere on 2026-11-25T06:16:13Z.
What is in it
Closes four mask-taint soundness holes in
mesh_wave::transfer()(crates/xcl/src/gpu/recomp/mesh_wave.rs, called byrecomp::geometry_wave32_hazards()):writes_lane_mask): TreatsV_ADD_CO_U32,V_ADD_CO_CI_U32,V_SUB_CO_U32,V_SUB_CO_CI_U32,V_SUBREV_CO_U32,V_SUBREV_CO_CI_U32,V_DIV_SCALE_F32,V_DIV_SCALE_F64,V_MAD_U64_U32, andV_MAD_I64_I32as lane-mask writers alongsideV_CMP*,SAVEEXEC, andWREXEC(leaving 32-bit lane readers likeV_READFIRSTLANE_B32/V_READLANE_B32excluded).reads_scc,keeps_destination): Propagatesstate.scctaint through SCC-reading SALU instructions (S_CSELECT_B32/B64,S_CMOV*,S_ADDC_U32,S_SUBB_U32), and for destination-preserving scalar ops (S_CMOV*,S_ADDK_I32,S_MULK_I32,S_BITSET0_B32/B64,S_BITSET1_B32/B64) folds any existing taint onwritesintoreads_maskand skips clearingwrites.reads_special_mask): Scans non-implicit scalar input operands forSRC_VCCZ(251),SRC_EXECZ(252), and taintedSRC_SCC(253) (skippingSRC0on non-plain SDWA/DPP encodings) so mask checks via special inline codes are not dropped.S_MOVREL*scalar moves: HandlesS_MOVRELS_B32/B64(definite overwrite ofSDSTwithM0orsrc..124taint),S_MOVRELD_B32/B64(never clearsSDST; taintsdst..124if source orM0is tainted), andS_MOVRELSD_2_B32(never clearsSDST; taintsdst..124ifM0orsrc..124is tainted), matchingemit.rsandx64_masks.rs.gpu::recomp::mesh_wave::testscovering all 4 holes (plus negative controls andgeometry_wave32_hazardschecks).Part of #336
Tested
Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC
1.9.2609.5(01b62ad4).cargo test -j 4 -p xcl --lib gpu::recomp::mesh_wave::tests -- --nocapture): 13 passed, 4 failed — all 4 new tests (valu_carry_and_div_scale_sdst_outputs_are_masks,scc_reading_and_rmw_scalar_ops_preserve_mask_taint,special_mask_sources_vccz_execz_and_scc_are_tainted,movrel_preserves_dst_and_tracks_indirect_sgpr_ranges) returned emptymask_scc_branchespre-fix.cargo test --release -p xcl --lib gpu::recomp::mesh_wave::tests -- --nocapture): 17 passed, 0 failed (pure CPU unit tests, CI WARP-safe).cargo build --release --workspaceandcargo test --release --workspace -- --test-threads=4 --nocapture): 1,158 passed, 0 failed, 46 ignored across 21 test binaries (1102inxcllib,56across the remaining 20 binaries), with 27SKIPPEDlines on this RTX 4060:no wave64(RTX 4060 is wave32-only)per-lane form: refused(wave32 f16 arithmetic, f16 packed, f32 conversions)no d3d12SDKLayers.dll/no D3D12 debug layercannot disable the driver cache(Windows Developer Mode not enabled)no heap windowsRegression run
Paired 60 s runs via
scripts/smoke.ps1on cleanorigin/main(6e1e2bef) and clean PR head (a614d310):Main (
6e1e2befc7430126b1e7b98b5c3fe93813c866b6):PR (
a614d310d5fdfe14df504f63d0a9ab7e04008913):Not tested
no wave64skips on RTX 4060), D3D12 debug layer tests (2 skips withoutd3d12SDKLayers.dll), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip withoutXCL_HEAP_WINDOWS).title: 29640639, andmesh_wave::analyzeis a static analysis pass (used for hazard diagnostics, not runtime code generation).AI use
Google Antigravity (Gemini 4 Neon) wrote the
mesh_wave::transfer()fixes, unit tests, and this PR description. All pre-fix/post-fix unit tests, full release workspace tests, paired 60 s smoke runs, andscripts/pr_check.py --localvalidation were run locally on this machine.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:49:28Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:18:52Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T00:37:47Z.
merge-check
base:
fa204595a4head:
a614d310d5merge: clean (trial merge 36e75690aca370fed5de46b296222a47b0d705fb, local, not pushed;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2612 passed, 0 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: none. All 17
mesh_wave::testsran and passed, including the 4 new ones (valu_carry_and_div_scale_sdst_outputs_are_masks,scc_reading_and_rmw_scalar_ops_preserve_mask_taint,special_mask_sources_vccz_execz_and_scc_are_tainted,movrel_preserves_dst_and_tracks_indirect_sgpr_ranges). These are CPU tests, so the GPU played no part.review: none blocking; whole diff read (
mesh_wave.rsonly). Every change only adds taint, never removes it.V_CMP/SAVEEXEC/WREXEC.S_CSELECT,S_ADDC...) carries SCC taint into the result.S_CMOV*,S_ADDK,S_MULK,S_BITSET*) keep the destination's prior taint, where before the write cleared it.SRC_VCCZ/SRC_EXECZtaint the result, and so doesSRC_SCCwhen SCC is tainted. The DPP/SDWA SRC0 field is skipped correctly, since it names a VGPR there.S_MOVREL*taints the indirect rangesrc..124/dst..124together with M0.S_MOVRELDnever clears.The negative controls (
V_READFIRSTLANE_B32output,S_MOVRELSover an untainted range) stay untainted.Note, not blocking:
mesh_wave::analyzeonly feedsrecomp::geometry_wave32_hazards, and nothing outside tests andbenches/gpu_cpu.rscalls that (it describes a possible split-free fast path). So this PR has no runtime effect today. When that fast path is wired in, the extra taint will rule out more geometry programs. That will be the time to count, on a retail pack, how many more programs it marks. Not done here: noXCL_SAMPLE_RPFsample on this machine.performance: none at runtime (nothing in the runtime calls this analysis). No title run: Recompiler / Tier 1.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite and full-diff review; this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T07:50:39Z.
merge-check claim
head:
a614d310d5Imported from ivall/xcl. Originally posted by throny on 2026-11-29T08:09:35Z.
merge-check
base:
fa204595head:
a614d310d5merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2612 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
fa204595: 2608 passed, 0 failed, 49 ignored.review: no blocking finding. The taint now follows SCC readers, ops that keep their destination, the VCCZ / EXECZ / SCC sources, the second outputs of the carry / div_scale / mad64 forms and the MOVREL family; checked against the operand types of the spec table, and the index ranges are clamped. Minor: in the MOVRELS branch the scanned range runs up to 124 and so includes VCC, which is always tainted, so any source register up to s107 gives a tainted result. That is sound but coarser than needed (the test uses s108 to step around it). Expected effect: more programs get the wave32 hazard flag and take the fallback; how many was not measured.
performance: not measured.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).