xmem: commit physical pages in pieces, and report the real count #561

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

@⁠JoshRob297 on GitHub · 2026-11-24 04:56 UTC · original
JoshRob297:JoshRob297/aporte-xmem-fisicas → main · +208 −20 · 2 files · 1 commits · open

Addresses #23.

A title that asks for a large block of physical pages fails outright when the host cannot commit all of it at once. The console ABI does not promise one contiguous commitment: the request carries a page count, the title compares what it got, and a host can commit what it allows in pieces and report the real count instead of failing the whole call.

What this changes (crates/victory-hle/src/modules/xmem.rs)

  • The physical-page allocation walks the request in pieces and commits what the host accepts, instead of a single commit that fails as a unit.
  • The count actually committed is what the title receives, so a title that compares the returned count sees the truth rather than a success it cannot use.
  • The startup path names the commit limit when the reservation cannot be satisfied at all, so a machine that cannot hold it says so at the point of failure instead of dying later inside the title.

Verification

cargo +1.98.1 check -p victory-hle --target x86_64-pc-windows-msvc
  Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.90s

That is a type-check against the target this project pins in rust-toolchain.toml, not a run: the change is in the physical-page path and has not been exercised against a title.

What it does not fix

If the title requires the full reservation contiguously — as opposed to asking for a count and comparing — this does not help, and the way to tell is to log the count the title asks for against the count the host can commit. I have not measured that on the failing machine.

Provenance

The measurement this rests on comes from static analysis of the retail executable's allocation call sites (flag word, 64 KiB unit, and one call site that compares the returned page count), not from the source of this project. No game data is included here: no paths, no container names, no hashes.

**@⁠JoshRob297** on GitHub · 2026-11-24 04:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/561) `JoshRob297:JoshRob297/aporte-xmem-fisicas` → `main` · +208 −20 · 2 files · 1 commits · open Addresses #23. A title that asks for a large block of physical pages fails outright when the host cannot commit all of it at once. The console ABI does not promise one contiguous commitment: the request carries a page count, the title compares what it got, and a host can commit what it allows in pieces and report the real count instead of failing the whole call. **What this changes** (`crates/victory-hle/src/modules/xmem.rs`) - The physical-page allocation walks the request in pieces and commits what the host accepts, instead of a single commit that fails as a unit. - The count actually committed is what the title receives, so a title that compares the returned count sees the truth rather than a success it cannot use. - The startup path names the commit limit when the reservation cannot be satisfied at all, so a machine that cannot hold it says so at the point of failure instead of dying later inside the title. **Verification** ``` cargo +1.98.1 check -p victory-hle --target x86_64-pc-windows-msvc Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.90s ``` That is a type-check against the target this project pins in `rust-toolchain.toml`, not a run: the change is in the physical-page path and has not been exercised against a title. **What it does not fix** If the title requires the full reservation contiguously — as opposed to asking for a count and comparing — this does not help, and the way to tell is to log the count the title asks for against the count the host can commit. I have not measured that on the failing machine. **Provenance** The measurement this rests on comes from static analysis of the retail executable's allocation call sites (flag word, 64 KiB unit, and one call site that compares the returned page count), not from the source of this project. No game data is included here: no paths, no container names, no hashes.
A title that asks for a large block of physical pages fails outright when the host cannot commit all of it
at once, which is the 6.5 GB case in #23. The console ABI does not promise one contiguous commitment: the
request carries a page count, the title compares what it got, and the shim can commit what the host allows
in pieces and report the real count instead of failing the whole call.

Also names the commit limit at startup, so a machine that cannot hold the reservation says so instead of
dying later inside the title.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:24 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 17:52 UTC · original

Verification ran against PR head 3c02d8cf89470f487bab9c3a207da75084aca8b2; the PR was open at refresh.

  • cargo test -j 1 -p victory-hle xmem::tests: 6 passed, 1 failed: modules::xmem::tests::allocated_physical_pages_are_committed.
  • cargo test -j 1 -p victory-hle xmem::tests -- --test-threads=1: the same 6 passed and 1 failed, so the failure reproduces without parallel test interference.

The failure is at xmem.rs:1112: VirtualFree(reserve, 0, MEM_RELEASE) returns 0. The test maps pages into the reservation, then calls XMemFreePhysicalPages, which removes the page-number records but does not unmap the view. XMemMapPhysicalPages with null pages is the unmap path; the test needs to unmap before releasing the reservation.

