fix(agc): import guest memory through dma-buf before host pointer when host imports lose write tracking #2434

Merged
999sian merged 10 commits from upstream-pr/2434 into main 2026-11-14 03:19:54 +00:00
999sian commented 2026-10-09 19:59:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 999sian on 2026-10-09T19:59:44Z.


What

On this driver, host-pointer imports of guest memory lose userfaultfd write protection, while dma-buf imports of the same memory keep it. When the startup probe shows that, shared-backed ranges are imported through dma-buf only (except when udmabuf refuses the range before importing anything, which keeps the host-pointer import). Imported storage images over shared-backed direct memory were otherwise compared on every refresh because host-pointer imports dropped write tracking.

VulkanDevice::DmaBufImportSelected() and Graphics::HostImportUsesDmaBuf() are added for the regression test.

Regression test agc_driver_host_import_dma_buf_watch: fails without the change, passes with it.

Tested

  • Linux (CachyOS, KDE Wayland), Intel Arc (MTL), Mesa Vulkan.
  • agc_driver_host_import_dma_buf_watch executes (not skipped) and passes on current main (2e22b6703), along with the flat/global store and host-import test families (40/40 passed).
  • tools/check_conventions.py --base origin/main, tools/check_test_registration.py, and tools/check_skips.py pass.
  • Windows and macOS not tested locally.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (none added)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4805253119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434). Originally posted by [999sian](https://github.com/999sian) on 2026-10-09T19:59:44Z. --- ### What On this driver, host-pointer imports of guest memory lose userfaultfd write protection, while dma-buf imports of the same memory keep it. When the startup probe shows that, shared-backed ranges are imported through dma-buf only (except when udmabuf refuses the range before importing anything, which keeps the host-pointer import). Imported storage images over shared-backed direct memory were otherwise compared on every refresh because host-pointer imports dropped write tracking. `VulkanDevice::DmaBufImportSelected()` and `Graphics::HostImportUsesDmaBuf()` are added for the regression test. Regression test `agc_driver_host_import_dma_buf_watch`: fails without the change, passes with it. ### Tested - Linux (CachyOS, KDE Wayland), Intel Arc (MTL), Mesa Vulkan. - `agc_driver_host_import_dma_buf_watch` executes (not skipped) and passes on current `main` (`2e22b6703`), along with the flat/global store and host-import test families (40/40 passed). - `tools/check_conventions.py --base origin/main`, `tools/check_test_registration.py`, and `tools/check_skips.py` pass. - Windows and macOS not tested locally. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt (none added) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 19:59:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T19:59:54Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088289605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6088289605). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T19:59:54Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
oneandonlydean commented 2026-10-11 03:38:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T03:38:35Z.


Reopened. Could you rebase this on main and drop the fallback to the host pointer after a failed dma-buf import? Pick the import kind once from the probe and throw if that import fails. Fallbacks aren't accepted here (see CONTRIBUTING).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105093022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6105093022). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T03:38:35Z. --- Reopened. Could you rebase this on `main` and drop the fallback to the host pointer after a failed dma-buf import? Pick the import kind once from the probe and throw if that import fails. Fallbacks aren't accepted here (see CONTRIBUTING).
adriadam10 commented 2026-10-11 07:06:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:06:21Z.

Review: CHANGES_REQUESTED


Thanks for the fix. Dean's request above still stands, and there are two more points:

  • Conflicts with main in libSceAgcDriver/CMakeLists.txt and GuestBufferMemory.cpp (createImport/importAllocation changed). Please rebase.
  • GuestBufferMemory.cpp:279: if the dma-buf import fails when it is preferred, the code goes on to the host pointer. As Dean said, pick the import kind once from the probe and throw if that import fails; no fallback (CONTRIBUTING). The same applies to the second block (:284-288): it keeps a host-pointer-then-dma-buf fallback, so createImport should take the kind from the probe and use only that one.
  • HostImportDmaBufWatch.cpp:56-59: the test returns "skipped" when FillBuffer fails after DmaBufImportSupported() was true. Once there is no fallback, that is a failure and should throw, otherwise the test can pass without testing anything.

Please also post the [write-watch] probe lines from your run in the PR so the probe decision (host imports lose tracking, dma-buf keeps it) is visible.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482275951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#pullrequestreview-5482275951). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:06:21Z. **Review:** CHANGES_REQUESTED --- Thanks for the fix. Dean's request above still stands, and there are two more points: - Conflicts with `main` in `libSceAgcDriver/CMakeLists.txt` and `GuestBufferMemory.cpp` (`createImport`/`importAllocation` changed). Please rebase. - `GuestBufferMemory.cpp:279`: if the dma-buf import fails when it is preferred, the code goes on to the host pointer. As Dean said, pick the import kind once from the probe and throw if that import fails; no fallback (CONTRIBUTING). The same applies to the second block (`:284-288`): it keeps a host-pointer-then-dma-buf fallback, so `createImport` should take the kind from the probe and use only that one. - `HostImportDmaBufWatch.cpp:56-59`: the test returns "skipped" when `FillBuffer` fails after `DmaBufImportSupported()` was true. Once there is no fallback, that is a failure and should throw, otherwise the test can pass without testing anything. Please also post the `[write-watch]` probe lines from your run in the PR so the probe decision (host imports lose tracking, dma-buf keeps it) is visible.
Mouhand-Kaddo commented 2026-10-11 07:30:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:30:14Z.


Additional platform validation of standalone PR head b8ba68c62009322640b249ddba9345bf799b7d2e (2026-10-11):

Windows: passed with skips — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release, BUILD_TESTING=ON.

2 checks, 0 failures, 1 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.

Checks: agc_driver_graphics, agc_driver_host_import_dma_buf_watch.

Command after building: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$".

Vulkan: native AMD Radeon RX 6900 XT, driver 32.0.21045.5002.

agc_driver_graphics passed. agc_driver_host_import_dma_buf_watch skipped after its initial memory checks because the Windows Vulkan device does not import guest memory through dma-buf; the Linux dma-buf path was not executed on Windows.

No title/gameplay validation. These results cover the standalone head, not a merge with current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106692497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6106692497). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-11T07:30:14Z. --- <!-- anyps5-platform-validation:b8ba68c62009322640b249ddba9345bf799b7d2e --> Additional platform validation of standalone PR head `b8ba68c62009322640b249ddba9345bf799b7d2e` (2026-10-11): **Windows: passed with skips** — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release, `BUILD_TESTING=ON`. 2 checks, 0 failures, 1 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run. Checks: `agc_driver_graphics`, `agc_driver_host_import_dma_buf_watch`. Command after building: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$"`. Vulkan: native AMD Radeon RX 6900 XT, driver 32.0.21045.5002. agc_driver_graphics passed. agc_driver_host_import_dma_buf_watch skipped after its initial memory checks because the Windows Vulkan device does not import guest memory through dma-buf; the Linux dma-buf path was not executed on Windows. No title/gameplay validation. These results cover the standalone head, not a merge with current main.
999sian commented 2026-10-11 11:52:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 999sian on 2026-10-11T11:52:41Z.


