Skip to content

runtime: add XMem virtual memory and write-watch exports - #2199

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
edupode:codex/xmem-virtual-write-watch
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
edupode:codex/xmem-virtual-write-watch

Conversation

@edupode

@edupode edupode commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Register XMemVirtualAlloc, XMemGetWriteWatch, and XMemResetWriteWatch in the XMem shim.
  • Route ordinary and 64 KiB allocations through VirtualAlloc with checked range rounding.
  • Forward write-watch queries/resets to the corresponding Win32 APIs.
  • Reject unsupported page modes, unknown allocation flags, and nonzero attributes until their host behavior is known.

Scope

Physical-page allocation/mapping, 2 MiB alignment, write-watch suspend/resume, and nonzero XMem attributes remain unsupported. Existing XMemAlloc/XMemFree behavior is unchanged. The API coverage was informed by xbox-emulator's XMem virtual-memory module; this implementation is independent and copies no code.

Win32 contracts: VirtualAlloc, GetWriteWatch, ResetWriteWatch.

Verification

  • git diff --check passed.
  • Built runtime/test/xmem_test.cpp with the registered shim and registry sources using MSVC 19.51 (VS 2026), then ran the executable: 35/35 checks passed. New synthetic cases cover dirty-page reporting, query-only preservation, reset and re-arm, and explicit rejection of unsupported large pages and nonzero attributes.
  • No game data, generated shaders, keys, or decryption material were accessed.

AI-assisted contribution by @edupode with assistance from ChatGPT 6.2 Astra (Ultra Thinking).

Expose XMemVirtualAlloc and the write-watch queries through the xmem shim. Map ordinary and 64 KiB allocations to host virtual memory, and reject unsupported page modes instead of silently using the wrong alignment.
Do not report a successful virtual allocation when nonzero XMem attributes have no host mapping yet.
@ezwinxdlmao

Copy link
Copy Markdown
Contributor

Tested 7c2fbe1 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo), with llvm-mc 21.1.8 for the translated-shader tests: pass.

AI-assisted (Claude Code).

@mrp1no

mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Built and tested 7c2fbe15 on Windows 11 Pro 26300, MSVC 19.52 (VS 18 Build Tools, Ninja, RelWithDebInfo), NVIDIA GeForce RTX 3060, driver 610.88, Vulkan headers/loader 1.4.357, since the PR says cl.exe wasn't available: it compiles cleanly, and ctest --test-dir runtime/build -C RelWithDebInfo passes 109/109, the same as main at 4eb6155d.

No test exercises the three new exports yet, so this only shows they build and don't break anything else. A small case in the existing shim tests (an XMemVirtualAlloc with MEM_WRITE_WATCH, a write, XMemGetWriteWatch returning the page, XMemResetWriteWatch clearing it, and the refused large-page mode and nonzero attributes) would pin the behaviour.

AI-assisted (Claude Code).

@richardsenra

richardsenra commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Update at 84f86c5: rebuilt the permanent xmem_test with MSVC 19.44.35230 / SDK NuGet 10.0.26100.9457. ctest -R "^xmem$" -V passes 35/35 checks, including the new registered exports and write-watch/reset/re-arm/rejection coverage. Targeted refresh only; the differential checks below were on the original implementation head. AI-assisted.

Independent Windows verification at 7c2fbe1544e5efd5a4d07a971bbd14d343d29fc0: the new host-backed virtual-memory/write-watch subset passes the targeted checks below. AI-assisted.

