xshader: check group shared accesses against the guest's LDS allocation #225

Merged
ReverendOzmund merged 4 commits from upstream-pr/225 into main 2026-11-26 14:39:11 +00:00
ReverendOzmund commented 2026-11-26 11:40:56 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-26T11:40:56Z.


not run yet. The GPU suites don't execute translated programs with out-of-range LDS addresses, so I'd value an AMD or NVIDIA run of tools/check_translator_gpu.py from someone whose host builds the full check.

<!-- greyfinch-sync:brcly/TuxBox:issue:6625878381 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225). Originally posted by [ReverendOzmund](https://github.com/ReverendOzmund) on 2026-11-26T11:40:56Z. --- not run yet. The GPU suites don't execute translated programs with out-of-range LDS addresses, so I'd value an AMD or NVIDIA run of `tools/check_translator_gpu.py` from someone whose host builds the full check.
ReverendOzmund commented 2026-11-26 11:59:44 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-26T11:59:44Z.


Added tools/check_lds_bounds_gpu.py and registered it as lds-bounds in the translator GPU checks. Each lane writes its own word and a second value 32 KiB past it, then reads both back: the lane's word must survive and the far read must return 0. With the old & 8191u index the far write wraps onto the lane's word, so this fails on main. I can't run the translator GPU checks on my host (no lld-link for the full check); a run on any NVIDIA or AMD card with python tools/check_translator_gpu.py --only lds-bounds ... would be appreciated.

<!-- greyfinch-sync:brcly/TuxBox:comment:7191429709 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7191429709). Originally posted by [ReverendOzmund](https://github.com/ReverendOzmund) on 2026-11-26T11:59:44Z. --- Added `tools/check_lds_bounds_gpu.py` and registered it as `lds-bounds` in the translator GPU checks. Each lane writes its own word and a second value 32 KiB past it, then reads both back: the lane's word must survive and the far read must return 0. With the old `& 8191u` index the far write wraps onto the lane's word, so this fails on main. I can't run the translator GPU checks on my host (no lld-link for the full check); a run on any NVIDIA or AMD card with `python tools/check_translator_gpu.py --only lds-bounds ...` would be appreciated.
NickStallman commented 2026-11-26 12:02:34 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-26T12:02:34Z.


AMD run of python tuxbox.py check on this PR's head (6f510a5):

  • GPU: AMD Raphael iGPU of a Ryzen 9 9950X (1002:13c0), Mesa RADV, Linux 7.0.0, GE-Proton11-14 (Proton backend). Host profile wave 64-64.
  • All groups passed, 100 gates, including "Shader translator on the GPU" (tools/check_translator_gpu.py), "Lanes and fixtures on the GPU" and the D3D12 regression controls.
  passed   Shader compiler tests
  passed   Build
  passed   Lanes and fixtures on the GPU
  passed   D3D12 regression controls
  passed   Shader translator on the GPU
All checks passed.

The RTX 5090 is busy with a game run right now. I can add an NVIDIA run afterwards if it's still needed.

<!-- greyfinch-sync:brcly/TuxBox:comment:7191491668 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7191491668). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-26T12:02:34Z. --- AMD run of `python tuxbox.py check` on this PR's head (`6f510a5`): - GPU: AMD Raphael iGPU of a Ryzen 9 9950X (`1002:13c0`), Mesa RADV, Linux 7.0.0, GE-Proton11-14 (Proton backend). Host profile wave 64-64. - All groups passed, 100 gates, including "Shader translator on the GPU" (`tools/check_translator_gpu.py`), "Lanes and fixtures on the GPU" and the D3D12 regression controls. ``` passed Shader compiler tests passed Build passed Lanes and fixtures on the GPU passed D3D12 regression controls passed Shader translator on the GPU All checks passed. ``` The RTX 5090 is busy with a game run right now. I can add an NVIDIA run afterwards if it's still needed.
ReverendOzmund commented 2026-11-26 12:03:43 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-26T12:03:43Z.


Also covered the lane-exchange array: tb_swizzle is sized to the group, and groups of 32 or 96 lanes (allowed by the "complete blocks of 32 lanes" check) end in half a guest wave64, so (tb_lane & ~63u) | lane could index past it. Those reads now go through tb_swizzle_read() and return 0 past the end. 335 translator tests pass; exec_group assertions updated for the new form.

