d3d12: default-on lazy publication causes radv/amdgpu CS rejection (-1 / EPERM) on AMD RADV #634

Closed
opened 2026-12-01 18:25:55 +00:00 by DrArroway · 2 comments
DrArroway commented 2026-12-01 18:25:55 +00:00 (Migrated from github.com)
Contributor

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-12-01T18:25:55Z.


Hit on AMD Radeon RX 6900 XT (1002:73bf) (Mesa 26.3.1-arch3.5 RADV NAVI21, GE-Proton11-14) on current main (93324a2b, post-e40d8052) with PR #630 (e242a160) applied so ProjectScarlett passes the slot 133 768x768x6 R16_TYPELESS assert.

With TUXBOX_LAZY_PUBLICATION left at its new default (1 after e40d8052), ProjectScarlett dies consistently before the intro when amdgpu rejects a command stream submission with -1 (-EPERM), with zero GPUVM faults in kernel logs and zero unfinished GPU commands. Toggling TUXBOX_LAZY_PUBLICATION=0 on the exact same build completely eliminates the rejection and lets the game proceed into the world.

Side-by-side comparison (same binary, 93324a2b + #630, TUXBOX_XMEM_PRIVATE_VIEWS=1, TUXBOX_TRACE_GPU_FAULT=1)

Setting Result Kernel (journalctl -k) TUXBOX_TRACE_GPU_FAULT=1
TUXBOX_LAZY_PUBLICATION=1 (default) Exits before intro at 227.8s (10,936+ frames) with radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). -> d3d12_command_queue_execute: Failed to submit queue(s), vr -4 -> VK_ERROR_DEVICE_LOST (0x887a0005) (exit code 5) 0 amdgpu GPUVM faults or ring timeouts fence signaled UINT64_MAX (device lost); 0 unfinished commands of 45159 recorded
TUXBOX_LAZY_PUBLICATION=0 0 CS rejected (-1) errors; clears the intro cleanly into the world (413.9s, 8,396 presents, 146,142 recorded GPU commands; later hits the separate #232/#603 TCP PERMISSION_FAULTS: 3 GPUVM read fault) [gfxhub] PERMISSION_FAULTS: 3 at 413s (no -1 CS rejection) 31 commands started and not finished, of 146142 recorded (PS 89f6b548 MS 5f6ec27e)

Relevant failure excerpt from the default (TUXBOX_LAZY_PUBLICATION=1) run:

0210:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: recorded ExecuteIndirect list=0x764a50a0 kind=2 max_count=1\n"
0214:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: read residency 9.7s: kept 0 views (0.0 MiB), left out 34739 (15782.5 MiB), textures read 5, indices past the heaps 0\n"
radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).
39154.473:016c:03b0:err:vkd3d-proton:d3d12_command_queue_execute: Failed to submit queue(s), vr -4.
39154.473:016c:03b0:warn:vkd3d-proton:d3d12_device_mark_as_removed: Device 00000000739d0080 is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST").
...
04fc:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: GPU fault trace: fence signaled UINT64_MAX (device lost); 0 unfinished commands of 45159 recorded\n"
04fc:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: command list cannot record placed texture publication failed: HRESULT(0x80004005)\n"

Why this happens on Linux AMDGPU / RADV

On Linux amdgpu, command submission (amdgpu_cs_parser_bos -> amdgpu_hmm_range_get_pages) validates page table permissions for every 4 KiB page inside every referenced AMDGPU_GEM_USERPTR BO (created via OpenExistingHeapFromAddress / OpenExistingHeapFromAddress1). If any 4 KiB page covered by a live userptr BO is PAGE_NOACCESS (PROT_NONE), the kernel rejects the CS ioctl immediately with -EPERM (-1) before the GPU ever executes a command.

