Skip to content

xmem: roll back failed physical page mapping batches - #7331

Draft
WebsiteStealer wants to merge 3 commits into
ItsNotRexed:mainfrom
WebsiteStealer:xmem/rollback-physical-maps
Draft

WebsiteStealer wants to merge 3 commits into
ItsNotRexed:mainfrom
WebsiteStealer:xmem/rollback-physical-maps

Conversation

@WebsiteStealer

Copy link
Copy Markdown

Claimed in the coordination issue as XMem physical mapping rollback.

Depends on: #6995. This is a draft stacked on that PR. The follow-up is commit 6b55bc1. The other commits in the comparison come from the dependency.

What and why

If Windows refuses a view after a physical page mapping call has already changed earlier views, restore the previous mappings and CPU page protections and return the original Windows error. Apply the same rollback to contiguous and scatter requests, including scatter requests that list an address more than once. This ports the rollback behavior we tested in WinDurango.

Tested

Windows 11 Pro build 26200, MSVC 19.50, RelWithDebInfo. Both Windows CPU tests, xmem and xmem_physical, passed. With the new test linked against #6995 alone, four rollback checks fail. With the fix, all 74 physical-page checks pass. The test uses synthetic memory, including a native placeholder replacement that forces the last mapping operation to fail. No GPU is required for these tests.

AI-assisted: yes (Codex).

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.
  • Translator contract update (no translator change).

coenflict and others added 3 commits November 23, 2026 16:48
…t startup

XMemAllocatePhysicalPages, XMemFreePhysicalPages, XMemMapPhysicalPages and
XMemMapPhysicalPagesScatter, with the shapes of the executable's call sites.
A page is a 64 KiB slot of a pagefile-backed section; a 64 KiB-page
reserve-only XMemVirtualAlloc is a placeholder reservation, and mapping a
page replaces its placeholder with a view of the slot, so one page can be
mapped at several addresses as on the console. The title's VirtualFree
releases such a reservation whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MartinIndra02

Copy link
Copy Markdown

Independent Windows test of 6b55bc192: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), no game files.

  • xmem_physical_test.exe: 74 checks, 0 failed (exit 0), including contiguous and scatter host-failure rollback and per-page CPU protection restoration.

AI-assisted review/test.

@memorypressure

Copy link
Copy Markdown

FAIL-class: rebase and shrink, do not close as-is. You merged cleanly through 5cf3daf, but main's #6919 (042c5f3) landed a physical-page implementation directly inside xmem.cpp and now conflicts with this PR's parallel xmem_physical.cpp — reconfirmed against current main 9177299. The page store, map/unmap placeholders and docs section are all superseded. The one piece main lacks is your atomic rollback of failed batch maps — and main documents the opposite explicitly (xmem.cpp:560: "A failure part-way leaves the pages before it mapped"), with no test asserting either behavior. If Win32 MapUserPhysicalPages atomicity motivates the rollback, that argument belongs against #6919: rebase keeping just that diff plus xmem_test cases for both paths, or close in favor of an issue. Also: draft PR with no CI checks. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants