XMem: a page mapping that cannot be served leaves the memory as it showed #538
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!538
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-538"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@kibagami-nc on GitHub · 2026-11-28 00:32 UTC · original
kibagami-nc:fix/xmem-remap-unknown-page→main· +171 −29 · 1 files · 1 commits · openThe problem
XMemMapPhysicalPagestakes the destination's views away (unmap) before it looks the page numbers up. A number that is not in the table makes the call return null, but the buffer has already become placeholders. Such a number can be one the title's list kept afterXMemFreePhysicalPages, or one whose allocation came late.After a failed remap the title keeps using what the buffer showed, so its next access is an access violation. The GPU side has also already been told the range changed.
The GPU's page-mapping copies have the same order:
alias_asunmaps the destination before reading the source. A source page that is not mapped leaves the destination a hole, and a source range that overlaps its destination loses its pages with it.map_aliasestakes the batched path whenVICTORY_MAP_THREADSis above 1, which is the default. For a missing source it pushes an empty op, andchange()then unmaps the destination page.The change
XMemMapPhysicalPageslooks every page number up first. If one is unknown, it returns null and changes nothing.alias_astakes every source slice first (the slices keep their sections alive), then unmaps the destination and maps. A missing source returnsfalsewith the destination unchanged. The overlapping case maps from the slices taken first, so the overlapped pages are not lost.map_aliasesfirst runs a look-ahead,missing_source. It counts pages that earlier ranges of the same call map or unmap, and nothing changes if a source will be missing. Inside a group, a source unmapped since then (the locks are given back between groups) leaves its destination as it is instead of unmapping it.a_copy_of_consecutive_pages_shows_them_through_one_viewasserted the old partial result: pages ahead of the missing one mapped, the rest a hole. It now asserts that the destination is unchanged.The idea follows fxceless/victory-fork#1460 (cwWwWwW), ported to this tree. That PR was against fxceless's fork; I found no PR here doing the same.
Tests
The new tests run without a GPU:
a_remap_that_cannot_be_served_changes_nothing: an unknown page number changes nothing and the buffer reads as before. A copy from a source with a hole leaves its destination. A two-page copy onto itself, shifted by one page, keeps the overlapped page.batched_copies_that_cannot_be_served_change_nothing: on the batched path, a missing source changes no destination, and a source that an earlier range of the call maps is served.a_source_counts_as_the_entries_before_it_leave_it: the look-ahead.cargo test -p victory-hle: 185 passed. Thexmemtests pass on one thread and on several.cargo clippy --workspace --all-targets -- -D warningsstops on lintsmainalready has (victory-formats/src/texture.rs:1346and dead code invictory-gpu, see #425, #265 and #86). This change adds no warning.No game files, dumps or extracted data are included.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.