kernelx: preserve null scatter unmaps with physical aliases #3074

Open
ZekkJJ wants to merge 6 commits from upstream-pr/3074 into main
ZekkJJ commented 2026-11-27 21:36:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ZekkJJ on 2026-11-27T21:36:28Z.


Stacked on #2307, which carries #2293 and #2294 by @adiologydev. Review the final commit, 785d7dc5533edc8577c9a8e8e221acd40d980d23, against the clean integration parent 3878609d850826fa51813477ffa7482081fb2383. The prerequisite commits are the original upstream commits. Focused diff

On main, #495 by @notdxbi treats a null XMemMapPhysicalPagesScatter array as an unmap for each address. Integrating #2307 onto current main preserves the legacy branch's null handling, but the section-backed branch still advances the null pointer. Starting at the second entry, map_aliased tries to read a page number at address 0x8. An archived retail crash with matching PDBs resolves to map_aliased <- XMemMapPhysicalPagesScatter.

What is in it

  • Pass the null page array through unchanged in the alias branch. The existing map_aliased path already interprets it as an unmap.
  • Exercise two null scatter entries, shared contents through surviving aliases, remapping in reverse order, and final page-ID release.

Tested

  • Windows 11 build 26200, Ryzen 7 8845HS, 16 GiB RAM, NVIDIA RTX 4060 Laptop GPU 8 GiB, driver 32.0.16.1656, Rust 1.98.1 MSVC.

  • On 785d7dc5533edc8577c9a8e8e221acd40d980d23 with XCL_PAGE_ALIAS=1, the focused filters for kernelx alias, sections and guards, DirectStorage physical pages, and concurrent-decommit texture reads gave 23 passed, 0 failed, 0 ignored, 0 capability skips.

  • The existing byte-exact GPU mirror upload fixture passed in conventional mode. Alias mode fails its write-watch setup assertion before readback, matching the prior Windows report on the prerequisite. Prerequisite test report

  • After building the test-title fixtures with cargo build --workspace, cargo test --workspace --no-fail-fast -- --test-threads=4 exited 0. The harness reported 1,486 pass statuses, 0 failures, and 47 ignored. It emitted 27 explicit skip notices separately (21 missing wave64, 3 unsupported per-lane forms, 1 Developer Mode requirement, 1 missing heap-window capability, and 1 default-mode skip of the new opt-in test, which passed separately).
    Regression run

The clean release builds are main 6089122a1c96dff16e93b6fdf04c8ed20cfb6102 and candidate 785d7dc5533edc8577c9a8e8e221acd40d980d23. No fresh smoke block was generated. The clean Series S preflight expired at 3205 MiB free RAM and 13200 MiB free commit. The guarded runner requires 6,600 MiB RAM and 18,000 MiB free commit at startup. The last idle check still showed 4129 MiB RAM and 13941 MiB free commit. Series X was deferred.

Historical evidence from a different integration, using the same executable in both Series S modes, reached 4,200 DirectStorage requests and 262 MiB with zero storage errors in both. System commit growth was 9,426 MiB in conventional mode and 1,985 MiB with section aliasing, a difference of 7,441 MiB. Both runs later crashed. The conventional crash was a texture read during concurrent decommit. The alias crash was the null scatter path covered here. This historical measurement belongs to the alias architecture and accompanying integration.

Not tested

  • Alias-mode GPU readback remains blocked at fixture setup. World entry and sustained gameplay remain unverified.
  • AMD and Intel GPUs, or Wine.

AI use

Codex (GPT-6 family, exact runtime variant unavailable) recovered and compared the patches, wrote the follow-up and regression test, ran local validation, and drafted this description.

