diff options
| author | hcristosm <hcristosm@gmail.com> | 2026-11-23 13:50:59 -0300 |
|---|---|---|
| committer | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 21:09:28 -0600 |
| commit | 80ed5dd30438b507a03c6bb10e0adf0a0a403dea (patch) | |
| tree | 49169f564713d4ab94b8642295e4c4623c0bc860 /runtime/shims/xmem.cpp | |
| parent | 84347bbb61ed406db10195f50d5911893b8b9a4b (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.
(cherry picked from commit 7e8e3c1db1dc3c4c44cc56e2e586f99de2e65ae2)
Diffstat (limited to 'runtime/shims/xmem.cpp')
| -rw-r--r-- | runtime/shims/xmem.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp index 1e286d712..552da6897 100644 --- a/runtime/shims/xmem.cpp +++ b/runtime/shims/xmem.cpp | |||
| @@ -554,7 +554,10 @@ bool install_physical_page_fault_handler() { | |||
| 554 | // Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still | 554 | // Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still |
| 555 | // GPU memory, which the D3D12 layer reads on the CPU. | 555 | // GPU memory, which the D3D12 layer reads on the CPU. |
| 556 | DWORD view_protect(const Window& window) { | 556 | DWORD view_protect(const Window& window) { |
| 557 | return window.protect == PAGE_NOACCESS ? PAGE_READWRITE : window.protect; | 557 | // A view takes no cache modifier: MapViewOfFile3 refuses PAGE_WRITECOMBINE (0x400, which three of the measured |
| 558 | // windows carry next to PAGE_READWRITE) and PAGE_NOCACHE with ERROR_INVALID_PARAMETER. | ||
| 559 | const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE | PAGE_GUARD); | ||
| 560 | return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect; | ||
| 558 | } | 561 | } |
| 559 | 562 | ||
| 560 | bool aligned_page_address(uintptr_t address) { return (address & (kPhysicalPageSize - 1)) == 0; } | 563 | bool aligned_page_address(uintptr_t address) { return (address & (kPhysicalPageSize - 1)) == 0; } |