runtime: reserve startup address space through XMemVirtualAlloc #888

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

@⁠descent81 on GitHub · 2026-11-23 16:07 UTC · original
descent81:runtime/xmem-startup-reservation → main · +139 −4 · 8 files · 1 commits · draft

Refs #870 and #874. The export table is shared with #880. This is a draft for comparison while that work and the current startup integration settle.

The startup investigation in #874 identified two reserve-only call shapes immediately after graphics virtual-memory configuration. This adds a named XMemVirtualAlloc export for those shapes. The desktop implementation accepts a null base, a 16 or 24 GiB size, and the two reported attribute/protection pairs. It reserves uncommitted address space with Win32 and rejects other input combinations with ERROR_INVALID_PARAMETER. This is a proposed desktop policy for those calls. The existing six export ordinals are preserved.

Verification

Windows x64, MSVC 19.50, base 7198727, tested at b29089c. The source-built EXE imports the new function by name and runs under both the Windows loader and pe_map. It checks the exact size, alignment and state of both live reservations at each size. Unsupported requests must leave both regions intact. The test releases both ranges and confirms it can reserve a released address again. The missing-provider control stops at IAT binding before entry.

Run for both dev and release (replace the preset in both commands):

cmake --build --preset dev --target cpu_xmem_reservation xmem_shim_check pe_map cpu_shim_startup_lifted
ctest --preset dev --no-tests=error -R '^(cpu_native_xmem_reservation|xmem_shim_(exports|allocation|default_allocation|query)|cpu_native_shim_startup|docs_links)$' --output-on-failure

7 passed in Debug and 7 passed in Release, zero skips. The fixture uses only source-built inputs. Later commit and physical-page mapping are outside this reserve-only profile. No title entry was exercised.

AI-assisted.

**@⁠descent81** on GitHub · 2026-11-23 16:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/888) `descent81:runtime/xmem-startup-reservation` → `main` · +139 −4 · 8 files · 1 commits · draft Refs #870 and #874. The export table is shared with #880. This is a draft for comparison while that work and the current startup integration settle. The startup investigation in #874 identified two reserve-only call shapes immediately after graphics virtual-memory configuration. This adds a named `XMemVirtualAlloc` export for those shapes. The desktop implementation accepts a null base, a 16 or 24 GiB size, and the two reported attribute/protection pairs. It reserves uncommitted address space with Win32 and rejects other input combinations with `ERROR_INVALID_PARAMETER`. This is a proposed desktop policy for those calls. The existing six export ordinals are preserved. ### Verification Windows x64, MSVC 19.50, base `7198727`, tested at `b29089c`. The source-built EXE imports the new function by name and runs under both the Windows loader and `pe_map`. It checks the exact size, alignment and state of both live reservations at each size. Unsupported requests must leave both regions intact. The test releases both ranges and confirms it can reserve a released address again. The missing-provider control stops at IAT binding before entry. Run for both `dev` and `release` (replace the preset in both commands): ```powershell cmake --build --preset dev --target cpu_xmem_reservation xmem_shim_check pe_map cpu_shim_startup_lifted ctest --preset dev --no-tests=error -R '^(cpu_native_xmem_reservation|xmem_shim_(exports|allocation|default_allocation|query)|cpu_native_shim_startup|docs_links)$' --output-on-failure ``` 7 passed in Debug and 7 passed in Release, zero skips. The fixture uses only source-built inputs. Later commit and physical-page mapping are outside this reserve-only profile. No title entry was exercised. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:25:58 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 17:50 UTC · original

I resolved the conflicts with the current grant and Tools Memory work locally. The reservation now uses an uncommitted PAGE_NOACCESS placeholder. On Windows x64 Release both loaders passed splitting a 64 KiB prefix from each reservation size, replacing it with a section view, writing and reading a word, restoring and coalescing the placeholder, and releasing it. The existing ordinals remain 1–9.

#934 adds the shared backing implementation. I will keep this draft separate and verify the two branches together using the real XMem map/unmap path, including remapping a live page and then releasing the grant. Please share any overlapping change here so we can keep a single reservation patch.

