xshader: guard inactive-lane loads through flat descriptor bases and BVH node tests #594
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/594"
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 brcly/TuxBox. Originally posted by DrArroway on 2026-11-30T19:02:34Z.
Guard vector loads through unbounds-checked descriptor-base root SRVs (such as
tb_bvh_heap) and console BVH node intersection helpers against inactive lanes and invalid node types.Root Cause
Two separate
RADV_DEBUG=hangcaptures on ProjectScarlett 1.0.2.1 (RDNA 2 RX 6900 XT, Mesa RADV) pinned a reproducibleCLIENT_ID: (TCP) 0x8,RW: 0,PERMISSION_FAULTS: 3GPUVM read fault (0x8001e2bfe000) to the same compute pipeline (6e71ad7a642136f9/571d96cad08597a9.dxil,DISPATCH_INDIRECT):tools/shader-compiler/src/hlsl/emitter/scalar_memory.rs(pointer_words,!scalar): emitstb_bvh_heap.Load(...)unconditionally on all vector lanes and only guards writeback inwv(...). On inactive lanes ((exec_lo & 1u) == 0), the address VGPR retained a stale float (-0.00829f=0xbc07e000), adding ~3 GiB to the 64 KiBtb_bvh_heaproot SRV base (0x800126b80000->0x8001e2bfe000exact faulting page).tools/shader-compiler/src/hlsl/bvh_node.rs(emit&HELPER): callstb_bvh_intersect(...)unconditionally across all lanes beforewv(...), and insidetb_bvh_intersect, loadsnodes.Load4(...)before checking for invalid node types (type > 1u && type != 4u && type != 5u, e.g.,0xffffffffsentinels).Changes
tools/shader-compiler/src/hlsl/emitter/scalar_memory.rs: For vector (!scalar) loads inpointer_words, mask inactive-lane offsets with(exec_lo & 1u) ? (({address}) & ~3u) : 0uand guard the buffer.Load(...)calls inside[branch] if (exec_lo & 1u). Scalar loads remain unguarded.tools/shader-compiler/src/hlsl/bvh_node.rs: Zero-initializet{t}and guardtb_bvh_intersect(...)inside[branch] if (exec_lo & 1u); checkif (type > 1u && type != 4u && type != 5u)and return0xffffffffbefore computingaddressor issuingnodes.Load4(...).tools/shader-compiler/src/tests/hlsl/descriptor_address.rs: Adda_flat_load_through_a_scene_base_guards_inactive_lanesanda_console_bvh_node_test_guards_inactive_lanes_and_invalid_types.Live Verification (ProjectScarlett 1.0.2.1 offline, RX 6900 XT, GE-Proton11-14, Mesa RADV)
Testing against
87298944+#389/#589/#590withTUXBOX_XMEM_PRIVATE_VIEWS=1,TUXBOX_CHECK_ONCE_PER_FRAME=1,VKD3D_CONFIG=no_upload_hvv:RADV_DEBUG=hang) hitTCP PERMISSION_FAULTS: 3read faults in0x8001e...–0x8001f...after 3–36 3D demo frames (234s,273s,704s, and3demo frames underRADV_DEBUG=hang), with 2/2RADV_DEBUG=hangdumps capturing571d96cad08597a9.dxil.RADV_DEBUG=hang): 1,036.8s (21,969 frames, 50+ 3D demo frames), 0 GPUVM faults; exited on an unrelated 6.09 GiBPrivateSpanalias failure (map_private_contiguous,[email protected],err=170,write=true).RADV_DEBUG=hang): hit 1 separateTCPread fault at0x80033d962000after 7 demo frames (294.5s, different VA range / sparseVK_OBJECT_TYPE_IMAGEregion, not0x8001...).VKD3D_CONFIG=no_upload_hvv,breadcrumbs, noRADV_DEBUG=hangorsyncshaders): 385.2s (9,616 frames, 49 full 3D demo frames), 0 GPUVM faults; exited on the same unrelated 6.09 GiBPrivateSpanalias failure ([email protected],err=170,write=true).Automated Verification
cargo fmt --all -- --check— passedcargo clippy --locked --target x86_64-unknown-linux-gnu -p tuxbox-xshader --all-targets -- -D warnings— passedcargo clippy --locked --target x86_64-pc-windows-msvc --workspace --all-targets -- -D warnings— passedRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --target x86_64-unknown-linux-gnu -p tuxbox-xshader --document-private-items— passedcargo test --locked --target x86_64-unknown-linux-gnu -p tuxbox-xshader— 666 lib + 3 bin + 2 integration tests passedEvidence: TuxBox check of
dc50c74c44, no uncommitted changes, GPU 1002:73bf: 16 passed, 0 failed, 0 not runEvidence: TuxBox check of
dc50c74c44, no uncommitted changes, GPU 1002:164e: 16 passed, 0 failed, 0 not runImported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-30T20:48:56Z.
Tested on an RX 6600 (RDNA 2, 8 GB,
1002:73ff, RADV / Mesa 26.3.1, GE-Proton11-14,section-import=substituted descriptor-bytes=64/16). The build is this PR atdc50c74conbbc26254, with warm caches andTUXBOX_XMEM_PRIVATE_VIEWS=1. I ran Series S (ConsoleMode=96) and packaged, twice each. The baseline isbbc26254without the PR, same settings.The
0x8001e…family is gone here. Today all 10 runs without the PR ended on a TCP read fault (PERMISSION_FAULTS 0x3,MAPPING_ERROR 0): 2 onbbc26254and 8 one5d2e913/87298944, Series S and packaged, with and without the index-map padding. In 9 of them the pages were in0x8001e5…–0x8001ed…, mostly the last pages below a 2 MiB boundary. The tenth (it had waited long at the account picker) faulted at0x8002344b0000–0x8002344b2000. With the PR, 0 of 4 runs faulted in0x8001e….bbc262540x8001e83fc000,0x8001e8dfa000,0x8001e91f8000,0x8001e91fd000bbc262540x8001edcf4000–0x8001edcfd0000x800242270000,0x8002422710000x800440440000,0x8004404410000x8002380a00000x8002daaf4000,0x8002daaf5000But every run with the PR still ends on a TCP read fault 6–8 frames after the mission is set, now in a different shape:
0x800238…–0x800440….PERMISSION_FAULTS 0x3andMAPPING_ERROR 0, from the game'svkd3d_queueon ring 24.gfx_0.0.0ring reset succeeds each time. Afterwards either the device is lost (exit 3) or the title's watchdog fires (exit 5).That fits the separate fault you saw at
0x80033d962000. The one run without the PR that missed0x8001e…(0x8002344b0000, also at a 64 KiB boundary) may already have been this second family. So the PR fixes what it targets, and this card shows a second fault family underneath it.Memory didn't change with the PR:
I haven't captured the faulting program for the new family yet (no
RADV_DEBUG=hangdump). If you have a candidate, I can run it with that.Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-30T21:42:46Z.
@1093i3511 Thanks a lot for the thorough A/B test on your RX 6600 (
1002:73ff), and @brcly thanks for the merge!That second 64 KiB-aligned TCP read fault family (
0x800238…–0x800440…) matches what I hit on AMD Radeon RX 6900 XT (1002:73bf) (0x8002e7364000right at world entry on451db047without #389).Now that #389 has merged into
main(40a69c3f), it cleared those remaining GPUVM faults completely in my runs — paired with #600 forTUXBOX_XMEM_PRIVATE_VIEWS=1, I am seeing 0 GPUVM faults across 5 consecutive runs well into the 3D mission (16–93 3D frames, stopping only on the pre-existing0x80000003breakpoint atgame_scarlett_master.exe + 0x4DA6315).If you get a chance to re-test on
40a69c3f(with #600 if runningTUXBOX_XMEM_PRIVATE_VIEWS=1), it would be great to hear whether #389 clears that second family on the RX 6600 as well.Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-30T21:51:05Z.
@DrArroway thanks, that fits what I saw before: on an older base (
fd636d09+ #501 + #389, private views), #389 removed the TCP faults on this card in 3 of 3 runs. One more run onee38dcf0with GE-Proton11-15 (no #389, Series S) ended on the second family again (0x80023b190000). Tonight's last run on that build usesRADV_DEBUG=hang, to name the shader behind it.I'll retest on
40a69c3f, with #600 forTUXBOX_XMEM_PRIVATE_VIEWS=1, in Series S and packaged mode. That will most likely be tomorrow after 15:00 UTC, and I'll post the results here.Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T07:19:42Z.
@DrArroway the promised retest, on main
717a74c4(with #389, #594 and the tile pool34be158b). RX 6600 (1002:73ff, 8 GB, RDNA2), Mesa 26.3.1 RADV, GE-Proton11-15, Series S profile. One run per setting.0x800602d14000/0x800602d15000, TCP read (0x00501031,PERMISSION_FAULTS 3)TUXBOX_XMEM_PRIVATE_VIEWS=1(no #608, it conflicts with main)+0x2592D69/+0x2215ECATUXBOX_XMEM_SECTION_WATCH=1+TUXBOX_CHECK_ONCE_PER_FRAME=1gfx_0.1.0timed out. The ring reset failed, so the kernel did a MODE1 reset and the desktop was lost. The devcoredump names the compositor, because it records the owner of the hung ring; the game's fault came 2 s earlier. So on this card, #389 doesn't remove the second family with default views. On your 6900 XT it did, so it may depend on the card or on VRAM pressure. Peaks: requested VRAM 6.8 GB, card GTT 9.0 GB.+0x4DA6315breakpoint didn't come in this run, although #608 isn't in it. 149Failed to import host memorylines.Game Init, frame 0, on the watchdog path after 53 s. The prepare's pipeline replay could not build 5,986 of 10,311 records, probably older records without 15bd9ab0'sroot_used. So the first 512 graphics pipelines likely compiled cold at creation. The relaunch got through.The default run's fault looks like #603 (a placed texture's sparse image read after it was destroyed). A dump from an earlier build matched it there.
Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-12-01T07:51:52Z.
@1093i3511 Thanks for the detailed retest and for sharing the
RADV_DEBUG=hangproof on #603 linkingVS 281b4977 / PS 96e8aaaato the placed-texture sparseVkImageuse-after-free.One clarification from our AMD Radeon RX 6900 XT (1002:73bf) runs on
40a69c3f(post-#389 and #594) withTUXBOX_XMEM_PRIVATE_VIEWS=1: we still intermittently hit the sameTCPPERMISSION_FAULTS: 3(RW: 0)0x800...GPUVM fault family too —TUXBOX_TRACE_GPU_FAULT=1caughtVS 72817cd3 / PS 9bcac3efin one run and compute dispatchCS 482ad7dcin another (details logged on #232), which fits #603's placed-texture UAF rather than an OOB root-descriptor read.Also, #608 is now cleanly rebased onto
717a74c4(including #573) with 5/5 CI checks green if you want to pull it into your nextTUXBOX_XMEM_PRIVATE_VIEWS=1test run.