kernelx: physical pages as section slices that can be mapped at many addresses #2293

Open
github-bot wants to merge 1 commit from github-bot/gh-2293 into main AGit
Owner

@⁠adiologydev on GitHub · 2026-11-25 12:45 UTC · original
adiologydev:kernelx/page-sections → main · +310 −0 · 2 files · 1 commits · open

First part of the plan on #1031 (real aliasing of physical pages): a block of physical pages as one pagefile-backed section, mapped as views into placeholders, so a page can show at every address it is mapped at. Nothing calls it yet; part of #1031 / #697.

On the console a physical page mapped at several addresses is one page. XCL keeps a page at one address at a time and copies it when the title maps it elsewhere (kernelx::move_away); a retail title maps its streamed pages into a pool, into the CPU view of a 24 GB reservation and into that reservation's GPU view.

What is in it

  • crates/xcl/src/hle/kernelx/sections.rs (new): Section (a SEC_RESERVE pagefile-backed section of N 64 KiB pages), Section::map (a view of pages first..first+n into a placeholder with MapViewOfFile3 / MEM_REPLACE_PLACEHOLDER), reserve / split / unmap (keeps the placeholder) / commit / release, and replace_with_reservation / reservation_to_placeholder (ordinary, optionally write-watched memory in part of a placeholder). 7 unit tests.
  • crates/xcl/src/hle/kernelx.rs: the module declaration.

Measured in a standalone program (not part of the PR) on the machine below, 200 000 pages: map 2.2 µs, unmap 2.75 µs, commit 0.9 µs, VirtualProtect 0.5 µs a page. GetWriteWatch refuses a range that holds a view (error 87) and one call cannot span two neighbouring reservations; one call per small reservation costs 0.83 µs.

Tested

  • NVIDIA GeForce RTX 5090 32 GB (driver 621.40), AMD Ryzen 9 7950X, 64 GB RAM, Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2609 (XCL_DXC_DIR), debug tests, release runs.
  • cargo test --workspace -- --test-threads=4 on 03ceddb: 1101 passed, 4 failed, 26 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState → E_OUTOFMEMORY on this card, #1905); main 568e7db fails the same 4 here (1094 passed, 4 failed, 26 ignored). SKIPPED (23, the same on main): 20 need 64-lane waves ("no wave64"), 3 per-lane f16 refusals in lower_dxil::tests::{f16,f32}_programs_on_the_gpu.
  • cargo test -p xcl --lib kernelx::sections: 7 passed.

Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 60, no input, main first, same machine (each run's xcl.exe built from a clean checkout of its commit):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5090
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1015 (PresentX 1015)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16257 MB
xcl-smoke v1
commit: 03ceddb0be3d06287ca21ae800dbb0d7f98049e7
gpu: NVIDIA GeForce RTX 5090
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1517 (PresentX 1517)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15514 MB

Not tested

  • AMD and Intel GPUs; Wine / Proton (placeholders and MapViewOfFile3 need a Windows 10 1803+ kernel – not tried under Wine).
  • Nothing in the runtime uses the module yet, so the smoke runs only show it changes nothing.

AI use

  • Claude Code (Claude Opus 5.5): wrote the code, the tests, the feasibility program and this description, and made the runs above on this hardware. I read every line of the diff and checked it.
**@⁠adiologydev** on GitHub · 2026-11-25 12:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293) `adiologydev:kernelx/page-sections` → `main` · +310 −0 · 2 files · 1 commits · open First part of the plan on #1031 (real aliasing of physical pages): a block of physical pages as one pagefile-backed section, mapped as views into placeholders, so a page can show at every address it is mapped at. Nothing calls it yet; part of #1031 / #697. On the console a physical page mapped at several addresses is one page. XCL keeps a page at one address at a time and copies it when the title maps it elsewhere (`kernelx::move_away`); a retail title maps its streamed pages into a pool, into the CPU view of a 24 GB reservation and into that reservation's GPU view. **What is in it** - `crates/xcl/src/hle/kernelx/sections.rs` (new): `Section` (a `SEC_RESERVE` pagefile-backed section of N 64 KiB pages), `Section::map` (a view of pages `first..first+n` into a placeholder with `MapViewOfFile3` / `MEM_REPLACE_PLACEHOLDER`), `reserve` / `split` / `unmap` (keeps the placeholder) / `commit` / `release`, and `replace_with_reservation` / `reservation_to_placeholder` (ordinary, optionally write-watched memory in part of a placeholder). 7 unit tests. - `crates/xcl/src/hle/kernelx.rs`: the module declaration. Measured in a standalone program (not part of the PR) on the machine below, 200 000 pages: map 2.2 µs, unmap 2.75 µs, commit 0.9 µs, `VirtualProtect` 0.5 µs a page. `GetWriteWatch` refuses a range that holds a view (error 87) and one call cannot span two neighbouring reservations; one call per small reservation costs 0.83 µs. **Tested** - NVIDIA GeForce RTX 5090 32 GB (driver 621.40), AMD Ryzen 9 7950X, 64 GB RAM, Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2609 (`XCL_DXC_DIR`), debug tests, release runs. - `cargo test --workspace -- --test-threads=4` on `03ceddb`: 1101 passed, 4 failed, 26 ignored. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` → `E_OUTOFMEMORY` on this card, #1905); `main` 568e7db fails the same 4 here (1094 passed, 4 failed, 26 ignored). SKIPPED (23, the same on `main`): 20 need 64-lane waves ("no wave64"), 3 per-lane f16 refusals in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu`. - `cargo test -p xcl --lib kernelx::sections`: 7 passed. **Regression run** `scripts/smoke.ps1 -Game <retail title> -Seconds 60`, no input, `main` first, same machine (each run's `xcl.exe` built from a clean checkout of its commit): ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 5090 title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1015 (PresentX 1015) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16257 MB ``` ``` xcl-smoke v1 commit: 03ceddb0be3d06287ca21ae800dbb0d7f98049e7 gpu: NVIDIA GeForce RTX 5090 title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1517 (PresentX 1517) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15514 MB ``` **Not tested** - AMD and Intel GPUs; Wine / Proton (placeholders and `MapViewOfFile3` need a Windows 10 1803+ kernel – not tried under Wine). - Nothing in the runtime uses the module yet, so the smoke runs only show it changes nothing. **AI use** - Claude Code (Claude Opus 5.5): wrote the code, the tests, the feasibility program and this description, and made the runs above on this hardware. I read every line of the diff and checked it.
On the console a physical page mapped at several addresses is one page. XCL
keeps a page at one address at a time and copies it when the title maps it
elsewhere (`move_away`), so the other addresses go stale; a retail title maps
its streamed pages into a pool, into the CPU view of a 24 GB reservation and
into that reservation's GPU view (#1031).