Environment: Windows 11 Pro 26300, MSVC 19.44.35230, CMake 4.2.1/Ninja 1.13.1, Microsoft.Windows.SDK.CPP and CPP.x64 10.0.26100.9457 (their include/lib directory is named 10.0.26100.0), Vulkan headers 1.4.363 for runtime compilation. CPU tests; no game files or GPU execution.

  • Built gta6rt, xmem_test and loader_test at this head. ctest -R '^(xmem|loader)$': 2/2 pass; the existing xmem test reports 19 checks.
  • Merged main 49475796c226c8511b9470bf97a4daf57b8af323 into an isolated worktree without committing. The same three targets build and the same two CTests pass. Aborted the scratch merge afterwards; the PR source remains unchanged and the worktree is clean. This is a targeted build with the stated newer SDK package, not an all-target/all-CTest check or a reproduction of BUILD-647 on older SDK headers.
  • Built an independent synthetic differential runner with the actual runtime/shims/xmem.cpp and registry.cpp. It resolves all three new exports with rt::shims::find, rather than including a copied allocator. 159 scenarios, 532 checks, 0 failures.

The runner covers:

Area Checked
Ordinary allocations Seven sizes spanning 4 KiB/64 KiB boundaries; reserve, commit, reserve+commit, top-down and write-watch flags; read/write, read-only and no-access protections. Success/failure codes, region extent, page state and protection compared with independent native VirtualAlloc allocations. Zero initialization and first/last-byte writes where writable.
Explicit-address commits Fifteen offset/size combinations in independently reserved arenas, including page-boundary crossings. Returned relative base and every page's commitment/protection compared with native Windows.
64 KiB guest mode Alignment and full-block commitment for four requested sizes; reserve-only followed by a two-byte commit crossing a 64 KiB boundary, verifying exactly two blocks commit while neighboring blocks remain reserved.
Write-watch, ordinary and guest64k allocations Initial state, three dirty pages with exact relative addresses, non-reset observation, capacity-one result, invalid flag, subrange query, subrange reset preserving other dirty pages, query-and-reset, and full reset. Output-array and count/granularity sentinels check buffer bounds and parameter widths.
Rejections Zero size, nonzero attributes, unsupported large-page mode, incomplete page-mode bits, unknown flags, and size/address/rounding overflows. Untracked allocations' watch/reset failures match Windows.

The Windows reference is the native API, with separate allocations for host/shim comparisons. For failed GetWriteWatch calls, only failure status and output guards are checked; undocumented error-path output is not treated as a valid address/count oracle.

Negative controls, compiled from private scratch copies only:

  • Force GetWriteWatch to reset even for observation-only calls: the runner fails with 12 failed checks.
  • Round null-address guest64k allocations to host 4 KiB pages: the runner fails with 2 failed checks.
  • The unmodified source passes and its bytes are unchanged after the controls.

I found no failure in this tested subset. This does not establish the Xbox calling convention from a real call site, nonzero-attribute semantics, 2 MiB/physical-page support, or write-watch suspend/resume; those remain outside the stated implementation. It also does not exercise game boot.

One useful follow-up in this PR would be permanent coverage of the three new exports: the existing 19-check xmem_test only resolves/tests the four old exports, so it would not catch the two regressions above. The standalone runner below is available to adapt into that test.

Standalone synthetic differential runner (compile from the repository root)

Save as xmem_virtual_review.cpp and run in a VS developer PowerShell:

cl /nologo /std:c++20 /EHsc /W4 /permissive- /utf-8 /DWIN32_LEAN_AND_MEAN /DNOMINMAX /I runtime/shims xmem_virtual_review.cpp runtime/shims/xmem.cpp runtime/shims/registry.cpp /Fe:xmem_virtual_review.exe /link /OPT:NOREF psapi.lib
.\xmem_virtual_review.exe
// Independent synthetic Windows differential review of PR #2199. AI-assisted.
// Uses the real registry.cpp/xmem.cpp, not copied allocation code. No game files.
#include <windows.h>
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include "shims.h"

using AllocFn = void*(WINAPI*)(void*, SIZE_T, DWORD, ULONGLONG, DWORD);
using WatchFn = UINT(WINAPI*)(DWORD, void*, SIZE_T, void**, ULONG_PTR*, ULONG*);
using ResetFn = UINT(WINAPI*)(void*, SIZE_T);
AllocFn guest_alloc;
WatchFn guest_watch;
ResetFn guest_reset;
int checks = 0, failures = 0, scenarios = 0;
DWORD page_bytes;
constexpr DWORD guest64k = 0x20400000;

