runtime: test aligned committed CPU memory on Windows #967

Merged
Jess-Doit merged 1 commit from upstream-pr/974 into main 2026-11-23 19:40:33 +00:00
Jess-Doit commented 2026-11-23 19:23:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-23T19:23:56Z.


Change

Refs #870. Add the aligned committed CPU memory fixture requested in the startup thread.

The fixture reserves three ordinary Windows pages at each guest alignment, 64 KiB and 2 MiB. It commits a non-page-multiple request, checks the exact commit and reserved tail with VirtualQuery, and verifies every committed byte before and after a cross-page write. It then checks that the allocation is released.

Three refusal cases cover rounding overflow, unsupported protection, and a real Win32 commit beyond the reservation. Each preserves the two live pages and the reserved tail. The host failure reaches the caller as ERROR_INVALID_ADDRESS (487).

Verification

02ebdbe on Windows 10 22H2 (19045.6456), MSVC 19.44.35230 x64, Windows SDK 10.0.26100. Both presets passed 5/5 with no skips. Each alignment committed 8,192 bytes for a 4,101-byte request, checked 8,192 zero bytes and a 16-byte cross-page pattern, and released the reservation.

foreach ($preset in 'dev','release') {
    cmake --preset $preset
    cmake --build --preset $preset --target xmem_committed_memory_check memory_query_check xmem_shim_check
    ctest --preset $preset --no-tests=error -R '^(xmem_committed_memory|desktop_memory_query|xmem_shim_(exports|physical_pages|mapped_pages))$' --output-on-failure
}
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff HEAD^ HEAD --check

The source-built mutation controls failed when the fixture allowed the unsupported protection, replaced error 487 with 87, or skipped the write at byte 4,096. The documentation and diff checks passed.

Evidence and follow-up

Original MIT-licensed source in tests/xmem_committed_memory_check.cpp. The synthetic fixture checks CPU backing through the public Win32 APIs. Its protection allowlist is fixture policy. Reserve-only XMem calls and GPU registration remain with #888 and #874. See aligned committed CPU memory for an isolated reproduction.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated the experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6567064894 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/974). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-23T19:23:56Z. --- ## Change Refs #870. Add the aligned committed CPU memory fixture requested in [the startup thread](https://github.com/R0Y00/Xbox2Windows/issues/870#issuecomment-7110987734). The fixture reserves three ordinary Windows pages at each guest alignment, 64 KiB and 2 MiB. It commits a non-page-multiple request, checks the exact commit and reserved tail with VirtualQuery, and verifies every committed byte before and after a cross-page write. It then checks that the allocation is released. Three refusal cases cover rounding overflow, unsupported protection, and a real Win32 commit beyond the reservation. Each preserves the two live pages and the reserved tail. The host failure reaches the caller as ERROR_INVALID_ADDRESS (487). ## Verification `02ebdbe` on Windows 10 22H2 (19045.6456), MSVC 19.44.35230 x64, Windows SDK 10.0.26100. Both presets passed 5/5 with no skips. Each alignment committed 8,192 bytes for a 4,101-byte request, checked 8,192 zero bytes and a 16-byte cross-page pattern, and released the reservation. ```powershell foreach ($preset in 'dev','release') { cmake --preset $preset cmake --build --preset $preset --target xmem_committed_memory_check memory_query_check xmem_shim_check ctest --preset $preset --no-tests=error -R '^(xmem_committed_memory|desktop_memory_query|xmem_shim_(exports|physical_pages|mapped_pages))$' --output-on-failure } python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py git diff HEAD^ HEAD --check ``` The source-built mutation controls failed when the fixture allowed the unsupported protection, replaced error 487 with 87, or skipped the write at byte 4,096. The documentation and diff checks passed. ## Evidence and follow-up Original MIT-licensed source in `tests/xmem_committed_memory_check.cpp`. The synthetic fixture checks CPU backing through the public Win32 APIs. Its protection allowlist is fixture policy. Reserve-only XMem calls and GPU registration remain with #888 and #874. See [aligned committed CPU memory](docs/experiments.md#aligned-committed-cpu-memory) for an isolated reproduction. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated the experiment documentation. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Codex).
upstream-sync closed this pull request 2026-11-24 06:45:39 +00:00
legacy-code-archaeologist commented 2026-11-24 06:49:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-23T19:43:41Z.


Independent run of 02ebdbe on Windows 11 (Windows 10 was the only OS so far): Windows 11 Pro 26100, Intel Core i7-6820HQ, MSVC 19.52, dev preset. The head merges cleanly with main at 23d2e93 (git merge-tree).

ctest --preset dev --no-tests=error -R '^xmem_committed_memory$' -V

The fixture passes with the same values at both alignments:

alignment=65536 requested=4101 committed=8192 zero_fill=8192 cross_page=16 released=1
refused overflow=534 protection=87 host_error=487 with existing pages unchanged
alignment=2097152 requested=4101 committed=8192 zero_fill=8192 cross_page=16 released=1
refused overflow=534 protection=87 host_error=487 with existing pages unchanged

The wider selection ^(xmem_|era_heap|desktop_memory_query) passes 22/22, with no skips. I did not run the release preset here.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112016397 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/974#issuecomment-7112016397). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-23T19:43:41Z. --- Independent run of `02ebdbe` on Windows 11 (Windows 10 was the only OS so far): Windows 11 Pro 26100, Intel Core i7-6820HQ, MSVC 19.52, `dev` preset. The head merges cleanly with `main` at `23d2e93` (`git merge-tree`). ```powershell ctest --preset dev --no-tests=error -R '^xmem_committed_memory$' -V ``` The fixture passes with the same values at both alignments: ```text alignment=65536 requested=4101 committed=8192 zero_fill=8192 cross_page=16 released=1 refused overflow=534 protection=87 host_error=487 with existing pages unchanged alignment=2097152 requested=4101 committed=8192 zero_fill=8192 cross_page=16 released=1 refused overflow=534 protection=87 host_error=487 with existing pages unchanged ``` The wider selection `^(xmem_|era_heap|desktop_memory_query)` passes 22/22, with no skips. I did not run the `release` preset here. AI-assisted (Claude Code).
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!967
No description provided.