<!-- greyfinch-sync:brcly/TuxBox:comment:7191516065 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7191516065). Originally posted by [ReverendOzmund](https://github.com/ReverendOzmund) on 2026-11-26T12:03:43Z. --- Also covered the lane-exchange array: tb_swizzle is sized to the group, and groups of 32 or 96 lanes (allowed by the "complete blocks of 32 lanes" check) end in half a guest wave64, so `(tb_lane & ~63u) | lane` could index past it. Those reads now go through tb_swizzle_read() and return 0 past the end. 335 translator tests pass; exec_group assertions updated for the new form.
ReverendOzmund commented 2026-11-26 12:04:17 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-26T12:04:17Z.


Thanks Nick! Since that run I pushed two more commits (head be9055c): the lds-bounds translator GPU check (each lane writes its word and a second value 32 KiB past it; the word must survive and the far read must be 0), and the same bounds treatment for lane reads through tb_swizzle in 32/96-lane groups. If you get a chance after your game run, --only lds-bounds on the 5090 would be the most useful one, since NVIDIA is where out-of-range shared memory can actually fault.

<!-- greyfinch-sync:brcly/TuxBox:comment:7191527896 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7191527896). Originally posted by [ReverendOzmund](https://github.com/ReverendOzmund) on 2026-11-26T12:04:17Z. --- Thanks Nick! Since that run I pushed two more commits (head be9055c): the `lds-bounds` translator GPU check (each lane writes its word and a second value 32 KiB past it; the word must survive and the far read must be 0), and the same bounds treatment for lane reads through `tb_swizzle` in 32/96-lane groups. If you get a chance after your game run, `--only lds-bounds` on the 5090 would be the most useful one, since NVIDIA is where out-of-range shared memory can actually fault.
NickStallman commented 2026-11-26 13:38:35 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-26T13:38:35Z.


NVIDIA run of python tuxbox.py check on be9055c: RTX 5090 (10de:2b85), driver 595.99.02, GE-Proton11-14, Linux 7.0.0.

Everything passes except lds-bounds (FAIL lds-bounds False 8 2048 failed 8). The shader never ran, though: lds-bounds.json has guest_exit: 1 and error: "invalid compute seed lds00".

The cause seems to be the seed size, not the GPU:

  • tools/reference/independent-shaders/compute.cpp:8 has constexpr UINT words = 384. At lines 37–41 it rejects a .seed whose size isn't exactly 384 * 4 bytes.
  • check_lds_bounds_gpu.py writes WORDS = 4 * LANES = 256 words (1,024 bytes).

So every case is rejected before dispatch, and I'd expect the same on AMD. My earlier AMD run was on 6f510a5, before this check existed. Padding the seed to 384 words, and comparing the first 256 of the readback (or the full 384 against an expected buffer padded the same way), should let it run. I'm happy to rerun it on the 5090 once that's pushed.

The other groups all passed: Lanes and fixtures on the GPU, the D3D12 regression controls, and every other translator case.

<!-- greyfinch-sync:brcly/TuxBox:comment:7193633907 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7193633907). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-26T13:38:35Z. --- NVIDIA run of `python tuxbox.py check` on `be9055c`: RTX 5090 (`10de:2b85`), driver 595.99.02, GE-Proton11-14, Linux 7.0.0. Everything passes except `lds-bounds` (`FAIL lds-bounds False 8 2048 failed 8`). The shader never ran, though: `lds-bounds.json` has `guest_exit: 1` and `error: "invalid compute seed lds00"`. The cause seems to be the seed size, not the GPU: - `tools/reference/independent-shaders/compute.cpp:8` has `constexpr UINT words = 384`. At lines 37–41 it rejects a `.seed` whose size isn't exactly `384 * 4` bytes. - `check_lds_bounds_gpu.py` writes `WORDS = 4 * LANES` = 256 words (1,024 bytes). So every case is rejected before dispatch, and I'd expect the same on AMD. My earlier AMD run was on `6f510a5`, before this check existed. Padding the seed to 384 words, and comparing the first 256 of the readback (or the full 384 against an expected buffer padded the same way), should let it run. I'm happy to rerun it on the 5090 once that's pushed. The other groups all passed: Lanes and fixtures on the GPU, the D3D12 regression controls, and every other translator case.
ReverendOzmund commented 2026-11-26 13:51:06 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-26T13:51:06Z.


Thanks, that was my mistake: I missed that compute.cpp takes exactly 384 seed words and exposes a 192-word view from word 96. Pushed a fix: the whole 384-word buffer is seeded and compared, the inputs sit at word 96, and each lane writes its two results over its own inputs. With the old & 8191u index the far write wraps onto the lane's word, so the check still fails on main. Would appreciate the 5090 rerun when you get a chance.

<!-- greyfinch-sync:brcly/TuxBox:comment:7193925270 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/225#issuecomment-7193925270). Originally posted by [ReverendOzmund](https://github.com/ReverendOzmund) on 2026-11-26T13:51:06Z. --- Thanks, that was my mistake: I missed that compute.cpp takes exactly 384 seed words and exposes a 192-word view from word 96. Pushed a fix: the whole 384-word buffer is seeded and compared, the inputs sit at word 96, and each lane writes its two results over its own inputs. With the old `& 8191u` index the far write wraps onto the lane's word, so the check still fails on main. Would appreciate the 5090 rerun when you get a chance.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!225
No description provided.