runtime: add an independent physical-page fixture for #880 #880

Closed
triggered02 wants to merge 2 commits from upstream-pr/887 into main
triggered02 commented 2026-11-23 15:54:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T15:54:34Z.


Draft for coordination. rasptum owns #880, and the maintainer asked to coordinate before adding another XMem shim implementation. This PR is the independent source-built fixture and negative-control offer from #880; the shim code is the local probe I used to prove the import can be passed, not a proposal to supersede rasptum's implementation.

Refs #880 and #870. Builds on the merged #879.

Change

Adds a source-built physical-page fixture for the desktop xmem.dll allocation pair:

  • cpu_xmem_physical.exe imports XMemAllocatePhysicalPages and XMemFreePhysicalPages by name. The same EXE runs under the Windows loader and pe_map, and the exit codes are compared.
  • The unit scenario checks valid 64 KiB allocate/release, in/out count, distinct nonzero PFNs, refusals for a null count, null array, large-page count not divisible by 32 and a count above the desktop cap, plus double free, unknown PFN and duplicate PFN. Refusals pre-fill the PFN array with canaries and require it unchanged.
  • The missing-provider control fails before entry on the first xmem import in table order.
  • src/xmem_shim.cpp/.def contain the local probe implementation used by the fixture. They are not proposed as the #880 implementation.

Verification

Windows 11 Pro 26200, MSVC 19.52, DXC 10.0.26100, CMake/Ninja, Ryzen 5 5500 (GPU not used).

ctest --preset dev --no-tests=error -R '^xmem_shim_(exports|allocation|default_allocation|physical_pages|query)$|^cpu_native_xmem_physical$' --output-on-failure

Dev: 6/6 passed.

ctest --preset release --no-tests=error -R '^xmem_shim_(exports|allocation|default_allocation|physical_pages|query)$|^cpu_native_xmem_physical$' --output-on-failure

Release: 6/6 passed. The existing cpu_native_shim_startup also passes in Release after the shim change.

python -B tests/docs_links_check.py (13 files, 179 links), python -B tests/bidi_controls_check.py (709 files) and git diff --check pass.

Evidence and follow-up

  • The fixture is source-built and MIT-licensed, with no game files.
  • The local shim behavior follows the public reimplementation evidence at omonkeyz/xbox-emulator f89e410, crates/compat/xmem/src/virt.rs (GPL-3.0; behavior only, no code copied). It is not an official ABI.
  • The Microsoft GDK samples linked in #880 establish the 64 KiB allocate/free pairing, the in/out count and page array, and the Boolean result.
  • Remaining open: mapped-page lifetime (mapping/scatter/transfer are out of scope), the public PFN range, 4 KiB page support, flag meanings beyond page size, and exact console error-code parity.
  • Once rasptum's #880 implementation lands, I will rebase and reduce this PR to the fixture and negative controls, or close it in favour of theirs.

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 README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6563206184 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/887). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T15:54:34Z. --- Draft for coordination. rasptum owns #880, and the maintainer asked to coordinate before adding another XMem shim implementation. This PR is the independent source-built fixture and negative-control offer from #880; the shim code is the local probe I used to prove the import can be passed, not a proposal to supersede rasptum's implementation. Refs #880 and #870. Builds on the merged #879. ## Change Adds a source-built physical-page fixture for the desktop `xmem.dll` allocation pair: - `cpu_xmem_physical.exe` imports `XMemAllocatePhysicalPages` and `XMemFreePhysicalPages` by name. The same EXE runs under the Windows loader and `pe_map`, and the exit codes are compared. - The unit scenario checks valid 64 KiB allocate/release, in/out count, distinct nonzero PFNs, refusals for a null count, null array, large-page count not divisible by 32 and a count above the desktop cap, plus double free, unknown PFN and duplicate PFN. Refusals pre-fill the PFN array with canaries and require it unchanged. - The missing-provider control fails before entry on the first xmem import in table order. - `src/xmem_shim.cpp`/`.def` contain the local probe implementation used by the fixture. They are not proposed as the #880 implementation. ## Verification Windows 11 Pro 26200, MSVC 19.52, DXC 10.0.26100, CMake/Ninja, Ryzen 5 5500 (GPU not used). ```powershell ctest --preset dev --no-tests=error -R '^xmem_shim_(exports|allocation|default_allocation|physical_pages|query)$|^cpu_native_xmem_physical$' --output-on-failure ``` Dev: 6/6 passed. ```powershell ctest --preset release --no-tests=error -R '^xmem_shim_(exports|allocation|default_allocation|physical_pages|query)$|^cpu_native_xmem_physical$' --output-on-failure ``` Release: 6/6 passed. The existing `cpu_native_shim_startup` also passes in Release after the shim change. `python -B tests/docs_links_check.py` (13 files, 179 links), `python -B tests/bidi_controls_check.py` (709 files) and `git diff --check` pass. ## Evidence and follow-up - The fixture is source-built and MIT-licensed, with no game files. - The local shim behavior follows the public reimplementation evidence at omonkeyz/xbox-emulator `f89e410`, `crates/compat/xmem/src/virt.rs` (GPL-3.0; behavior only, no code copied). It is not an official ABI. - The Microsoft GDK samples linked in #880 establish the 64 KiB allocate/free pairing, the in/out count and page array, and the Boolean result. - Remaining open: mapped-page lifetime (mapping/scatter/transfer are out of scope), the public PFN range, 4 KiB page support, flag meanings beyond page size, and exact console error-code parity. - Once rasptum's #880 implementation lands, I will rebase and reduce this PR to the fixture and negative controls, or close it in favour of theirs. ## 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 README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:15 +00:00
R0Y00 commented 2026-11-24 06:49:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:58:03Z.