Three gaps in how lazy.rs coordinates with userptr imports leave PAGE_NOACCESS pages inside live OpenExistingHeapFromAddress* BOs:

  1. Narrow byte ranges vs. 64 KiB+ imported extents (import.rs:202 vs. pages.rs:85-151): lazy::reason (runtime/d3d12/src/device/placement/lazy.rs:96-109) only checks gpu_writes::any_import_overlaps(&range), which tests narrow guest buffer byte ranges (address..address + desc.Width from runtime/d3d12/src/device/heap/import.rs:202) against the texture's byte range — not the 64 KiB page / multi-page span extents (or rounded pages_of(&range) 4 KiB pages) actually imported into AMDGPU_GEM_USERPTR via OpenExistingHeapFromAddress1. A deferred texture sharing a 64 KiB userptr heap with a buffer/view can leave PAGE_NOACCESS pages inside the BO.
  2. Later imports over already-deferred textures: lazy::defer (lazy.rs:252-274) only checks any_import_overlaps at deferral time; nothing releases or skips lazy-held PAGE_NOACCESS pages if a buffer or view opens a new OpenExistingHeapFromAddress* userptr import over the same 64 KiB page afterwards while the deferred texture hasn't been CPU-touched yet.
  3. Sub-page / PAGE_NOACCESS page rounding (pages_of): VirtualProtect(..., PAGE_NOACCESS) in lazy.rs:260-263 protects whole 4 KiB pages (pages_of), so any OpenExistingHeapFromAddress* region touching the same 4 KiB page hits PROT_NONE.

