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.
This commit is contained in:
hcristosm
2026-11-23 14:05:51 -03:00
parent 7e8e3c1db1
commit 954fcb1061

View File

@ -460,9 +460,11 @@ bool map_page(uintptr_t address, uint64_t page, DWORD protect) {
// Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still
// GPU memory, which the D3D12 layer reads on the CPU.
DWORD view_protect(const Window& window) {
// A view takes no cache modifier: MapViewOfFile3 refuses PAGE_WRITECOMBINE (0x400, which three of the measured
// windows carry next to PAGE_READWRITE) and PAGE_NOCACHE with ERROR_INVALID_PARAMETER.
const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE | PAGE_GUARD);
// A view takes no cache modifier. Three of the measured windows carry PAGE_WRITECOMBINE (0x400) next to
// PAGE_READWRITE: Wine's MapViewOfFile3 refuses it, and PAGE_NOCACHE, with ERROR_INVALID_PARAMETER, and on Windows
// the view comes out write-combined, which an import of those pages as a GPU buffer refuses (#7218). PAGE_GUARD
// is an access alarm, not a cache modifier, so it is left as the window has it.
const DWORD protect = window.protect & ~static_cast<DWORD>(PAGE_WRITECOMBINE | PAGE_NOCACHE);
return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect;
}