void check(bool ok, const char* label) {
    ++checks;
    if (!ok) { ++failures; std::printf("FAIL: %s\n", label); }
}

struct Region {
    void* base{};
    Region() = default;
    explicit Region(void* p) : base(p) {}
    Region(const Region&) = delete;
    Region& operator=(const Region&) = delete;
    ~Region() { if (base) VirtualFree(base, 0, MEM_RELEASE); }
    void* at(SIZE_T offset) const { return static_cast<unsigned char*>(base) + offset; }
};

void* allocate(bool shim, void* address, SIZE_T size, DWORD type, DWORD protect) {
    return shim ? guest_alloc(address, size, type, 0, protect) : VirtualAlloc(address, size, type, protect);
}

bool query(void* address, MEMORY_BASIC_INFORMATION& info) {
    return VirtualQuery(address, &info, sizeof(info)) == sizeof(info);
}

void compare_null_alloc(SIZE_T size, DWORD type, DWORD protect) {
    ++scenarios;
    SetLastError(0xdead);
    Region native(allocate(false, nullptr, size, type, protect));
    const DWORD native_error = GetLastError();
    SetLastError(0xdead);
    Region shim(allocate(true, nullptr, size, type, protect));
    const DWORD shim_error = GetLastError();
    const bool same_success = (native.base != nullptr) == (shim.base != nullptr);
    check(same_success, "ordinary VirtualAlloc success matches host");
    if (!same_success) std::printf("  size=%zu type=%08lx protect=%08lx native=%d/%lu shim=%d/%lu\n",
                                 size, type, protect, native.base != nullptr, native_error, shim.base != nullptr, shim_error);
    if (!native.base || !shim.base) {
        if (!native.base && !shim.base) check(native_error == shim_error, "ordinary allocation failure code matches host");
        return;
    }
    MEMORY_BASIC_INFORMATION a{}, b{};
    check(query(native.base, a) && query(shim.base, b), "query ordinary allocations");
    check(a.RegionSize == b.RegionSize && a.State == b.State && a.Protect == b.Protect &&
          a.AllocationProtect == b.AllocationProtect && a.Type == b.Type,
          "ordinary allocation extent/state/protection matches host");
    if (a.State == MEM_COMMIT && (a.Protect & 0xff) == PAGE_READWRITE && !(a.Protect & PAGE_GUARD)) {
        auto* bytes = static_cast<volatile unsigned char*>(shim.base);
        bool zero = true;
        for (SIZE_T offset = 0; offset < size; offset += page_bytes) zero &= bytes[offset] == 0;
        check(zero && bytes[size - 1] == 0, "new committed memory is zero initialized");
        bytes[0] = 0x35; bytes[size - 1] = 0x79;
        check(bytes[size - 1] == 0x79, "first and last requested bytes writable");
    }
}

void compare_commit(SIZE_T offset, SIZE_T size) {
    ++scenarios;
    constexpr SIZE_T extent = 0x40000;
    Region native(VirtualAlloc(nullptr, extent, MEM_RESERVE, PAGE_NOACCESS));
    Region shim(VirtualAlloc(nullptr, extent, MEM_RESERVE, PAGE_NOACCESS));
    check(native.base && shim.base, "reserve independent arenas for commit comparison");
    if (!native.base || !shim.base) return;
    void* a = allocate(false, native.at(offset), size, MEM_COMMIT, PAGE_READWRITE);
    void* b = allocate(true, shim.at(offset), size, MEM_COMMIT, PAGE_READWRITE);
    check(a && b, "commit unaligned requested range succeeds on host and shim");
    if (!a || !b) return;
    check(static_cast<unsigned char*>(a) - static_cast<unsigned char*>(native.base) ==
          static_cast<unsigned char*>(b) - static_cast<unsigned char*>(shim.base), "commit returned offset matches host");
    bool same = true;
    for (SIZE_T at = 0; at < extent; at += page_bytes) {
        MEMORY_BASIC_INFORMATION x{}, y{};
        same &= query(native.at(at), x) && query(shim.at(at), y) && x.State == y.State && x.Protect == y.Protect;
    }
    check(same, "every page's commit state/protection matches host");
}

