Skip to content

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

Open
adiologydev wants to merge 1 commit into
xcl-dev:mainfrom
adiologydev:kernelx/page-sections
Open

adiologydev wants to merge 1 commit into
xcl-dev:mainfrom
adiologydev:kernelx/page-sections

Conversation

@adiologydev

@adiologydev adiologydev commented Nov 25, 2026 •

Copy link
Copy Markdown

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, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #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.

…addresses

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 (xcl-dev#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.
@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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.

@ClosetPie107

Copy link
Copy Markdown

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.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source defect found; SEC_RESERVE/view splitting/aliasing/write-watch tests are internally consistent. Current head lacks Windows CI and the module remains unused, so no runtime alias lifecycle/concurrency integration exists. Also, failed MapViewOfFile3 occurs after placeholder split and leaves reservation fragmented; document this recoverable state or restore transactionally before wiring into callers. Provide current CI and integration once connected.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2293 at head 03ceddb0be3d06287ca21ae800dbb0d7f98049e7 (1 commit; exact parent & merge-base: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (03ceddb0)

Command Result
cargo test --release -p xcl --lib hle::kernelx::sections:: -- --test-threads=1 --nocapture (3 consecutive runs) 7 passed; 0 failed; 0 ignored; 1124 filtered out × 3 (0.00s × 3, 0 skipped: 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)
cargo test --release -p xcl --lib hle::kernelx:: -- --test-threads=1 (3 consecutive runs) 45 passed; 0 failed; 1 ignored; 1085 filtered out × 3 (1.15s, 1.17s, 1.16s, 0 skipped)
cargo build --release -p xcl Clean build (1m 18s, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (568e7db7729c8fa6c8f0f4b32d798faaf11462bb, cached baseline on the same machine):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14527 MB

PR #2293 (03ceddb0be3d06287ca21ae800dbb0d7f98049e7):

xcl-smoke v1
commit: 03ceddb0be3d06287ca21ae800dbb0d7f98049e7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14520 MB

Limits of coverage

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants