Shaders: LDS accesses past the program's allocation read 0 and drop writes #92
No reviewers
Labels
No labels
accessibility
bug
crash
documentation
duplicate
enhancement
good first issue
graphics
help wanted
invalid
needs logs
performance
question
rdna2
rdna3
rdna4
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/eikkapine--victory-amd!92
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-92"
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?
@murillojndem on GitHub · 2026-12-01 10:48 UTC · original
amd/lds-past-the-allocation→main· +184 −14 · 4 files · 1 commits · closed without mergingWhat
On the console an LDS access past the program's allocation reads 0 and its write is dropped. The translation took every LDS address as in bounds (
lower.rs: "taken as dword-aligned and in bounds"), with two outcomes:getelementptr [128 x i32] ... i32 128in the test below), so the program is not translated.0x0badf00din the test), where the console reads 0.Change
emit/lower.rs, the DS lowering:write2) and atomics there are skipped. A returning atomic gives 0 to a lane outside it, and a lane EXEC leaves out keeps its register.Tag::Clamp, soVICTORY_SHADER_CENSUScounts it.Shader::lds_programset wherelds_dwordsis first set (compute and mesh programs). It is notlds_dwords: the translation appends dwords of its own after the program's (the wave64 exchange on 32-lane hosts, thehalvesdword).TRANSLATOR_VERSIONgoes from 4 to 5.This ports Marvisak/VIctory@eabb6b8 (by wwwwwwww3333333, upstream PR 1949, for upstream issue 1870), which bounds by the group-shared size; here that size can be larger than the program's allocation, hence
lds_program.Tests
New tests in
emit::valu_tests, ten probes each on 64 threads with 512 bytes of LDS: a read past the end, a write past the end that must land nowhere, a byte write and a byte read past the end, a read at offset 65532,read2with its second dword past the end, a returning atomic past the end without and under EXEC (with EXEC leaving every lane out the register must keep its old value), and an address that wraps at 32 bits back inside.lds_past_the_allocation_at_a_constant_addresshas the address known at translation,lds_past_the_allocation_at_a_computed_addresscomputes it from an input.On main
5d91fde, the constant-address test fails DXIL validation (on WARP and the card alike), and the computed-address one passes on WARP but fails on the RX 7900 XT (driver 32.0.32015.7029):a read past the end: 0x0badf00d, want 0x00000000. With this branch both pass on WARP and on the card.Also run:
victory-shader --libon WARP: 311 passed, 4 failed, 4 ignored (main: 309, 4, 4). The four failures are the same on main: three fail PSV0 validation with the SDK 10.0.22621dxil.dllon this PC, anda_lane_mask_joined_with_a_number_is_read_as_the_number_it_isis a hardware-only test thatVICTORY_WARP=1sends to WARP.victory-shader --libon the RX 7900 XT (and WARP, through the same harness): 312 passed, 3 failed, 4 ignored (main: 310, 3, 4). The three failures are the PSV0 ones.cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test -p xtask:repository_passes_policypasses (lower.rsis 635,800 bytes of the 655,360-byte limit).documented_switches_are_readfails, the same way as on main (VICTORY_NAMEin README.md).Limits
b64,b128orread2access. Not measured in a title.wave64: falseprograms, wherelds_programandlds_dwordsare equal, so they do not reach the case that needslds_program.cmpst,min_f32/max_f32, awrite2orb64that straddles the end and the d16 forms are not probed.victory-shaderonly. My checkout leaves outcrates/victory-formats/src/bcpack-tables.bin, so I did not build-p victoryor run the workspace clippy.The same change is open as DexNom/VIctory#227.
Generated with Claude Code
On the console an LDS access past the program's allocation reads 0 and its write is dropped. The translation took every LDS address as in bounds ("taken as dword-aligned and in bounds"), with two outcomes: - A constant address past the group-shared array makes DXIL that the validator refuses ("Access to out-of-bounds memory is disallowed"), so the program is not translated. - A computed one is undefined on the host. On an RX 7900 XT a read past the end returns what a write past the end put there (0x0badf00d in the test), where the console reads 0. Each dword an LDS access touches now comes with whether it lies in the program's own LDS. Reads give 0 outside it; writes and atomics there are skipped; a returning atomic gives 0 to a lane outside it, and a lane EXEC leaves out keeps its register. The host index stays in the group-shared array whatever the address. The bound is the program's allocation, a new Shader::lds_program set where lds_dwords is first set (compute and mesh programs), not lds_dwords: the translation appends dwords of its own after the program's (the wave64 exchange on 32-lane hosts, the halves dword). The index select is tagged as a clamp for VICTORY_SHADER_CENSUS. Port of Marvisak/VIctory eabb6b8 (upstream PR 1949, issue 1870), which bounds by the group-shared size; here that size can be larger than the program's allocation, hence lds_program. Tests lds_past_the_allocation_at_a_constant_address and lds_past_the_allocation_at_a_computed_address run ten probes on 64 threads with 512 bytes of LDS: reads, byte and dword writes, read2, a returning atomic with and without EXEC, and an address that wraps at 32 bits back inside. Without the change the first fails DXIL validation and the second reads 0x0badf00d past the end on an RX 7900 XT. TRANSLATOR_VERSION 4 -> 5, since programs with LDS accesses translate differently. Co-authored-by: wwwwwwww3333333 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>Pull request closed