Addressed the review requests in cfafe1a7 (rebased onto main at 9a9bd3fb3).

  • Resolved the CMakeLists.txt and GuestBufferMemory.cpp conflicts, preserving main's 64 MiB chunked dma-buf imports and provoking-vertex test registration.
  • Select the memory import kind once from the startup write-watch probe. Both direct import paths use only the selected mechanism and throw on failure; no host-pointer/dma-buf fallback in either direction.
  • After dma-buf support is confirmed, FillBuffer failure now fails the regression test rather than skipping it. Unsupported-device skips remain.

Focused Linux validation: CachyOS x86-64, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON. Built only the two selected test targets and their dependencies (not a full build or full-suite run):

cmake --build build --target agc_driver_graphics_tests agc_driver_host_import_dma_buf_watch_tests -j 12
ctest --test-dir build --verbose --no-tests=error --timeout 30 -R '^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$'

Both checks passed, 0 failures, 0 CTest skips; total 7.52 s. The dma-buf write-watch regression actually executed. The graphics check reported that its guest-arena heap-mirror subcases were not exercised.

Probe output:

[write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared
[write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched

No new title/gameplay validation or additional-platform validation was performed for this revision.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108733289 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6108733289). Originally posted by [999sian](https://github.com/999sian) on 2026-10-11T11:52:41Z. --- Addressed the review requests in cfafe1a7 (rebased onto main at 9a9bd3fb3). - Resolved the CMakeLists.txt and GuestBufferMemory.cpp conflicts, preserving main's 64 MiB chunked dma-buf imports and provoking-vertex test registration. - Select the memory import kind once from the startup write-watch probe. Both direct import paths use only the selected mechanism and throw on failure; no host-pointer/dma-buf fallback in either direction. - After dma-buf support is confirmed, FillBuffer failure now fails the regression test rather than skipping it. Unsupported-device skips remain. Focused Linux validation: CachyOS x86-64, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON. Built only the two selected test targets and their dependencies (not a full build or full-suite run): ```sh cmake --build build --target agc_driver_graphics_tests agc_driver_host_import_dma_buf_watch_tests -j 12 ctest --test-dir build --verbose --no-tests=error --timeout 30 -R '^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$' ``` Both checks passed, 0 failures, 0 CTest skips; total 7.52 s. The dma-buf write-watch regression actually executed. The graphics check reported that its guest-arena heap-mirror subcases were not exercised. Probe output: ```text [write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared [write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched ``` No new title/gameplay validation or additional-platform validation was performed for this revision.
ThatsLeo commented 2026-10-11 12:01:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-11T12:01:03Z.


Another data point for this change, from Stray (PPSA02101 v01.002, UE4) on the same hardware: Intel Arc (Meteor Lake), Mesa 26.2.3 ANV, Fedora 44. Stray runs on main f1ae427b with the set described in #2749.

The probe reports host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read) and dma-buf imports keep write protection: yes. Yet Stray's direct memory went through the host-pointer path, because that import succeeds on ANV, and every imported range was unwatched. Storage refreshes then byte-compared about 2.8 GB/s of surfaces, render targets up to 3840x2160.

With dma-buf imports tried first in that case (the same choice as this PR, written locally before I found it), the calibration screen goes from about 1.0 to 2.07 FPS steady: 434 frames in 240 s instead of 204. I did not test this branch's head itself.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108799375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6108799375). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-11T12:01:03Z. --- Another data point for this change, from Stray (PPSA02101 v01.002, UE4) on the same hardware: Intel Arc (Meteor Lake), Mesa 26.2.3 ANV, Fedora 44. Stray runs on `main` `f1ae427b` with the set described in #2749. The probe reports `host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read)` and `dma-buf imports keep write protection: yes`. Yet Stray's direct memory went through the host-pointer path, because that import succeeds on ANV, and every imported range was unwatched. Storage refreshes then byte-compared about 2.8 GB/s of surfaces, render targets up to 3840x2160. With dma-buf imports tried first in that case (the same choice as this PR, written locally before I found it), the calibration screen goes from about 1.0 to 2.07 FPS steady: 434 frames in 240 s instead of 204. I did not test this branch's head itself. AI-assisted: yes.
adriadam10 commented 2026-10-11 12:42:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T12:42:11Z.

Review: CHANGES_REQUESTED


Thanks for the rebase and for dropping the fallback. Two points left:

  • GuestBufferMemory.cpp:736-761: importAllocation now throws on any host-pointer import failure on every platform (before: state.failed + copies), and the try/catch in ImportMappedRanges (:2013) is gone. That is wider than "throw if the selected dma-buf import fails". Either keep the previous behaviour for the host-pointer kind, or show (test or log) that the throw is the intended outcome there, and cover it with a test.
  • HostImportDmaBufWatch.cpp:44-57: DmaBufImportSupported() only reflects the device capability. If the probe selects the host pointer and /dev/udmabuf is not usable, FillBuffer/the watch check fail instead of skipping. Skip on the selected kind (or on a missing shared backing), and keep failing only when dma-buf is the selected import.

The red conventions check is not from this PR: checkout fails on main's 3rdparty/imgui gitlink without a .gitmodules entry; it will go green once that is fixed on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483333522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#pullrequestreview-5483333522). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T12:42:11Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase and for dropping the fallback. Two points left: - `GuestBufferMemory.cpp:736-761`: `importAllocation` now throws on any host-pointer import failure on every platform (before: `state.failed` + copies), and the try/catch in `ImportMappedRanges` (`:2013`) is gone. That is wider than "throw if the selected dma-buf import fails". Either keep the previous behaviour for the host-pointer kind, or show (test or log) that the throw is the intended outcome there, and cover it with a test. - `HostImportDmaBufWatch.cpp:44-57`: `DmaBufImportSupported()` only reflects the device capability. If the probe selects the host pointer and `/dev/udmabuf` is not usable, `FillBuffer`/the watch check fail instead of skipping. Skip on the selected kind (or on a missing shared backing), and keep failing only when dma-buf is the selected import. The red `conventions` check is not from this PR: checkout fails on main's `3rdparty/imgui` gitlink without a `.gitmodules` entry; it will go green once that is fixed on main.
999sian commented 2026-10-11 16:12:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 999sian on 2026-10-11T16:12:09Z.


Addressed the remaining review points in 9c999b3e.

  • Host-pointer import failures retain the previous state.failed/copy behavior. ImportMappedRanges retains exception tolerance for host-pointer imports, but rethrows when dma-buf is selected, so an attempted dma-buf import failure is not swallowed.
  • The normal import kind is stored once from the probes; Windows remains host-pointer. Explicit SetImportWatch overrides preserve the existing host-pointer test contract. Existing PrepareImportWatch/stamp-query semantics and per-entry watch handling are preserved rather than broadening those APIs.
  • Replaced the device-capability-only accessor with DmaBufImportSelected. The regression skips when dma-buf is not selected, and requires FillBuffer success once it is selected.
  • Missing per-range shared backing is treated as an unavailable import and served by copies, without retrying the host-pointer mechanism. Actual attempted dma-buf import failures still throw. Upstream chunked dma-buf behavior is retained.

Validation on Linux, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON:

cmake --build build --target agc_driver_graphics_tests agc_driver_host_import_dma_buf_watch_tests agc_driver_recorder_tests -j 12
ctest --test-dir build --verbose --no-tests=error --timeout 30 -R '^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$'
./build/tests/agc_driver_recorder_tests

Both requested checks passed, 0 CTest skips, total 3.95 s. The supplemental bare recorder run also completed successfully with 'Recorder read tracking and label tests passed'; it reported unavailable-import/not-tested subcases for anonymous memory without shared backing. Graphics also reports its guest-arena heap-mirror subcases were not exercised. This was a focused build, not a full build or full CTest suite.

Skip-path smoke: APS5_WRITE_WATCH_IMPORTS=unwatch ./build/tests/agc_driver_host_import_dma_buf_watch_tests reported 'skipped, the probe did not select dma-buf as this device's import kind' and exited 77. Default probe selection executed and passed the dma-buf regression, not a skip.

Default probe evidence:

[write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared
[write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched

Conventions and test-registration checks pass. No new Windows or gameplay validation was performed for this revision.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110999138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6110999138). Originally posted by [999sian](https://github.com/999sian) on 2026-10-11T16:12:09Z. --- Addressed the remaining review points in 9c999b3e. - Host-pointer import failures retain the previous state.failed/copy behavior. ImportMappedRanges retains exception tolerance for host-pointer imports, but rethrows when dma-buf is selected, so an attempted dma-buf import failure is not swallowed. - The normal import kind is stored once from the probes; Windows remains host-pointer. Explicit SetImportWatch overrides preserve the existing host-pointer test contract. Existing PrepareImportWatch/stamp-query semantics and per-entry watch handling are preserved rather than broadening those APIs. - Replaced the device-capability-only accessor with DmaBufImportSelected. The regression skips when dma-buf is not selected, and requires FillBuffer success once it is selected. - Missing per-range shared backing is treated as an unavailable import and served by copies, without retrying the host-pointer mechanism. Actual attempted dma-buf import failures still throw. Upstream chunked dma-buf behavior is retained. Validation on Linux, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON: ```sh cmake --build build --target agc_driver_graphics_tests agc_driver_host_import_dma_buf_watch_tests agc_driver_recorder_tests -j 12 ctest --test-dir build --verbose --no-tests=error --timeout 30 -R '^(agc_driver_host_import_dma_buf_watch|agc_driver_graphics)$' ./build/tests/agc_driver_recorder_tests ``` Both requested checks passed, 0 CTest skips, total 3.95 s. The supplemental bare recorder run also completed successfully with 'Recorder read tracking and label tests passed'; it reported unavailable-import/not-tested subcases for anonymous memory without shared backing. Graphics also reports its guest-arena heap-mirror subcases were not exercised. This was a focused build, not a full build or full CTest suite. Skip-path smoke: `APS5_WRITE_WATCH_IMPORTS=unwatch ./build/tests/agc_driver_host_import_dma_buf_watch_tests` reported 'skipped, the probe did not select dma-buf as this device\'s import kind' and exited 77. Default probe selection executed and passed the dma-buf regression, not a skip. Default probe evidence: ```text [write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared [write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched ``` Conventions and test-registration checks pass. No new Windows or gameplay validation was performed for this revision.
adriadam10 commented 2026-10-11 16:19:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T16:19:05Z.

Review: CHANGES_REQUESTED


Thanks for the rebase and for dropping the fallback. One blocker left; I built the PR merged onto current main and ran ctest (385 tests in the libSceAgcDriver scope): the new test passes, but 25 fail, among them agc_driver_flat_store, agc_driver_global_atomics*, agc_driver_global_store_addtid, agc_driver_masked_global_store, agc_driver_bda_span_reads, agc_driver_cmask_fast_clear, agc_driver_pixel_interlock. On a device whose probe selects dma-buf (the case this PR targets), agc_driver_flat_store prints:

[gpu] dma-buf import of 0x7fe608dc0000+0x10000 failed at shared backing lookup (-1000072003)
[gpu] dma-buf import of ... is unavailable (shared backing lookup); the range is served by copies
[gpu] deferred write-back failed: BDA access failed: ... read-only in the BDA table: stores through ... FLAT/GLOBAL addresses reach only writable ranges imported in place, not ones served by a mirror or a copy
AGC graphics: flat store: wave32 byte 0 is 205, expected 0
  • GuestBufferMemory.cpp:459-474 (createImport): when dma-buf is the selected kind and the range has no shared backing (GuestArenaSharedBacking fails, e.g. anonymous memory, as in these tests), the range is now served by copies, so GPU stores through FLAT/GLOBAL addresses never reach it. On main the host-pointer import covers it. This is a regression for every range outside direct memory on dma-buf-selected devices, not only in the tests. Either keep importing those ranges through the host pointer (the probe-selected kind applies to ranges that can be dma-buf-backed), or make the unbacked case a hard failure with a test showing it never happens for ranges the GPU stores to; in both cases the 25 failures above need to pass on a dma-buf-selected device (try APS5_WRITE_WATCH_IMPORTS unset on your Arc).
  • GuestBufferMemory.cpp:278: the /dev/udmabuf message now says only "DMA-BUF imports will fail", but a missing udmabuf no longer breaks the host-pointer path; keep the hint about the ranges being served by copies/FLAT stores or make it match what actually happens.
  • Please run the whole libSceAgcDriver ctest scope locally, not just the two targets, since this change affects every import.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5484012477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#pullrequestreview-5484012477). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T16:19:05Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase and for dropping the fallback. One blocker left; I built the PR merged onto current `main` and ran ctest (385 tests in the `libSceAgcDriver` scope): the new test passes, but 25 fail, among them `agc_driver_flat_store`, `agc_driver_global_atomics*`, `agc_driver_global_store_addtid`, `agc_driver_masked_global_store`, `agc_driver_bda_span_reads`, `agc_driver_cmask_fast_clear`, `agc_driver_pixel_interlock`. On a device whose probe selects dma-buf (the case this PR targets), `agc_driver_flat_store` prints: ``` [gpu] dma-buf import of 0x7fe608dc0000+0x10000 failed at shared backing lookup (-1000072003) [gpu] dma-buf import of ... is unavailable (shared backing lookup); the range is served by copies [gpu] deferred write-back failed: BDA access failed: ... read-only in the BDA table: stores through ... FLAT/GLOBAL addresses reach only writable ranges imported in place, not ones served by a mirror or a copy AGC graphics: flat store: wave32 byte 0 is 205, expected 0 ``` - `GuestBufferMemory.cpp:459-474` (`createImport`): when dma-buf is the selected kind and the range has no shared backing (`GuestArenaSharedBacking` fails, e.g. anonymous memory, as in these tests), the range is now served by copies, so GPU stores through FLAT/GLOBAL addresses never reach it. On `main` the host-pointer import covers it. This is a regression for every range outside direct memory on dma-buf-selected devices, not only in the tests. Either keep importing those ranges through the host pointer (the probe-selected kind applies to ranges that can be dma-buf-backed), or make the unbacked case a hard failure with a test showing it never happens for ranges the GPU stores to; in both cases the 25 failures above need to pass on a dma-buf-selected device (try `APS5_WRITE_WATCH_IMPORTS` unset on your Arc). - `GuestBufferMemory.cpp:278`: the `/dev/udmabuf` message now says only "DMA-BUF imports will fail", but a missing udmabuf no longer breaks the host-pointer path; keep the hint about the ranges being served by copies/FLAT stores or make it match what actually happens. - Please run the whole `libSceAgcDriver` ctest scope locally, not just the two targets, since this change affects every import.
blawesom commented 2026-10-12 08:12:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T08:12:01Z.


Pre-review found a deterministic regression on Linux/RADV — flagging early since full CI doesn't run automatically on PRs.

Independent pre-review (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV GFX1201):

  • The PR builds and tools/check_conventions.py passes.
  • 25 tests fail deterministically (confirmed in two full-suite runs), the whole flat-memory/storage family:
agc_driver_flat_store, agc_driver_flat_apertures_0..5, agc_driver_constant_store(_full/_none),
agc_driver_global_atomics(64/_float/_lanes), agc_driver_global_atomic_csub, agc_driver_global_store_addtid,
agc_driver_global_vcc_base, agc_driver_masked_global_store, agc_driver_cmask_fast_clear,
agc_driver_bda_span_reads, agc_driver_cross_workgroup_flag, agc_driver_dcc_keys_first_write,
agc_driver_flat_cache_bits, agc_driver_pixel_interlock, agc_driver_storage_one_slice_alias

The shared error mode is visible in the log and it is exactly this PR's subject:

[gpu] dma-buf import of 0x200050000+0x20000 failed at shared backing lookup (-1000072003)
[gpu] dma-buf import of 0x200050000+0x20000 is unavailable (shared backing lookup); the range is served by copies

Negative control: the same tests pass 100% at this branch's own merge base (9a9bd3fb) on the same machine — the regression is introduced by the branch's changes on this setup, not the base.

One data point for interpretation: RADV here exports/imports host-visible memory fine in general, so the failure at shared backing lookup specifically may be a path where the guest allocation wasn't created with an exportable backing at this branch's base. Separately, the branch is ~741 commits behind main and needs a rebase regardless. Reproduce with:

ctest -R agc_driver_flat_store --output-on-failure

Happy to provide the full output or probe further if useful.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120337775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6120337775). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T08:12:01Z. --- **Pre-review found a deterministic regression on Linux/RADV** — flagging early since full CI doesn't run automatically on PRs. Independent pre-review (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV GFX1201): - The PR builds and `tools/check_conventions.py` passes. - **25 tests fail deterministically** (confirmed in two full-suite runs), the whole flat-memory/storage family: ``` agc_driver_flat_store, agc_driver_flat_apertures_0..5, agc_driver_constant_store(_full/_none), agc_driver_global_atomics(64/_float/_lanes), agc_driver_global_atomic_csub, agc_driver_global_store_addtid, agc_driver_global_vcc_base, agc_driver_masked_global_store, agc_driver_cmask_fast_clear, agc_driver_bda_span_reads, agc_driver_cross_workgroup_flag, agc_driver_dcc_keys_first_write, agc_driver_flat_cache_bits, agc_driver_pixel_interlock, agc_driver_storage_one_slice_alias ``` The shared error mode is visible in the log and it is exactly this PR's subject: ``` [gpu] dma-buf import of 0x200050000+0x20000 failed at shared backing lookup (-1000072003) [gpu] dma-buf import of 0x200050000+0x20000 is unavailable (shared backing lookup); the range is served by copies ``` **Negative control:** the same tests pass 100% at this branch's own merge base (`9a9bd3fb`) on the same machine — the regression is introduced by the branch's changes on this setup, not the base. One data point for interpretation: RADV here exports/imports host-visible memory fine in general, so the failure at *shared backing lookup* specifically may be a path where the guest allocation wasn't created with an exportable backing at this branch's base. Separately, the branch is ~741 commits behind `main` and needs a rebase regardless. Reproduce with: ``` ctest -R agc_driver_flat_store --output-on-failure ``` Happy to provide the full output or probe further if useful.
999sian commented 2026-10-12 19:02:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 999sian on 2026-10-12T19:02:26Z.


Addressed the unbacked-range regression in d9af73bcd and rebased onto main at 2a5eca11cd.

  • Import kind is selected per range before an import attempt: probe-selected dma-buf is used only when shared backing exists; anonymous/unbacked ranges use host-pointer import. An attempted dma-buf import failure does not retry another mechanism.
  • Write-watch/stamp behavior follows the actual per-range import kind. Texture tracking and the regression use locked range queries rather than dereferencing an import entry after its lock is released.
  • Corrected the /dev/udmabuf diagnostic and strengthened the shared-backed regression to require an actual dma-buf import.

Validation on Linux/CachyOS x86-64, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON:

cmake --build build --target all --parallel 12
env APS5_WRITE_WATCH_IMPORTS=probe ctest --test-dir build/core/libs/prx/libSceAgcDriver --output-on-failure --no-tests=error --timeout 600

The all-target build succeeded. The complete libSceAgcDriver directory scope ran 448 checks: 445 passed, 3 skipped, 0 failed; 355.11 seconds. Skips: agc_driver_interpolation_f16, agc_driver_oversized_dispatch, agc_driver_shader_clock. This is the full driver scope, not the full repository test suite. The reported flat-memory/storage failures, including flat_store and bda_span_reads, passed.

Standalone flat-store and dma-buf write-watch checks also passed with probe selection enabled; the latter executed rather than skipped. An initial run with a 30-second timeout reported six timeouts. Debugger investigation located the delay in Intel vkCreateComputePipelines after import, and the standalone flat-store check completed in 192.73 seconds. The final full-scope run used a 600-second timeout with no source timeout changes.

No new Windows, RADV, or title/gameplay validation was performed for this revision.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130736232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6130736232). Originally posted by [999sian](https://github.com/999sian) on 2026-10-12T19:02:26Z. --- Addressed the unbacked-range regression in d9af73bcd and rebased onto main at 2a5eca11cd1bf583db39ce67034e8453842ac244. - Import kind is selected per range before an import attempt: probe-selected dma-buf is used only when shared backing exists; anonymous/unbacked ranges use host-pointer import. An attempted dma-buf import failure does not retry another mechanism. - Write-watch/stamp behavior follows the actual per-range import kind. Texture tracking and the regression use locked range queries rather than dereferencing an import entry after its lock is released. - Corrected the /dev/udmabuf diagnostic and strengthened the shared-backed regression to require an actual dma-buf import. Validation on Linux/CachyOS x86-64, Intel Arc MTL, Release/Ninja, BUILD_TESTING=ON: ```sh cmake --build build --target all --parallel 12 env APS5_WRITE_WATCH_IMPORTS=probe ctest --test-dir build/core/libs/prx/libSceAgcDriver --output-on-failure --no-tests=error --timeout 600 ``` The all-target build succeeded. The complete libSceAgcDriver directory scope ran 448 checks: 445 passed, 3 skipped, 0 failed; 355.11 seconds. Skips: agc_driver_interpolation_f16, agc_driver_oversized_dispatch, agc_driver_shader_clock. This is the full driver scope, not the full repository test suite. The reported flat-memory/storage failures, including flat_store and bda_span_reads, passed. Standalone flat-store and dma-buf write-watch checks also passed with probe selection enabled; the latter executed rather than skipped. An initial run with a 30-second timeout reported six timeouts. Debugger investigation located the delay in Intel vkCreateComputePipelines after import, and the standalone flat-store check completed in 192.73 seconds. The final full-scope run used a 600-second timeout with no source timeout changes. No new Windows, RADV, or title/gameplay validation was performed for this revision.
adriadam10 commented 2026-10-13 09:20:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:20:24Z.

Review: DISMISSED


Thanks for the fix and for the work on the earlier points. This still conflicts with main, and the conflict is in logic, not only text:

  • GuestBufferMemory.cpp (4 hunks), GuestBufferMemory.hpp, Texture.cpp and docs/dev/debt/libSceAgcDriver.md conflict. #3874 (compare an import window's pages when the window closes) changed the same stamping code this PR replaces (WatchedImportsStampPages → HostImportStampsPages, Texture.cpp:1973-1976). After rebasing, check that the per-import stampsPages still matches what #3874 decides, and rerun agc_driver_host_import_dma_buf_watch plus the whole libSceAgcDriver ctest scope on the rebased tree.
  • GuestBufferMemory.cpp:146-148: the ImportFailure members lost their indentation (whitespace-only change); please restore it.
  • Texture.cpp:1973-1976: the comment and indentation of the lines around the else captureGuestBytes changed without a functional reason; keep that hunk minimal.
  • GuestBufferMemory.cpp:185-187: selectedImportKind only returns state.importKind; use the member directly.
  • blawesom's RADV (RX 9070 XT) run found 25 failing tests on an earlier head; you report them fixed in d9af73bcd. Please post the full-scope result on the rebased head, or ask them to rerun.

We could not build this head locally (build infrastructure failure on our side), so none of the above comes from a test run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5501393212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#pullrequestreview-5501393212). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T09:20:24Z. **Review:** DISMISSED --- Thanks for the fix and for the work on the earlier points. This still conflicts with `main`, and the conflict is in logic, not only text: - `GuestBufferMemory.cpp` (4 hunks), `GuestBufferMemory.hpp`, `Texture.cpp` and `docs/dev/debt/libSceAgcDriver.md` conflict. #3874 (compare an import window's pages when the window closes) changed the same stamping code this PR replaces (`WatchedImportsStampPages` → `HostImportStampsPages`, `Texture.cpp:1973-1976`). After rebasing, check that the per-import `stampsPages` still matches what #3874 decides, and rerun `agc_driver_host_import_dma_buf_watch` plus the whole `libSceAgcDriver` ctest scope on the rebased tree. - `GuestBufferMemory.cpp:146-148`: the `ImportFailure` members lost their indentation (whitespace-only change); please restore it. - `Texture.cpp:1973-1976`: the comment and indentation of the lines around the `else captureGuestBytes` changed without a functional reason; keep that hunk minimal. - `GuestBufferMemory.cpp:185-187`: `selectedImportKind` only returns `state.importKind`; use the member directly. - blawesom's RADV (RX 9070 XT) run found 25 failing tests on an earlier head; you report them fixed in d9af73bcd. Please post the full-scope result on the rebased head, or ask them to rerun. We could not build this head locally (build infrastructure failure on our side), so none of the above comes from a test run.
999sian commented 2026-10-13 20:59:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 999sian on 2026-10-13T20:59:11Z.


Rebased onto main at a0f5916a2 as a single commit, 7bbaaf7cf. With #3874 the conflict was in logic, so I rebuilt the change against main instead of carrying the old hunks forward.

  • #3874 / stamping: #3874 removed WatchedImportsStampPages, the importsStampPages/dmaBufImportsStampPages state and the Texture.cpp branch that used them; window-close comparison now lives in GuestMemory. The per-import stampsPages, HostImportStampsPages and the Texture.cpp hunk from this PR therefore had nothing left to reconcile and are dropped. Texture.cpp is no longer touched.
  • Selection: HostImports has a dmaBufSelected member, set in decideImportWatch when host imports drop write tracking and dma-buf imports keep it, and cleared by SetImportWatch. In importRunAt, a range with a shared backing is imported through createBackingImport only (inside ImportWatched(..., watchedDmaBuf)). A failure throws DmaBufImportFailure, which ImportMappedRanges rethrows. Every other range keeps main's existing path unchanged, so anonymous/unbacked ranges still get host-pointer imports and FLAT/GLOBAL stores reach them.
  • Nits: ImportFailure is untouched (main's indentation); selectedImportKind is gone and the member is used directly. Main's /dev/udmabuf message is accurate as is (dma-buf is only selected after a successful dma-buf probe), so that hunk is dropped too.

Validation on Linux/CachyOS x86-64, Intel Arc MTL (Mesa ANV), Release/Ninja, BUILD_TESTING=ON, on head 7bbaaf7cf:

cmake --build build --target all --parallel 12
python3 tools/check_conventions.py
env APS5_WRITE_WATCH_IMPORTS=probe ./build/tests/agc_driver_host_import_dma_buf_watch_tests
env APS5_WRITE_WATCH_IMPORTS=probe ctest --test-dir build/core/libs/prx/libSceAgcDriver --output-on-failure --no-tests=error --timeout 600
  • All-target build succeeded; conventions checks passed.
  • agc_driver_host_import_dma_buf_watch passed and executed (not skipped):
[write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared
[write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched
dma-buf import keeps write tracking tests passed
  • Full libSceAgcDriver directory scope: 492 tests, 489 passed, 3 skipped, 0 failed, 982.97 s. The 3 skips are agc_driver_interpolation_f16, agc_driver_oversized_dispatch and agc_driver_shader_clock. The --timeout 600 is for Intel shader-pipeline compile time (flat_store took ~190 s earlier); no source timeouts were changed.

This is not a RADV run. @blawesom, could you rerun the full scope on your RX 9070 XT against 7bbaaf7cf? No Windows or gameplay validation for this revision.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6155079356 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6155079356). Originally posted by [999sian](https://github.com/999sian) on 2026-10-13T20:59:11Z. --- Rebased onto main at a0f5916a2 as a single commit, 7bbaaf7cf. With #3874 the conflict was in logic, so I rebuilt the change against main instead of carrying the old hunks forward. - **#3874 / stamping:** #3874 removed `WatchedImportsStampPages`, the `importsStampPages`/`dmaBufImportsStampPages` state and the `Texture.cpp` branch that used them; window-close comparison now lives in `GuestMemory`. The per-import `stampsPages`, `HostImportStampsPages` and the `Texture.cpp` hunk from this PR therefore had nothing left to reconcile and are dropped. `Texture.cpp` is no longer touched. - **Selection:** `HostImports` has a `dmaBufSelected` member, set in `decideImportWatch` when host imports drop write tracking and dma-buf imports keep it, and cleared by `SetImportWatch`. In `importRunAt`, a range with a shared backing is imported through `createBackingImport` only (inside `ImportWatched(..., watchedDmaBuf)`). A failure throws `DmaBufImportFailure`, which `ImportMappedRanges` rethrows. Every other range keeps main's existing path unchanged, so anonymous/unbacked ranges still get host-pointer imports and FLAT/GLOBAL stores reach them. - **Nits:** `ImportFailure` is untouched (main's indentation); `selectedImportKind` is gone and the member is used directly. Main's `/dev/udmabuf` message is accurate as is (dma-buf is only selected after a successful dma-buf probe), so that hunk is dropped too. Validation on Linux/CachyOS x86-64, Intel Arc MTL (Mesa ANV), Release/Ninja, BUILD_TESTING=ON, on head 7bbaaf7cf: ```sh cmake --build build --target all --parallel 12 python3 tools/check_conventions.py env APS5_WRITE_WATCH_IMPORTS=probe ./build/tests/agc_driver_host_import_dma_buf_watch_tests env APS5_WRITE_WATCH_IMPORTS=probe ctest --test-dir build/core/libs/prx/libSceAgcDriver --output-on-failure --no-tests=error --timeout 600 ``` - All-target build succeeded; conventions checks passed. - `agc_driver_host_import_dma_buf_watch` passed and executed (not skipped): ```text [write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import); imported ranges are compared [write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched dma-buf import keeps write tracking tests passed ``` - Full `libSceAgcDriver` directory scope: **492 tests, 489 passed, 3 skipped, 0 failed**, 982.97 s. The 3 skips are `agc_driver_interpolation_f16`, `agc_driver_oversized_dispatch` and `agc_driver_shader_clock`. The `--timeout 600` is for Intel shader-pipeline compile time (flat_store took ~190 s earlier); no source timeouts were changed. This is not a RADV run. @blawesom, could you rerun the full scope on your RX 9070 XT against 7bbaaf7cf? No Windows or gameplay validation for this revision.
oneandonlydean commented 2026-10-14 05:20:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:20:05Z.


This conflicts with main again after #290 (host import windows with least-recent eviction): HostImports and the importAllocation call in the bind path changed in GuestBufferMemory.cpp. Please rebase, and check that a range #290 evicts and imports again keeps its dma-buf kind. Then rerun agc_driver_host_import_dma_buf_watch and the flat/global store tests on a device whose probe picks dma-buf.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161503041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6161503041). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:20:05Z. --- This conflicts with `main` again after #290 (host import windows with least-recent eviction): `HostImports` and the `importAllocation` call in the bind path changed in `GuestBufferMemory.cpp`. Please rebase, and check that a range #290 evicts and imports again keeps its dma-buf kind. Then rerun `agc_driver_host_import_dma_buf_watch` and the flat/global store tests on a device whose probe picks dma-buf.
oneandonlydean commented 2026-10-14 21:33:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:33:07Z.


Thanks for the rebase onto #290. The rest of the 10-14 ask is still open: please confirm a range #290 evicts and imports again comes back as dma-buf, and post the agc_driver_host_import_dma_buf_watch and flat/global store test results on a device whose probe picks dma-buf.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178978716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6178978716). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T21:33:07Z. --- Thanks for the rebase onto #290. The rest of the 10-14 ask is still open: please confirm a range #290 evicts and imports again comes back as dma-buf, and post the `agc_driver_host_import_dma_buf_watch` and flat/global store test results on a device whose probe picks dma-buf.
blawesom commented 2026-10-16 17:09:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T17:09:24Z.


Rebase + the requested dma-buf checks — rebased onto current main (143f13055), authorship unchanged; the head moved to 554b9a42e since your branch was based on older main.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV) — a device whose probe does pick dma-buf (host imports resolve write protection here, dma-buf imports keep it; the agc_driver_host_import_dma_buf_watch run confirms the selection rather than skipping):

  • agc_driver_host_import_dma_buf_watch — passed (ran, not skipped): the fill reached mapped memory through the dma-buf import and write tracking was kept
  • agc_driver_flat_store, agc_driver_global_store_addtid, agc_driver_masked_global_store — all passed
  • full suite: 1287/1288 — the only failure is the known main regression (agc_driver_tessellation segfault, #4727); conventions pass

On evict-and-reimport keeping the dma-buf kind: the selection is device-level state, not per-import — decideImportWatch sets dmaBufSelected once from the probe, and every importAllocation (including one that re-imports a range #290's LRU just evicted) consults that same state through dmaBufOnly = state.dmaBufSelected && sharedBacking(...). So an evicted range comes back as dma-buf by construction, and the #290 eviction cycles exercised by agc_driver_host_import_windows (passing here, with dma-buf active on this device) re-import successfully under that selection. If you want it pinned explicitly, a small test asserting HostImportUsesDmaBuf after an over-budget eviction would close it directly.

To pick up the rebase:

git fetch https://github.com/blawesom/AnyPS5 rebase/2434
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 554b9a42e.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6220710391 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6220710391). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-16T17:09:24Z. --- **Rebase + the requested dma-buf checks** — rebased onto current `main` (`143f13055`), authorship unchanged; the head moved to `554b9a42e` since your branch was based on older `main`. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV) — a device whose probe **does** pick dma-buf (host imports resolve write protection here, dma-buf imports keep it; the `agc_driver_host_import_dma_buf_watch` run confirms the selection rather than skipping): - `agc_driver_host_import_dma_buf_watch` — **passed** (ran, not skipped): the fill reached mapped memory through the dma-buf import and write tracking was kept - `agc_driver_flat_store`, `agc_driver_global_store_addtid`, `agc_driver_masked_global_store` — **all passed** - full suite: **1287/1288** — the only failure is the known `main` regression (`agc_driver_tessellation` segfault, #4727); conventions pass **On evict-and-reimport keeping the dma-buf kind:** the selection is device-level state, not per-import — `decideImportWatch` sets `dmaBufSelected` once from the probe, and every `importAllocation` (including one that re-imports a range #290's LRU just evicted) consults that same state through `dmaBufOnly = state.dmaBufSelected && sharedBacking(...)`. So an evicted range comes back as dma-buf by construction, and the #290 eviction cycles exercised by `agc_driver_host_import_windows` (passing here, with dma-buf active on this device) re-import successfully under that selection. If you want it pinned explicitly, a small test asserting `HostImportUsesDmaBuf` after an over-budget eviction would close it directly. **To pick up the rebase:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/2434 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `554b9a42e`.
oneandonlydean commented 2026-10-19 09:52:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T09:52:16Z.


@999sian We merged current main into this branch for you (2b806712b6; your changes are patch-identical, and the conflicts were only adjacent added functions). It's mergeable again, and full CI is running.

We reviewed it on the merged tree, and the mechanism reads right: dma-buf only on Linux devices where the probe shows host imports lose tracking and dma-buf keeps it, only for shared-backed ranges, and evicted ranges come back as dma-buf because importRunAt recomputes it each time. adriadam10's 13 Oct points look addressed to us. Three things left, two small:

  1. Since the merge, main's settle step for dma-buf imports of 1 MiB and up takes the "falling back to copies" branch when it fails. For ranges this PR selects for dma-buf, it should throw instead, like the rest of the dma-buf path.
  2. HostImportUsesDmaBuf calls findImport(state, address, address + bytes) without the hostImportAlignment/importsStale guards, and findImport bumps the LRU. Could it mirror main's new ExistingHostImportFor and use peekImport?
  3. The one we can't do ourselves: our hardware never selects dma-buf (NVIDIA imports none, and the new test skips there and on llvmpipe), so CI can't exercise this path. Could you, or @blawesom on RADV, run the merged head on a device that selects dma-buf and post the [write-watch] lines, the new test passing (not skipped), the flat/global family and the full driver test scope?

Thanks!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264469778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6264469778). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T09:52:16Z. --- @999sian We merged current `main` into this branch for you (2b806712b6; your changes are patch-identical, and the conflicts were only adjacent added functions). It's mergeable again, and full CI is running. We reviewed it on the merged tree, and the mechanism reads right: dma-buf only on Linux devices where the probe shows host imports lose tracking and dma-buf keeps it, only for shared-backed ranges, and evicted ranges come back as dma-buf because `importRunAt` recomputes it each time. adriadam10's 13 Oct points look addressed to us. Three things left, two small: 1. Since the merge, `main`'s settle step for dma-buf imports of 1 MiB and up takes the "falling back to copies" branch when it fails. For ranges this PR selects for dma-buf, it should throw instead, like the rest of the dma-buf path. 2. `HostImportUsesDmaBuf` calls `findImport(state, address, address + bytes)` without the `hostImportAlignment`/`importsStale` guards, and `findImport` bumps the LRU. Could it mirror `main`'s new `ExistingHostImportFor` and use `peekImport`? 3. The one we can't do ourselves: our hardware never selects dma-buf (NVIDIA imports none, and the new test skips there and on llvmpipe), so CI can't exercise this path. Could you, or @blawesom on RADV, run the merged head on a device that selects dma-buf and post the `[write-watch]` lines, the new test passing (not skipped), the flat/global family and the full driver test scope? Thanks!
oneandonlydean commented 2026-10-19 10:21:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T10:21:59Z.


@999sian One more, from the full CI run on 2b806712b6: the only failure is Linux check_skips ("agc_driver_host_import_dma_buf_watch skipped"). On lavapipe the new test prints skipped, the probe did not select dma-buf as this device's import kind, and tools/check_skips.py only accepts device-limitation skips that match its pattern (for example "the device does not ..." or "the device imports no ..."). Rewording that line to something like skipped, the device does not select dma-buf for host imports should make it pass. The test itself is fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6265001696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6265001696). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T10:21:59Z. --- @999sian One more, from the full CI run on 2b806712b6: the only failure is Linux `check_skips` ("agc_driver_host_import_dma_buf_watch skipped"). On lavapipe the new test prints `skipped, the probe did not select dma-buf as this device's import kind`, and `tools/check_skips.py` only accepts device-limitation skips that match its pattern (for example "the device does not ..." or "the device imports no ..."). Rewording that line to something like `skipped, the device does not select dma-buf for host imports` should make it pass. The test itself is fine.
simonbbby commented 2026-10-19 10:31:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-19T10:31:57Z.


@oneandonlydean Native RADV result for the hardware part of your request, on the exact merged head 2b806712b64d63fe619a2aa888d49d8fb8ef3d11.

Ubuntu 24.04, Ryzen 9 9950X iGPU (1002:13c0, gfx1036 / RADV RAPHAEL_MENDOCINO), Mesa 25.2.8, GCC 13.3, Release, BUILD_TESTING=ON. NVIDIA was excluded with VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.json. All execution fixtures were enabled (ANYPS5_AGC_EXECUTION_TESTS empty) and built, including the separately registered converted lifetime fixture and relinker.

The new test executes and passes, rather than skipping. Probe output:

[write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 4 after the import); imported ranges are compared
[write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched
dma-buf import keeps write tracking tests passed

Results on this head:

  • agc_driver_host_import_dma_buf_watch: passes in the full scope and 3/3 fresh processes after restoring the control below. GPU fill reaches the mapped direct-memory block, HostImportUsesDmaBuf is true, and the block remains watched.
  • All 34 flat/global tests pass, with no skips in that family, including flat_store, the aperture cases, global atomics, global_store_addtid and masked_global_store.
  • Whole libSceAgcDriver CTest scope: 785 passed, 6 skipped, 3 failed out of 794, -j4, 21.58 s. Normal cache/journal settings, plus ANYPS5_REQUIRE_VULKAN=1; individual tests retain their registered environments.
  • The three failures are agc_pipeline_cache_file (the cache file lost a pipeline), agc_driver_image_table_vouched_lookups (#7766, zero vouch counters), and agc_driver_guest_memory_lifetime (#7784, CS rejected with -14 then guest prefix unmap failed). I checked out and rebuilt the exact merged-main parent 83bf557dcfe760042fe472151626ee7852f2282b and reran those three: all fail there with the same messages. This was a focused parent comparison, not a full parent-scope run.

The six skips were agc_unit_shadow, agc_shadowed_key_stores, agc_driver_unit_shadow, agc_driver_unit_shadow_budget, agc_driver_native_depth_bda_clear, and agc_driver_ngg_vertex_wave_reduction. The dma-buf test is not among them.

Local negative control: inside the selected dma-buf branch, replace only createBackingImport(...selected...) with createHostPointerImport(...), leaving the probe selection intact. The new test fails at vkAllocateMemory (-13), rather than skipping or reporting a pass. Restoring the exact source and rebuilding restores 3/3 passes. The clean PR executable and runtime libraries were also frozen separately; a fresh run of that frozen runtime still passes after the main-parent comparison.

No experimental source changes remain. This supplies the native selection/flat-global/full-scope evidence; it does not resolve the settle-failure policy, accessor guards/LRU, or the newer lavapipe skip-message review requests. No injected settle-failure, Windows, macOS, title, validation-layer or performance result is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6265176033 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6265176033). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-19T10:31:57Z. --- @oneandonlydean Native RADV result for the hardware part of your request, on the exact merged head `2b806712b64d63fe619a2aa888d49d8fb8ef3d11`. Ubuntu 24.04, Ryzen 9 9950X iGPU (`1002:13c0`, gfx1036 / RADV RAPHAEL_MENDOCINO), Mesa 25.2.8, GCC 13.3, Release, `BUILD_TESTING=ON`. NVIDIA was excluded with `VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.json`. All execution fixtures were enabled (`ANYPS5_AGC_EXECUTION_TESTS` empty) and built, including the separately registered converted lifetime fixture and relinker. The new test **executes and passes, rather than skipping**. Probe output: ```text [write-watch] host imports resolve write protection: yes (4 of 4 scratch pages written after a GPU read, 4 after a GPU write, 4 after the import); imported ranges are compared [write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import, 1 seen after a CPU store); imported ranges stay watched dma-buf import keeps write tracking tests passed ``` Results on this head: - `agc_driver_host_import_dma_buf_watch`: passes in the full scope and **3/3 fresh processes** after restoring the control below. GPU fill reaches the mapped direct-memory block, `HostImportUsesDmaBuf` is true, and the block remains watched. - **All 34 flat/global tests pass**, with no skips in that family, including `flat_store`, the aperture cases, global atomics, `global_store_addtid` and `masked_global_store`. - **Whole `libSceAgcDriver` CTest scope: 785 passed, 6 skipped, 3 failed out of 794**, `-j4`, 21.58 s. Normal cache/journal settings, plus `ANYPS5_REQUIRE_VULKAN=1`; individual tests retain their registered environments. - The three failures are `agc_pipeline_cache_file` (`the cache file lost a pipeline`), `agc_driver_image_table_vouched_lookups` (#7766, zero vouch counters), and `agc_driver_guest_memory_lifetime` (#7784, CS rejected with -14 then `guest prefix unmap failed`). I checked out and rebuilt the exact merged-main parent `83bf557dcfe760042fe472151626ee7852f2282b` and reran those three: **all fail there with the same messages**. This was a focused parent comparison, not a full parent-scope run. The six skips were `agc_unit_shadow`, `agc_shadowed_key_stores`, `agc_driver_unit_shadow`, `agc_driver_unit_shadow_budget`, `agc_driver_native_depth_bda_clear`, and `agc_driver_ngg_vertex_wave_reduction`. The dma-buf test is not among them. Local negative control: inside the selected dma-buf branch, replace only `createBackingImport(...selected...)` with `createHostPointerImport(...)`, leaving the probe selection intact. The new test fails at `vkAllocateMemory` (-13), rather than skipping or reporting a pass. Restoring the exact source and rebuilding restores 3/3 passes. The clean PR executable and runtime libraries were also frozen separately; a fresh run of that frozen runtime still passes after the main-parent comparison. No experimental source changes remain. This supplies the native selection/flat-global/full-scope evidence; it does not resolve the settle-failure policy, accessor guards/LRU, or the newer lavapipe skip-message review requests. No injected settle-failure, Windows, macOS, title, validation-layer or performance result is claimed.
oneandonlydean commented 2026-10-20 04:01:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T04:01:00Z.


@simonbbby thank you, that's exactly the evidence we couldn't produce: the probe selects dma-buf, the new test runs and passes 3/3, the flat/global family is clean, and your negative control (host-pointer import inside the selected branch → vkAllocateMemory -13) shows the test fails for the right reason. The three failures reproducing on 83bf557dcfe puts them outside this PR.

@999sian what's left is on the code side:

  1. Conflict with current main. main has changed GuestBufferMemory.hpp/.cpp again since our merge (HostImportFor now takes an ImportRequester, and the requester block in AcquireRegistered was rewritten). This PR wraps that block for DmaBufImportFailure, so it needs your resolution, not a mechanical one.
  2. Settle failure (from our 19 Oct comment): for ranges this PR selects for dma-buf, a failed settle should throw DmaBufImportFailure rather than take main's "falling back to copies" branch.
  3. HostImportUsesDmaBuf: add the hostImportAlignment/importsStale guards that ExistingHostImportFor has, and use peekImport so the query doesn't bump the LRU.
  4. Skip text: skipped, the probe did not select dma-buf as this device's import kind fails Linux check_skips. skipped, the device does not select dma-buf for host imports matches its pattern.

Since 1 and 2 touch the import path, once they're pushed we'd ask for one short re-run on the new head on a dma-buf device: agc_driver_host_import_dma_buf_watch passing (not skipped) plus the flat/global family. @simonbbby if you can repeat it then, that would close it out.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283064145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2434#issuecomment-6283064145). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T04:01:00Z. --- @simonbbby thank you, that's exactly the evidence we couldn't produce: the probe selects dma-buf, the new test runs and passes 3/3, the flat/global family is clean, and your negative control (host-pointer import inside the selected branch → `vkAllocateMemory` -13) shows the test fails for the right reason. The three failures reproducing on `83bf557dcfe` puts them outside this PR. @999sian what's left is on the code side: 1. **Conflict with current `main`.** `main` has changed `GuestBufferMemory.hpp/.cpp` again since our merge (`HostImportFor` now takes an `ImportRequester`, and the requester block in `AcquireRegistered` was rewritten). This PR wraps that block for `DmaBufImportFailure`, so it needs your resolution, not a mechanical one. 2. **Settle failure** (from our 19 Oct comment): for ranges this PR selects for dma-buf, a failed settle should throw `DmaBufImportFailure` rather than take `main`'s "falling back to copies" branch. 3. **`HostImportUsesDmaBuf`**: add the `hostImportAlignment`/`importsStale` guards that `ExistingHostImportFor` has, and use `peekImport` so the query doesn't bump the LRU. 4. **Skip text**: `skipped, the probe did not select dma-buf as this device's import kind` fails Linux `check_skips`. `skipped, the device does not select dma-buf for host imports` matches its pattern. Since 1 and 2 touch the import path, once they're pushed we'd ask for one short re-run on the new head on a dma-buf device: `agc_driver_host_import_dma_buf_watch` passing (not skipped) plus the flat/global family. @simonbbby if you can repeat it then, that would close it out.
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
boykopovar/AnyPS5!2434
No description provided.