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:
authoredupode <30982306+edupode@users.noreply.github.com>2026-11-22 16:14:56 +0000
committeredupode <30982306+edupode@users.noreply.github.com>2026-11-22 16:14:56 +0000
commit7c2fbe1544e5efd5a4d07a971bbd14d343d29fc0 (patch)
tree5262bb1fbb9b69d43ac91e9a659bd7660e36ce4b /runtime/shims/xmem.cpp
parenteb09c40f125ab8c24f5bc0dfb0ce6cd9890b8eaa (diff)
runtime: reject unmapped XMem allocation attributes
Do not report a successful virtual allocation when nonzero XMem attributes have no host mapping yet.
Diffstat (limited to 'runtime/shims/xmem.cpp')
-rw-r--r--runtime/shims/xmem.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp
index ff793996d..7d4a1bcfd 100644
--- a/runtime/shims/xmem.cpp
+++ b/runtime/shims/xmem.cpp
@@ -103,11 +103,15 @@ bool round_up_size(SIZE_T value, SIZE_T alignment, SIZE_T& rounded) {
103void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect) { 103void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect) {
104 // Host-backed support covers ordinary and 64 KiB guest reservations. The 2 MiB guest mode needs an aligned 104 // Host-backed support covers ordinary and 64 KiB guest reservations. The 2 MiB guest mode needs an aligned
105 // reservation strategy that this shim does not provide, so fail explicitly instead of returning a misaligned 105 // reservation strategy that this shim does not provide, so fail explicitly instead of returning a misaligned
106 // region. Attribute bits are accepted but have no host mapping yet. 106 // region. Nonzero attribute flags also fail until their host mapping is known.
107 if (size == 0) { 107 if (size == 0) {
108 SetLastError(ERROR_INVALID_PARAMETER); 108 SetLastError(ERROR_INVALID_PARAMETER);
109 return nullptr; 109 return nullptr;
110 } 110 }
111 if (attributes != 0) {
112 SetLastError(ERROR_NOT_SUPPORTED);
113 return nullptr;
114 }
111 115
112 const DWORD page_mode = allocation_type & kXmemPageModeMask; 116 const DWORD page_mode = allocation_type & kXmemPageModeMask;
113 if (page_mode == kXmemLargePages) { 117 if (page_mode == kXmemLargePages) {
@@ -163,7 +167,6 @@ void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type,
163 return nullptr; 167 return nullptr;
164 } 168 }
165 169
166 (void)attributes;
167 return VirtualAlloc(address, size, host_type, protect); 170 return VirtualAlloc(address, size, host_type, protect);
168} 171}
169 172