[PR #650] rdna2spirv: out-of-range s_buffer_load reads safely from heap base without branch (OLD-9916) #691

Open
opened 2026-11-26 20:18:43 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/650
Author: @TanmaySatyam
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/old-9916-smem-oob-safe-address


📝 Commits (3)

  • 4c1b8cb rdna2spirv: an out-of-range s_buffer_load is loaded with no branch, from the V# base (llvmpipe segfault)
  • c662c62 scalar_load: out of range, the branchless s_buffer_load reads the heap base, not the V# base
  • bf61dd3 tests: mark cs_smem_oob_far.asm for regen_fixtures discovery

📊 Changes

8 files changed (+317 additions, -28 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 runtime/test/shaders/check.py (+3 -1)
➕ runtime/test/shaders/cs_smem_oob_far.asm (+73 -0)
📝 scripts/run_gpu_tests.py (+4 -2)
➕ tests/semantic/fixtures/disasm/cs_smem_oob_far.s (+55 -0)
📝 tests/semantic/test_scalar_mem_smem.py (+19 -1)
➕ tests/semantic/test_smem_oob_safe_address.py (+144 -0)
📝 tools/rdna2spirv.py (+18 -24)

📄 Description

Claimed in the coordination issue as: OLD-9916

AI-assisted.

What and why

Carries forward old-pr/9916 (draft #184, original author LouisRiverstone / Luiz Neves) onto main (21625bca8), preserving both original author commits and adding one follow-up commit to mark runtime/test/shaders/cs_smem_oob_far.asm for tests/semantic/regen_fixtures.py (main's marker-based discovery):

  1. Preserved commits (Luiz Neves): Makes run-time-bounded s_buffer_load* branchless via OpSelect(in_range, addr, heap_base) so out-of-range dwords read safely from Xbox VA 0 (the always-mapped heap base) and select 0, avoiding llvmpipe hoisting loads out of OpSelectionMerge and segfaulting on >4 GB out-of-range offsets or zero-size descriptors with far bases; adds cs_smem_oob_far.asm and tests/semantic/test_smem_oob_safe_address.py.
  2. Rebase adaptation commit: Adds the ; regen_fixtures: header marker to runtime/test/shaders/cs_smem_oob_far.asm so tests/test_regen_fixtures.py passes on current main.

Testing & Verification

  • GPUs tested: NVIDIA GeForce RTX 5070 (Blackwell, Driver 591.74, Windows 11, Vulkan validation enabled):
    • vk_compute_test cs_smem_oob_far.spv 1 dump → 1 groups x 64: 0 mismatches, out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142 (0 validation errors).
  • python -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v (6/6 OK)
  • python -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py (44/44 OK)
  • python -I tests/test_regen_fixtures.py (7/7 OK)
  • python -I tests/test_text_write_line_endings.py (3/3 OK)
  • Clean-room verified: python -I scripts/check_no_game_data.py exited 0 on all modified/added files.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/650 **Author:** [@TanmaySatyam](https://github.com/TanmaySatyam) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/old-9916-smem-oob-safe-address` --- ### 📝 Commits (3) - [`4c1b8cb`](https://github.com/ubiquitarianism/leonida/commit/4c1b8cb01b7570a426fc50505ead860d381ca4ac) rdna2spirv: an out-of-range s_buffer_load is loaded with no branch, from the V# base (llvmpipe segfault) - [`c662c62`](https://github.com/ubiquitarianism/leonida/commit/c662c62f0d653b631597eb0e73eee3fe25418ceb) scalar_load: out of range, the branchless s_buffer_load reads the heap base, not the V# base - [`bf61dd3`](https://github.com/ubiquitarianism/leonida/commit/bf61dd3d7df6ee384a9bdd2d099a81942e1837ff) tests: mark cs_smem_oob_far.asm for regen_fixtures discovery ### 📊 Changes **8 files changed** (+317 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `runtime/test/shaders/check.py` (+3 -1) ➕ `runtime/test/shaders/cs_smem_oob_far.asm` (+73 -0) 📝 `scripts/run_gpu_tests.py` (+4 -2) ➕ `tests/semantic/fixtures/disasm/cs_smem_oob_far.s` (+55 -0) 📝 `tests/semantic/test_scalar_mem_smem.py` (+19 -1) ➕ `tests/semantic/test_smem_oob_safe_address.py` (+144 -0) 📝 `tools/rdna2spirv.py` (+18 -24) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9916 AI-assisted. ### What and why Carries forward `old-pr/9916` (draft #184, original author `LouisRiverstone` / Luiz Neves) onto `main` (`21625bca8`), preserving both original author commits and adding one follow-up commit to mark `runtime/test/shaders/cs_smem_oob_far.asm` for `tests/semantic/regen_fixtures.py` (`main`'s marker-based discovery): 1. **Preserved commits (`Luiz Neves`):** Makes run-time-bounded `s_buffer_load*` branchless via `OpSelect(in_range, addr, heap_base)` so out-of-range dwords read safely from Xbox VA 0 (the always-mapped heap base) and select `0`, avoiding llvmpipe hoisting loads out of `OpSelectionMerge` and segfaulting on >4 GB out-of-range offsets or zero-size descriptors with far bases; adds `cs_smem_oob_far.asm` and `tests/semantic/test_smem_oob_safe_address.py`. 2. **Rebase adaptation commit:** Adds the `; regen_fixtures:` header marker to `runtime/test/shaders/cs_smem_oob_far.asm` so `tests/test_regen_fixtures.py` passes on current `main`. ### Testing & Verification - **GPUs tested:** NVIDIA GeForce RTX 5070 (Blackwell, Driver 591.74, Windows 11, Vulkan validation enabled): - `vk_compute_test cs_smem_oob_far.spv 1 dump` → `1 groups x 64: 0 mismatches`, `out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142` (0 validation errors). - `python -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v` (6/6 OK) - `python -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py` (44/44 OK) - `python -I tests/test_regen_fixtures.py` (7/7 OK) - `python -I tests/test_text_write_line_endings.py` (3/3 OK) - Clean-room verified: `python -I scripts/check_no_game_data.py` exited 0 on all modified/added files. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#691
No description provided.