xmem: physical page numbers are never reused; after ~124 GiB of total allocations they overflow the title's 21-bit field #233

Open
opened 2026-11-26 12:12:08 +00:00 by kekonn · 0 comments
kekonn commented 2026-11-26 12:12:08 +00:00 (Migrated from github.com)
Contributor

Imported from avatarmanz/VIctory-7900XTX. Originally posted by kekonn on 2026-11-26T12:12:08Z.


crates/victory-hle/src/modules/xmem.rs:695: table.next_page += n * FRAMES only ever increases. XMemFreePhysicalPages (~719-731) removes entries but never makes their numbers available again. The doc at ~713-716 says the title stores number >> 4 in 21 bits (128 GiB of pages at most).

Once the total of all XMemAllocatePhysicalPages calls over the run passes about 124 GiB, the title's truncated numbers are unknown to us (XMemMapPhysicalPages returns null, ~1226) or alias live low-numbered pages, which means the wrong memory gets mapped.

When: the default path, but only with repeated allocate/free cycles. The title allocates about 6.1 GiB at once, and nothing shows it churning, so this is latent.

Sketch: when next_page + n*FRAMES would pass 1 << 25, search from 0x10_0000 for a run of n numbers not in table.pages. Normal behaviour is unchanged. The minimal version is a one-time warning when the limit is crossed (~5 lines).

(Checked, and not worth changing: stale LOW_RESERVATIONS entries only matter with VICTORY_PORT_CONSTANTS=1, where they cannot be observed; stale Physical.holes entries only cost a fast path.)

Upstream: no open PR changes this.


Generated by Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6626383097 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/issues/233). Originally posted by [kekonn](https://github.com/kekonn) on 2026-11-26T12:12:08Z. --- `crates/victory-hle/src/modules/xmem.rs:695`: `table.next_page += n * FRAMES` only ever increases. `XMemFreePhysicalPages` (~719-731) removes entries but never makes their numbers available again. The doc at ~713-716 says the title stores `number >> 4` in 21 bits (128 GiB of pages at most). Once the total of all `XMemAllocatePhysicalPages` calls over the run passes about 124 GiB, the title's truncated numbers are unknown to us (`XMemMapPhysicalPages` returns null, ~1226) or alias live low-numbered pages, which means the wrong memory gets mapped. **When:** the default path, but only with repeated allocate/free cycles. The title allocates about 6.1 GiB at once, and nothing shows it churning, so this is latent. **Sketch:** when `next_page + n*FRAMES` would pass `1 << 25`, search from `0x10_0000` for a run of `n` numbers not in `table.pages`. Normal behaviour is unchanged. The minimal version is a one-time warning when the limit is crossed (~5 lines). (Checked, and not worth changing: stale `LOW_RESERVATIONS` entries only matter with `VICTORY_PORT_CONSTANTS=1`, where they cannot be observed; stale `Physical.holes` entries only cost a fast path.) **Upstream:** no open PR changes this. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
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
avatarmanz/VIctory-7900XTX#233
No description provided.