`kernelx::sections` is the base for real aliasing: a block of physical pages
is one pagefile-backed SEC_RESERVE section, and a page is mapped as a view of
its 64 KiB slice into a placeholder (MapViewOfFile3 with
MEM_REPLACE_PLACEHOLDER). Every view of a slice is the same memory and a page
takes commit once, when it is committed through any view. Unmapping leaves a
placeholder for the next view. Ordinary reserved memory (write-watched if
asked) can replace part of a placeholder and go back to one.

Nothing calls it yet. Measured in a standalone program on Windows 11 26200
over 200 000 pages: map 2.2 us, unmap 2.75 us, commit 0.9 us a page.
GetWriteWatch refuses a range that holds a view (error 87), and one call
cannot span two neighbouring reservations either.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:26:02 +00:00
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 14:56 UTC · original

Independent native Windows check of the section and placeholder primitives on 03ceddb0be3d06287ca21ae800dbb0d7f98049e7.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. CPU-side tests using native Windows memory APIs.
  • cargo test --locked -p xcl --lib hle::kernelx::sections -- --nocapture --test-threads=1 gave 7 passed, 0 failed, 0 ignored and no skips. The same page was visible through multiple addresses, committing through one view made it visible to the others, and unmapping left a reusable placeholder. The multi-page, write-watch adjacency and invalid-size checks also passed.

Not tested

Wine, a retail title, performance, GPU integration and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

**@⁠nnonno91** on GitHub · 2026-11-25 14:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293#issuecomment-7166051905) Independent native Windows check of the section and placeholder primitives on `03ceddb0be3d06287ca21ae800dbb0d7f98049e7`. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. CPU-side tests using native Windows memory APIs. - `cargo test --locked -p xcl --lib hle::kernelx::sections -- --nocapture --test-threads=1` gave 7 passed, 0 failed, 0 ignored and no skips. The same page was visible through multiple addresses, committing through one view made it visible to the others, and unmapping left a reusable placeholder. The multi-page, write-watch adjacency and invalid-size checks also passed. **Not tested** Wine, a retail title, performance, GPU integration and the full workspace suite. **AI use** OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 16:57 UTC · original

