d3d12: map a root SRV in a GPU reservation as far as one in committed memory #677

Open
NickStallman wants to merge 2 commits from upstream-pr/677 into main
NickStallman commented 2026-12-03 16:43:01 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-03T16:43:01Z.


Summary

A root SRV bound inside a GPU reservation could be read past the end of its host buffer.

In ProjectScarlett, mesh draws bind root SRVs inside GPU reservations where the title streams models. A root in committed memory gets up to 4 MiB of reach (root_view_address). A root in a reservation went through imported(address, 1) to a shared read-only view buffer that ended at the next 4 MiB boundary. A console shader reads title memory as far past a root as the title placed data, so a root just below a boundary was read past the buffer's end. That returns whatever the driver has at the next address: silently wrong data, or an MMU fault (NVIDIA Xid 13) when nothing is mapped there.

Measured on an RTX 5090 with vkd3d-proton's fault reporting: in one run the fault was 0xa000 past a window's end. An unfinished mesh draw's root sat 0x5fb0 before that end, and the address after the window had belonged to a 2 MiB sparse buffer destroyed 71 s earlier.

The change:

  • A shared window buffer now spans two 4 MiB boundaries, clipped to its reservation (heap/view_window.rs), as a root window of committed memory does.
  • A read-only root asks for its whole reach of the reservation (gpu_reach, up to ROOT_VIEW_REACH) instead of one byte.
  • recorded_buffer binds a root only into a registered buffer that holds that reach, not one that merely contains the address.

Limits:

  • Root UAVs aren't covered; they still get a buffer of their own.
  • The cost is not measured conclusively: median frame 33.2 ms without and 33.5 ms with, one run each.

Claimed on #533. #655 adds a Lanes test for #389's committed-memory root window. This PR's self-test covers the reservation case, and the two only meet in the scenario lists.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed: check --no-gpu and the RTX 5090 passed. On AMD, every failure is a page-mapping call returning E_NOTIMPL: #656's three self-tests, which fail the same way on main 106120ca on this card, and the new self-test, which stops at the same kind of call before it reads anything (see below)
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: root-reach-reservation binds a root SRV 256 bytes below a 4 MiB boundary of a reservation with no CPU pages, and reads 256 bytes past the boundary. On the RTX 5090 it fails without the fix (read 0, expected 0x5eed0002) and passes with it. Unit tests cover view_window::reach and window.
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both ran. NVIDIA passed. On AMD the new self-test can't run past its page mapping until #656 is fixed on this card, so its behaviour there is unverified. A discrete AMD card hasn't run it

GPU, driver and backend: RTX 5090 (10de:2b85, NVIDIA 620.70.10) and AMD Ryzen 9 9950X graphics, RDNA 2 (1002:13c0, RADV, Mesa 26.0.8), both through GE-Proton11-15. tuxbox.py check --changed 106120ca, run one card at a time.

