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

Closed
b3IKK wants to merge 1 commit from upstream-pr/1796 into main
b3IKK commented 2026-11-24 20:52:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T20:52:03Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5480126311 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T20:52:03Z. --- 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 commented 2026-11-24 21:29:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T21:15:35Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7144690686 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7144690686). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T21:15:35Z. --- 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.
futurepro62 commented 2026-11-24 22:06:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T21:31:14Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7145038297 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7145038297). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T21:31:14Z. --- 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.
DavidM1911 commented 2026-11-25 00:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:41:56Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7147695176 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7147695176). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T23:41:56Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
throny commented 2026-11-25 10:10:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T09:55:44Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7158990701 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7158990701). Originally posted by [throny](https://github.com/throny) on 2026-11-25T09:55:44Z. --- 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 commented 2026-11-26 09:07:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-26T08:08:23Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7186232574 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7186232574). Originally posted by [throny](https://github.com/throny) on 2026-11-26T08:08:23Z. --- <!-- 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.
raylitebull commented 2026-11-28 21:13:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-28T21:13:04Z.


Closing as a duplicate of #1564 (confirmed by 2+ contributors in #1607, group D91). Thanks for the contribution — feel free to comment if this covers something #1564 does not.

<!-- greyfinch-sync:ivall/xcl:comment:7245856987 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1796#issuecomment-7245856987). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-28T21:13:04Z. --- Closing as a duplicate of #1564 (confirmed by 2+ contributors in #1607, group D91). Thanks for the contribution — feel free to comment if this covers something #1564 does not.

Pull request closed

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!1786
No description provided.