kernelx: VirtualAllocEx for this process is the title's allocator #1796

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

@⁠b3IKK on GitHub · 2026-11-24 20:52 UTC · original
b3IKK:kernelx/virtualallocex-title-memory → main · +29 −0 · 1 files · 1 commits · open

Addresses XCL-BT-030 from #1488.

VirtualAllocEx forwarded every call to Windows with the console's allocation flags sanitised — for GetCurrentProcess(), which is the title's own memory, that meant MEM_GRAPHICS was dropped and the title got a plain Windows reservation the GPU has no address for. VirtualAlloc is where the console's memory actually comes from: placeholders, the sparse windows, video memory in the unified region, 64 KiB pages, and the write-watched graphics fallback. VirtualFreeEx already routes this process back to VirtualFree for exactly those allocations (kernelx.rs:454-464) — the allocation side did not match.

This routes VirtualAllocEx(GetCurrentProcess(), …) to VirtualAlloc, the same way VirtualFreeEx routes to VirtualFree.

What is in it

  • crates/xcl/src/hle/kernelx.rs: VirtualAllocEx sends this process to VirtualAlloc; other processes stay Windows' VirtualAllocEx. Test virtual_alloc_ex_for_this_process_is_the_titles_allocator (a MEM_RESERVE | MEM_GRAPHICS allocation must be inside the unified region or a sparse window, then VirtualFreeEx releases it).

Evidence it fails without the fix:
VirtualAllocEx(GetCurrentProcess()) must land in the title's memory, got 0x25c95970000 — a host reservation with the graphics flag dropped; with the fix it is a sparse-window/unified address and test result: ok.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 893 passed, 0 failed, 42 ignored (SKIPPED: 2 no wave64; 1 no heap windows; 1 cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib virtual_alloc_ex_for_this_process: 1 passed, 0 failed

Regression run

main (e9e94ce, clean tree, no local changes):

xcl-smoke v1
commit: e9e94ce665d16bb0e2d2e4cb6b37e149f0d27721
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1646 (PresentX 1646)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14489 MB

PR (c702d7d, clean tree, no local changes):

xcl-smoke v1
commit: c702d7d573f6b829d77b633c83a160f91f2f31c0
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1643 (PresentX 1643)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14613 MB

Not tested

  • a title that calls VirtualAllocEx(GetCurrentProcess(), …) for a normal (non-graphics) allocation and then writes to it before committing (the unified/sparse path handles commits, but no game here was traced doing it)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: checked XCL-BT-030 against VirtualAlloc/VirtualFreeEx, wrote the fix and test (and confirmed it fails without it), rebased onto e9e94ce, ran the test suite and scripts/smoke.ps1 regression runs with #677's title hashing, and drafted this PR description.
**@⁠b3IKK** on GitHub · 2026-11-24 20:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796) `b3IKK:kernelx/virtualallocex-title-memory` → `main` · +29 −0 · 1 files · 1 commits · open Addresses `XCL-BT-030` from #1488. `VirtualAllocEx` forwarded every call to Windows with the console's allocation flags sanitised — for `GetCurrentProcess()`, which is the title's own memory, that meant `MEM_GRAPHICS` was dropped and the title got a plain Windows reservation **the GPU has no address for**. `VirtualAlloc` is where the console's memory actually comes from: placeholders, the sparse windows, video memory in the unified region, 64 KiB pages, and the write-watched graphics fallback. `VirtualFreeEx` already routes this process back to `VirtualFree` for exactly those allocations (`kernelx.rs:454-464`) — the allocation side did not match. This routes `VirtualAllocEx(GetCurrentProcess(), …)` to `VirtualAlloc`, the same way `VirtualFreeEx` routes to `VirtualFree`. **What is in it** - `crates/xcl/src/hle/kernelx.rs`: `VirtualAllocEx` sends this process to `VirtualAlloc`; other processes stay Windows' `VirtualAllocEx`. Test `virtual_alloc_ex_for_this_process_is_the_titles_allocator` (a `MEM_RESERVE | MEM_GRAPHICS` allocation must be inside the unified region or a sparse window, then `VirtualFreeEx` releases it). **Evidence it fails without the fix:** `VirtualAllocEx(GetCurrentProcess()) must land in the title's memory, got 0x25c95970000` — a host reservation with the graphics flag dropped; with the fix it is a sparse-window/unified address and `test result: ok`. **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 893 passed, 0 failed, 42 ignored (SKIPPED: 2 `no wave64`; 1 `no heap windows`; 1 `cannot disable the driver cache (Windows Developer Mode is required))` - `cargo test -p xcl --lib virtual_alloc_ex_for_this_process`: 1 passed, 0 failed **Regression run** main (`e9e94ce`, clean tree, no local changes): ``` xcl-smoke v1 commit: e9e94ce665d16bb0e2d2e4cb6b37e149f0d27721 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1646 (PresentX 1646) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14489 MB ``` PR (`c702d7d`, clean tree, no local changes): ``` xcl-smoke v1 commit: c702d7d573f6b829d77b633c83a160f91f2f31c0 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1643 (PresentX 1643) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14613 MB ``` **Not tested** - a title that calls `VirtualAllocEx(GetCurrentProcess(), …)` for a normal (non-graphics) allocation and then writes to it before committing (the unified/sparse path handles commits, but no game here was traced doing it) - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: checked `XCL-BT-030` against `VirtualAlloc`/`VirtualFreeEx`, wrote the fix and test (and confirmed it fails without it), rebased onto `e9e94ce`, ran the test suite and `scripts/smoke.ps1` regression runs with #677's title hashing, and drafted this PR description.
VirtualAllocEx forwarded every call to Windows' VirtualAllocEx with the
console's allocation flags sanitised, so for this process - the title's
own memory - MEM_GRAPHICS was dropped and the title got a plain
reservation the GPU has no address for. VirtualAlloc is where the
console's memory comes from: placeholders, the sparse windows, video
memory in the unified region, 64 KiB pages, the write-watched graphics
fallback. VirtualFreeEx already routed this process back to VirtualFree
for exactly those allocations; the allocation side did not.

