upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/xmem.cpp
diff options
context:
space:
mode:
authorhcristosm <hcristosm@gmail.com>2026-11-23 13:50:59 -0300
committerhcristosm <hcristosm@gmail.com>2026-11-23 13:50:59 -0300
commit7e8e3c1db1dc3c4c44cc56e2e586f99de2e65ae2 (patch)
tree47dd9d8beb005b14fd1f3ea13b90bc53b276a0e6 /runtime/shims/xmem.cpp
parent37f2151079c9105e177607e548423d02670fe2d4 (diff)
xmem: map physical pages without a cache modifier in the view protection
Three of the retail executable's five physical-page windows carry 0x400 (PAGE_WRITECOMBINE on the PC) next to PAGE_READWRITE. host_protect drops only the PAGE_GRAPHICS_* range, so map_page passed PAGE_READWRITE | PAGE_WRITECOMBINE to MapViewOfFile3, which refuses it with ERROR_INVALID_PARAMETER: the first XMemMapPhysicalPages into such a window failed and the title's descriptor-heap setup returned false. view_protect now drops PAGE_WRITECOMBINE, PAGE_NOCACHE and PAGE_GUARD. xmem_test maps a page into a window reserved with that protection. AI-assisted.
Diffstat (limited to 'runtime/shims/xmem.cpp')
-rw-r--r--runtime/shims/xmem.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp
index 37f29459f..27c86cfa9 100644
--- a/runtime/shims/xmem.cpp
+++ b/runtime/shims/xmem.cpp
@@ -460,7 +460,10 @@ bool map_page(uintptr_t address, uint64_t page, DWORD protect) {
460// Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still 460// Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still
461// GPU memory, which the D3D12 layer reads on the CPU. 461// GPU memory, which the D3D12 layer reads on the CPU.
462DWORD view_protect(const Window& window) { 462DWORD view_protect(const Window& window) {
463 return window.protect == PAGE_NOACCESS ? PAGE_READWRITE : window.protect; 463 // A view takes no cache modifier: MapViewOfFile3 refuses PAGE_WRITECOMBINE (0x400, which three of the measured
464 // windows carry next to PAGE_READWRITE) and PAGE_NOCACHE with ERROR_INVALID_PARAMETER.
465 const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE | PAGE_GUARD);
466 return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect;
464} 467}
465 468
466bool aligned_page_address(uintptr_t address) { return (address & (kPhysicalPageSize - 1)) == 0; } 469bool aligned_page_address(uintptr_t address) { return (address & (kPhysicalPageSize - 1)) == 0; }