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

Closed
Fedalv wants to merge 1 commit from upstream-pr/351 into main
Fedalv commented 2026-11-26 18:13:00 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Fedalv on 2026-11-26T18:13:00Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5515087345 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/351). Originally posted by [Fedalv](https://github.com/Fedalv) on 2026-11-26T18:13:00Z. --- ## 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)
Fedalv commented 2026-11-26 20:47:31 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Fedalv on 2026-11-26T20:47:31Z.


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).

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7203077133 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/351#issuecomment-7203077133). Originally posted by [Fedalv](https://github.com/Fedalv) on 2026-11-26T20:47:31Z. --- **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).

Pull request closed

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
avatarmanz/VIctory-7900XTX!351
No description provided.