Repository navigation
Conversation
…t startup XMemAllocatePhysicalPages, XMemFreePhysicalPages, XMemMapPhysicalPages and XMemMapPhysicalPagesScatter, with the shapes of the executable's call sites. A page is a 64 KiB slot of a pagefile-backed section; a 64 KiB-page reserve-only XMemVirtualAlloc is a placeholder reservation, and mapping a page replaces its placeholder with a view of the slot, so one page can be mapped at several addresses as on the console. The title's VirtualFree releases such a reservation whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows 11 check at PR head
|
|
Additional Windows coverage at
CPU only, no game inputs. AI-assisted (Codex). |
6743495 to
e282ed2
Compare
|
Tested
|
|
Tested merged on top of main a637671 + #7017 #4531 #6582 #4313 #4348 #6964 #6982 #6953 #6954 (local boot stack, my own 1.0.2.1 copy, Windows 11, RTX 4080, driver 32.0.16.2101):
AI-assisted. |
|
Tested
AI-assisted (Claude Code); outcomes only, no game data. |
|
Tested e282ed2 on RTX 5090, 621.24, Windows 11 (CPU side): pass.
|
|
Codex ran the synthetic XMem tests for PR head
No game files were used. This is targeted validation of the synthetic CPU-side tests; it does not validate GPU-backed physical pages or game boot, and the macOS Wine result is not a native Windows result. AI-assisted testing by Codex. |
|
Checked One regression from
The reserve succeeds in both. It may not matter for the retail title, whose startup calls all succeed, but a test pinning the intended behaviour would help either way. The rest of the same probe passed here: a bad page number keeps the existing mapping, contiguous and scatter requests are all-or-nothing, and freeing a mapped page unmaps it before its number is reused. A AI-assisted. Synthetic inputs only, no game files. |
|
Tested Setup: RTX 4070 (driver 621.01), Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo with Ninja, Vulkan SDK 1.4.363.0. The PR head was merged alone into main 8575d36 and AI-assisted review (Claude Code). How this compares with the other boot-chain PRs: #7333 (comment) |
|
Code read of
Not run: code read only, no tests run. AI-assisted review. |
Claimed in the coordination issue as: #6750 (comment) (new RT item, RT-5's next stop after @Pipodi's finding)
Based on
main(rebased at6de3970e1): since #6908,mainserves the 64 KiB reserve-onlyXMemVirtualAllocform and drops thePAGE_GRAPHICS_*bits, so this no longer depends on #6709; the hook usesmain'shost_protect. Overlaps #6919 (@NiiRoZz, claimed 11 minutes after this item, same four exports), #4531 (XMemVirtualAllocrestructure; the hook here is four lines and moves into its wrapper unchanged) and #5381 (@maxxgabriel's device-local half of physical pages, which can take this store's sections).What and why
With #6709, #4531, #6582, #4313 and #4348 merged locally, the retail executable stops at
xmem.dll!XMemAllocatePhysicalPages: it is unimplemented, and the title asserts when it fails. This PR serves it and the three calls that go with it. The shapes come from the executable's call sites. Only argument roles and return checks are given here: four callers allocate, three free, eleven map and two scatter.XMemAllocatePhysicalPagesBOOL (ULONG64 attributes, ULONG_PTR* count, ULONG_PTR* page_array), count in 64 KiB pages, attributes0x180/0x280/0x380TRUEand the count unchangedXMemFreePhysicalPagesBOOL (ULONG_PTR count, ULONG_PTR* page_array)XMemMapPhysicalPagesPVOID (PVOID va, ULONG_PTR count, ULONG_PTR* page_array), a null array unmapsXMemMapPhysicalPagesScatterBOOL (PVOID* va_array, ULONG_PTR count, ULONG_PTR* page_array), null array or 0 entries unmapHow it works (
runtime/shims/xmem_physical.cpp, a new file):(slot + 1) * 16, a 4 KiB frame number, because one caller rebuilds an entry as a 64 KiB index times 16, masked to 25 bits. So entries are never 0, and there are at most 2^21 - 1 slots.XMemVirtualAlloc(nullptr, size, MEM_RESERVE | 0x20400000, attributes, protect)becomes a placeholder reservation (VirtualAlloc2,MEM_RESERVE_PLACEHOLDER). It accepts any attribute word, and the CPU protection is kept with thePAGE_GRAPHICS_*bits dropped. These are the ranges the title maps into: both 24 GiB startup reservations and the per-pool ones (attributes0x21,0x3,0x23).MapViewOfFile3,MEM_REPLACE_PLACEHOLDER). Unmapping puts the placeholder back.VirtualFree. The title'sVirtualFree(base, 0, MEM_RELEASE)of such a range is shimmed (kernel32, kernelbase and the memory API sets). The host's own would release only the first placeholder.xmem.cppreaches the store through a hook thatxmem_physical.cppregisters at static initialisation (xmem_physical.h). The many test targets that compilexmem.cppwithout the store keep the old behaviour, and no other target's sources change.Not done:
docs/runtime_imports.mdgains a "Physical pages" section with the table above.Tested
Windows 11 (10.0.26340), MSVC 19.51 (VS 18), NVIDIA GeForce RTX 5090, driver 621.24:
xmem_physical_test: 60/60 checks.PAGE_NOACCESSalias, remapping over a mapped page, bad and unaligned input leaving state untouched, scatter with 0 entries, free-while-mapped unmapping everywhere, zeroed reuse and duplicate frames in one free.xmem_test: OK. Fullctestafter the rebase: everything passes exceptd3d12_vulkan_device, which fails at itsGetResourceTilingpacked-tile check (tiles == 1). Plainmainat6de3970e1fails the same check on this machine, and that test doesn't link xmem.python -I tests/test_docs_*.py: all 11 OK.gta6rt --run,LEONIDA_D3D12=vulkan):XMemVirtualAllocattribute word (the 2 MiB reserve-and-commit calls, @Pipodi's stop 1, not in this PR).XMemAllocatePhysicalPages.D3D12XboxCreateDevice(the Vulkan device is created) to an access violation in device slot 26, which @sennecools claimed at 15:23.XMemMapPhysicalPages*call failed.Not tested: Wine. @Stalkerino offered a Linux / Wine 11.22 check; Wine needs
VirtualAlloc2/MapViewOfFile3placeholders, and without them reservations fall back to ordinary ones with one[rt]line.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (Not a translator change.)🤖 Generated with Claude Code