(Related to #625 from the same e40d8052 default flip, though distinct: #625 is Pages::release restoring stale VirtualProtect flags on CPU access, whereas this happens with zero CPU access faults because kernel HMM userptr validation sees PAGE_NOACCESS on a referenced BO at submit time.)

Happy to help test a fix (or coordinate with #625 once it lands) on both AMD Radeon RX 6900 XT (1002:73bf) and AMD Raphael Radeon 610M iGPU (1002:164e).

<!-- greyfinch-sync:brcly/TuxBox:issue:6727571257 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/634). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-12-01T18:25:55Z. --- Hit on **AMD Radeon RX 6900 XT (1002:73bf)** (Mesa `26.3.1-arch3.5` RADV NAVI21, `GE-Proton11-14`) on current `main` (`93324a2b`, post-`e40d8052`) with PR `#630` (`e242a160`) applied so ProjectScarlett passes the slot 133 `768x768x6 R16_TYPELESS` assert. With `TUXBOX_LAZY_PUBLICATION` left at its new default (`1` after `e40d8052`), ProjectScarlett dies consistently before the intro when `amdgpu` rejects a command stream submission with `-1` (`-EPERM`), with **zero** GPUVM faults in kernel logs and **zero** unfinished GPU commands. Toggling `TUXBOX_LAZY_PUBLICATION=0` on the exact same build completely eliminates the rejection and lets the game proceed into the world. ### Side-by-side comparison (same binary, `93324a2b` + `#630`, `TUXBOX_XMEM_PRIVATE_VIEWS=1`, `TUXBOX_TRACE_GPU_FAULT=1`) | Setting | Result | Kernel (`journalctl -k`) | `TUXBOX_TRACE_GPU_FAULT=1` | |---|---|---|---| | `TUXBOX_LAZY_PUBLICATION=1` (default) | Exits before intro at `227.8s` (`10,936+` frames) with `radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).` -> `d3d12_command_queue_execute: Failed to submit queue(s), vr -4` -> `VK_ERROR_DEVICE_LOST (0x887a0005)` (exit code `5`) | **0** `amdgpu` GPUVM faults or ring timeouts | `fence signaled UINT64_MAX (device lost); 0 unfinished commands of 45159 recorded` | | `TUXBOX_LAZY_PUBLICATION=0` | **0** `CS rejected (-1)` errors; clears the intro cleanly into the world (`413.9s`, `8,396` presents, `146,142` recorded GPU commands; later hits the separate `#232`/`#603` `TCP` `PERMISSION_FAULTS: 3` GPUVM read fault) | `[gfxhub]` `PERMISSION_FAULTS: 3` at `413s` (no `-1` CS rejection) | `31 commands started and not finished, of 146142 recorded` (`PS 89f6b548 MS 5f6ec27e`) | Relevant failure excerpt from the default (`TUXBOX_LAZY_PUBLICATION=1`) run: ```text 0210:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: recorded ExecuteIndirect list=0x764a50a0 kind=2 max_count=1\n" 0214:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: read residency 9.7s: kept 0 views (0.0 MiB), left out 34739 (15782.5 MiB), textures read 5, indices past the heaps 0\n" radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). 39154.473:016c:03b0:err:vkd3d-proton:d3d12_command_queue_execute: Failed to submit queue(s), vr -4. 39154.473:016c:03b0:warn:vkd3d-proton:d3d12_device_mark_as_removed: Device 00000000739d0080 is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST"). ... 04fc:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: GPU fault trace: fence signaled UINT64_MAX (device lost); 0 unfinished commands of 45159 recorded\n" 04fc:warn:debugstr:OutputDebugStringA "TuxBox d3d12_xs: command list cannot record placed texture publication failed: HRESULT(0x80004005)\n" ``` ### Why this happens on Linux AMDGPU / RADV On Linux `amdgpu`, command submission (`amdgpu_cs_parser_bos` -> `amdgpu_hmm_range_get_pages`) validates page table permissions for every 4 KiB page inside every referenced `AMDGPU_GEM_USERPTR` BO (created via `OpenExistingHeapFromAddress` / `OpenExistingHeapFromAddress1`). If **any** 4 KiB page covered by a live userptr BO is `PAGE_NOACCESS` (`PROT_NONE`), the kernel rejects the CS ioctl immediately with `-EPERM` (`-1`) before the GPU ever executes a command. Three gaps in how `lazy.rs` coordinates with userptr imports leave `PAGE_NOACCESS` pages inside live `OpenExistingHeapFromAddress*` BOs: 1. **Narrow byte ranges vs. 64 KiB+ imported extents (`import.rs:202` vs. `pages.rs:85-151`):** `lazy::reason` (`runtime/d3d12/src/device/placement/lazy.rs:96-109`) only checks `gpu_writes::any_import_overlaps(&range)`, which tests narrow guest buffer byte ranges (`address..address + desc.Width` from `runtime/d3d12/src/device/heap/import.rs:202`) against the texture's byte range — not the 64 KiB page / multi-page span extents (or rounded `pages_of(&range)` 4 KiB pages) actually imported into `AMDGPU_GEM_USERPTR` via `OpenExistingHeapFromAddress1`. A deferred texture sharing a 64 KiB userptr heap with a buffer/view can leave `PAGE_NOACCESS` pages inside the BO. 2. **Later imports over already-deferred textures:** `lazy::defer` (`lazy.rs:252-274`) only checks `any_import_overlaps` at deferral time; nothing releases or skips `lazy`-held `PAGE_NOACCESS` pages if a buffer or view opens a new `OpenExistingHeapFromAddress*` userptr import over the same 64 KiB page afterwards while the deferred texture hasn't been CPU-touched yet. 3. **Sub-page / `PAGE_NOACCESS` page rounding (`pages_of`):** `VirtualProtect(..., PAGE_NOACCESS)` in `lazy.rs:260-263` protects whole 4 KiB pages (`pages_of`), so any `OpenExistingHeapFromAddress*` region touching the same 4 KiB page hits `PROT_NONE`. (Related to `#625` from the same `e40d8052` default flip, though distinct: `#625` is `Pages::release` restoring stale `VirtualProtect` flags on CPU access, whereas this happens with zero CPU access faults because kernel HMM userptr validation sees `PAGE_NOACCESS` on a referenced BO at submit time.) Happy to help test a fix (or coordinate with `#625` once it lands) on both **AMD Radeon RX 6900 XT (1002:73bf)** and **AMD Raphael Radeon 610M iGPU (1002:164e)**.
Kayotic1337 commented 2026-12-01 19:14:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-12-01T19:14:59Z.


Same on RDNA4: RX 9070 XT (1002:7550), Mesa 26.3.1 RADV, kernel 7.3.6, GE-Proton11-15 with its own vkd3d-proton. Build: main 712fb960 (after e40d8052) + #630, plus a local log line for placed texture drops. Default settings, no TUXBOX_XMEM_PRIVATE_VIEWS, VKD3D_CONFIG=fault.

Run Extra setting Result
1 none exit 5 after 631.6 s
2 none exit 5 after 625.6 s
3 VKD3D_DISABLE_EXTENSIONS=VK_EXT_device_generated_commands (log confirms it was off) exit 5 after 434.3 s

All three end the same way:

TuxBox d3d12_xs: bound paged resource descriptor index map at compute root slot 1
TuxBox d3d12_xs: recorded ExecuteIndirect list=0x... kind=2 max_count=1
radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).
d3d12_command_queue_execute: Failed to submit queue(s), vr -4.

followed by VK_ERROR_DEVICE_LOST. In all three, the recorded ExecuteIndirect line is the first of the run (it is logged once), and the rejection follows within about a second.

  • Kernel: dmesg and journalctl -k have no amdgpu or drm lines for any of the three runs: no GPUVM fault, ring timeout or reset.
  • Not vkd3d's DGC path: run 3 has device-generated commands disabled and fails the same way.
  • Not private views: these runs didn't use TUXBOX_XMEM_PRIVATE_VIEWS.

With TUXBOX_LAZY_PUBLICATION=0 (same build and settings, one run): no CS rejection. The run got past the first indirect dispatch (recorded ExecuteIndirect ... kind=2 is logged, then one with kind=10) and ran 807 s. As in your run, it then ended on a GPUVM TCP read fault (0x0070113B, PERMISSION_FAULTS 3). That fault is in a sparse placed-texture VA range whose previous image had been destroyed 5.3 s earlier, which is the #603 shape.

<!-- greyfinch-sync:brcly/TuxBox:comment:7322473860 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/634#issuecomment-7322473860). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-12-01T19:14:59Z. --- Same on RDNA4: RX 9070 XT (`1002:7550`), Mesa 26.3.1 RADV, kernel 7.3.6, GE-Proton11-15 with its own vkd3d-proton. Build: main `712fb960` (after e40d8052) + #630, plus a local log line for placed texture drops. Default settings, **no** `TUXBOX_XMEM_PRIVATE_VIEWS`, `VKD3D_CONFIG=fault`. | Run | Extra setting | Result | |---|---|---| | 1 | none | exit 5 after 631.6 s | | 2 | none | exit 5 after 625.6 s | | 3 | `VKD3D_DISABLE_EXTENSIONS=VK_EXT_device_generated_commands` (log confirms it was off) | exit 5 after 434.3 s | All three end the same way: ```text TuxBox d3d12_xs: bound paged resource descriptor index map at compute root slot 1 TuxBox d3d12_xs: recorded ExecuteIndirect list=0x... kind=2 max_count=1 radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). d3d12_command_queue_execute: Failed to submit queue(s), vr -4. ``` followed by `VK_ERROR_DEVICE_LOST`. In all three, the `recorded ExecuteIndirect` line is the first of the run (it is logged once), and the rejection follows within about a second. - **Kernel:** `dmesg` and `journalctl -k` have no amdgpu or drm lines for any of the three runs: no GPUVM fault, ring timeout or reset. - **Not vkd3d's DGC path:** run 3 has device-generated commands disabled and fails the same way. - **Not private views:** these runs didn't use `TUXBOX_XMEM_PRIVATE_VIEWS`. **With `TUXBOX_LAZY_PUBLICATION=0`** (same build and settings, one run): no CS rejection. The run got past the first indirect dispatch (`recorded ExecuteIndirect ... kind=2` is logged, then one with `kind=10`) and ran 807 s. As in your run, it then ended on a GPUVM TCP read fault (`0x0070113B`, `PERMISSION_FAULTS 3`). That fault is in a sparse placed-texture VA range whose previous image had been destroyed 5.3 s earlier, which is the #603 shape.
DrArroway commented 2026-12-01 19:42:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-12-01T19:42:47Z.


Thanks @Kayotic1337 for confirming this on RDNA4 (1002:7550) too — especially ruling out VK_EXT_device_generated_commands and TUXBOX_XMEM_PRIVATE_VIEWS!

I'm claiming #634 now and working on a fix that tracks live OpenExistingHeapFromAddress* userptr extents in lazy.rs / heap (both preventing lazy::defer from VirtualProtect(..., PAGE_NOACCESS)-ing pages inside any live userptr BO and publishing/releasing overlapping deferred textures before a new userptr heap is opened), while leaving Pages::protect / Pages::release untouched so this stays orthogonal to #625.

<!-- greyfinch-sync:brcly/TuxBox:comment:7323281991 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/issues/634#issuecomment-7323281991). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-12-01T19:42:47Z. --- Thanks `@Kayotic1337` for confirming this on RDNA4 (`1002:7550`) too — especially ruling out `VK_EXT_device_generated_commands` and `TUXBOX_XMEM_PRIVATE_VIEWS`! I'm claiming `#634` now and working on a fix that tracks live `OpenExistingHeapFromAddress*` userptr extents in `lazy.rs` / `heap` (both preventing `lazy::defer` from `VirtualProtect(..., PAGE_NOACCESS)`-ing pages inside any live userptr BO and publishing/releasing overlapping deferred textures before a new userptr heap is opened), while leaving `Pages::protect` / `Pages::release` untouched so this stays orthogonal to `#625`.
Sign in to join this conversation.
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#634
No description provided.