Repository navigation
xmem: serve the seven missing imports (physical pages, default allocators, XMemIsToolsMemAvailable); XMemVirtualAlloc takes 2 MiB pages and placeholders - #6919
Conversation
|
Tested |
|
Tested Result: every
The title no longer stops at any of its allocation checks. Where it stops next: the first Tested and written by Claude (Claude Code). |
IAmNotSiob
left a comment
There was a problem hiding this comment.
tested on win10 VM (RTX 6000 passthrough, MSVC, RelWithDebInfo) at this pr's head: builds clean, xmem test passes. full ctest 255/260; the 5 failures are gameinput_host, root_signature_oracle, d3d12_indirect_dispatch_count, d3d12_close_parity, d3d12_indirect_rt, none of which touch xmem (that VM has no controller / its own d3d12 quirks). didn't rerun them on main, so treat those as "not caused by this", not "known".
code read, looks careful:
- placeholder windows + section-backed 64 KiB pages under one mutex is the right model for map/unmap, and page numbers as non-zero multiples of 16 below 2^25 match what #6824 describes
- freed slots reused, so a long run can't exhaust page numbers
- VirtualAlloc2/MapViewOfFile3 resolved at run time with ERROR_NOT_SUPPORTED otherwise, nice, no onecore.lib
- dropping PAGE_WRITECOMBINE too is a good call given the D3D12 layer reads these pages on the CPU
small things, non-blocking:
- the ASSUMPTION that nobody kernel32!VirtualAlloc-commits inside a window: if the title ever does, the placeholder refuses it with a fairly opaque error. a one-line trace there would make that obvious from a boot log
XMemIsToolsMemAvailablelogging once to stderr is fine, but the title hits it right before a deliberate int3 on OOM, so maybe mention that in the message (so people reading a boot log know the break after it is expected)
also: this covers what #6709, #6814, #6878, #6908 and #6733 do for XMemVirtualAlloc (attribute words, protection bits, error/trace), and it's the only one that unblocks the #6824 stop. all six touch xmem.cpp, so i'll point those at this one.
AI-assisted (Claude Code).
TL;DR: approve: builds and xmem test passes on Windows, design is sound, two optional logging nits. it supersedes five other xmem prs.
|
Independently tested |
|
On |
|
Tested Local integration branch: From the startup trace (
Counts, API names and offsets only. AI-assisted (Claude Code). |
|
Tested on the retail executable: pass, and on its own it covers the whole xmem part of the startup. Own 1.0.2.1 copy (exe sha256 The startup trace shows every xmem call succeeding, with no
The run then gets through AI-assisted (Claude Code). |
c9c9063 to
94fe02a
Compare
shayderrr
left a comment
There was a problem hiding this comment.
Summary
runtime/shims/xmem.cpp adds seven measured xmem.dll imports: XMemAllocDefault/XMemFreeDefault share a heap with the existing allocators, XMemIsToolsMemAvailable returns FALSE, and physical-page calls use Windows placeholders (VirtualAlloc2, MapViewOfFile3, UnmapViewOfFile2) for pagefile-backed 64 KiB pages. XMemVirtualAlloc now accepts the attribute word, strips console graphics/write-combine bits and commits 2 MiB-aligned pages; new xmem_virtual_alloc/xmem_physical_pages trace events and SHIM_TABLE entries, with tests in xmem_test.cpp and docs in runtime_imports.md/runtime/README.md.
Why merge
Grounds the runtime's memory shim in measured title behavior, unblocking physical-page and large-page paths during static recompilation. Thoroughly tested and documented.
Verdict: Approve
|
Summary Why merge Verdict: Approve |
…orts (physical pages, default allocators, XMemIsToolsMemAvailable) Author: NiiRoZz Conflicts with ItsNotRexed#6709 in xmem.cpp, xmem_test.cpp and docs/runtime_imports.md, resolved to this PR's side: it accepts every attribute word and reserves 64 KiB-page regions as placeholders, which replaces the two allow-listed reservation forms of 6709 and the tests that expected the other forms to be refused. Not built here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UkEUa9YfGQH4p9g1Guw9gq
…emVirtualAlloc takes 2 MiB pages and placeholders Serve the seven xmem.dll imports the shim table lacked, with argument shapes measured at a title's call sites: - XMemAllocDefault / XMemFreeDefault share XMemAlloc's heap. - XMemAllocatePhysicalPages / XMemFreePhysicalPages / XMemMapPhysicalPages / XMemMapPhysicalPagesScatter: 64 KiB pages of pagefile-backed sections, one MapViewOfFile3 view per page in a placeholder window, so pages keep their contents across remaps and can alias. Page numbers are non-zero multiples of 16 below 2^25; 0 unmaps. - XMemIsToolsMemAvailable returns FALSE. XMemVirtualAlloc no longer refuses 2 MiB pages (aligned through VirtualAlloc2), makes reserve-only 64 KiB regions placeholder windows, and passes MEM_RESERVE_PLACEHOLDER and MEM_REPLACE_PLACEHOLDER through. The attribute word and PAGE_GRAPHICS_* handling from ItsNotRexed#6908 is kept as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94fe02a to
36936f3
Compare
|
Retail-exe validation on Windows 11 / RTX 5070 Ti,
This is the fix that gets the retail title past its boot-time virtual-memory allocation. Thank you. |
|
AI-assisted. No game files used. A compatibility/test-coverage question: reserve-then-commit inside a 64 KiB-page reservation worked on For each attribute word (
Should ordinary Setup:
|
|
Tested
AI-assisted (Claude Code); outcomes only, no game data. |
|
Tested on the retail executable: pass. this PR carries the whole memory sequence the title runs before slot 133: the placeholder reservation, its splits by the host Setup: own Xbox 1.0.2.1 copy (exe 120,181,760 bytes), Windows 11 26200, RX 9070 XT (AMD Windows driver), MSVC 14.44 RelWithDebInfo, Result (one run): the device is created; 5 queues (4 through slot 48), 5 fences and 7 allocators; 581 command lists created and closed through slot 73 (list slots 132 and 131 reached on the console-IID lists); slots 78/79 answered; then the xmem placeholder window, its 2 MiB commits and the physical-page maps all succeed ( AI-assisted (Claude Code). |
|
Independent Linux/Wine validation of current head Arch Linux, Wine 11.18, clang-cl 23.1.6, xwin MSVC 14.44.17.14 / SDK 10.0.26100, Ninja RelWithDebInfo, Vulkan and SDL3 enabled. Ryzen 7 9800X3D, Radeon RX 7900 XT, RADV Mesa 26.2.3; the startup failure below occurs before GPU work. Targeted synthetic comparison:
The targeted CTest selection passes 5/5 on both builds. The full suite was not run. With the local package,
No game files, raw traces, or executable data attached. AI-assisted. |
|
Checked To give the open reports one place, I wrote a probe that calls everything through
So B–F reproduce the reports above from @editrice, @Zunraz, @ICUMADETHIS and @byPreaZy on the current head. #6995's map/scatter/free handling is a working reference for B–E (prevalidate, and unmap on free like AI-assisted. Synthetic inputs only, no game files. |
|
Follow-up on One With the cache modifiers dropped for the view, all five maps succeed (752, 1600, 160, 16 and 432 pages) and the boot goes on to the next known stop (device slot 133, a call through a null pointer): DWORD view_protect(const Window& window) {
// A section view takes no cache modifier: MapViewOfFile3 refuses PAGE_WRITECOMBINE / PAGE_NOCACHE (Wine with
// ERROR_INVALID_PARAMETER), and they are only a caching hint for these pagefile-backed CPU views.
const DWORD protect = window.protect & ~(PAGE_WRITECOMBINE | PAGE_NOCACHE);
return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect;
}I measured this only on Wine. I haven't checked whether Windows accepts AI-assisted (Claude Code); outcomes only, no game data. |
|
Tested Works: every One Wine-only failure, with a fix: the first Fix + test on top of this branch, one commit: gkissel@34c7135e9 (branch
With it, the boot goes past the pool and on to the next stop, device slot 133 (stop 12 in the boot-chain doc). Feel free to cherry-pick it, or I can open it as a PR against your branch. AI-assisted (Claude Code). No game files, bytes or code addresses here. |
|
Tested 36936f3 alone and stacked under #7132 (6324dec, all 30 console imports bound) against the retail 1.0.2.1 package, Windows 11, MSVC 14.50, SDK 10.0.26100. Dry-run: alone this leaves 23 unimplemented imports (the AcpHal/xapu/chad/xg_xs/DStorage/D3D12ConfigureVirtualMemoryX groups); stacked under #7132 it is 0 unimplemented, 5 modules mapped.
Reading -1 as a pointer right after the placeholder/physical-page sequence suggests one of the page calls returns or leaves a value the title dereferences (e.g. an out-parameter page number the shim does not write, or a BOOL-vs-handle signature mismatch). The five XMemVirtualAlloc events above are the last trace lines before the fault in both runs. AI-assisted. Counts and API names only, no game data (no addresses, RVAs or dumps). |
|
Wine 11.22 / CachyOS retail result on a local boot stack with this XMem implementation: the per-page path is still mapping at roughly 32 s, when the startup watchdog faults. It had logged 73,728 of 99,776 pages. An opt-in diagnostic mapped the same contiguous section as one view in 10 ms and reached the next D3D12 call. Partial remaps of that view need separate handling. AI-assisted testing. |
|
Compared
The parent reproduced our earlier breakpoint at the same location. With the PR, the exception occurred at a different location after two additional XMem events. The cause of the access violation is still undetermined. AI-assisted. |
|
A count to check against the docs line here ("the same dry run lists 23"). On current The 29 are the doc table's list minus that one:
Windows 11 26300, MSVC 19.44, clean runtime build (299/299). Counts only, nothing from the game. AI-assisted (Claude Code). |
|
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) |
Claimed in the coordination issue as: #6750 (comment)
Depends on: none. Rebased onto #6908 (merged): its attribute-word recording and
PAGE_GRAPHICS_*handling are kept as they are. Overlaps in part with #4531 (2 MiB pages), #5253 (XMemAllocDefault/XMemFreeDefault) and #5381 (the physical-page mechanism). Whichever lands first, I'll rebase this one onto it.What and why
xmem.dllhad seven imports with no shim, which a dry run listed as unimplemented.XMemVirtualAllocstill refused some of the calls a title actually makes: five ask for 2 MiB pages, and several reserve placeholder regions or carve windows out of them. This PR serves all seven imports and adds thoseXMemVirtualAllocforms. The argument shapes were measured locally at a title's call sites. The comments inruntime/shims/xmem.cppgive each shape, as counts and argument roles only.New imports
XMemAllocDefault/XMemFreeDefaulttakeXMemAlloc's andXMemFree's arguments and share their heap, so a block from either allocator can be freed by either.XMemAllocatePhysicalPages(attributes, UINT64* count, UINT64* pages)→BOOL, with an in/out count. Each call is backed by one pagefile-backed section of 64 KiB pages.0means "unmap".XMemMapPhysicalPages(address, UINT64 count, pages)→ the address. A null array unmaps.XMemMapPhysicalPagesScatter(addresses, UINT32 count, pages)→BOOL. A0entry, or a null array, unmaps.XMemFreePhysicalPages(UINT64 count, pages)→BOOL.MapViewOfFile3view in a 64 KiB placeholder. So a page keeps its contents across unmap and remap, can be mapped at several addresses, and can be remapped on its own.XMemIsToolsMemAvailable()→FALSE: a PC has no devkit tools memory. Callers only ask on an out-of-memory path.XMemVirtualAllocVirtualAlloc2, without the host's large-page privilege.host_protect) is recorded. Mapped pages take the window's protection, as AWE does. A window reservedPAGE_NOACCESSmaps its pages read-write, because they are GPU memory the D3D12 layer reads on the CPU.MEM_RESERVE_PLACEHOLDERandMEM_REPLACE_PLACEHOLDERare passed through. A reserve-only replacement stays a window.The placeholder APIs are looked up in
kernelbase.dllat run time, so nothing new is linked. A host without them getsERROR_NOT_SUPPORTED.ASSUMPTION (in the code and in
docs/runtime_imports.md): nothing commits memory into a window throughkernel32!VirtualAlloc, which a placeholder would refuse.The startup trace records the default allocators in
xmem_attributesand adds anxmem_physical_pagesevent.runtime/README.md(shim list, trace events) anddocs/runtime_imports.mddescribe the new behaviour.Tested
Windows 11, MSVC 19.44,
scripts/build_runtime.ps1(CPU build, no Vulkan headers):xmem_test: 173 checks, OK (including xmem: record XMemVirtualAlloc's attribute word and drop the PAGE_GRAPHICS_* protection bits (retail exe GPU pools) #6908's). The old check that expected 2 MiB pages to be refused now checks that they succeed. New checks cover:0entry, scatter maps and unmaps, invalid addresses and page numbers, double free, and page numbers reused after a freectest: 107/107 passed. The skipped tests are the ones that need game files, the same as onmain.gta6rt --dry-runagainst a local copy: unimplemented imports went from 30 to 23, with none left inxmem.dll.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code