Skip to content

Runtime: support the observed committed 64 KiB CPU XMem allocation - #6814

Open
Stalkerino wants to merge 1 commit into
ItsNotRexed:mainfrom
Stalkerino:fix/xmem-cpu-64k
Open

Stalkerino wants to merge 1 commit into
ItsNotRexed:mainfrom
Stalkerino:fix/xmem-cpu-64k

Conversation

@Stalkerino

Copy link
Copy Markdown

Implements the CPU allocation reported in the coordination thread. A null-address XMemVirtualAlloc requesting MEM_RESERVE | MEM_COMMIT, console 64 KiB pages, access word 0x181 and PAGE_READWRITE currently fails with ERROR_NOT_SUPPORTED. This change routes that exact combination through the existing aligned 64 KiB allocation path. The meaning of the access word’s 0x100 bit is still unknown.

The regression test requests 20 MiB, checks the base alignment, committed extent and protection with VirtualQuery, writes and reads the first and last bytes, and releases the allocation. It also covers the boundary with reserve-only, explicit-address and graphics requests.

Verification

  • CachyOS x86-64, Wine 11.22, clang-cl/xwin. On 1cc6e3c12, the added test fails at the new allocation. With this patch, xmem_test passes all 114 checks.
  • On a separate local integration build, the 20 MiB request succeeds and the title reaches GDK initialization. That run used independent experimental CPU backing for earlier graphics allocations. This PR only implements the CPU request.

@jlric

jlric commented Nov 23, 2026

Copy link
Copy Markdown

Tested a55ee82 on CachyOS x86-64 with Wine 11.22 and clang-cl/xwin. All 114 synthetic XMem checks passed, including the 64 KiB commit and rejection cases. CPU-only. AI-assisted.

@BeegSchmooze

Copy link
Copy Markdown
Contributor

Native Windows check of a55ee82b (the PR was run under Wine): pass. Windows 11 26200, MSVC 19.51 (VS 18), RelWithDebInfo, xmem_test target only, CPU only.

  • xmem_test: 114 checks, 0 failed, exit 0.
  • On the host's VirtualAlloc/VirtualQuery, the new allocation behaves as described: access word 0x181 commits a new 64 KiB-page CPU allocation; the 20 MiB region is aligned, committed and CPU-writable; and reserve-only with zero attributes still leaves its region uncommitted.

I don't have the retail executable, so I haven't run the startup path past this call.

AI-assisted (Claude Code). No game files.

@LLLL-zzzz0

Copy link
Copy Markdown

Independent native Windows check of a55ee82b5 (the description's run is under Wine).

Environment: Windows 11 26100, MSVC 19.44.35213 (VS 2022 17.14), VS generator RelWithDebInfo.

  • xmem_test: OK (114 checks).
  • Red control: with runtime/shims/xmem.cpp back at the merge base (test kept), xmem_test fails at FAIL 0x181 commits a new 64 KiB CPU allocation (111 checks, 1 failure), so the new path is exactly what the regression test covers.
  • The neighbouring checks pass on native Windows too: reserve-only with zero attributes stays uncommitted, explicit-address and graphics requests behave, and the committed allocation is writable and released.
  • I did not exercise the title's GDK initialisation (no game copy), only the shim test.

AI-assisted.

@IAmNotSiob

Copy link
Copy Markdown
Contributor

heads up: #6919 (xmem physical pages, the #6824 boot stop) also covers this XMemVirtualAlloc change, and all of these touch xmem.cpp. might be worth checking whether anything here is still missing on top of it, otherwise one of them will need a rebase :) AI-assisted (Claude Code).

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

runtime/shims/xmem.cpp:XMemVirtualAlloc now permits the exact observed CPU request (attribute 0x181, null address, PAGE_READWRITE, 64 KiB reserve|commit) by routing it to the existing aligned allocation path; other nonzero attribute forms still fail with ERROR_NOT_SUPPORTED. xmem_test.cpp adds test_cpu_64k_commit verifying alignment, committed extent, read/write at both ends and negative controls; docs/runtime_imports.md documents the call.

Why merge

Advances the RT-5 boot path by backing the observed committed 64 KiB XMem CPU allocation the title requests at startup.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

runtime/shims/xmem.cpp:XMemVirtualAlloc now permits the exact observed CPU request (attribute 0x181, null address, PAGE_READWRITE, 64 KiB reserve|commit) by routing it to the existing aligned allocation path; other nonzero attribute forms still fail with ERROR_NOT_SUPPORTED. xmem_test.cpp adds test_cpu_64k_commit verifying alignment, committed extent, read/write at both ends and negative controls; docs/runtime_imports.md documents the call.

Why merge

Advances the RT-5 boot path by backing the observed committed 64 KiB XMem CPU allocation the title requests at startup.

Verdict: Approve

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested a55ee82b on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363: no regression.

AI-assisted (Claude Code).

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