The Evidence: line tuxbox.py check prints last, one per card (it names the commit it tested; run it on this pull request's head):

Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run
Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run
Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU 1002:13c0: 16 passed, 1 failed, 0 not run

Commands run and their results:

python tuxbox.py check --no-gpu                                  # 13 passed, 0 failed
python tuxbox.py check --changed 106120ca --adapter 10de:2b85   # 17 passed, 0 failed
  lanes-selftest PASS pci=10de:2b85 scenario=root-reach-reservation passed=1
python tuxbox.py check --changed 106120ca --adapter 1002:13c0   # 16 passed, 1 failed (Lanes and fixtures):
  lanes-selftest FAIL queue-page-mappings: copy ordered GPU mapping failed: 0x80004001
  lanes-selftest FAIL queue-texture-boundary: map the texture tail failed: 0x80004001
  lanes-selftest FAIL root-reach-reservation: map a page on each side of the boundary failed: 0x80004001
  lanes-selftest FAIL ray-tracing-rehydrate: map physical pages for the GPU failed: 0x80004001
python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0   # on main 106120ca: the same three #656 failures

Game run. These ran in ProjectScarlett on the RTX 5090, in 15-minute runs from boot into gameplay. The build was upstream 106120ca plus #671, #672 and a local translator change for guarded float divisions (the area #670 now covers), with and without these two commits:

  • Without this change: 9 of 9 runs lost the GPU.
  • With it: 3 of 4 ran the full 15 minutes with no loss. The fourth lost the GPU to a compute dispatch with no address in the fault report. That may be a separate root-UAV problem, which this change doesn't touch; it isn't diagnosed.

It hasn't been run in the game on plain upstream with only this change.

Checks

CI runs the code checks: the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU.

No evidence JSON changes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5630826540 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/677). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-03T16:43:01Z. --- ## Summary A root SRV bound inside a GPU reservation could be read past the end of its host buffer. In ProjectScarlett, mesh draws bind root SRVs inside GPU reservations where the title streams models. A root in committed memory gets up to 4 MiB of reach (`root_view_address`). A root in a reservation went through `imported(address, 1)` to a shared read-only view buffer that ended at the next 4 MiB boundary. A console shader reads title memory as far past a root as the title placed data, so a root just below a boundary was read past the buffer's end. That returns whatever the driver has at the next address: silently wrong data, or an MMU fault (NVIDIA Xid 13) when nothing is mapped there. Measured on an RTX 5090 with vkd3d-proton's fault reporting: in one run the fault was 0xa000 past a window's end. An unfinished mesh draw's root sat 0x5fb0 before that end, and the address after the window had belonged to a 2 MiB sparse buffer destroyed 71 s earlier. The change: - A shared window buffer now spans two 4 MiB boundaries, clipped to its reservation (`heap/view_window.rs`), as a root window of committed memory does. - A read-only root asks for its whole reach of the reservation (`gpu_reach`, up to `ROOT_VIEW_REACH`) instead of one byte. - `recorded_buffer` binds a root only into a registered buffer that holds that reach, not one that merely contains the address. Limits: - Root UAVs aren't covered; they still get a buffer of their own. - The cost is not measured conclusively: median frame 33.2 ms without and 33.5 ms with, one run each. Claimed on #533. #655 adds a Lanes test for #389's committed-memory root window. This PR's self-test covers the reservation case, and the two only meet in the scenario lists. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [ ] The checks relevant to this change passed: `check --no-gpu` and the RTX 5090 passed. On AMD, every failure is a page-mapping call returning E_NOTIMPL: #656's three self-tests, which fail the same way on main `106120ca` on this card, and the new self-test, which stops at the same kind of call before it reads anything (see below) - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below: `root-reach-reservation` binds a root SRV 256 bytes below a 4 MiB boundary of a reservation with no CPU pages, and reads 256 bytes past the boundary. On the RTX 5090 it fails without the fix (`read 0, expected 0x5eed0002`) and passes with it. Unit tests cover `view_window::reach` and `window`. - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: both ran. NVIDIA passed. On AMD the new self-test can't run past its page mapping until #656 is fixed on this card, so its behaviour there is unverified. A discrete AMD card hasn't run it GPU, driver and backend: RTX 5090 (`10de:2b85`, NVIDIA 620.70.10) and AMD Ryzen 9 9950X graphics, RDNA 2 (`1002:13c0`, RADV, Mesa 26.0.8), both through GE-Proton11-15. `tuxbox.py check --changed 106120ca`, run one card at a time. The `Evidence:` line `tuxbox.py check` prints last, one per card (it names the commit it tested; run it on this pull request's head): ```text Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not run Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU 1002:13c0: 16 passed, 1 failed, 0 not run ``` Commands run and their results: ```text python tuxbox.py check --no-gpu # 13 passed, 0 failed python tuxbox.py check --changed 106120ca --adapter 10de:2b85 # 17 passed, 0 failed lanes-selftest PASS pci=10de:2b85 scenario=root-reach-reservation passed=1 python tuxbox.py check --changed 106120ca --adapter 1002:13c0 # 16 passed, 1 failed (Lanes and fixtures): lanes-selftest FAIL queue-page-mappings: copy ordered GPU mapping failed: 0x80004001 lanes-selftest FAIL queue-texture-boundary: map the texture tail failed: 0x80004001 lanes-selftest FAIL root-reach-reservation: map a page on each side of the boundary failed: 0x80004001 lanes-selftest FAIL ray-tracing-rehydrate: map physical pages for the GPU failed: 0x80004001 python tuxbox.py verify --only lanes-selftest --adapter 1002:13c0 # on main 106120ca: the same three #656 failures ``` **Game run.** These ran in ProjectScarlett on the RTX 5090, in 15-minute runs from boot into gameplay. The build was upstream `106120ca` plus #671, #672 and a local translator change for guarded float divisions (the area #670 now covers), with and without these two commits: - Without this change: 9 of 9 runs lost the GPU. - With it: 3 of 4 ran the full 15 minutes with no loss. The fourth lost the GPU to a compute dispatch with no address in the fault report. That may be a separate root-UAV problem, which this change doesn't touch; it isn't diagnosed. It hasn't been run in the game on plain upstream with only this change. ## Checks CI runs the [code checks](../CONTRIBUTING.md#code-checks): the Python and Rust unit tests, the translator tests through DXC, a Windows typecheck, clippy, formatting, rustdoc, and Miri on the providers. It has no GPU. No evidence JSON changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
JeffreyBytes commented 2026-12-03 17:54:12 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-12-03T17:54:12Z.


RDNA 2 run on the head (da7a4da4). RX 6700 XT 12 GB (1002:73df), Mesa 26.3.1 RADV, GE-Proton11-15, full check:

Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run

Page mappings work on this card at 106120ca, so the new root-reach-reservation self-test ran here and passed. No amdgpu faults or resets in the kernel log during the run.

<!-- greyfinch-sync:brcly/TuxBox:comment:7387256387 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/677#issuecomment-7387256387). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-12-03T17:54:12Z. --- RDNA 2 run on the head (da7a4da4). RX 6700 XT 12 GB (`1002:73df`), Mesa 26.3.1 RADV, GE-Proton11-15, full check: ```text Evidence: TuxBox check of da7a4da43ca4, no uncommitted changes, GPU default adapter: 17 passed, 0 failed, 0 not run ``` Page mappings work on this card at `106120ca`, so the new `root-reach-reservation` self-test ran here and passed. No amdgpu faults or resets in the kernel log during the run.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/677:upstream-pr/677'
git switch 'upstream-pr/677'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/677'
git switch 'upstream-pr/677'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/677'
git switch 'upstream-pr/677'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/677'
git switch 'main'
git merge --squash 'upstream-pr/677'
git switch 'main'
git merge --ff-only 'upstream-pr/677'
git switch 'main'
git merge 'upstream-pr/677'
git push origin 'main'
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!677
No description provided.