NVIDIA test report for 03ceddb (head as is, base 568e7db), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after cargo build --workspace:

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1152 passed, 0 failed, 46 ignored. The end-to-end title tests pass.
  • main 0829441 on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).
  • Skipped hle::xaudio2, because its tests fail or hang on this machine on main too. The PR doesn't touch it.
  • SKIPPED lines: 25: 20 no wave64 on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off.

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.

**@⁠upipibi** on GitHub · 2026-11-25 16:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293#issuecomment-7168797591) NVIDIA test report for `03ceddb` (head as is, base `568e7db`), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after `cargo build --workspace`: - `cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2`: **1152 passed, 0 failed, 46 ignored**. The end-to-end title tests pass. - `main` `0829441` on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests). - Skipped `hle::xaudio2`, because its tests fail or hang on this machine on `main` too. The PR doesn't touch it. - SKIPPED lines: 25: 20 `no wave64` on this card, 3 f16/f32 forms the per-lane path refuses, 1 no heap windows, and 1 PSO measurement that needs Developer Mode to turn the driver cache off. AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 17:29 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 17:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293#issuecomment-7169586996) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:33 UTC · original

RX 7800 XT (RDNA3, wave32/wave64) report on exact head 03ceddb0be3d06287ca21ae800dbb0d7f98049e7 (as is, on its base 568e7db7; no merge with current main, which merges cleanly).

Tested

  • AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 build 26200; Rust 1.100.0 MSVC; debug profile; dxc.exe from Windows SDK 10.0.26100.0.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head: 1160 passed, 1 failed, 46 ignored (21 targets). The one failure is fuzz_validate_and_gpu_1, which fails the same way on main; nothing else failed.
  • Baseline, same machine and command, unmodified main at c9ee916a: 1330 passed, 2 failed, 46 ignored (24 targets). The 2 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: CPU 0x7fffffff, GPU 0x1) and gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier.
  • Note: a_bridged_mask_write... does not exist on this older head, so only fuzz_validate_and_gpu_1 is comparable with main.
  • Relevant tests, all passing: the 7 hle::kernelx::sections::tests::* (e.g. a_page_mapped_at_two_addresses_is_one_page)
  • SKIPPED (7 lines on the heads that have these tests, same as main): the f16 / f32-conversion per-lane programs, "refused (unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 ...)", and heap_window_out_of_memory_falls_back_to_the_switch_form ("no heap windows").

Not tested

  • No title and no scripts/smoke.ps1 run (no xcl-smoke blocks): I did not run an untrusted retail executable. This is a test-suite report only, not the regression run the PR needs.
  • Release profile, NVIDIA, Intel, Wine, RDNA2/RDNA4.

AI use

  • This run and report were done by Claude Code (Claude Sonnet 5.5): it fetched the head, ran the commands above and wrote this comment. Nothing was reviewed line by line for correctness here.
**@⁠oni-swr** on GitHub · 2026-11-25 18:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293#issuecomment-7171082137) **RX 7800 XT (RDNA3, wave32/wave64) report on exact head `03ceddb0be3d06287ca21ae800dbb0d7f98049e7`** (as is, on its base `568e7db7`; no merge with current `main`, which merges cleanly). **Tested** - AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 build 26200; Rust 1.100.0 MSVC; debug profile; `dxc.exe` from Windows SDK 10.0.26100.0. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on this head: 1160 passed, 1 failed, 46 ignored (21 targets). The one failure is `fuzz_validate_and_gpu_1`, which fails the same way on `main`; nothing else failed. - Baseline, same machine and command, unmodified `main` at `c9ee916a`: 1330 passed, 2 failed, 46 ignored (24 targets). The 2 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722: CPU `0x7fffffff`, GPU `0x1`) and `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`. - Note: `a_bridged_mask_write...` does not exist on this older head, so only `fuzz_validate_and_gpu_1` is comparable with `main`. - Relevant tests, all passing: the 7 `hle::kernelx::sections::tests::*` (e.g. `a_page_mapped_at_two_addresses_is_one_page`) - `SKIPPED` (7 lines on the heads that have these tests, same as `main`): the f16 / f32-conversion per-lane programs, "refused (unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 ...)", and `heap_window_out_of_memory_falls_back_to_the_switch_form` ("no heap windows"). **Not tested** - No title and no `scripts/smoke.ps1` run (no `xcl-smoke` blocks): I did not run an untrusted retail executable. This is a test-suite report only, not the regression run the PR needs. - Release profile, NVIDIA, Intel, Wine, RDNA2/RDNA4. **AI use** - This run and report were done by Claude Code (Claude Sonnet 5.5): it fetched the head, ran the commands above and wrote this comment. Nothing was reviewed line by line for correctness here.
Author
Owner