void test_guest64k() {
    for (SIZE_T requested : {SIZE_T(1), SIZE_T(0xffff), SIZE_T(0x10000), SIZE_T(0x10001)}) {
        ++scenarios;
        const SIZE_T expected = requested <= 0x10000 ? 0x10000 : 0x20000;
        Region shim(guest_alloc(nullptr, requested, guest64k | MEM_RESERVE | MEM_COMMIT, 0, PAGE_READWRITE));
        check(shim.base != nullptr, "guest 64K allocation succeeds");
        if (!shim.base) continue;
        MEMORY_BASIC_INFORMATION info{};
        check((reinterpret_cast<uintptr_t>(shim.base) & 0xffff) == 0, "guest 64K allocation aligned");
        const bool whole_extent = query(shim.base, info) && info.State == MEM_COMMIT && info.RegionSize == expected;
        check(whole_extent, "guest 64K commitment rounds to complete 64K blocks");
        if (!whole_extent) continue;  // fail the mutation without touching an uncommitted tail
        auto* bytes = static_cast<volatile unsigned char*>(shim.base);
        bytes[0] = 0x12; bytes[expected - 1] = 0x34;
        check(bytes[0] == 0x12 && bytes[expected - 1] == 0x34, "whole guest 64K committed extent writable");
    }
    ++scenarios;
    Region arena(guest_alloc(nullptr, 0x40000, guest64k | MEM_RESERVE, 0, PAGE_NOACCESS));
    check(arena.base != nullptr, "guest 64K reserve-only arena");
    if (!arena.base) return;
    // Two bytes cross a 64K boundary: precisely blocks 1 and 2 should commit.
    void* result = guest_alloc(arena.at(0x1ffff), 2, guest64k | MEM_COMMIT, 0, PAGE_READWRITE);
    check(result == arena.at(0x10000), "guest 64K unaligned commit returns rounded base");
    bool exact = true;
    for (SIZE_T i = 0; i < 0x40000; i += page_bytes) {
        MEMORY_BASIC_INFORMATION info{};
        const DWORD expected = i >= 0x10000 && i < 0x30000 ? MEM_COMMIT : MEM_RESERVE;
        exact &= query(arena.at(i), info) && info.State == expected;
    }
    check(exact, "64K boundary crossing commits exactly two guest blocks, preserves neighbors");
}

struct WatchResult {
    UINT status{};
    ULONG_PTR count{};
    ULONG granularity{};
    std::vector<SIZE_T> offsets;
    bool sentinels{};
};

WatchResult watch(bool shim, DWORD flags, const Region& region, SIZE_T offset, SIZE_T bytes, ULONG_PTR capacity = 32) {
    std::array<void*, 34> output{};
    std::fill(output.begin(), output.end(), reinterpret_cast<void*>(uintptr_t(0xcafef00d)));
    struct Count { ULONG_PTR value; std::uint64_t sentinel; } count{capacity, 0x123456789abcdef0};
    struct Gran { ULONG value; ULONG sentinel; } gran{0xdeadbeef, 0x89abcdef};
    const UINT status = shim ? guest_watch(flags, region.at(offset), bytes, output.data(), &count.value, &gran.value)
                             : GetWriteWatch(flags, region.at(offset), bytes, output.data(), &count.value, &gran.value);
    WatchResult result{status, count.value, gran.value, {}, true};
    for (ULONG_PTR i = 0; i < (std::min)(count.value, capacity); ++i)
        result.offsets.push_back(reinterpret_cast<uintptr_t>(output[i]) - reinterpret_cast<uintptr_t>(region.base));
    std::sort(result.offsets.begin(), result.offsets.end());
    for (SIZE_T i = capacity; i < output.size(); ++i)
        result.sentinels &= output[i] == reinterpret_cast<void*>(uintptr_t(0xcafef00d));
    result.sentinels &= count.sentinel == 0x123456789abcdef0 && gran.sentinel == 0x89abcdef;
    return result;
}

