xmem tests take the per-page path again; a reservation shown whole has its own test #16

Open
Ekabusto wants to merge 1 commit from upstream-pr/16 into main
Ekabusto commented 2026-11-25 11:59:40 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Ekabusto on 2026-11-25T11:59:40Z.


Fixes the five xmem failures in #2 and #8, following the first of the two ways out proposed in #2: keep map_whole and point the old tests back at the path they were written for.

Cause

Since map_whole (fa07481), a reservation as long as the section of the pages mapped into it is shown whole by one view, and unmapping inside it changes nothing. Five tests reserved exactly as many pages as they allocated, so they took that path, then found an unmapped page still committed (MEM_COMMIT 0x1000 where MEM_RESERVE 0x2000 was expected).

Change (crates/victory-hle/src/modules/xmem.rs only)

  • physical_pages_map_alias_and_unmap, mapping_no_pages_changes_nothing and pages_and_reservation (used by the four a_run_*/a_failed_run_* tests) allocate one page more than the reservation holds, so mappings go page by page. Their assertions are unchanged.
  • New a_reservation_is_shown_whole: a 3-page reservation mapped in three calls is one view of 3 pages; pages land where they are first put (pages 1 and 2 swapped, checked through page_bytes); unmapping a page leaves it shown; map_alias into it is refused.
  • map_alias with len == 0 returns true before the in_whole check. This is the one non-test change. in_whole(base, 0) is true when base is the start of a reservation shown whole, so mapping_no_pages_changes_nothing's probe "past the view" (a + 2 pages) was refused about 1 run in 20 whenever the new test's reservation happened to follow its own. A copy of no bytes now changes nothing anywhere, the same way unmap already returns early for len == 0. For len > 0 nothing changes.

Checks (Windows 11 build 26300, Rust 1.98.1, no game data)

  • cargo test --locked -p victory-hle --lib xmem: 15 passed, 0 failed, 100 runs in a row. On main (71652a2): 9 passed, 5 failed.
  • cargo test --locked -p victory-hle --lib: 103 passed, 1 ignored.
  • cargo fmt --check and cargo clippy -p victory-hle --all-targets -- -D warnings report only what they report on main (rustfmt line wrapping in map_whole/map_alias, clippy's items_after_test_module); nothing new from this change.

Not checked: the game. The map_alias change only affects zero-length copies; I don't know whether the GPU queue ever issues one into the whole-shown heap, but if it did it was refused (with a warning) before and is a no-op now.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:6603974976 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/16). Originally posted by [Ekabusto](https://github.com/Ekabusto) on 2026-11-25T11:59:40Z. --- Fixes the five `xmem` failures in #2 and #8, following the first of the two ways out proposed in #2: keep `map_whole` and point the old tests back at the path they were written for. ## Cause Since `map_whole` (`fa07481`), a reservation as long as the section of the pages mapped into it is shown whole by one view, and unmapping inside it changes nothing. Five tests reserved exactly as many pages as they allocated, so they took that path, then found an unmapped page still committed (`MEM_COMMIT` 0x1000 where `MEM_RESERVE` 0x2000 was expected). ## Change (`crates/victory-hle/src/modules/xmem.rs` only) - `physical_pages_map_alias_and_unmap`, `mapping_no_pages_changes_nothing` and `pages_and_reservation` (used by the four `a_run_*`/`a_failed_run_*` tests) allocate one page more than the reservation holds, so mappings go page by page. Their assertions are unchanged. - New `a_reservation_is_shown_whole`: a 3-page reservation mapped in three calls is one view of 3 pages; pages land where they are first put (pages 1 and 2 swapped, checked through `page_bytes`); unmapping a page leaves it shown; `map_alias` into it is refused. - `map_alias` with `len == 0` returns `true` before the `in_whole` check. **This is the one non-test change.** `in_whole(base, 0)` is true when `base` is the start of a reservation shown whole, so `mapping_no_pages_changes_nothing`'s probe "past the view" (`a + 2 pages`) was refused about 1 run in 20 whenever the new test's reservation happened to follow its own. A copy of no bytes now changes nothing anywhere, the same way `unmap` already returns early for `len == 0`. For `len > 0` nothing changes. ## Checks (Windows 11 build 26300, Rust 1.98.1, no game data) - `cargo test --locked -p victory-hle --lib xmem`: 15 passed, 0 failed, **100 runs in a row**. On `main` (`71652a2`): 9 passed, 5 failed. - `cargo test --locked -p victory-hle --lib`: 103 passed, 1 ignored. - `cargo fmt --check` and `cargo clippy -p victory-hle --all-targets -- -D warnings` report only what they report on `main` (rustfmt line wrapping in `map_whole`/`map_alias`, clippy's `items_after_test_module`); nothing new from this change. **Not checked:** the game. The `map_alias` change only affects zero-length copies; I don't know whether the GPU queue ever issues one into the whole-shown heap, but if it did it was refused (with a warning) before and is a no-op now. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ekabusto commented 2026-11-25 12:47:30 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Ekabusto on 2026-11-25T12:47:30Z.


For whoever reviews this: #14 fixes the same five failures and conflicts with this PR. It limits map_whole to reservations of 16 MiB and up, matching the GPU side's 16 MiB minimum for in-place mapped views, instead of changing the tests. I think #14 is the better fix for the title; if it is merged, I'll close this one.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7162862028 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/16#issuecomment-7162862028). Originally posted by [Ekabusto](https://github.com/Ekabusto) on 2026-11-25T12:47:30Z. --- For whoever reviews this: #14 fixes the same five failures and conflicts with this PR. It limits `map_whole` to reservations of 16 MiB and up, matching the GPU side's 16 MiB minimum for in-place mapped views, instead of changing the tests. I think #14 is the better fix for the title; if it is merged, I'll close this one. AI-assisted (Claude Code).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/16:upstream-pr/16'
git switch 'upstream-pr/16'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/16'
git switch 'upstream-pr/16'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/16'
git switch 'upstream-pr/16'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/16'
git switch 'main'
git merge --squash 'upstream-pr/16'
git switch 'main'
git merge --ff-only 'upstream-pr/16'
git switch 'main'
git merge 'upstream-pr/16'
git push origin 'main'
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
Belobug/VIctory-Belobug-AMD!16
No description provided.