Reserve low address space for 32-bit XMem allocations #6

Open
github-bot wants to merge 2 commits from github-bot/gh-6 into main AGit
Owner

@⁠drowniscool on GitHub · 2026-12-01 18:13 UTC · original
drowniscool:fix/xmem-32bit-address-space-spare → main · +76 −10 · 1 files · 2 commits · open

Problem

On Windows, the title requests console-compatible XMem in a constrained 32-bit address window. Host graphics mappings can fragment the low 4 GiB before that request. My logs show a 193,986,560-byte allocation failing with Win32 error 8 and largest_free_mb=0; this is virtual-address-space exhaustion, not proof that physical RAM is exhausted. This can prevent the title from completing startup allocations.

Change

Reserve a separate address-space-only spare below 4 GiB before host graphics mappings. If a constrained ADDRESS_32BIT allocation fails, release that spare and retry; keep the existing high-range spare for other allocations. Add a test that verifies the spare is within the 32-bit address range.

Validation

  • cargo test -p sixmoon-hle title_32bit_spare_reserves_space_below_four_gib (passes on Windows).
  • In the follow-up log, the failed request retries successfully at 0xe0000000.

This targets the early XMem allocation failure only; it does not claim to fix later graphics-driver crashes.

**@⁠drowniscool** on GitHub · 2026-12-01 18:13 UTC · [original](https://github.com/srmooon/sixmoon/pull/6) `drowniscool:fix/xmem-32bit-address-space-spare` → `main` · +76 −10 · 1 files · 2 commits · open ## Problem On Windows, the title requests console-compatible XMem in a constrained 32-bit address window. Host graphics mappings can fragment the low 4 GiB before that request. My logs show a 193,986,560-byte allocation failing with Win32 error 8 and `largest_free_mb=0`; this is virtual-address-space exhaustion, not proof that physical RAM is exhausted. This can prevent the title from completing startup allocations. ## Change Reserve a separate address-space-only spare below 4 GiB before host graphics mappings. If a constrained `ADDRESS_32BIT` allocation fails, release that spare and retry; keep the existing high-range spare for other allocations. Add a test that verifies the spare is within the 32-bit address range. ## Validation - `cargo test -p sixmoon-hle title_32bit_spare_reserves_space_below_four_gib` (passes on Windows). - In the follow-up log, the failed request retries successfully at `0xe0000000`. This targets the early XMem allocation failure only; it does not claim to fix later graphics-driver crashes.
Keep a dedicated spare below 4 GiB before host graphics mappings can fragment the title's 32-bit allocation range. Release it and retry only when a constrained 32-bit XMem allocation fails.

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:39:36 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-12-01 18:16 UTC · original · reviewed

🔵 Needs a closer look

The extracted helper triggers clippy::let_and_return, which blocks both CI Clippy jobs because they use -D warnings.

No open issues 🎉

What changed in this PR

This PR protects low address space from host graphics mappings so constrained 32-bit XMem allocations can complete during title startup.

Changes:

  • Adds a configurable address-space-only spare below 4 GiB, alongside the existing high-range spare.
  • Releases the appropriate spare and retries when a constrained allocation fails.
  • Adds a test verifying that the low-address reservation stays within the 32-bit range.
File Description
crates/​sixmoon-hle/​src/​modules/​xmem.rs Adds low-address reservation, allocation retry handling, and a range-validation test.

Review effort: Balanced

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-12-01 18:16 UTC · [original](https://github.com/srmooon/sixmoon/pull/6#pullrequestreview-6137277943) · **reviewed** <!-- ccr-overview-v2 --> ### 🔵 Needs a closer look The extracted helper triggers `clippy::let_and_return`, which blocks both CI Clippy jobs because they use `-D warnings`. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> This PR protects low address space from host graphics mappings so constrained 32-bit XMem allocations can complete during title startup. **Changes:** - Adds a configurable address-space-only spare below 4 GiB, alongside the existing high-range spare. - Releases the appropriate spare and retries when a constrained allocation fails. - Adds a test verifying that the low-address reservation stays within the 32-bit range. | File | Description | | ---- | ----------- | | `crates/​sixmoon-hle/​src/​modules/​xmem.rs` | Adds low-address reservation, allocation retry handling, and a range-validation test. | </details> <sub>Review effort: Balanced</sub>
Author
Owner

@⁠drowniscool on GitHub · 2026-12-01 23:01 UTC · original

Just one of a few issues I've found, let me know if this is acceptable.

**@⁠drowniscool** on GitHub · 2026-12-01 23:01 UTC · [original](https://github.com/srmooon/sixmoon/pull/6#issuecomment-7328664293) Just one of a few issues I've found, let me know if this is acceptable.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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