Skip to content

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

Open
JoshRob297 wants to merge 1 commit into
Marvisak:mainfrom
JoshRob297:JoshRob297/aporte-xmem-fisicas
Open

JoshRob297 wants to merge 1 commit into
Marvisak:mainfrom
JoshRob297:JoshRob297/aporte-xmem-fisicas

Conversation

@JoshRob297

Copy link
Copy Markdown

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.

…il whole

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 Marvisak#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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.

@jeremygold02

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Owner

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

@jeremygold02

jeremygold02 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Evidence

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 Report Windows commit-limit failures in crashes.log #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants