Card steps: leave out copies outside their buffers instead of recording them (GPU page fault and whole-GPU reset on RADV) #351

Closed
github-bot wants to merge 1 commit from github-bot/gh-351 into main AGit
Owner

@⁠Fedalv on GitHub · 2026-11-26 18:13 UTC · original
card-steps-bounds → main · +24 −0 · 1 files · 1 commits · closed without merging

Problem

A card step (VICTORY_CARD_STEPS, on in play.ps1) records CopyBufferRegion calls whose offsets and lengths are worked out from title memory, and nothing checks them against the buffers before they are recorded. On Windows the runtime/driver may catch a bad range; vkd3d-proton does not validate CopyBufferRegion, and on RADV a copy past a buffer's end becomes a write by the card's command processor to an address of no allocation.

What that looks like when it happens (Linux, RX 7900 XTX, RADV 26.2.5, Proton Experimental with vkd3d-proton master, three minutes into the opening sequence):

[gfxhub] page fault (src_id:0 ring:169 vmid:0 pasid:0)
  in page starting at address 0x0000fffffffff000 from client 10
Faulty UTCL2 client ID: CPC (0x5)  WALKER_ERROR: 0x1  PERMISSION_FAULTS: 0x5  MAPPING_ERROR: 0x1  RW: 0x1
ring comp_1.0.1 timeout ... Process main thread vkd3d_queue
failed to reset legacy queue ... The CPFW hasn't support pipe reset yet.
VRAM is lost due to GPU reset!

A write (RW 1) by the command processor (CPC) on vkd3d's compute queue to 0xfffffffff000: the shape of a buffer copy or fill with a wrapped offset. The queue reset fails, the whole GPU is reset, and the Wayland compositor dies with it (a full desktop crash, not just the title). #13 saw VICTORY_CARD_STEPS=2 remove the device on the same card under Proton.

Change

record() in host/card_steps.rs checks every range against its buffer's width (GetDesc) and the staging buffer (BETWEEN), with overflow-checked sums, and leaves out a range that does not fit, with a warning (card step: a copy out of its buffer's range left out, the first 16 and then at powers of two). The barriers are built from the ranges that remain. One file, 25 lines; nothing else changes when every range fits.

What this does and does not show

  • I have not caught the check firing: in 18 runs since (150-300 s each, same machine, CARD_STEPS=2) the warning count is 0 and the kernel logged no GPU fault. So I cannot prove the reset above came from this path rather than another write on that queue; the PR is a guard, not a diagnosed fix.
  • What it does buy: a bad range becomes a log line instead of a GPU reset, and the line says which offsets were wrong, which is the evidence missing above.
  • With card steps off the same scenes ran at 118 ms a frame against 50 with them on (the submitting thread waits for the card), so turning them off on Linux is not a good workaround.

