fix(agc): import a span's ranges one at a time when Windows refuses its alias #3324

Merged
reyani-dev merged 1 commit from upstream-pr/3324 into main 2026-10-11 08:01:21 +00:00
reyani-dev commented 2026-10-11 07:40:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T07:40:02Z.


What

Carries @Silverash-i8's fix from #3320 (the author is under the intake threshold). The commit is theirs, unchanged (aa653ec5), and merges cleanly onto current main.

Since #3158, an import covers the whole run of address-adjacent registered ranges. On Windows, a shared mapping in that run needs a read-write alias, and WindowsMappings::MapAlias refuses one unless the range is a single contiguous run of views of one section. Ranges that are adjacent in guest address can still be separate views, so the span's alias is refused and the exception escapes importAllocation. As a result, agc_driver_dcc_keys_first_write fails on main on Windows:

read-write alias of shared guest memory 0x200000000+0x40000: the range is not one contiguous run of views of a section

When the alias of a multi-range span is refused, the span's base is recorded in HostImports::unaliasedSpans and importRun returns just the containing range for that span from then on, so the import, runCovers and the refresh check agree. A refused alias for a single range still throws as before. Spans that alias fine, and all of Linux, are unchanged. A buffer that crosses two ranges of a refused span is copied as it was before #3158, which the host-import entry in TechnicalDebt now says.

Closes #3320. cc @XairRrR (#3158)

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, NVIDIA RTX 4070 Laptop GPU (driver 616.92), the commit merged onto main b6f649d9, with VK_LOADER_DRIVERS_DISABLE=*dzn* (#3255). This is a second machine next to the author's RTX 5060 run in #3320:

  • On main, agc_driver_dcc_keys_first_write fails with the message above.
  • With this change it passes 3/3, as do agc_driver_graphics (including #3158's importCrossingTests / importSpanTests), agc_driver_bda_device and agc_driver_bda_span_reads.
  • ctest -R "^agc_|video_out|^shader|recompiler": 366/366.
  • check_conventions.py passes, and pr_overlap.py reports no overlap.

Not run on Linux; the change only takes effect when Windows refuses an alias.

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
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4817465129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3324). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T07:40:02Z. --- ### What Carries @Silverash-i8's fix from #3320 (the author is under the intake threshold). The commit is theirs, unchanged (`aa653ec5`), and merges cleanly onto current `main`. Since #3158, an import covers the whole run of address-adjacent registered ranges. On Windows, a shared mapping in that run needs a read-write alias, and `WindowsMappings::MapAlias` refuses one unless the range is a single contiguous run of views of one section. Ranges that are adjacent in guest address can still be separate views, so the span's alias is refused and the exception escapes `importAllocation`. As a result, `agc_driver_dcc_keys_first_write` fails on `main` on Windows: ``` read-write alias of shared guest memory 0x200000000+0x40000: the range is not one contiguous run of views of a section ``` When the alias of a multi-range span is refused, the span's base is recorded in `HostImports::unaliasedSpans` and `importRun` returns just the containing range for that span from then on, so the import, `runCovers` and the refresh check agree. A refused alias for a single range still throws as before. Spans that alias fine, and all of Linux, are unchanged. A buffer that crosses two ranges of a refused span is copied as it was before #3158, which the host-import entry in TechnicalDebt now says. Closes #3320. cc @XairRrR (#3158) ### Tested Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release, NVIDIA RTX 4070 Laptop GPU (driver 616.92), the commit merged onto `main` `b6f649d9`, with `VK_LOADER_DRIVERS_DISABLE=*dzn*` (#3255). This is a second machine next to the author's RTX 5060 run in #3320: - On `main`, `agc_driver_dcc_keys_first_write` fails with the message above. - With this change it passes 3/3, as do `agc_driver_graphics` (including #3158's `importCrossingTests` / `importSpanTests`), `agc_driver_bda_device` and `agc_driver_bda_span_reads`. - `ctest -R "^agc_|video_out|^shader|recompiler"`: 366/366. - `check_conventions.py` passes, and `pr_overlap.py` reports no overlap. Not run on Linux; the change only takes effect when Windows refuses an alias. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Mouhand-Kaddo commented 2026-10-11 07:51:27 +00:00 (Migrated from github.com)

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


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

Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release, BUILD_TESTING=ON.

4 checks, 0 failures, 0 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_bda_device, agc_driver_bda_span_reads, agc_driver_dcc_keys_first_write.

Command after building: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(graphics|dcc_keys_first_write|bda_device|bda_span_reads)$".

Vulkan: Mesa lavapipe 26.2.4 / LLVM 23.1.1 software Vulkan; no native Linux hardware-GPU result.

Internal limitation: heap-mirror subcases returned early because the guest arena was not write-watched in WSL. Zero CTest skips does not include that early return.

These Linux checks cover the portable graphics/import path. The Windows alias-refusal fallback itself is platform-specific and was not exercised by this Linux run; the PR already reports Windows coverage.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106853830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3324#issuecomment-6106853830). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-11T07:51:27Z. --- <!-- anyps5-platform-validation:aa653ec50e6b516fef73d428e3c358e59d634b66 --> Additional platform validation of standalone PR head `aa653ec50e6b516fef73d428e3c358e59d634b66` (2026-10-11): **Linux: passed** — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release, `BUILD_TESTING=ON`. 4 checks, 0 failures, 0 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_bda_device`, `agc_driver_bda_span_reads`, `agc_driver_dcc_keys_first_write`. Command after building: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(graphics|dcc_keys_first_write|bda_device|bda_span_reads)$"`. Vulkan: Mesa lavapipe 26.2.4 / LLVM 23.1.1 software Vulkan; no native Linux hardware-GPU result. Internal limitation: heap-mirror subcases returned early because the guest arena was not write-watched in WSL. Zero CTest skips does not include that early return. These Linux checks cover the portable graphics/import path. The Windows alias-refusal fallback itself is platform-specific and was not exercised by this Linux run; the PR already reports Windows coverage. No title/gameplay validation. These results cover the standalone head, not a merge with current main.
adriadam10 commented 2026-10-11 08:01:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:01:18Z.


Checked on Linux: PR merged onto current main, libSceAgcDriver build and ctest green (the Windows-only path is not reachable there). Code reviewed: the retry after recording the span's base terminates because importRun then returns the single containing range, a single-range refusal still throws, and the TechnicalDebt entry matches the behaviour. Windows results from @AchrafReyani (RTX 4070) and @Silverash-i8 (RTX 5060) show agc_driver_dcc_keys_first_write failing on main and passing with this change; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106926606 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3324#issuecomment-6106926606). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:01:18Z. --- Checked on Linux: PR merged onto current main, libSceAgcDriver build and ctest green (the Windows-only path is not reachable there). Code reviewed: the retry after recording the span's base terminates because `importRun` then returns the single containing range, a single-range refusal still throws, and the TechnicalDebt entry matches the behaviour. Windows results from @AchrafReyani (RTX 4070) and @Silverash-i8 (RTX 5060) show `agc_driver_dcc_keys_first_write` failing on main and passing with this change; merging.
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!3324
No description provided.