Thanks for making the same-EXE comparison available. For the fixture-only follow-up, the stable fixture baseline is the 64 KiB pair imported by name, the successful in/out count and release, and the omitted-provider control before entry. Keep the canary check with the agreed failure policy. The draft currently accepts zero pages and exercises a large-page success case, while #880 starts with 64 KiB. Please keep those prototype-specific expectations, LastError values and PFN-number restrictions out of the common fixture unless the accepted implementation explicitly promises them.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106397871 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/887#issuecomment-7106397871). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:58:03Z. --- Thanks for making the same-EXE comparison available. For the fixture-only follow-up, the stable fixture baseline is the 64 KiB pair imported by name, the successful in/out count and release, and the omitted-provider control before entry. Keep the canary check with the agreed failure policy. The draft currently accepts zero pages and exercises a large-page success case, while #880 starts with 64 KiB. Please keep those prototype-specific expectations, LastError values and PFN-number restrictions out of the common fixture unless the accepted implementation explicitly promises them.
triggered02 commented 2026-11-24 06:49:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T16:01:36Z.


Thanks. Agreed. Once rasptum's #880 lands, I'll rebase this to the fixture-only follow-up and remove the local shim. The common fixture will keep only the stable baseline:

  • 64 KiB pair imported by name;
  • successful in/out count and release;
  • the omitted-provider control before entry;
  • one canary refusal using a refused flag under the accepted failure policy, with count 0 and the array untouched.

I'll drop the zero-page acceptance, the large-page success case, and the prototype-specific LastError and PFN-value assertions. If #880's accepted failure policy differs, I'll use that instead.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106489942 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/887#issuecomment-7106489942). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T16:01:36Z. --- Thanks. Agreed. Once rasptum's #880 lands, I'll rebase this to the fixture-only follow-up and remove the local shim. The common fixture will keep only the stable baseline: - 64 KiB pair imported by name; - successful in/out count and release; - the omitted-provider control before entry; - one canary refusal using a refused flag under the accepted failure policy, with count 0 and the array untouched. I'll drop the zero-page acceptance, the large-page success case, and the prototype-specific LastError and PFN-value assertions. If #880's accepted failure policy differs, I'll use that instead. AI-assisted.
triggered02 commented 2026-11-24 06:49:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-23T16:19:28Z.


Superseded by #892, which now includes the independent source-built comparison, canary-on-refusal checks, missing-provider control and the physical-page policy. Closing this draft to avoid duplicate review; the xmem-physical-pages branch stays available for reference.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7106958009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/887#issuecomment-7106958009). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-23T16:19:28Z. --- Superseded by #892, which now includes the independent source-built comparison, canary-on-refusal checks, missing-provider control and the physical-page policy. Closing this draft to avoid duplicate review; the `xmem-physical-pages` branch stays available for reference.

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
R0Y00/Xbox2Windows!880
No description provided.