Tested

  • cargo xwin clippy -p victory-gpu with and without --features diagnostics: no lint in card_steps.rs (the one error is watch.rs:3626, already on main and fixed by #241/#324).
  • cargo xtask policy: ok.
  • In play as above; not tested on Windows or NVIDIA, where nothing should change unless a range is out of bounds.

AI-assisted (Claude Code); runs on my machine.

🤖 Generated with Claude Code

**@⁠Fedalv** on GitHub · 2026-11-26 18:13 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/351) `card-steps-bounds` → `main` · +24 −0 · 1 files · 1 commits · closed without merging ## Problem A card step (`VICTORY_CARD_STEPS`, on in `play.ps1`) records `CopyBufferRegion` calls whose offsets and lengths are worked out from title memory, and nothing checks them against the buffers before they are recorded. On Windows the runtime/driver may catch a bad range; vkd3d-proton does not validate `CopyBufferRegion`, and on RADV a copy past a buffer's end becomes a write by the card's command processor to an address of no allocation. What that looks like when it happens (Linux, RX 7900 XTX, RADV 26.2.5, Proton Experimental with vkd3d-proton master, three minutes into the opening sequence): ``` [gfxhub] page fault (src_id:0 ring:169 vmid:0 pasid:0) in page starting at address 0x0000fffffffff000 from client 10 Faulty UTCL2 client ID: CPC (0x5) WALKER_ERROR: 0x1 PERMISSION_FAULTS: 0x5 MAPPING_ERROR: 0x1 RW: 0x1 ring comp_1.0.1 timeout ... Process main thread vkd3d_queue failed to reset legacy queue ... The CPFW hasn't support pipe reset yet. VRAM is lost due to GPU reset! ``` A write (RW 1) by the command processor (CPC) on vkd3d's compute queue to `0xfffffffff000`: the shape of a buffer copy or fill with a wrapped offset. The queue reset fails, the whole GPU is reset, and the Wayland compositor dies with it (a full desktop crash, not just the title). #13 saw `VICTORY_CARD_STEPS=2` remove the device on the same card under Proton. ## Change `record()` in `host/card_steps.rs` checks every range against its buffer's width (`GetDesc`) and the staging buffer (`BETWEEN`), with overflow-checked sums, and leaves out a range that does not fit, with a warning (`card step: a copy out of its buffer's range left out`, the first 16 and then at powers of two). The barriers are built from the ranges that remain. One file, 25 lines; nothing else changes when every range fits. ## What this does and does not show - I have **not** caught the check firing: in 18 runs since (150-300 s each, same machine, `CARD_STEPS=2`) the warning count is 0 and the kernel logged no GPU fault. So I cannot prove the reset above came from this path rather than another write on that queue; the PR is a guard, not a diagnosed fix. - What it does buy: a bad range becomes a log line instead of a GPU reset, and the line says which offsets were wrong, which is the evidence missing above. - With card steps off the same scenes ran at 118 ms a frame against 50 with them on (the submitting thread waits for the card), so turning them off on Linux is not a good workaround. ## Tested - `cargo xwin clippy -p victory-gpu` with and without `--features diagnostics`: no lint in `card_steps.rs` (the one error is `watch.rs:3626`, already on main and fixed by #241/#324). - `cargo xtask policy`: ok. - In play as above; not tested on Windows or NVIDIA, where nothing should change unless a range is out of bounds. AI-assisted (Claude Code); runs on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Every range a card step records (VICTORY_CARD_STEPS) is checked against
its buffer's width and the staging buffer before CopyBufferRegion: a
range past a buffer's end is left out, with a warning (the first 16, then
at powers of two), instead of being recorded.

vkd3d-proton does not validate CopyBufferRegion. On RADV a copy past a
buffer is a write by the command processor to an address of no
allocation: a GPU page fault, and when the queue reset fails a reset of
the whole GPU, which takes the Wayland compositor with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:15:30 +00:00
Author
Owner

@⁠Fedalv on GitHub · 2026-11-26 20:47 UTC · original

Update: the reset in the description is not from this path. It happened again (run 23, ~3 min in) with this check active: the same command-processor write to 0xfffffffff000, this time on comp_1.2.0, and the check logged nothing (card step: a copy out of its buffer's range 0 times). Both faults are in VMID 0 (vmid:0 pasid:0) on compute rings, which points below the layer (the driver's or firmware's handling of the compute queue) rather than at a copy the layer recorded.

So this PR is only what it was described as in "What this does and does not show": a guard that turns an out-of-range card-step copy into a log line instead of a GPU write past a buffer, with no observed case of it firing. Fine to close if you'd rather not carry an unexercised check; I'll follow up on #352 with what the reset turns out to be.

AI-assisted (Claude Code).

**@⁠Fedalv** on GitHub · 2026-11-26 20:47 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/351#issuecomment-7203077133) **Update: the reset in the description is not from this path.** It happened again (run 23, ~3 min in) with this check active: the same command-processor write to `0xfffffffff000`, this time on `comp_1.2.0`, and the check logged nothing (`card step: a copy out of its buffer's range` 0 times). Both faults are in VMID 0 (`vmid:0 pasid:0`) on compute rings, which points below the layer (the driver's or firmware's handling of the compute queue) rather than at a copy the layer recorded. So this PR is only what it was described as in "What this does and does not show": a guard that turns an out-of-range card-step copy into a log line instead of a GPU write past a buffer, with no observed case of it firing. Fine to close if you'd rather not carry an unexercised check; I'll follow up on #352 with what the reset turns out to be. AI-assisted (Claude Code).
github-bot closed this pull request 2026-11-27 10:39:12 +00:00

Pull request closed

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