@⁠ClosetPie107 on GitHub · 2026-11-25 20:46 UTC · original

Independent AMD RDNA4 / Linux (Proton/Wine, RADV, native wave64) test report for head 03ceddb0be3d06287ca21ae800dbb0d7f98049e7 (merged cleanly onto main 6d12f58).

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu (debug)

Unit tests (XCL_REQUIRE_GPU=wave64, XCL_DXC_DIR, VKD3D_CONFIG=ignore_shared_fence, --test-threads=1 --nocapture)

  • hle::kernelx::sections: 7 passed, 0 failed, 0 ignored (0 skipped)
    • All 7 tests pass under Proton Experimental (a_page_mapped_at_two_addresses_is_one_page, a_run_of_pages_is_one_view, a_section_of_no_pages_is_refused, committing_through_one_view_commits_the_page_for_all, splitting_a_range_that_is_already_a_placeholder_is_a_no_op, unmapping_leaves_a_placeholder_for_the_next_page, write_watched_memory_lives_beside_views_in_one_placeholder), confirming MapViewOfFile3 / MEM_REPLACE_PLACEHOLDER + write-watched neighbours work on Proton 11.

Not tested

  • Full workspace test suite, native Windows, or a retail-title smoke pair (module is not wired into the runtime yet).

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged the PR onto main, ran the tests under Proton on this machine, and drafted this report.
**@⁠ClosetPie107** on GitHub · 2026-11-25 20:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2293#issuecomment-7174160498) Independent AMD RDNA4 / Linux (Proton/Wine, RADV, native wave64) test report for head `03ceddb0be3d06287ca21ae800dbb0d7f98049e7` (merged cleanly onto `main` `6d12f58`). **Hardware & environment** - AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux - Proton Experimental (`experimental-11.0-20261112`), `vkd3d-proton` `master` `ec207194` (3.2.0) + `dxil-spirv` `b540c8a2` + relaxed-vtable patch (`-Db_ndebug=true`), DXVK `v3.1.1-209`, DXC `1.9.2609.5`, Rust `x86_64-pc-windows-gnu` (debug) **Unit tests** (`XCL_REQUIRE_GPU=wave64`, `XCL_DXC_DIR`, `VKD3D_CONFIG=ignore_shared_fence`, `--test-threads=1 --nocapture`) - `hle::kernelx::sections`: **7 passed, 0 failed, 0 ignored** (0 skipped) - All 7 tests pass under Proton Experimental (`a_page_mapped_at_two_addresses_is_one_page`, `a_run_of_pages_is_one_view`, `a_section_of_no_pages_is_refused`, `committing_through_one_view_commits_the_page_for_all`, `splitting_a_range_that_is_already_a_placeholder_is_a_no_op`, `unmapping_leaves_a_placeholder_for_the_next_page`, `write_watched_memory_lives_beside_views_in_one_placeholder`), confirming `MapViewOfFile3` / `MEM_REPLACE_PLACEHOLDER` + write-watched neighbours work on Proton 11. **Not tested** - Full workspace test suite, native Windows, or a retail-title smoke pair (module is not wired into the runtime yet). **AI use** - T3 Code / Antigravity (Gemini 4 Neon) merged the PR onto `main`, ran the tests under Proton on this machine, and drafted this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2293/head:github-bot/gh-2293'
git switch 'github-bot/gh-2293'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2293'
git switch 'github-bot/gh-2293'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2293'
git switch 'github-bot/gh-2293'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2293'
git switch 'main'
git merge --squash 'github-bot/gh-2293'
git switch 'main'
git merge --ff-only 'github-bot/gh-2293'
git switch 'main'
git merge 'github-bot/gh-2293'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.