mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:05:54 +01:00
[PR #328] [MERGED] xmem: map physical pages without a cache modifier in the view protection, again (RT-XMEM-VIEW-PROTECT) #382
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#382
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/328
Author: @Mumogg
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:xmem-view-protect📝 Commits (3)
80ed5ddxmem: map physical pages without a cache modifier in the view protection8d4dd7axmem: keep PAGE_GUARD in the view protection; only the cache modifiers are droppedf70ed48xmem_test: the write-combine window's page is written before its view is queried📊 Changes
2 files changed (+37 additions, -1 deletions)
View changed files
📝
runtime/shims/xmem.cpp(+6 -1)📝
runtime/test/xmem_test.cpp(+31 -0)📄 Description
Claimed in #14 as
RT-XMEM-VIEW-PROTECT.What and why
Three of the retail executable's physical-page windows carry
PAGE_WRITECOMBINEnext toPAGE_READWRITE. Onmain,view_protecthands that protection toMapViewOfFile3, which refuses a cache modifier, so the firstXMemMapPhysicalPagesinto such a window fails and the title's device set-up returns false.The fix is two commits by hcristosm, cherry-picked unchanged (
-x, authorship kept):7e8e3c1dbdrops the cache modifiers from the view protection and954fcb106keepsPAGE_GUARD. Both are ancestors ofmain, but the change is not in the tree (finding in #14), so a merge does not bring it back.One commit of mine on top: the test case that came with the fix queried the view right after mapping it.
main's xmem commits a page on first touch, so the case now writes the page first, as the read-write case above it does.Measured
Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100.
xmem_testunder Wine, the new write-combine case:a page maps into a window reserved with PAGE_WRITECOMBINEmain'sxmem.cppwith the new test casethe page in the write-combine window holds datapasses tooAt boot (own 1.0.2.1 copy, network off), measured in the integration branch of #321 with
main'sxmem.cppswapped in: without the fix the run stops at 1,181 D3D12 calls, on the title's ownint3after the function that creates its device returns false; with it the run goes on to 50,468 pipeline states. It cannot be measured onmainalone yet, becausemainstops earlier (#127, #131, then device slot 26).Two checks that fail under Wine with and without this change
a mapped page is a read-write view with the window's protectionalready fails onmainunder Wine, and the newthe page mapped there is a plain read-write viewfails the same way: after the page has been written, Wine'sVirtualQuerystill reports the view asMEM_RESERVE/MEM_MAPPEDwith protection 0. The data checks around them pass, so the page is there. I do not know what Windows reports for these two; CI will say, and if the new check is wrong for the commit-on-touch design I will change it.This matters beyond the test: any code that decides whether title memory is readable from
VirtualQuery'sState == MEM_COMMITwill see these pages as unreadable under Wine. That may be why #321 fails a submit with an unknown resource when it usesmain's xmem; not confirmed.Not built with MSVC and not run on Windows.
AI-assisted (Claude Code); built and run on the machine above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.