<!-- greyfinch-sync:ivall/xcl:issue:5533386528 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074). Originally posted by [ZekkJJ](https://github.com/ZekkJJ) on 2026-11-27T21:36:28Z. --- Stacked on #2307, which carries #2293 and #2294 by @adiologydev. Review the final commit, `785d7dc5533edc8577c9a8e8e221acd40d980d23`, against the clean integration parent `3878609d850826fa51813477ffa7482081fb2383`. The prerequisite commits are the original upstream commits. [Focused diff](https://github.com/ZekkJJ/xcl/compare/3878609d850826fa51813477ffa7482081fb2383...785d7dc5533edc8577c9a8e8e221acd40d980d23) On `main`, #495 by @notdxbi treats a null `XMemMapPhysicalPagesScatter` array as an unmap for each address. Integrating #2307 onto current main preserves the legacy branch's null handling, but the section-backed branch still advances the null pointer. Starting at the second entry, `map_aliased` tries to read a page number at address `0x8`. An archived retail crash with matching PDBs resolves to `map_aliased <- XMemMapPhysicalPagesScatter`. **What is in it** - Pass the null page array through unchanged in the alias branch. The existing `map_aliased` path already interprets it as an unmap. - Exercise two null scatter entries, shared contents through surviving aliases, remapping in reverse order, and final page-ID release. **Tested** - Windows 11 build 26200, Ryzen 7 8845HS, 16 GiB RAM, NVIDIA RTX 4060 Laptop GPU 8 GiB, driver `32.0.16.1656`, Rust `1.98.1` MSVC. - On `785d7dc5533edc8577c9a8e8e221acd40d980d23` with `XCL_PAGE_ALIAS=1`, the focused filters for kernelx alias, sections and guards, DirectStorage physical pages, and concurrent-decommit texture reads gave 23 passed, 0 failed, 0 ignored, 0 capability skips. - The existing byte-exact GPU mirror upload fixture passed in conventional mode. Alias mode fails its write-watch setup assertion before readback, matching the prior Windows report on the prerequisite. [Prerequisite test report](https://github.com/xcl-dev/xcl/pull/2307#issuecomment-7165808335) - After building the test-title fixtures with `cargo build --workspace`, `cargo test --workspace --no-fail-fast -- --test-threads=4` exited 0. The harness reported 1,486 pass statuses, 0 failures, and 47 ignored. It emitted 27 explicit skip notices separately (21 missing wave64, 3 unsupported per-lane forms, 1 Developer Mode requirement, 1 missing heap-window capability, and 1 default-mode skip of the new opt-in test, which passed separately). **Regression run** The clean release builds are main `6089122a1c96dff16e93b6fdf04c8ed20cfb6102` and candidate `785d7dc5533edc8577c9a8e8e221acd40d980d23`. No fresh smoke block was generated. The clean Series S preflight expired at 3205 MiB free RAM and 13200 MiB free commit. The guarded runner requires 6,600 MiB RAM and 18,000 MiB free commit at startup. The last idle check still showed 4129 MiB RAM and 13941 MiB free commit. Series X was deferred. Historical evidence from a different integration, using the same executable in both Series S modes, reached 4,200 DirectStorage requests and 262 MiB with zero storage errors in both. System commit growth was 9,426 MiB in conventional mode and 1,985 MiB with section aliasing, a difference of 7,441 MiB. Both runs later crashed. The conventional crash was a texture read during concurrent decommit. The alias crash was the null scatter path covered here. This historical measurement belongs to the alias architecture and accompanying integration. **Not tested** - Alias-mode GPU readback remains blocked at fixture setup. World entry and sustained gameplay remain unverified. - AMD and Intel GPUs, or Wine. **AI use** Codex (GPT-6 family, exact runtime variant unavailable) recovered and compared the patches, wrote the follow-up and regression test, ran local validation, and drafted this description.
grahamster2 commented 2026-11-27 22:36:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by grahamster2 on 2026-11-27T22:36:00Z.


Retail world test of #3074 + #3075 with XCL_PAGE_ALIAS=1: it reaches the world, ran the full 720 s without a crash, and uses much less memory.

Setup

  • RTX 3080 10 GB, Ryzen 5 7600X, 31 GB RAM, Windows 11, Series S mode (XCL_DEVICE_TYPE=lockhart).
  • Build: main 6089122a plus some local default-off memory diagnostics, with 785d7dc5 (#3074) and cfe04f43 (#3075) merged on top. No shader-cache-key files changed, so both runs used the same warm shader cache.
  • Both runs used the same scripted path into the world and the same environment. The only differences are XCL_PAGE_ALIAS=1 and the #3074/#3075 code itself: the alias-off run was an earlier build without those commits.

Results

alias off (run 93) XCL_PAGE_ALIAS=1 (run 99)
Presents per 2 s in the world (last 12 samples) 5–6 19–26
Peak process commit 33.4 GB 20.9 GB
Process private at the end 34.2 GB 21.1 GB
System commit at the end 49.7 GB 44.0 GB
D3D12 driver write-combined/uncached private 13.8 GB 9.1 GB
Device removed / panic none none

Caveats

  • This is one run each, so treat it as a single A/B pair, not a benchmark.
  • On this NVIDIA setup main renders a grey picture in the world either way. I can't say anything about rendering correctness in alias mode, only that the world loads, the title keeps submitting and presenting, and nothing crashed.
  • Free physical RAM still went down to about 2.5 GB near the end. The aliased pages count as shared rather than private, so process private understates how much RAM the run used. System commit (−5.7 GB) is the fairer comparison for that.
<!-- greyfinch-sync:ivall/xcl:comment:7229462623 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074#issuecomment-7229462623). Originally posted by [grahamster2](https://github.com/grahamster2) on 2026-11-27T22:36:00Z. --- Retail world test of #3074 + #3075 with `XCL_PAGE_ALIAS=1`: it reaches the world, ran the full 720 s without a crash, and uses much less memory. **Setup** - RTX 3080 10 GB, Ryzen 5 7600X, 31 GB RAM, Windows 11, Series S mode (`XCL_DEVICE_TYPE=lockhart`). - Build: main `6089122a` plus some local default-off memory diagnostics, with `785d7dc5` (#3074) and `cfe04f43` (#3075) merged on top. No shader-cache-key files changed, so both runs used the same warm shader cache. - Both runs used the same scripted path into the world and the same environment. The only differences are `XCL_PAGE_ALIAS=1` and the #3074/#3075 code itself: the alias-off run was an earlier build without those commits. **Results** | | alias off (run 93) | `XCL_PAGE_ALIAS=1` (run 99) | |---|---|---| | Presents per 2 s in the world (last 12 samples) | 5–6 | 19–26 | | Peak process commit | 33.4 GB | 20.9 GB | | Process private at the end | 34.2 GB | 21.1 GB | | System commit at the end | 49.7 GB | 44.0 GB | | D3D12 driver write-combined/uncached private | 13.8 GB | 9.1 GB | | Device removed / panic | none | none | **Caveats** - This is one run each, so treat it as a single A/B pair, not a benchmark. - On this NVIDIA setup main renders a grey picture in the world either way. I can't say anything about rendering correctness in alias mode, only that the world loads, the title keeps submitting and presenting, and nothing crashed. - Free physical RAM still went down to about 2.5 GB near the end. The aliased pages count as shared rather than private, so process private understates how much RAM the run used. System commit (−5.7 GB) is the fairer comparison for that.
ZekkJJ commented 2026-11-28 19:53:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ZekkJJ on 2026-11-28T19:53:04Z.


@bmjask mind reviewing this when you get a chance? We've got independent retail validation now, with noticeable rendering and stability improvements.

<!-- greyfinch-sync:ivall/xcl:comment:7244875346 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074#issuecomment-7244875346). Originally posted by [ZekkJJ](https://github.com/ZekkJJ) on 2026-11-28T19:53:04Z. --- @bmjask mind reviewing this when you get a chance? We've got independent retail validation now, with noticeable rendering and stability improvements.
brainhay5 commented 2026-12-01 01:54:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T01:54:05Z.


Triage note: this no longer merges with current main (mergeable=false), so it cannot be built or tested as it stands.

Why I am asking rather than just noting it: we have run fifteen mergeable candidates on the retail title on an RTX 5070 Ti, and every one still stops presenting at 50–80 s (device removed, surfacing ~88 s later on the next allocation). The PRs whose descriptions actually match that symptom are the ones that no longer apply — this is one of them. A rebase would make it testable again, and we will run it and report the numbers.

If it has been superseded by merged work, saying so is enough and it can be closed.

AI use: an agent posted this triage note.

<!-- greyfinch-sync:ivall/xcl:comment:7298019932 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074#issuecomment-7298019932). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T01:54:05Z. --- Triage note: this no longer merges with current `main` (`mergeable=false`), so it cannot be built or tested as it stands. Why I am asking rather than just noting it: we have run fifteen mergeable candidates on the retail title on an RTX 5070 Ti, and every one still stops presenting at 50–80 s (device removed, surfacing ~88 s later on the next allocation). The PRs whose descriptions actually match that symptom are the ones that no longer apply — this is one of them. A rebase would make it testable again, and we will run it and report the numbers. If it has been superseded by merged work, saying so is enough and it can be closed. *AI use: an agent posted this triage note.*
Foniass commented 2026-12-01 09:26:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:26:51Z.


Triage (#1607) – head 785d7dc

Stacked on #2307 (section-backed physical page aliases, still open); only the top commit 785d7dc belongs here. #3075 is stacked on this PR and contains it, which is not a duplicate.
The fix in kernelx.rs:XMemMapPhysicalPagesScatter passes a null page array through to map_aliased, which already treats it as an unmap, instead of advancing the null pointer; scatter_without_pages_unmaps_only_the_listed_aliases covers it (only with XCL_PAGE_ALIAS=1, otherwise skipped). No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306713859 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074#issuecomment-7306713859). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:26:51Z. --- **Triage (#1607)** – head 785d7dc Stacked on #2307 (section-backed physical page aliases, still open); only the top commit `785d7dc` belongs here. #3075 is stacked on this PR and contains it, which is not a duplicate. The fix in `kernelx.rs:XMemMapPhysicalPagesScatter` passes a null page array through to `map_aliased`, which already treats it as an unmap, instead of advancing the null pointer; `scatter_without_pages_unmaps_only_the_listed_aliases` covers it (only with `XCL_PAGE_ALIAS=1`, otherwise skipped). No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Foniass commented 2026-12-01 10:51:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:51:13Z.


Review (head 785d7dc5, diff read, not a merge-check; conflicts with main, PR description red: no smoke blocks):

  • Most of the diff isn't this PR. Its own commit is +38 / -1. The other ~1,388 lines are #2293, #2294 and #2307, all still open. The bug only exists in merge 3878609d: it takes main's #495 "null array = unmap" behaviour but leaves the alias branch stepping through the null pointer (entry 2 reads a page number at 0x8). #2307 on its own rejects a null page array, so this fix belongs in #2307's rebase rather than in a PR of its own.
  • The conflicts are all in the carried code: kernelx.rs (the VirtualFreeEx condition, now is_view on main, and the new api_cost timing in MapTitlePhysicalPages), lazy.rs (is_marked / ensure) and vfs_hooks.rs. The fix's own hunk auto-merges, though main has since changed the scatter function (commit_homes_ahead).
  • CI never runs the regression test: it skips unless XCL_PAGE_ALIAS=1 (alias.rs ~422). With aliasing on, it would crash without the fix.

Fine: the fix itself (kernelx.rs ~1529-1533). A null array reaches map_aliased as page 0, and map_one unmaps it. Aliasing is off by default and read once. The archived retail crash stack (map_aliased <- XMemMapPhysicalPagesScatter) backs the bug. #3075 is stacked on it.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7308821411 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3074#issuecomment-7308821411). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:51:13Z. --- Review (head 785d7dc5, diff read, not a merge-check; conflicts with main, `PR description` red: no smoke blocks): - **Most of the diff isn't this PR.** Its own commit is +38 / -1. The other ~1,388 lines are #2293, #2294 and #2307, all still open. The bug only exists in merge 3878609d: it takes main's #495 "null array = unmap" behaviour but leaves the alias branch stepping through the null pointer (entry 2 reads a page number at 0x8). #2307 on its own rejects a null page array, so this fix belongs in #2307's rebase rather than in a PR of its own. - **The conflicts are all in the carried code:** `kernelx.rs` (the `VirtualFreeEx` condition, now `is_view` on main, and the new `api_cost` timing in `MapTitlePhysicalPages`), `lazy.rs` (`is_marked` / `ensure`) and `vfs_hooks.rs`. The fix's own hunk auto-merges, though main has since changed the scatter function (`commit_homes_ahead`). - **CI never runs the regression test:** it skips unless `XCL_PAGE_ALIAS=1` (`alias.rs` ~422). With aliasing on, it would crash without the fix. Fine: the fix itself (`kernelx.rs` ~1529-1533). A null array reaches `map_aliased` as page 0, and `map_one` unmaps it. Aliasing is off by default and read once. The archived retail crash stack (`map_aliased <- XMemMapPhysicalPagesScatter`) backs the bug. #3075 is stacked on it. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3074:upstream-pr/3074'
git switch 'upstream-pr/3074'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3074'
git switch 'upstream-pr/3074'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3074'
git switch 'upstream-pr/3074'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3074'
git switch 'main'
git merge --squash 'upstream-pr/3074'
git switch 'main'
git merge --ff-only 'upstream-pr/3074'
git switch 'main'
git merge 'upstream-pr/3074'
git push origin 'main'
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
xcl-dev/xcl!3074
No description provided.