commits_across_a_piece_boundary and the other five xmem tests pass. The focused tests cover the 64-MiB commit boundary and a 4-page allocation, but do not simulate host commit-limit exhaustion or a short allocation.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-24 17:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/561#issuecomment-7139841293) Verification ran against PR head [`3c02d8cf89470f487bab9c3a207da75084aca8b2`](https://github.com/Marvisak/VIctory/commit/3c02d8cf89470f487bab9c3a207da75084aca8b2); the PR was open at refresh. - `cargo test -j 1 -p victory-hle xmem::tests`: 6 passed, 1 failed: `modules::xmem::tests::allocated_physical_pages_are_committed`. - `cargo test -j 1 -p victory-hle xmem::tests -- --test-threads=1`: the same 6 passed and 1 failed, so the failure reproduces without parallel test interference. The failure is at [`xmem.rs:1112`](https://github.com/Marvisak/VIctory/blob/3c02d8cf89470f487bab9c3a207da75084aca8b2/crates/victory-hle/src/modules/xmem.rs#L1112): `VirtualFree(reserve, 0, MEM_RELEASE)` returns 0. The test maps pages into the reservation, then calls `XMemFreePhysicalPages`, which removes the page-number records but does not unmap the view. [`XMemMapPhysicalPages`](https://github.com/Marvisak/VIctory/blob/3c02d8cf89470f487bab9c3a207da75084aca8b2/crates/victory-hle/src/modules/xmem.rs#L607) with null pages is the unmap path; the test needs to unmap before releasing the reservation. `commits_across_a_piece_boundary` and the other five xmem tests pass. The focused tests cover the 64-MiB commit boundary and a 4-page allocation, but do not simulate host commit-limit exhaustion or a short allocation. This verification was AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:25 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-hle/src/modules/xmem.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/561#issuecomment-7148499400) <!-- victory-triage v1 head=3c02d8cf89470f487bab9c3a207da75084aca8b2 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-hle/src/modules/xmem.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 03:13 UTC · original · edited 2026-11-25 03:22 UTC

Triage verdict — Rebase and verify short allocations (3c02d8c)

Evidence

  • The rebase changes the scope of this PR. Merged #51 already records the failing commit request and system commit figures in the crash log, with paging-file guidance.
  • The distinct change in 3c02d8c is charging pages at allocation time and returning a short count.
  • There is a Wine constraint on the rebase too: main uses SEC_COMMIT under Wine to avoid repeated wineserver scans.

Checks and limits

  • On current main 940d32f, cargo test -p victory-hle commit_limit_report_includes_request_and_system_commit passed with synthetic inputs. That verifies the diagnostic text; it does not force a host allocation failure.
  • The earlier cleanup failure is separate from that missing coverage.

Next step

  • I’d rebase around that behavior, retain #51’s crash-log path when resolving the commit conflict, and test a deterministic partial commit before calling it ready. The acceptance case should assert the returned count, which page IDs can still be mapped, and what happens when nothing can be committed.
  • Keep that platform path or provide a Wine comparison before replacing it with SEC_RESERVE and piece commits.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 03:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/561#issuecomment-7151706503) · edited 2026-11-25 03:22 UTC **Triage verdict — Rebase and verify short allocations** (`3c02d8c`) **Evidence** - The rebase changes the scope of this PR. Merged #51 already records the failing commit request and system commit figures in the crash log, with paging-file guidance. - The distinct change in `3c02d8c` is charging pages at allocation time and returning a short count. - There is a Wine constraint on the rebase too: [main uses `SEC_COMMIT` under Wine](https://github.com/Marvisak/VIctory/blob/940d32f69b22265690a0b5a15d6ded572ba33baf/crates/victory-hle/src/modules/xmem.rs#L483-L487) to avoid repeated wineserver scans. **Checks and limits** - On current main `940d32f`, `cargo test -p victory-hle commit_limit_report_includes_request_and_system_commit` passed with synthetic inputs. That verifies the diagnostic text; it does not force a host allocation failure. - The [earlier cleanup failure](https://git.gtahub.st/github/Marvisak--VIctory/pulls/561) is separate from that missing coverage. **Next step** - I’d rebase around that behavior, retain #51’s crash-log path when resolving the `commit` conflict, and test a deterministic partial commit before calling it ready. The acceptance case should assert the returned count, which page IDs can still be mapped, and what happens when nothing can be committed. - Keep that platform path or provide a Wine comparison before replacing it with `SEC_RESERVE` and piece commits. This verification was AI-assisted.
This pull request has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/xmem.rs
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/561/head:github-bot/gh-561'
git switch 'github-bot/gh-561'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-561'
git switch 'github-bot/gh-561'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-561'
git switch 'github-bot/gh-561'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-561'
git switch 'main'
git merge --squash 'github-bot/gh-561'
git switch 'main'
git merge --ff-only 'github-bot/gh-561'
git switch 'main'
git merge 'github-bot/gh-561'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!561
No description provided.