Skip to content

xmem: a mapped physical page keeps its window's PAGE_NOACCESS - #7693

Open
lisboon wants to merge 1 commit into
ItsNotRexed:mainfrom
lisboon:xmem-noaccess-window-protection
Open

lisboon wants to merge 1 commit into
ItsNotRexed:mainfrom
lisboon:xmem-noaccess-window-protection

Conversation

@lisboon

@lisboon lisboon commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as: #7496 (comment)

Depends on: none. Touches view_protect, as #7492 and #7499 do (cache modifiers); whichever lands first, the other rebases on a one-line function.

What and why

Since #6919, XMemMapPhysicalPages and XMemMapPhysicalPagesScatter map a page read-write when its window was reserved PAGE_NOACCESS. XMemMapPhysicalPages takes no protection: the GDK documents a mapping's protection as its reservation's. The XMemMapPhysicalPages reference maps one set of pages into a PAGE_READWRITE and a PAGE_READONLY reservation, and the memory guide says pages "can be mapped multiple times with different page protections".

The two retail windows reserved PAGE_NOACCESS pass 0x801, PAGE_NOACCESS | PAGE_GRAPHICS_NOACCESS (docs/xmem_exe_calls.md, attributes 0x3), so on the console neither the CPU nor the GPU reaches those pages through them. Slot 133 (#7218) places GPU resources in the 0x20406000 windows, which are CPU read-write, not in these.

view_protect now returns the window's protection.

Tests

Synthetic only, no game files. Windows 11 26200, RTX 4060 (NVIDIA 621.24), VS 2026 MSVC, Vulkan SDK 1.4.363.0.

  • New xmem_test case test_mapping_protection: the documented example in its 64 KiB-page form (one set of pages in a PAGE_READWRITE and a PAGE_READONLY window; written through the first, compared through the second; the read-only view is PAGE_READONLY) and a 0x801 window, whose mapped page must be PAGE_NOACCESS.
  • Without the change: FAIL a page mapped in a 0x801 window is PAGE_NOACCESS (1 of 181). With it: xmem_test: OK (181 checks).
  • Full runtime build: no new warnings. Full ctest: serial run on 203a348cf + this change, 247 passed; the only failures are the three already failing on main here (d3d12_vulkan_device, d3d12_indirect_dispatch_count, d3d12_indirect_rt: TEST-1698 / d3d12: an ARRAY_OF_POINTERS entry below the arena is not an overflow (d3d12_indirect_rt on NVIDIA) #6010).

Not run against the retail executable. Someone with a boot stack past the physical-page stops: a run with this change shows whether anything in the runtime reads those 0x801 pages through the title's VA (it would now fault there instead of reading).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

view_protect mapped pages read-write in a window reserved PAGE_NOACCESS. The GDK
documents a mapping's protection as its reservation's: the XMemMapPhysicalPages
reference maps one set of pages into a PAGE_READWRITE and a PAGE_READONLY
reservation. The two retail windows reserved this way pass 0x801
(PAGE_NOACCESS | PAGE_GRAPHICS_NOACCESS), which denies the GPU as well.

xmem_test covers the documented example in its 64 KiB-page form and a 0x801
window.

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

Copy link
Copy Markdown

Independent Windows test of c54e23245: pass.

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

  • xmem_test.exe: PASS (exit 0).

AI-assisted review/test.

@DeSunShine

Copy link
Copy Markdown
Contributor

Tested c54e23245 merged into main dde82f27e on NVIDIA GeForce RTX 4090 (driver 621.24), Windows 11 Pro 26200, MSVC (VS Build Tools 18) + Ninja, Vulkan SDK 1.4.363: pass.

  • ctest -R "xmem|tiny_game" --output-on-failure: 100% passed out of 11 (xmem and the run_tiny_game* tests).

AI-assisted (Claude Code).

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested c54e232 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass

  • Adds a negative control to the existing Windows pass. Built xmem_test with MSVC 19.44 (RelWithDebInfo, native Windows, no game files): OK, 181 checks.
  • Put runtime/shims/xmem.cpp back to the merge base and kept the new test. It fails: 181 checks, 1 failure ("a page mapped in a 0x801 window is PAGE_NOACCESS"). Restored the file and it passes again.
  • Not done: no GPU path is touched. Not run against the retail executable.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Tested head c54e232 against main dde82f2 (merges clean, tree 57a22b702). C++-only diff (xmem view_protect + test) — not runnable on this Linux host (no wine/cmake); CI is the execution gate. Review: main still has the PAGE_NOACCESS→PAGE_READWRITE escalation from #6919, so no supersession; the claim is grounded in the GDK mapping-protection rule and the 0x801 attrs recorded in docs/xmem_exe_calls.md, and test_mapping_protection exercises both the documented RW+RO example and the 0x801 case with before/after results. Note: #7492 is open editing the same view_protect (#7499 closed unmerged since check) — whichever lands first, the other rebakes. Flag: NO CI checks reported on the branch — please get CI running before merge. 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.

5 participants