Route VirtualAllocEx(GetCurrentProcess(), ...) to VirtualAlloc, as
VirtualFreeEx does to VirtualFree.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:34 +00:00
Author
Owner

@⁠b3IKK on GitHub · 2026-11-24 21:15 UTC · original

Rebased onto e9e94ce (which also brought #677's anonymised itle: line into scripts/smoke.ps1) and re-ran the test suite and both smoke runs: 893 passed, 0 failed, 42 ignored; blocks pasted above are from the new script.

**@⁠b3IKK** on GitHub · 2026-11-24 21:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7144690686) Rebased onto e9e94ce (which also brought #677's anonymised itle: line into scripts/smoke.ps1) and re-ran the test suite and both smoke runs: 893 passed, 0 failed, 42 ignored; blocks pasted above are from the new script.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 21:31 UTC · original · edited 2026-11-24 22:20 UTC

Full-suite run, since this PR has no test report yet. Tested exact head c702d7d (on its base e9e94ce).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 891 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: virtual_alloc_ex_for_this_process_is_the_titles_allocator.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 893 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (#1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skipped because Developer Mode was off. Developer Mode was turned on before the AMD run, and there pso_measurement_compiles_an_exact_synthetic_record ran and passed.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 21:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7145038297) · edited 2026-11-24 22:20 UTC Full-suite run, since this PR has no test report yet. Tested exact head `c702d7d` (on its base `e9e94ce`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record`: **891 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `virtual_alloc_ex_for_this_process_is_the_titles_allocator`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **893 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - Two tests were skipped with `--skip` on NVIDIA. Both fail on main `7f7e768` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns their skips into failures. `heap_window_out_of_memory_falls_back_to_the_switch_form` skips when `XCL_HEAP_WINDOWS` is unset (#1651), and `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` skipped because Developer Mode was off. Developer Mode was turned on before the AMD run, and there `pso_measurement_compiles_an_exact_synthetic_record` ran and passed. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 23:41 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 23:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7147695176) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠throny on GitHub · 2026-11-25 09:55 UTC · original

Test report for exact head c702d7d.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 MSVC; DXC 1.9.2602.17; tests in debug, title runs in release.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on c702d7d as it is (its own base): 893 passed, 0 failed, 42 ignored. SKIPPED: 4 lines (no wave64 on this adapter, and the like).
  • scripts/smoke.ps1, the retail title, 60 s, release builds, main 568e7db first, then this head:

main:

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

PR:

xcl-smoke v1
commit: c702d7d573f6b829d77b633c83a160f91f2f31c0
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1604 (PresentX 1604)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16068 MB

Not tested: AMD, the head merged onto current main, a world load.

AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.

**@⁠throny** on GitHub · 2026-11-25 09:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7158990701) Test report for exact head `c702d7d`. **Tested** - Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 MSVC; DXC 1.9.2602.17; tests in debug, title runs in release. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` on `c702d7d` as it is (its own base): **893 passed, 0 failed, 42 ignored**. `SKIPPED`: 4 lines (no wave64 on this adapter, and the like). - `scripts/smoke.ps1`, the retail title, 60 s, release builds, `main` `568e7db` first, then this head: main: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1602 (PresentX 1602) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15852 MB ``` PR: ``` xcl-smoke v1 commit: c702d7d573f6b829d77b633c83a160f91f2f31c0 gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1604 (PresentX 1604) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16068 MB ``` **Not tested:** AMD, the head merged onto current `main`, a world load. AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
Author
Owner

@⁠throny on GitHub · 2026-11-26 08:08 UTC · original

Two contributors checked independently and found that this PR makes the same change as #1564 (for #1488): #1607, group D91. They suggest keeping #1564. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-26 08:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7186232574) <!-- xcl-1607-hint:D91 --> Two contributors checked independently and found that this PR makes the same change as #1564 (for #1488): #1607, group D91. They suggest keeping #1564. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
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/1796/head:github-bot/gh-1796'
git switch 'github-bot/gh-1796'

Merge

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