agc_driver_guest_memory_lifetime fails on RADV since the host-import cut larger-side keep (16473dbbe, #6499 family) #7784

Closed
opened 2026-10-19 07:22:34 +00:00 by blawesom · 3 comments
blawesom commented 2026-10-19 07:22:34 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T07:22:34Z.


What

agc_driver_guest_memory_lifetime fails on main on RADV with:

[device-fault] result 0:
guest memory host import lifetime: guest prefix unmap failed

(the guest munmap of the block after the lifetime checks returns nonzero)

Bisect

  • 16473dbbe~1 (6970fb0b0, "test(agc): check that a trimmed host import keeps its write watch and guest bytes"): passes
  • 16473dbbe ("perf(agc): keep the larger side of a host import cut inside its range"): fails — deterministic (3/3 solo), same assertion

The commit is part of the #6499 family ("perf/keep-import-across-split", merged as fac38912d → f9caa0974 → 16473dbbe).

Environment

  • Linux (CachyOS), kernel 7.2.9, GCC 16.2.1, Release, BUILD_TESTING=ON
  • AMD RX 9070 XT, RADV Mesa 26.2.4
  • tests/agc_driver_guest_memory_tests (lifetime suite), ~2 s

Not the Mesa tessellation bug (#5444), not the BDA anchor regression (#7584), not the image-table vouch failure (#7766) — this is a fourth, separate failure. The suite currently has four failing tests on this machine, all bisected to distinct causes.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5919644600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7784). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-19T07:22:34Z. --- ### What `agc_driver_guest_memory_lifetime` fails on `main` on RADV with: [device-fault] result 0: guest memory host import lifetime: guest prefix unmap failed (the guest `munmap` of the block after the lifetime checks returns nonzero) ### Bisect - `16473dbbe~1` (`6970fb0b0`, "test(agc): check that a trimmed host import keeps its write watch and guest bytes"): **passes** - `16473dbbe` ("perf(agc): keep the larger side of a host import cut inside its range"): **fails** — deterministic (3/3 solo), same assertion The commit is part of the #6499 family ("perf/keep-import-across-split", merged as `fac38912d` → `f9caa0974` → `16473dbbe`). ### Environment - Linux (CachyOS), kernel 7.2.9, GCC 16.2.1, Release, `BUILD_TESTING=ON` - AMD RX 9070 XT, RADV Mesa 26.2.4 - `tests/agc_driver_guest_memory_tests` (lifetime suite), ~2 s Not the Mesa tessellation bug (#5444), not the BDA anchor regression (#7584), not the image-table vouch failure (#7766) — this is a fourth, separate failure. The suite currently has four failing tests on this machine, all bisected to distinct causes. AI-assisted: yes
root-over commented 2026-10-19 10:17:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by root-over on 2026-10-19T10:17:28Z.


Same failure on an older AMD generation: AMD Ryzen 5 5625U iGPU (Vega, RADV RENOIR), Mesa 26.0.8, Ubuntu, kernel 7.0, GCC 15.2.0, Release. Passes with lavapipe on the same build.

  • A first-parent bisect between 452494439 (good) and 8816fd772 (bad) lands on the #6499 merge 64a9caa62 (parent c1ca83479 good), consistent with 16473dbbe above.
  • git revert -m 1 64a9caa62 on main 8816fd772: the test passes 3/3.
  • Right before the assertion RADV reports that the kernel refused the submission:
radv/amdgpu: The CS has been rejected, see dmesg for more information (-14).
[device-fault] result 0:
guest memory host import lifetime: guest prefix unmap failed

-14 is EFAULT from the amdgpu CS ioctl, which suggests a submission still references a userptr import whose pages were already unmapped or protected when the kept side of the cut was used, rather than the munmap itself failing first.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264920371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7784#issuecomment-6264920371). Originally posted by [root-over](https://github.com/root-over) on 2026-10-19T10:17:28Z. --- Same failure on an older AMD generation: AMD Ryzen 5 5625U iGPU (Vega, RADV RENOIR), Mesa 26.0.8, Ubuntu, kernel 7.0, GCC 15.2.0, Release. Passes with lavapipe on the same build. - A first-parent bisect between `452494439` (good) and `8816fd772` (bad) lands on the #6499 merge `64a9caa62` (parent `c1ca83479` good), consistent with `16473dbbe` above. - `git revert -m 1 64a9caa62` on `main` `8816fd772`: the test passes 3/3. - Right before the assertion RADV reports that the kernel refused the submission: ``` radv/amdgpu: The CS has been rejected, see dmesg for more information (-14). [device-fault] result 0: guest memory host import lifetime: guest prefix unmap failed ``` `-14` is `EFAULT` from the amdgpu CS ioctl, which suggests a submission still references a userptr import whose pages were already unmapped or protected when the kept side of the cut was used, rather than the `munmap` itself failing first.
thuanquang commented 2026-10-19 16:48:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T16:48:18Z.


An AMD proprietary driver data point: on main dbac9fa15 (which contains 16473dbbe), agc_driver_guest_memory_lifetime and its _copy, _direct, _locked, _heap and _heap_uncached variants pass 3 of 3 each under ctest on an RX 6700 XT (gfx1031, RDNA 2), AMD's Windows driver 32.0.21045.5002, Windows 11 26200 (ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1).

Windows maps and imports guest memory through a different path from Linux's munmap, so this doesn't tell RADV apart from the Linux host side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272395706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7784#issuecomment-6272395706). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-19T16:48:18Z. --- An AMD proprietary driver data point: on `main` `dbac9fa15` (which contains `16473dbbe`), `agc_driver_guest_memory_lifetime` and its `_copy`, `_direct`, `_locked`, `_heap` and `_heap_uncached` variants pass 3 of 3 each under `ctest` on an RX 6700 XT (gfx1031, RDNA 2), AMD's Windows driver 32.0.21045.5002, Windows 11 26200 (`ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`). Windows maps and imports guest memory through a different path from Linux's `munmap`, so this doesn't tell RADV apart from the Linux host side.
EagleBearerYS commented 2026-10-21 02:47:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T02:47:53Z.


A code reading that may explain root-over's -14, on main cd700fe9ec. I couldn't test it, since I have no RADV device.

  • What a trim keeps: a cut strictly inside a plain host import now keeps the larger side as a trimmed import (retireOrTrim, GuestBufferMemory.cpp L487-L510). Only the buffer is destroyed and base/bytes narrowed. The VkDeviceMemory is the original import's, over the whole original host range.
  • What reuse binds: when the kept side is used again, reattachTrimmed (L1948) binds a new buffer into that same memory at an offset. So every later submission that uses the kept side still references the original host-pointer allocation, cut pages included.
  • Why only RADV fails: on amdgpu, a host-pointer import is a userptr buffer object, and the kernel validates its whole range at submission. If the cut unmapped pages inside it, the CS ioctl fails with EFAULT (-14). That matches root-over's "The CS has been rejected (-14)" right before the assertion. Lavapipe, NVIDIA and AMD's Windows driver don't validate the whole range that way, which would explain why they pass.
  • A possible fix: keep the old memory only when the cut leaves every page of the original range mapped (a protect that keeps them accessible). When the cut unmaps pages, retire the import and import the kept side fresh, as before 16473dbbe. Head and tail trims reuse the memory the same way, so the same rule may apply there. The lifetime checks pass for those cases today, so I'm not claiming they fail.

@parl0v, happy to send this as a ready commit with a lavapipe test that checks no kept import's memory covers an unmapped cut, if that would help. It would need someone with RADV to confirm the fix.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306756664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7784#issuecomment-6306756664). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T02:47:53Z. --- A code reading that may explain root-over's `-14`, on `main` cd700fe9ec. I couldn't test it, since I have no RADV device. - **What a trim keeps:** a cut strictly inside a plain host import now keeps the larger side as a trimmed import ([`retireOrTrim`, GuestBufferMemory.cpp L487-L510](https://github.com/boykopovar/AnyPS5/blob/cd700fe9ec/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L487-L510)). Only the buffer is destroyed and `base`/`bytes` narrowed. The `VkDeviceMemory` is the original import's, over the whole original host range. - **What reuse binds:** when the kept side is used again, [`reattachTrimmed` (L1948)](https://github.com/boykopovar/AnyPS5/blob/cd700fe9ec/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L1948) binds a new buffer into that same memory at an offset. So every later submission that uses the kept side still references the original host-pointer allocation, cut pages included. - **Why only RADV fails:** on amdgpu, a host-pointer import is a userptr buffer object, and the kernel validates its whole range at submission. If the cut unmapped pages inside it, the CS ioctl fails with `EFAULT` (-14). That matches root-over's "The CS has been rejected (-14)" right before the assertion. Lavapipe, NVIDIA and AMD's Windows driver don't validate the whole range that way, which would explain why they pass. - **A possible fix:** keep the old memory only when the cut leaves every page of the original range mapped (a protect that keeps them accessible). When the cut unmaps pages, retire the import and import the kept side fresh, as before 16473dbbe. Head and tail trims reuse the memory the same way, so the same rule may apply there. The lifetime checks pass for those cases today, so I'm not claiming they fail. @parl0v, happy to send this as a ready commit with a lavapipe test that checks no kept import's memory covers an unmapped cut, if that would help. It would need someone with RADV to confirm the fix.
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
boykopovar/AnyPS5#7784
No description provided.