void compare_watch(const WatchResult& a, const WatchResult& b, const char* label) {
    ++scenarios;
    check(a.status == b.status, label);
    // GetWriteWatch only documents the returned addresses/count/granularity on success.
    // Error output is not an oracle (untouched address sentinels are not relative pointers).
    if (a.status == 0 && b.status == 0)
        check(a.count == b.count && a.granularity == b.granularity && a.offsets == b.offsets,
              "write-watch count/granularity/relative addresses match host");
    check(a.sentinels && b.sentinels, "write-watch respects array capacity and out-parameter widths");
}

void dirty(const Region& region) {
    auto* bytes = static_cast<volatile unsigned char*>(region.base);
    bytes[1] = 1; bytes[2 * page_bytes + 17] = 2; bytes[7 * page_bytes + page_bytes - 1] = 3;
}

void test_write_watch(DWORD mode) {
    const SIZE_T extent = 0x20000;
    Region native(VirtualAlloc(nullptr, extent, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE));
    Region shim(guest_alloc(nullptr, extent, mode | MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, 0, PAGE_READWRITE));
    check(native.base && shim.base, "create independent write-watch arenas");
    if (!native.base || !shim.base) return;
    compare_watch(watch(false, 0, native, 0, extent), watch(true, 0, shim, 0, extent), "initial write-watch status matches");
    dirty(native); dirty(shim);
    auto a = watch(false, 0, native, 0, extent), b = watch(true, 0, shim, 0, extent);
    compare_watch(a, b, "three dirty pages match host");
    check(b.status == 0 && b.offsets == std::vector<SIZE_T>{0, 2 * page_bytes, 7 * page_bytes} && b.granularity == page_bytes,
          "write-watch finds exact dirty pages with host page granularity");
    // Non-reset observation must retain dirty state. Also compare small capacities and invalid flags.
    compare_watch(watch(false, 0, native, 0, extent), watch(true, 0, shim, 0, extent), "observation does not reset");
    compare_watch(watch(false, 0, native, 0, extent, 1), watch(true, 0, shim, 0, extent, 1), "capacity-one behavior matches host");
    compare_watch(watch(false, 2, native, 0, extent), watch(true, 2, shim, 0, extent), "invalid write-watch flag matches host");
    compare_watch(watch(false, 0, native, page_bytes, 3 * page_bytes),
                  watch(true, 0, shim, page_bytes, 3 * page_bytes), "subrange dirty pages match host");
    UINT ar = ResetWriteWatch(native.at(2 * page_bytes), page_bytes);
    UINT br = guest_reset(shim.at(2 * page_bytes), page_bytes);
    ++scenarios; check(ar == br && br == 0, "subrange ResetWriteWatch succeeds like host");
    a = watch(false, 0, native, 0, extent); b = watch(true, 0, shim, 0, extent);
    compare_watch(a, b, "subrange reset preserves dirty pages outside subrange");
    check(b.offsets == std::vector<SIZE_T>{0, 7 * page_bytes}, "reset clears exactly its dirty page");
    compare_watch(watch(false, WRITE_WATCH_FLAG_RESET, native, 0, extent),
                  watch(true, WRITE_WATCH_FLAG_RESET, shim, 0, extent), "query-and-reset returns remaining dirty pages");
    a = watch(false, 0, native, 0, extent); b = watch(true, 0, shim, 0, extent);
    compare_watch(a, b, "query-and-reset clears subsequent observation");
    check(b.status == 0 && b.count == 0, "no pages remain dirty after query-and-reset");
    dirty(native); dirty(shim);
    ar = ResetWriteWatch(native.base, extent); br = guest_reset(shim.base, extent);
    ++scenarios; check(ar == br && br == 0, "full ResetWriteWatch succeeds like host");
    b = watch(true, 0, shim, 0, extent);
    check(b.status == 0 && b.count == 0, "full reset clears all dirty pages");
}