**@⁠R0Y00** on GitHub · 2026-11-23 17:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/888#issuecomment-7109252587) I resolved the conflicts with the current grant and Tools Memory work locally. The reservation now uses an uncommitted PAGE_NOACCESS placeholder. On Windows x64 Release both loaders passed splitting a 64 KiB prefix from each reservation size, replacing it with a section view, writing and reading a word, restoring and coalescing the placeholder, and releasing it. The existing ordinals remain 1–9. #934 adds the shared backing implementation. I will keep this draft separate and verify the two branches together using the real XMem map/unmap path, including remapping a live page and then releasing the grant. Please share any overlapping change here so we can keep a single reservation patch.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 18:05 UTC · original

The source-built integration can now map a 64 KiB page directly inside each untouched 16/24 GiB reservation. The shared backend splits the target page, preserves the written word through remapping, and coalesces the range before Win32 release. Keep the compatibility test in this PR, using the actual XMem map/unmap exports from #934. Keep a control for an ordinary reserved range and verify the whole range is reusable at the same address after release.

The prototype records reservation intervals for automatic splitting. Please define how a record stops authorizing splitting after the caller releases the range through Win32. Add a control that releases an XMem reservation, creates an unrelated range over the same address, and verifies that the old record cannot change the new range. If the shim cannot establish ownership after external release, document and scope the supported split or release path before merging. The two currently tested reserve configurations stay the scope of this PR.

**@⁠R0Y00** on GitHub · 2026-11-23 18:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/888#issuecomment-7109641610) The source-built integration can now map a 64 KiB page directly inside each untouched 16/24 GiB reservation. The shared backend splits the target page, preserves the written word through remapping, and coalesces the range before Win32 release. Keep the compatibility test in this PR, using the actual XMem map/unmap exports from #934. Keep a control for an ordinary reserved range and verify the whole range is reusable at the same address after release. The prototype records reservation intervals for automatic splitting. Please define how a record stops authorizing splitting after the caller releases the range through Win32. Add a control that releases an XMem reservation, creates an unrelated range over the same address, and verifies that the old record cannot change the new range. If the shim cannot establish ownership after external release, document and scope the supported split or release path before merging. The two currently tested reserve configurations stay the scope of this PR.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 09:37 UTC · original

This PR now conflicts with main. Conflicting files:

  • docs/experiments.md
  • src/xmem_shim.def
  • tests/xmem_shim_check.cpp

Could you merge main into your branch (a merge commit, no force push needed) and resolve these? Thank you.

AI-assisted; commands listed were executed locally. (git merge-tree origin/main <head>)

**@⁠tedin7** on GitHub · 2026-11-27 09:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/888#issuecomment-7214897451) This PR now conflicts with `main`. Conflicting files: - `docs/experiments.md` - `src/xmem_shim.def` - `tests/xmem_shim_check.cpp` Could you merge `main` into your branch (a merge commit, no force push needed) and resolve these? Thank you. AI-assisted; commands listed were executed locally. (`git merge-tree origin/main <head>`)
Author
Owner

@⁠Leyukaka on GitHub · 2026-12-01 16:20 UTC · original

This looks superseded by main: #945 (merged as b3de0f4a0) reserves the XMem address space as mappable placeholders, #934 shares physical page backing across views, and #1098 commits startup blocks through XMemVirtualAlloc. The maintainer's comments here asked for split, remap, coalescing and reuse after a Win32 release; if one of those is still missing on current main, it would fit a focused PR. Otherwise this one can probably be closed. Happy to be corrected if I missed something.

**@⁠Leyukaka** on GitHub · 2026-12-01 16:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/888#issuecomment-7317449142) This looks superseded by `main`: #945 (merged as b3de0f4a0) reserves the XMem address space as mappable placeholders, #934 shares physical page backing across views, and #1098 commits startup blocks through `XMemVirtualAlloc`. The maintainer's comments here asked for split, remap, coalescing and reuse after a Win32 release; if one of those is still missing on current `main`, it would fit a focused PR. Otherwise this one can probably be closed. Happy to be corrected if I missed something.
This pull request has changes conflicting with the target branch.
  • docs/experiments.md
  • src/xmem_shim.cpp
  • src/xmem_shim.def
  • tests/xmem_shim_check.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/888/head:github-bot/gh-888'
git switch 'github-bot/gh-888'

Merge

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