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 14:05:51 -0300
committerMumogg <104529023+Mumogg@users.noreply.github.com>2026-11-23 21:09:28 -0600
commit8d4dd7a80cbd55f8cbf1a89ef7780d806e04f401 (patch)
tree03f9ef4ca7262723c81fce7a709dd81f6f7ff9a4 /runtime/shims/xmem.cpp
parent80ed5dd30438b507a03c6bb10e0adf0a0a403dea (diff)
xmem: keep PAGE_GUARD in the view protection; only the cache modifiers are dropped
PAGE_GUARD is an access alarm, not a cache modifier (review on #7492). The comment also says what the write-combine bit does on Windows, where the view is created write-combined and #7218's import of those pages refuses it. (cherry picked from commit 954fcb10617a456632b3f9b8697138988e7675cd)
Diffstat (limited to 'runtime/shims/xmem.cpp')
-rw-r--r--runtime/shims/xmem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp
index 552da6897..a0335a237 100644
--- a/runtime/shims/xmem.cpp
+++ b/runtime/shims/xmem.cpp
@@ -554,9 +554,11 @@ 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.
556DWORD view_protect(const Window& window) { 556DWORD view_protect(const Window& window) {
557 // A view takes no cache modifier: MapViewOfFile3 refuses PAGE_WRITECOMBINE (0x400, which three of the measured 557 // A view takes no cache modifier. Three of the measured windows carry PAGE_WRITECOMBINE (0x400) next to
558 // windows carry next to PAGE_READWRITE) and PAGE_NOCACHE with ERROR_INVALID_PARAMETER. 558 // PAGE_READWRITE: Wine's MapViewOfFile3 refuses it, and PAGE_NOCACHE, with ERROR_INVALID_PARAMETER, and on Windows
559 const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE | PAGE_GUARD); 559 // the view comes out write-combined, which an import of those pages as a GPU buffer refuses (#7218). PAGE_GUARD
560 // is an access alarm, not a cache modifier, so it is left as the window has it.
561 const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE);
560 return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect; 562 return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect;
561} 563}
562 564