void test_rejections() {
    struct Bad { void* address; SIZE_T size; DWORD flags; ULONGLONG attributes; DWORD error; };
    const SIZE_T max = (std::numeric_limits<SIZE_T>::max)();
    const Bad cases[] = {
        {nullptr, 0, MEM_RESERVE | MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
        {nullptr, 1, MEM_RESERVE | MEM_COMMIT, 1, ERROR_NOT_SUPPORTED},
        {nullptr, 1, 0x20000000 | MEM_RESERVE | MEM_COMMIT, 0, ERROR_NOT_SUPPORTED},
        {nullptr, 1, 0x00400000 | MEM_RESERVE | MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
        {nullptr, 1, 0x80000000 | MEM_RESERVE | MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
        {nullptr, max, guest64k | MEM_RESERVE | MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
        {reinterpret_cast<void*>(max - 1), 4, MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
        {reinterpret_cast<void*>(max - 2), 1, guest64k | MEM_COMMIT, 0, ERROR_INVALID_PARAMETER},
    };
    for (const auto& bad : cases) {
        ++scenarios;
        SetLastError(0xdead);
        Region result(guest_alloc(bad.address, bad.size, bad.flags, bad.attributes, PAGE_READWRITE));
        const DWORD error = GetLastError();
        check(!result.base && error == bad.error, "documented rejected/overflow case returns deterministic error");
    }
    Region native(VirtualAlloc(nullptr, 0x10000, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE));
    Region shim(guest_alloc(nullptr, 0x10000, MEM_RESERVE | MEM_COMMIT, 0, PAGE_READWRITE));
    if (native.base && shim.base) {
        compare_watch(watch(false, 0, native, 0, 0x10000), watch(true, 0, shim, 0, 0x10000),
                      "write-watch on untracked allocation matches host failure");
        ++scenarios;
        const UINT a = ResetWriteWatch(native.base, 0x10000), b = guest_reset(shim.base, 0x10000);
        check(a == b && b != 0, "reset on untracked allocation matches host failure");
    }
}

int main() {
    guest_alloc = reinterpret_cast<AllocFn>(rt::shims::find("xmem.dll", "XMemVirtualAlloc"));
    guest_watch = reinterpret_cast<WatchFn>(rt::shims::find("xmem.dll", "XMemGetWriteWatch"));
    guest_reset = reinterpret_cast<ResetFn>(rt::shims::find("xmem.dll", "XMemResetWriteWatch"));
    check(guest_alloc && guest_watch && guest_reset, "all three new exports resolve through real shim registry");
    if (!guest_alloc || !guest_watch || !guest_reset) return 1;
    SYSTEM_INFO sys{}; GetSystemInfo(&sys); page_bytes = sys.dwPageSize;
    std::printf("host page=%lu allocation granularity=%lu; registered PR exports\n", page_bytes, sys.dwAllocationGranularity);
    const SIZE_T sizes[] = {1, 0xfff, 0x1000, 0x1001, 0xffff, 0x10000, 0x10001};
    const DWORD types[] = {MEM_RESERVE, MEM_COMMIT, MEM_RESERVE | MEM_COMMIT,
                          MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH};
    const DWORD protections[] = {PAGE_READWRITE, PAGE_READONLY, PAGE_NOACCESS};
    for (SIZE_T size : sizes) for (DWORD type : types) for (DWORD protect : protections)
        compare_null_alloc(size, type, protect);
    // Host rejection behavior for bad protection values is also observable without touching memory.
    compare_null_alloc(0x1000, MEM_RESERVE | MEM_COMMIT, 0);
    compare_null_alloc(0x1000, MEM_WRITE_WATCH, PAGE_READWRITE);
    for (SIZE_T offset : {SIZE_T(1), SIZE_T(0xfff), SIZE_T(0x1001), SIZE_T(0xffff), SIZE_T(0x10001)})
        for (SIZE_T size : {SIZE_T(1), SIZE_T(2), SIZE_T(0x1001)}) compare_commit(offset, size);
    test_guest64k();
    test_write_watch(0);
    test_write_watch(guest64k);
    test_rejections();
    std::printf("xmem virtual review: %d scenarios, %d checks, %d failures\n", scenarios, checks, failures);
    return failures ? 1 : 0;
}

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 7c2fbe1 (merged onto main 4947579) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass

  • Clean configure + build of runtime/ (Visual Studio generator, RelWithDebInfo): no new warnings (same C4201/C4456/C4996 counts as main).
  • ctest -C RelWithDebInfo: 116/116 passed (7 skipped for missing inputs or optional components, gameinput disabled, as on main).
  • The PR adds no test, so I built a throwaway probe (not committed) against this branch's shims/xmem.cpp + registry.cpp and resolved the exports through rt::shims::find("xmem.dll", ...). 16/16 checks pass:
    • the registry exposes XMemVirtualAlloc, XMemGetWriteWatch, XMemResetWriteWatch
    • plain reserve+commit works; allocation type 0 defaults to reserve+commit
    • 64 KiB mode (0x20400000): 64 KiB-aligned base, size rounded up to 64 KiB and committed
    • large-page mode (0x20000000) → ERROR_NOT_SUPPORTED; nonzero attributes → ERROR_NOT_SUPPORTED
    • size 0 → ERROR_INVALID_PARAMETER; MEM_PHYSICAL alone → ERROR_INVALID_PARAMETER
    • commit at an unaligned address inside a reservation returns the page base
    • write watch reports exactly the two written pages (granularity 4096); after XMemResetWriteWatch it reports none; WRITE_WATCH_FLAG_RESET passes through

Suggestion: those checks would fit as a small xmem ctest case so the 64 KiB rounding and the refusal codes stay pinned.

AI-assisted (Claude).

@edupode

edupode commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Added permanent synthetic coverage in commit 84f86c5: xmem_test now exercises write-watch dirty-page reporting, query-only preservation, reset/re-arm, and rejection of unsupported large pages/nonzero attributes. Built with MSVC 19.51; 35/35 checks pass. No game files or generated shader data used. AI-assisted contribution by @edupode with assistance from ChatGPT 6.2 Astra (Ultra Thinking).

@mesterember104-cpu

Copy link
Copy Markdown

Tested 7c2fbe1 on Tiger Lake (Xe-LP) iGPU 0x9a78 (Intel(R) UHD Graphics, driver 32.0.101.7088), Windows 11, MSVC 14.44: pass

Built the runtime test suite with MSVC 14.44 and Vulkan SDK 1.4.363.0 (RelWithDebInfo). Same coverage note as my other Intel runs here: the translated-shader GPU tests and d3d12_subgroup_test are not built on this machine (no llvm-mc with the AMDGPU target), gameinput disabled (no SDL3).

Full ctest: 93/95 pass; the 2 failures are the same pre-existing main failures as on PR #1991's head (d3d12_descriptor, d3d12_draw bundle blend) — the PR does not touch either area. 7 tests not run (game-data/environment-gated skips + disabled gameinput) — game-gated: skipped, no game copy wired.

The PR's own area, run separately (ctest -R "^xmem$"): passes. The shim builds clean and the xmem tests (including the new XMemVirtualAlloc / write-watch export surface) are green on Windows/Intel.

AI-assisted (GLM, operated by the account owner).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants