runtime: commit startup blocks through XMemVirtualAlloc #1091

Merged
rasptum merged 3 commits from upstream-pr/1098 into main 2026-11-24 03:03:00 +00:00
rasptum commented 2026-11-24 00:59:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T00:59:10Z.


Refs #870

Change

The desktop XMemVirtualAlloc accepted only the two reserve-only startup calls (#888/#945). In the startup checkpoints on #870, the next calls ask for committed blocks and were refused. This adds one commit profile to the existing export in src/xmem_mapped_pages.cpp, with no export or ordinal change.

Accepted configurations, each with a null address and a nonzero size that is a multiple of 64 KiB:

Type Attributes Protection Caller (static read, file reads only)
0x20003000 0x183 0x22004 pool loop, three slots
0x20003000 0x283 0x2404 pool loop, one slot
0x20403000 0x181 PAGE_READWRITE three other sites, one with a fixed 20 MiB

Each call commits a fresh private PAGE_READWRITE block of exactly the requested size (not rounded), zero-filled and released by the caller with VirtualFree. Alignment: the MEM_LARGE_PAGES type 0x20003000 gets a 2 MiB-aligned base (VirtualAlloc2 with an address requirement). The MEM_64K_PAGES type 0x20403000 (MEM_LARGE_PAGES | MEM_PHYSICAL in winnt.h) keeps the 64 KiB granularity of VirtualAlloc. Sizes are not rounded to 2 MiB because two of the four pool sizes the caller requests are odd multiples of 1 MiB. Treating MEM_LARGE_PAGES as a 2 MiB requirement is an assumption from the desktop definition. A local run of the startup sequence showed no difference between 64 KiB-only and 2 MiB-aligned pool bases up to its next stop, so it is no evidence either way. If Windows cannot commit the block, the call returns NULL with the Windows error. Every other argument set keeps the existing ERROR_INVALID_PARAMETER refusal, and the reserve-only profile is unchanged.

This is a proposed desktop policy. No independent reference describes these attribute words. Large pages themselves, the console protection bits above PAGE_READWRITE (0x2000, 0x20000, and write-combining 0x400) and any GPU visibility they request are not reproduced.

The third configuration (call 7 in the sequence) was found by @mumba17 in their independent Windows 11 native-loader repeat on #870. Thanks for that; I added it here after reading the call sites.

Verification

Windows 10 Pro 22H2 (19045.6466), MSVC 19.44.35207.1 x64, CMake/Ninja, Python 3.13 venv. Tested head 96309447 on main 072e85b6. The full release suite ran on 4f52ce68 (same change on main c205cffd); after the final rebase (no XMem file changed on main), the fixture and the xmem|configure_vm|vm_translation|era_ families were rerun in both presets.

New test cpu_native_xmem_pool_commit (tests/cpu/xmem_pool_commit.asm + tests/cpu/xmem_pool_commit_check.py). The source-built EXE imports XMemVirtualAlloc by name, and the same body runs under the Windows loader and from pe_map_run:

  • Per configuration (4 MiB, 2 MiB + 64 KiB, 1 MiB + 192 KiB): base alignment (2 MiB for the two large-page blocks, 64 KiB for the 64 KiB-page block); VirtualQuery base, allocation base, MEM_COMMIT, PAGE_READWRITE, MEM_PRIVATE; a region size equal to the requested size, with the byte just past the block outside the allocation (the 2 MiB + 64 KiB block exposes any rounding to 2 MiB); every byte reads zero; a block-specific pattern in the first and last QWORD of every 64 KiB page (so also the block's first and last QWORD) reads back; release with VirtualFree, after which the block reads as MEM_FREE.
  • Ten neighbouring requests must be refused with 87: each type without MEM_COMMIT, the two pool pairs crossed, each type with a pair from the other, protection 0x2004 with 0x183, PAGE_READONLY with 0x181, the live block as the address, size 0, and size 4 MiB + 4 KiB. All three blocks keep their patterns through these calls.
  • Host allocation failure: an accepted configuration with a 128 TiB size returns NULL with a Windows error other than 87. Here it is ERROR_NOT_ENOUGH_MEMORY (8).
  • Controls, each with a known failing step under both loaders: the first block taken from the reserve-only call (0xF02), the 2 MiB check applied to a 64 KiB-aligned, non-2-MiB base (MISALIGNED, 0xF02), one nonzero QWORD at the end of the first block (0xF03), the accepted pair in place of a crossed one (0xF0F), a size that fits in place of the host failure (0xF17), and no release of the first block (0xF19). A provider without XMemVirtualAlloc stops pe_map at that import before entry.
cmake --build --preset dev
cmake --build --preset release
ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V
ctest --preset dev --no-tests=error -R 'xmem|configure_vm|vm_translation|era_'
ctest --preset release --no-tests=error -R 'xmem|configure_vm|vm_translation|era_'
ctest --preset release --no-tests=error -j 4
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py

Results:

  • cpu_native_xmem_pool_commit: original 0x870 and every control at its expected code under both loaders; missing provider unresolved import xmem.dll!XMemVirtualAlloc.
  • dev and release xmem|configure_vm|vm_translation|era_: 55 passed, 0 failed in each, plus 1 capability skip (vm_translation_range_warp on in-box WARP 10.0.19041, as documented).
  • Full release suite (on 4f52ce68): 638 tests: 577 passed, 54 capability skips (reported separately), 7 failed, none in a test that exercises this change. Four were _hardware timeouts under -j 4 (compute_store_aot_hardware, compute_store_aot_guard_read_hardware, compute_store_aot_lds_private_hardware, pixel_aot_blend_scalar_hardware) and all four passed when rerun serially (19 to 30 s each) on the RTX 3060 (driver 32.0.15.9636, debug layer on). gpu_alias_lookup_writes_warp and pixel_aot_title_loads_warp fail on in-box WARP 10.0.19041 in offscreen_check, which does not link xmem_shim (the first prints the documented array-atomics adapter defect). pe_package_import_closure needs symlink privilege, which this account lacks (WinError 1314).
  • Docs link and bidi checks pass.

Shim mutations (local, not committed). Each was caught under both loaders, and the restored shim passes:

  • 64 KiB-only pool base: step 2 (0xF02);
  • pool size rounded up to 2 MiB: step 6 (0xF06);
  • no 64 KiB size check: step 22 (0xF16);
  • host failure reported as 87: step 23 (0xF17);
  • commit only the first 64 KiB: step 2 (0xF02).

Which validator each refusal reaches. With the commit profile's pair check forced to accept, steps 15 to 19 are accepted, so those refusals come from the new pair check. Steps 13, 14 and 20 stay refused, so they come from the reserve-only validator, and step 22 comes from the 64 KiB check (mutation above). The size-0 case (step 21) matches what VirtualAlloc returns for size 0 on its own, so it does not isolate the shim's check.

xmem_commit_protection still passes. Its MEM_COMMIT variant (type 0x20403000 with attribute 0x21) remains refused, and its header comment now describes both profiles.

Evidence and follow-up

  • Local checkpoint (private, local harness, not in the repository; API names and codes only): with this change, all seven startup XMemVirtualAlloc calls succeed (two reservations, four pool slots, then the 20 MiB block), and no missing-import stub is reached.
  • Not established: what follows these allocations. Under the repository's trap runner (#1075/#1085), the next stop after the seven allocations is the trap on xcrdapi.dll!DStorageGetFactory. An earlier private harness crashed after that point instead, and that is not part of this PR.
  • What the console does with these attribute and protection bits, and whether any of these blocks must be GPU-visible, remain open.
  • Overlap, checked against the open PRs right before pushing: only #888 (draft, reserve-only, other files) mentions XMemVirtualAlloc, and it does not change this function or add this test.

AI-assisted (Claude).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572157440 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-24T00:59:10Z. --- Refs #870 ## Change The desktop `XMemVirtualAlloc` accepted only the two reserve-only startup calls (#888/#945). In the startup checkpoints on #870, the next calls ask for committed blocks and were refused. This adds one commit profile to the existing export in `src/xmem_mapped_pages.cpp`, with no export or ordinal change. Accepted configurations, each with a null address and a nonzero size that is a multiple of 64 KiB: | Type | Attributes | Protection | Caller (static read, file reads only) | |---|---|---|---| | `0x20003000` | `0x183` | `0x22004` | pool loop, three slots | | `0x20003000` | `0x283` | `0x2404` | pool loop, one slot | | `0x20403000` | `0x181` | `PAGE_READWRITE` | three other sites, one with a fixed 20 MiB | Each call commits a fresh private `PAGE_READWRITE` block of exactly the requested size (not rounded), zero-filled and released by the caller with `VirtualFree`. **Alignment:** the `MEM_LARGE_PAGES` type `0x20003000` gets a 2 MiB-aligned base (`VirtualAlloc2` with an address requirement). The `MEM_64K_PAGES` type `0x20403000` (`MEM_LARGE_PAGES | MEM_PHYSICAL` in `winnt.h`) keeps the 64 KiB granularity of `VirtualAlloc`. Sizes are not rounded to 2 MiB because two of the four pool sizes the caller requests are odd multiples of 1 MiB. Treating `MEM_LARGE_PAGES` as a 2 MiB requirement is an assumption from the desktop definition. A local run of the startup sequence showed no difference between 64 KiB-only and 2 MiB-aligned pool bases up to its next stop, so it is no evidence either way. If Windows cannot commit the block, the call returns NULL with the Windows error. Every other argument set keeps the existing `ERROR_INVALID_PARAMETER` refusal, and the reserve-only profile is unchanged. This is a **proposed desktop policy**. No independent reference describes these attribute words. Large pages themselves, the console protection bits above `PAGE_READWRITE` (`0x2000`, `0x20000`, and write-combining `0x400`) and any GPU visibility they request are not reproduced. The third configuration (call 7 in the sequence) was found by @mumba17 in their independent Windows 11 native-loader repeat on #870. Thanks for that; I added it here after reading the call sites. ## Verification Windows 10 Pro 22H2 (19045.6466), MSVC 19.44.35207.1 x64, CMake/Ninja, Python 3.13 venv. Tested head `96309447` on `main` `072e85b6`. The full release suite ran on `4f52ce68` (same change on `main` `c205cffd`); after the final rebase (no XMem file changed on `main`), the fixture and the `xmem|configure_vm|vm_translation|era_` families were rerun in both presets. New test `cpu_native_xmem_pool_commit` (`tests/cpu/xmem_pool_commit.asm` + `tests/cpu/xmem_pool_commit_check.py`). The source-built EXE imports `XMemVirtualAlloc` by name, and the same body runs under the Windows loader and from `pe_map_run`: - **Per configuration** (4 MiB, 2 MiB + 64 KiB, 1 MiB + 192 KiB): base alignment (2 MiB for the two large-page blocks, 64 KiB for the 64 KiB-page block); `VirtualQuery` base, allocation base, `MEM_COMMIT`, `PAGE_READWRITE`, `MEM_PRIVATE`; a region size equal to the requested size, with the byte just past the block outside the allocation (the 2 MiB + 64 KiB block exposes any rounding to 2 MiB); every byte reads zero; a block-specific pattern in the first and last QWORD of every 64 KiB page (so also the block's first and last QWORD) reads back; release with `VirtualFree`, after which the block reads as `MEM_FREE`. - **Ten neighbouring requests must be refused with `87`:** each type without `MEM_COMMIT`, the two pool pairs crossed, each type with a pair from the other, protection `0x2004` with `0x183`, `PAGE_READONLY` with `0x181`, the live block as the address, size 0, and size 4 MiB + 4 KiB. All three blocks keep their patterns through these calls. - **Host allocation failure:** an accepted configuration with a 128 TiB size returns NULL with a Windows error other than `87`. Here it is `ERROR_NOT_ENOUGH_MEMORY` (`8`). - **Controls, each with a known failing step under both loaders:** the first block taken from the reserve-only call (`0xF02`), the 2 MiB check applied to a 64 KiB-aligned, non-2-MiB base (`MISALIGNED`, `0xF02`), one nonzero QWORD at the end of the first block (`0xF03`), the accepted pair in place of a crossed one (`0xF0F`), a size that fits in place of the host failure (`0xF17`), and no release of the first block (`0xF19`). A provider without `XMemVirtualAlloc` stops `pe_map` at that import before entry. ```powershell cmake --build --preset dev cmake --build --preset release ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V ctest --preset dev --no-tests=error -R 'xmem|configure_vm|vm_translation|era_' ctest --preset release --no-tests=error -R 'xmem|configure_vm|vm_translation|era_' ctest --preset release --no-tests=error -j 4 .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py ``` Results: - `cpu_native_xmem_pool_commit`: `original` `0x870` and every control at its expected code under both loaders; missing provider `unresolved import xmem.dll!XMemVirtualAlloc`. - dev and release `xmem|configure_vm|vm_translation|era_`: 55 passed, 0 failed in each, plus **1 capability skip** (`vm_translation_range_warp` on in-box WARP 10.0.19041, as documented). - Full release suite (on `4f52ce68`): 638 tests: 577 passed, 54 capability skips (reported separately), 7 failed, none in a test that exercises this change. Four were `_hardware` timeouts under `-j 4` (`compute_store_aot_hardware`, `compute_store_aot_guard_read_hardware`, `compute_store_aot_lds_private_hardware`, `pixel_aot_blend_scalar_hardware`) and all four passed when rerun serially (19 to 30 s each) on the RTX 3060 (driver 32.0.15.9636, debug layer on). `gpu_alias_lookup_writes_warp` and `pixel_aot_title_loads_warp` fail on in-box WARP 10.0.19041 in `offscreen_check`, which does not link `xmem_shim` (the first prints the documented array-atomics adapter defect). `pe_package_import_closure` needs symlink privilege, which this account lacks (`WinError 1314`). - Docs link and bidi checks pass. **Shim mutations** (local, not committed). Each was caught under both loaders, and the restored shim passes: - 64 KiB-only pool base: step 2 (`0xF02`); - pool size rounded up to 2 MiB: step 6 (`0xF06`); - no 64 KiB size check: step 22 (`0xF16`); - host failure reported as `87`: step 23 (`0xF17`); - commit only the first 64 KiB: step 2 (`0xF02`). **Which validator each refusal reaches.** With the commit profile's pair check forced to accept, steps 15 to 19 are accepted, so those refusals come from the new pair check. Steps 13, 14 and 20 stay refused, so they come from the reserve-only validator, and step 22 comes from the 64 KiB check (mutation above). The size-0 case (step 21) matches what `VirtualAlloc` returns for size 0 on its own, so it does not isolate the shim's check. `xmem_commit_protection` still passes. Its `MEM_COMMIT` variant (type `0x20403000` with attribute `0x21`) remains refused, and its header comment now describes both profiles. ## Evidence and follow-up - **Local checkpoint** (private, local harness, not in the repository; API names and codes only): with this change, all seven startup `XMemVirtualAlloc` calls succeed (two reservations, four pool slots, then the 20 MiB block), and no missing-import stub is reached. - **Not established:** what follows these allocations. Under the repository's trap runner (#1075/#1085), the next stop after the seven allocations is the trap on `xcrdapi.dll!DStorageGetFactory`. An earlier private harness crashed after that point instead, and that is not part of this PR. - What the console does with these attribute and protection bits, and whether any of these blocks must be GPU-visible, remain open. - **Overlap**, checked against the open PRs right before pushing: only #888 (draft, reserve-only, other files) mentions `XMemVirtualAlloc`, and it does not change this function or add this test. AI-assisted (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:46:17 +00:00
Holastor commented 2026-11-24 06:46:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-24T01:10:15Z.

Review: APPROVED


Independent Windows 11 run and review.

Environment

  • OS: Windows 11 Pro x64 (build 26100.3037)
  • Compiler: Visual Studio 2026 Developer PowerShell v18.11.4 (MSVC 19.51.36263.0)
  • CMake: 4.3.1 / Ninja 1.13.0
  • Python: 3.11 (out/pe-env)
  • Tested Commit: 36e010f1 (branch runtime/xmem-reserve-commit)

Verification & Test Results

Dev Preset:

cmake --build --preset dev --target pe_map xmem_shim cpu_exe_io cpu_xmem_pool_original cpu_xmem_pool_reserve_only cpu_xmem_pool_dirty cpu_xmem_pool_accepted_refusal cpu_xmem_pool_host_fit cpu_xmem_pool_skip_release xmem_commit_protection_check xmem_committed_memory_check
ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V
ctest --preset dev --no-tests=error -R 'xmem|configure_vm'
  • cpu_native_xmem_pool_commit: Passed (0.76 sec).
    • original: Windows launch 0x870, pe_map 0x870.
    • reserve_only: Windows launch 0xf02, pe_map 0xf02.
    • dirty: Windows launch 0xf03, pe_map 0xf03.
    • accepted_refusal: Windows launch 0xf0f, pe_map 0xf0f.
    • host_fit: Windows launch 0xf17, pe_map 0xf17.
    • skip_release: Windows launch 0xf19, pe_map 0xf19.
    • provider without XMemVirtualAlloc: caught before entry with unresolved import xmem.dll!XMemVirtualAlloc.
  • 26 of 26 tests in xmem|configure_vm passed (100% pass, real time 6.20s).

Release Preset:

cmake --build --preset release --target pe_map xmem_shim cpu_exe_io cpu_xmem_pool_original cpu_xmem_pool_reserve_only cpu_xmem_pool_dirty cpu_xmem_pool_accepted_refusal cpu_xmem_pool_host_fit cpu_xmem_pool_skip_release xmem_commit_protection_check xmem_committed_memory_check cpu_xmem_delay cpu_configure_vm_4 cpu_xmem_attributes cpu_configure_vm_3 cpu_xmem_physical_original cpu_xmem_physical_full_count cpu_xmem_physical_skip_release cpu_xmem_default_original cpu_xmem_default_skip_gpu_free cpu_xmem_default_skip_heap_free cpu_xmem_default_uninduced cpu_heap_probe
ctest --preset release --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V
ctest --preset release --no-tests=error -R 'xmem|configure_vm'
  • cpu_native_xmem_pool_commit: Passed (0.72 sec), identical exit codes and provider observations.
  • 26 of 26 tests in xmem|configure_vm passed (100% pass, real time 5.75s).

Linters & Documentation:

./out/pe-env/Scripts/python.exe -B tests/docs_links_check.py
# Self-test passed. Checked 15 Markdown files and 245 links.

./out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py
# Self-test passed. Checked 923 tracked source, script and build/CI files: no bidirectional controls.

The three startup configurations, the 10 neighbouring argument refusals, host error propagation, and all negative controls reproduce reliably across both loaders.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032098771 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#pullrequestreview-6032098771). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-24T01:10:15Z. **Review:** APPROVED --- Independent Windows 11 run and review. ### Environment - **OS:** Windows 11 Pro x64 (build 26100.3037) - **Compiler:** Visual Studio 2026 Developer PowerShell v18.11.4 (MSVC 19.51.36263.0) - **CMake:** 4.3.1 / Ninja 1.13.0 - **Python:** 3.11 (`out/pe-env`) - **Tested Commit:** `36e010f1` (branch `runtime/xmem-reserve-commit`) ### Verification & Test Results **Dev Preset:** ```powershell cmake --build --preset dev --target pe_map xmem_shim cpu_exe_io cpu_xmem_pool_original cpu_xmem_pool_reserve_only cpu_xmem_pool_dirty cpu_xmem_pool_accepted_refusal cpu_xmem_pool_host_fit cpu_xmem_pool_skip_release xmem_commit_protection_check xmem_committed_memory_check ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V ctest --preset dev --no-tests=error -R 'xmem|configure_vm' ``` - `cpu_native_xmem_pool_commit`: **Passed** (0.76 sec). - `original`: Windows launch `0x870`, `pe_map` `0x870`. - `reserve_only`: Windows launch `0xf02`, `pe_map` `0xf02`. - `dirty`: Windows launch `0xf03`, `pe_map` `0xf03`. - `accepted_refusal`: Windows launch `0xf0f`, `pe_map` `0xf0f`. - `host_fit`: Windows launch `0xf17`, `pe_map` `0xf17`. - `skip_release`: Windows launch `0xf19`, `pe_map` `0xf19`. - `provider without XMemVirtualAlloc`: caught before entry with `unresolved import xmem.dll!XMemVirtualAlloc`. - 26 of 26 tests in `xmem|configure_vm` passed (100% pass, real time 6.20s). **Release Preset:** ```powershell cmake --build --preset release --target pe_map xmem_shim cpu_exe_io cpu_xmem_pool_original cpu_xmem_pool_reserve_only cpu_xmem_pool_dirty cpu_xmem_pool_accepted_refusal cpu_xmem_pool_host_fit cpu_xmem_pool_skip_release xmem_commit_protection_check xmem_committed_memory_check cpu_xmem_delay cpu_configure_vm_4 cpu_xmem_attributes cpu_configure_vm_3 cpu_xmem_physical_original cpu_xmem_physical_full_count cpu_xmem_physical_skip_release cpu_xmem_default_original cpu_xmem_default_skip_gpu_free cpu_xmem_default_skip_heap_free cpu_xmem_default_uninduced cpu_heap_probe ctest --preset release --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V ctest --preset release --no-tests=error -R 'xmem|configure_vm' ``` - `cpu_native_xmem_pool_commit`: **Passed** (0.72 sec), identical exit codes and provider observations. - 26 of 26 tests in `xmem|configure_vm` passed (100% pass, real time 5.75s). **Linters & Documentation:** ```powershell ./out/pe-env/Scripts/python.exe -B tests/docs_links_check.py # Self-test passed. Checked 15 Markdown files and 245 links. ./out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py # Self-test passed. Checked 923 tracked source, script and build/CI files: no bidirectional controls. ``` The three startup configurations, the 10 neighbouring argument refusals, host error propagation, and all negative controls reproduce reliably across both loaders.
R0Y00 commented 2026-11-24 06:46:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:18:47Z.

Review: CHANGES_REQUESTED


One boundary to settle before merging: the fixture currently requires only 64 KiB address alignment for the pool allocations. The existing commit comparison already exercises a separate 2 MiB-aligned profile. Please confirm which alignment these pool requests need and add a source-built test that would reject a 64 KiB-aligned but non-2-MiB base if 2 MiB is required. Also pin the reported size to the chosen byte-rounding policy, so the fixture distinguishes host page rounding from the requested guest alignment. Keep the independent later 64 KiB case and the existing refusal controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032177681 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#pullrequestreview-6032177681). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:18:47Z. **Review:** CHANGES_REQUESTED --- One boundary to settle before merging: the fixture currently requires only 64 KiB address alignment for the pool allocations. The existing commit comparison already exercises a separate 2 MiB-aligned profile. Please confirm which alignment these pool requests need and add a source-built test that would reject a 64 KiB-aligned but non-2-MiB base if 2 MiB is required. Also pin the reported size to the chosen byte-rounding policy, so the fixture distinguishes host page rounding from the requested guest alignment. Keep the independent later 64 KiB case and the existing refusal controls.
R0Y00 commented 2026-11-24 06:46:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T02:24:24Z.

Review: APPROVED


The updated allocation profile passed 10/10 Windows Release checks. The source-built EXE agrees under the Windows loader and pe_map. The deliberately 64 KiB-aligned but non-2 MiB-aligned control hits the expected failure marker, and the 2 MiB plus 64 KiB allocation has the exact requested span. I added a documentation-only commit to describe the independently reproducible evidence and the Windows alignment policy. The branch now needs CI on that exact commit.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032723295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#pullrequestreview-6032723295). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T02:24:24Z. **Review:** APPROVED --- The updated allocation profile passed 10/10 Windows Release checks. The source-built EXE agrees under the Windows loader and pe_map. The deliberately 64 KiB-aligned but non-2 MiB-aligned control hits the expected failure marker, and the 2 MiB plus 64 KiB allocation has the exact requested span. I added a documentation-only commit to describe the independently reproducible evidence and the Windows alignment policy. The branch now needs CI on that exact commit.
R0Y00 commented 2026-11-24 06:50:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:12:39Z.


Maintainer verification of the source-built fixture

I ran Windows Release on the current candidate 36e010f1:

ctest --preset release --no-tests=error -R '^(xmem_commit_protection|cpu_native_xmem_pool_commit|xmem_committed_memory)' -V

10/10 passed. The original fixture returned the same success code under Windows and pe_map. All five deliberately incorrect variants hit their expected failure markers and the missing provider was rejected before entry. The separate protection checks also preserved the supported reserve and refusal behavior. This is evidence for the shim and source-built fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118871062 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#issuecomment-7118871062). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:12:39Z. --- ### Maintainer verification of the source-built fixture I ran Windows Release on the current candidate `36e010f1`: ```powershell ctest --preset release --no-tests=error -R '^(xmem_commit_protection|cpu_native_xmem_pool_commit|xmem_committed_memory)' -V ``` 10/10 passed. The original fixture returned the same success code under Windows and pe_map. All five deliberately incorrect variants hit their expected failure markers and the missing provider was rejected before entry. The separate protection checks also preserved the supported reserve and refusal behavior. This is evidence for the shim and source-built fixture.
mumba17 commented 2026-11-24 06:50:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-24T01:29:56Z.


Main-executable retest of this branch through the repository runner only, now that #1075 and #1085 are merged. No private harness and no local xmem.dll patch.

Environment: Windows 11 Pro build 26300, MSVC 19.44.35207.1 x64, dev preset, NVIDIA RTX 3090 (driver 32.0.16.1664). Runner and pe_map.dll from main at a7710b7, xmem.dll built from this branch at 36e010f1, and d3d12_xs.dll from main.

python -B tools/pe_run_package.py out/build/dev/pe_map.dll <package> <main exe> `
  --shim xmem.dll <xmem.dll> --shim d3d12_xs.dll <d3d12_xs.dll> `
  --system <each of the 79 System32 / API-set imports> `
  --trap-callable <dll>!<symbol>   # once for each of the 22 missing function imports
xmem.dll Result (2 of 2 runs identical)
main at a7710b7 0x80000003 after about 3 s, at the refused reserve+commit request; no trap reached
this branch at 36e010f1 trap 20, xcrdapi.dll!DStorageGetFactory, exit 0xE7A00014 after about 1.8 s

With this branch the run gets past the whole memory setup under pe_map and stops at the first missing function import. That matches the boundary in my native-loader checkpoint, where I used a lenient local xmem.dll, and it is now reproducible from the repository. The runner does not log the individual XMemVirtualAlloc calls, so this establishes the boundary, not which of the three profiles each call used.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119157876 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#issuecomment-7119157876). Originally posted by [mumba17](https://github.com/mumba17) on 2026-11-24T01:29:56Z. --- Main-executable retest of this branch through the repository runner only, now that #1075 and #1085 are merged. No private harness and no local `xmem.dll` patch. **Environment:** Windows 11 Pro build 26300, MSVC 19.44.35207.1 x64, `dev` preset, NVIDIA RTX 3090 (driver 32.0.16.1664). Runner and `pe_map.dll` from `main` at `a7710b7`, `xmem.dll` built from this branch at `36e010f1`, and `d3d12_xs.dll` from `main`. ```powershell python -B tools/pe_run_package.py out/build/dev/pe_map.dll <package> <main exe> ` --shim xmem.dll <xmem.dll> --shim d3d12_xs.dll <d3d12_xs.dll> ` --system <each of the 79 System32 / API-set imports> ` --trap-callable <dll>!<symbol> # once for each of the 22 missing function imports ``` | `xmem.dll` | Result (2 of 2 runs identical) | | --- | --- | | `main` at `a7710b7` | `0x80000003` after about 3 s, at the refused reserve+commit request; no trap reached | | this branch at `36e010f1` | trap 20, `xcrdapi.dll!DStorageGetFactory`, exit `0xE7A00014` after about 1.8 s | With this branch the run gets past the whole memory setup under `pe_map` and stops at the first missing function import. That matches the boundary in my native-loader checkpoint, where I used a lenient local `xmem.dll`, and it is now reproducible from the repository. The runner does not log the individual `XMemVirtualAlloc` calls, so this establishes the boundary, not which of the three profiles each call used. AI-assisted (Claude Code).
rasptum commented 2026-11-24 06:50:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T02:02:53Z.


@R0Y00 thanks. Addressed in a new commit on top; the branch head is now 96309447 on main 072e85b6.

1. Which alignment the pool requests need. The evidence:

  • The Windows SDK winnt.h (10.0.26100) defines MEM_LARGE_PAGES as 0x20000000 and MEM_64K_PAGES as MEM_LARGE_PAGES | MEM_PHYSICAL (0x20400000, already era_physical::mem_64k_pages here). So the pool type 0x20003000 asks for MEM_LARGE_PAGES (2 MiB on desktop x64), and the later type 0x20403000 asks for 64 KiB pages.
  • Two of the four pool sizes the caller requests are odd multiples of 1 MiB (0x89700000, 0x23300000), so they are not 2 MiB multiples. The other two are multiples of 4 MiB.
  • A local run of the startup sequence (under the trap runner from #1075/#1085) gives no evidence either way. With 64 KiB-only pool bases, which were 2 MiB-aligned by chance in 2 of 12 cases, and with forced 2 MiB bases, every run reached the same next stop (xcrdapi.dll!DStorageGetFactory) with no difference before it.

Chosen policy (desktop policy, an assumption from the desktop definition of MEM_LARGE_PAGES; the console's own alignment for this type is not established):

  • 0x20003000: 2 MiB-aligned base, from VirtualAlloc2 with an address requirement.
  • 0x20403000: unchanged, the 64 KiB granularity of VirtualAlloc.

2. A test that rejects a 64 KiB-aligned, non-2-MiB base. The fixture now checks 2 MiB alignment for both large-page blocks (steps 2 and 6) and only 64 KiB for the 64 KiB-page block (step 10). There are two ways to show that the check can fail:

  • New committed control MISALIGNED: applies the 2 MiB check to the first block's base + 64 KiB. Result: 0xF02 under both loaders.
  • Local shim mutant that returns a deliberately 64 KiB-aligned, non-2-MiB pool base: caught at step 2 (0xF02) under both loaders.

3. Size pinned to the rounding policy. Policy: commit exactly the requested size. It must be a nonzero multiple of 64 KiB and is not rounded to 2 MiB; a size that is not a multiple of 64 KiB is refused, not rounded to host pages (step 22).

  • Each block's VirtualQuery region size must equal the requested size, and the byte just past the block must not belong to the same allocation.
  • The second pool block is 2 MiB + 64 KiB, so rounding to 2 MiB would show. A local mutant that rounds pool sizes up to 2 MiB is caught at step 6 (0xF06).

4. Kept. The independent 64 KiB-page case (0x20403000, 0x181/PAGE_READWRITE) and all ten refusal controls, plus the host allocation failure (ERROR_NOT_ENOUGH_MEMORY) and the earlier controls.

Each refusal reaches the path the docs name: with the commit profile's pair check forced to accept, the five pair refusals were accepted and the rest stayed refused. The size-0 case also matches Windows' own refusal of a zero size, so it does not isolate the shim's check; the PR body says so.

Environment: Windows 10 Pro 22H2 (19045.6466), MSVC 19.44.35207.1 x64.

cmake --build --preset dev
cmake --build --preset release
ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V
ctest --preset dev --no-tests=error -R 'xmem|configure_vm|vm_translation|era_'
ctest --preset release --no-tests=error -R 'xmem|configure_vm|vm_translation|era_'
ctest --preset release --no-tests=error -j 4
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py

Results: full release suite on 4f52ce68; everything else rerun on the final head 96309447 after rebasing past 25 unrelated main commits.

  • cpu_native_xmem_pool_commit: original 0x870 under both loaders. Controls: reserve_only 0xF02, misaligned 0xF02, dirty 0xF03, accepted_refusal 0xF0F, host_fit 0xF17, skip_release 0xF19. Missing provider stops at unresolved import xmem.dll!XMemVirtualAlloc.
  • dev and release xmem|configure_vm|vm_translation|era_: 55 passed, 0 failed in each, plus 1 capability skip (vm_translation_range_warp, in-box WARP 10.0.19041).
  • Full release suite (on 4f52ce68): 638 tests: 577 passed, 54 capability skips (reported separately), 7 failed, none in a test that exercises this change. Four were _hardware timeouts under -j 4 (compute_store_aot_hardware, compute_store_aot_guard_read_hardware, compute_store_aot_lds_private_hardware, pixel_aot_blend_scalar_hardware) and all four passed when rerun serially (19 to 30 s each) on the RTX 3060 (driver 32.0.15.9636, debug layer on). gpu_alias_lookup_writes_warp and pixel_aot_title_loads_warp fail on in-box WARP 10.0.19041 in offscreen_check, which does not link xmem_shim (the first prints the documented array-atomics adapter defect). pe_package_import_closure needs symlink privilege, which this account lacks (WinError 1314).
  • Docs links and bidi checks pass.

Local shim mutants (not committed), each caught under both loaders and the restored shim passing:

Mutant Caught at
64 KiB-only pool base step 2 (0xF02)
pool size rounded up to 2 MiB step 6 (0xF06)
no 64 KiB size check step 22 (0xF16)
host failure reported as 87 step 23 (0xF17)
commit only the first 64 KiB step 2 (0xF02)

Overlap, checked right before pushing: only #888 (draft, reserve-only, other files) mentions XMemVirtualAlloc.

AI-assisted (Claude).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119702520 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1098#issuecomment-7119702520). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-24T02:02:53Z. --- @R0Y00 thanks. Addressed in a new commit on top; the branch head is now `96309447` on `main` `072e85b6`. **1. Which alignment the pool requests need.** The evidence: - The Windows SDK `winnt.h` (10.0.26100) defines `MEM_LARGE_PAGES` as `0x20000000` and `MEM_64K_PAGES` as `MEM_LARGE_PAGES | MEM_PHYSICAL` (`0x20400000`, already `era_physical::mem_64k_pages` here). So the pool type `0x20003000` asks for `MEM_LARGE_PAGES` (2 MiB on desktop x64), and the later type `0x20403000` asks for 64 KiB pages. - Two of the four pool sizes the caller requests are odd multiples of 1 MiB (`0x89700000`, `0x23300000`), so they are not 2 MiB multiples. The other two are multiples of 4 MiB. - A local run of the startup sequence (under the trap runner from #1075/#1085) gives no evidence either way. With 64 KiB-only pool bases, which were 2 MiB-aligned by chance in 2 of 12 cases, and with forced 2 MiB bases, every run reached the same next stop (`xcrdapi.dll!DStorageGetFactory`) with no difference before it. Chosen policy (desktop policy, an assumption from the desktop definition of `MEM_LARGE_PAGES`; the console's own alignment for this type is not established): - `0x20003000`: 2 MiB-aligned base, from `VirtualAlloc2` with an address requirement. - `0x20403000`: unchanged, the 64 KiB granularity of `VirtualAlloc`. **2. A test that rejects a 64 KiB-aligned, non-2-MiB base.** The fixture now checks 2 MiB alignment for both large-page blocks (steps 2 and 6) and only 64 KiB for the 64 KiB-page block (step 10). There are two ways to show that the check can fail: - New committed control `MISALIGNED`: applies the 2 MiB check to the first block's base + 64 KiB. Result: `0xF02` under both loaders. - Local shim mutant that returns a deliberately 64 KiB-aligned, non-2-MiB pool base: caught at step 2 (`0xF02`) under both loaders. **3. Size pinned to the rounding policy.** Policy: commit exactly the requested size. It must be a nonzero multiple of 64 KiB and is not rounded to 2 MiB; a size that is not a multiple of 64 KiB is refused, not rounded to host pages (step 22). - Each block's `VirtualQuery` region size must equal the requested size, and the byte just past the block must not belong to the same allocation. - The second pool block is 2 MiB + 64 KiB, so rounding to 2 MiB would show. A local mutant that rounds pool sizes up to 2 MiB is caught at step 6 (`0xF06`). **4. Kept.** The independent 64 KiB-page case (`0x20403000`, `0x181`/`PAGE_READWRITE`) and all ten refusal controls, plus the host allocation failure (`ERROR_NOT_ENOUGH_MEMORY`) and the earlier controls. Each refusal reaches the path the docs name: with the commit profile's pair check forced to accept, the five pair refusals were accepted and the rest stayed refused. The size-0 case also matches Windows' own refusal of a zero size, so it does not isolate the shim's check; the PR body says so. **Environment:** Windows 10 Pro 22H2 (19045.6466), MSVC 19.44.35207.1 x64. ```powershell cmake --build --preset dev cmake --build --preset release ctest --preset dev --no-tests=error -R '^cpu_native_xmem_pool_commit$' -V ctest --preset dev --no-tests=error -R 'xmem|configure_vm|vm_translation|era_' ctest --preset release --no-tests=error -R 'xmem|configure_vm|vm_translation|era_' ctest --preset release --no-tests=error -j 4 .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py ``` **Results:** full release suite on `4f52ce68`; everything else rerun on the final head `96309447` after rebasing past 25 unrelated `main` commits. - `cpu_native_xmem_pool_commit`: `original` `0x870` under both loaders. Controls: `reserve_only` `0xF02`, `misaligned` `0xF02`, `dirty` `0xF03`, `accepted_refusal` `0xF0F`, `host_fit` `0xF17`, `skip_release` `0xF19`. Missing provider stops at `unresolved import xmem.dll!XMemVirtualAlloc`. - dev and release `xmem|configure_vm|vm_translation|era_`: 55 passed, 0 failed in each, plus 1 capability skip (`vm_translation_range_warp`, in-box WARP 10.0.19041). - Full release suite (on `4f52ce68`): 638 tests: 577 passed, 54 capability skips (reported separately), 7 failed, none in a test that exercises this change. Four were `_hardware` timeouts under `-j 4` (`compute_store_aot_hardware`, `compute_store_aot_guard_read_hardware`, `compute_store_aot_lds_private_hardware`, `pixel_aot_blend_scalar_hardware`) and all four passed when rerun serially (19 to 30 s each) on the RTX 3060 (driver 32.0.15.9636, debug layer on). `gpu_alias_lookup_writes_warp` and `pixel_aot_title_loads_warp` fail on in-box WARP 10.0.19041 in `offscreen_check`, which does not link `xmem_shim` (the first prints the documented array-atomics adapter defect). `pe_package_import_closure` needs symlink privilege, which this account lacks (`WinError 1314`). - Docs links and bidi checks pass. **Local shim mutants** (not committed), each caught under both loaders and the restored shim passing: | Mutant | Caught at | |---|---| | 64 KiB-only pool base | step 2 (`0xF02`) | | pool size rounded up to 2 MiB | step 6 (`0xF06`) | | no 64 KiB size check | step 22 (`0xF16`) | | host failure reported as `87` | step 23 (`0xF17`) | | commit only the first 64 KiB | step 2 (`0xF02`) | **Overlap**, checked right before pushing: only #888 (draft, reserve-only, other files) mentions `XMemVirtualAlloc`. AI-assisted (Claude).
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
R0Y00/Xbox2Windows!1091
No description provided.