rt: bound V# offsets to the translator signed 48-bit range (SHADER-VSHARP-47-BOUND) #2109

Closed
github-bot wants to merge 1 commit from gh-pr/2109/head into gh-pr/2109/base
Owner

@⁠Undefined3301 on GitHub · 2026-11-25 21:00 UTC · original
rt-vsharp-47-bound → main · +99 −8 · 6 files · 1 commits · closed without merging

Item: SHADER-VSHARP-47-BOUND

What and why

Every translated shader reads a V#'s 48-bit base sign-extended from bit 47 (docs/design.md, "Heap-relative buffer device addresses"). vsharp_address accepted any positive offset below 2^48, so a base in [2^47, 2^48) became a device address 2^48 lower — a wild read (one such base produced a fault at 0xffff...).

This adds runtime/src/vsharp_range.h with the portable predicate the runtime uses:

  • a positive offset must stay below 2^47 (and the access fit below it);
  • a negative offset may reach -2^47 (the signed range of the 48-bit field).

vsharp_address's encodable uses it, and a slot-133 import whose device address would need bit 47 above the arena takes the arena shadow instead (its console VA is then an arena offset, which is always in range). A base outside the range is refused and the slot gets the existing no-records treatment.

Tests

  • runtime/test/vsharp_range_test.cpp (new, portable): the boundaries, a below-arena buffer, and the sign-extension equivalence.
  • runtime/test/d3d12_title_va_test.cpp: extra cases for the refused range.
  • Measured on RTX 4080 / NVIDIA 621.24: the related ctests pass (11/11, including d3d12_title_va, d3d12_indirect_rt, d3d12_mesh, d3d12_console_descriptor_heap) and the retail boot with below-arena imports is unchanged (LEONIDA_IMPORT_BELOW_ARENA=1, same frame rate, no new faults).

No game files are needed for the tests.

AI-assisted: yes (Claude Code patch series, reviewed and carried over by DeepSeek V4.1 Flash via OpenCode/T3 Code).

**@⁠Undefined3301** on GitHub · 2026-11-25 21:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2109) `rt-vsharp-47-bound` → `main` · +99 −8 · 6 files · 1 commits · closed without merging Item: SHADER-VSHARP-47-BOUND ## What and why Every translated shader reads a V#'s 48-bit base sign-extended from bit 47 (docs/design.md, "Heap-relative buffer device addresses"). `vsharp_address` accepted any positive offset below 2^48, so a base in `[2^47, 2^48)` became a device address 2^48 lower — a wild read (one such base produced a fault at `0xffff...`). This adds `runtime/src/vsharp_range.h` with the portable predicate the runtime uses: - a positive offset must stay below `2^47` (and the access fit below it); - a negative offset may reach `-2^47` (the signed range of the 48-bit field). `vsharp_address`'s `encodable` uses it, and a slot-133 import whose device address would need bit 47 above the arena takes the arena shadow instead (its console VA is then an arena offset, which is always in range). A base outside the range is refused and the slot gets the existing no-records treatment. ## Tests - `runtime/test/vsharp_range_test.cpp` (new, portable): the boundaries, a below-arena buffer, and the sign-extension equivalence. - `runtime/test/d3d12_title_va_test.cpp`: extra cases for the refused range. - Measured on RTX 4080 / NVIDIA 621.24: the related ctests pass (11/11, including `d3d12_title_va`, `d3d12_indirect_rt`, `d3d12_mesh`, `d3d12_console_descriptor_heap`) and the retail boot with below-arena imports is unchanged (`LEONIDA_IMPORT_BELOW_ARENA=1`, same frame rate, no new faults). No game files are needed for the tests. AI-assisted: yes (Claude Code patch series, reviewed and carried over by DeepSeek V4.1 Flash via OpenCode/T3 Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:11 +00:00
github-bot closed this pull request 2026-11-26 10:18:11 +00:00
Author
Owner

@⁠Undefined3301 on GitHub · 2026-11-25 23:45 UTC · original

Closing this; not pursuing the contribution.

**@⁠Undefined3301** on GitHub · 2026-11-25 23:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2109#issuecomment-7178000828) Closing this; not pursuing the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.