Skip to content

xmem: a physical-page view drops PAGE_WRITECOMBINE and PAGE_NOCACHE (Wine refuses them; RT-5 boot on Proton) - #7550

Closed
ramenbellic wants to merge 1 commit into
ProjectLeonida:mainfrom
ramenbellic:fix/xmem-view-writecombine
Closed

ramenbellic wants to merge 1 commit into
ProjectLeonida:mainfrom
ramenbellic:fix/xmem-view-writecombine

Conversation

@ramenbellic

@ramenbellic ramenbellic commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue: #7333 (comment) (new RT item, RT-5 follow-up of #6919)

Depends on: none (applies to main; follow-up of #6919, which is merged).

Problem

The retail executable reserves some physical-page windows with protection 0x2404: a graphics bit plus PAGE_READWRITE | PAGE_WRITECOMBINE. host_protect drops only the PAGE_GRAPHICS_* bits (0x800–0x40000), so the window keeps PAGE_WRITECOMBINE. view_protect passes that to MapViewOfFile3, which refuses it on Wine with ERROR_INVALID_PARAMETER.

Under gta6rt --run on Linux/Proton, the title's first XMemMapPhysicalPages into that window (752 pages) fails. The title then unmaps its other ranges, its device init returns false and it asserts. That ends every Wine/Proton boot before the descriptor heaps. Measured on #6919's head before it merged: #6919 (comment)

Fix

view_protect drops PAGE_WRITECOMBINE and PAGE_NOCACHE. These views are pagefile-backed CPU mappings, so the modifier is only a caching hint. Nothing else changes; a PAGE_NOACCESS window still maps read-write as before.

Tested

Linux, Proton Experimental (wine 11.0), runtime cross-built with clang-cl 23.1.6 + xwin SDK 10.0.26100 (RelWithDebInfo), RTX 3070 (driver 620.70.06):

Not run on Windows. Dropping the modifier there changes nothing but the caching hint of a CPU view.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

The retail executable reserves physical-page windows with protection 0x2404: a graphics bit plus
PAGE_READWRITE | PAGE_WRITECOMBINE. host_protect keeps the write-combine modifier, and view_protect
passed it to MapViewOfFile3, which refuses it on Wine with ERROR_INVALID_PARAMETER. On Linux/Proton the
title's first XMemMapPhysicalPages into that window failed and its device init asserted. The views are
pagefile-backed CPU mappings, so the modifier is only a caching hint; it is dropped for the view.

xmem_test: a window reserved with the title's protection maps a page and its view is plain read-write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013puXaEnm3gXuUo4XsSt4g4
@MartinIndra02

Copy link
Copy Markdown
Contributor

Independent Windows test of 95df4e282: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), no game files.

  • xmem_test.exe: PASS (exit 0).

AI-assisted review/test.

@lunarminus

Copy link
Copy Markdown

Tested 95df4e282 on Wine 11.22 (CachyOS Linux) with an AMD Radeon 760M (RADV Mesa 26.3.1), against my own 1.0.2.1 retail executable, network off, gta6rt cross-built with clang-cl 23.1.5 + xwin: pass

I didn't compare it against #7499 or #7492, which make the same core change. Outcomes only, no game data. AI-assisted (Claude Code).

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

A native-Windows reason for this change, measured on my own 1.0.2.1 copy (Windows 11, RTX 5060 Ti, NVIDIA driver, MSVC RelWithDebInfo, LEONIDA_D3D12=vulkan). Integration tree: main plus the boot-path PRs through device slot 133 (#4313, #6582, #4348, #3410 + SDL3, #6954, #7076, #6953, #7218).

Without this PR, device slot 133 (#7218) falls back to an ordinary buffer: [rt] d3d12: a title-placed buffer (device slot 133) could not import its pages … HRESULT -2147467263 (E_NOTIMPL). A local probe in create_host_buffer shows why. The first page of the 182,452,224-byte buffer is committed and MEM_MAPPED, but its protection is PAGE_READWRITE | PAGE_WRITECOMBINE (0x404). The import loop deliberately refuses write-combined pages, so the title's writes never reach the GPU buffer. That is not Wine-specific: on Windows MapViewOfFile3 accepts the flag, and the view keeps it.

With this PR merged on top (nothing else changed), the same run creates the slot-133 buffer as a host import. There is no fallback line and no probe hit, and the boot reaches the same next stop (heap slot 9, stop 13).

So the cache modifier matters for #7218's import on Windows/NVIDIA as well as for MapViewOfFile3 under Wine. #7492 and #7499 make the same change; this measurement applies to whichever one lands. Counts and flag values only, no game files. AI-assisted (Claude Code).

@skorex

skorex commented Nov 23, 2026

Copy link
Copy Markdown

Duplicate of #7492

#7492 makes the same change and was opened earlier. Topic: xmem: a physical-page view drops PAGE_WRITECOMBINE and PAGE_NOCACHE from the window protection.

Suggest closing this PR in favour of #7492, and porting anything this one adds that #7492 lacks there.

@ramenbellic

Copy link
Copy Markdown
Author

Closing as a duplicate of #7492, which makes the same view_protect change, was opened first and has a larger xmem_test (180 checks, passing under Wine as well). My Wine result is on #7492. Sorry for the noise.

@DeSunShine

Copy link
Copy Markdown
Contributor

Tested 95df4e282 merged into main dde82f27e on NVIDIA GeForce RTX 4090 (driver 621.24), Windows 11 Pro 26200, MSVC (VS Build Tools 18) + Ninja, Vulkan SDK 1.4.363: pass.

  • ctest -R "xmem|tiny_game" --output-on-failure: 100% passed out of 11 (xmem and the run_tiny_game* tests). Native Windows only; the Wine refusal the PR targets was not exercised.

AI-assisted (Claude Code).

@ramenbellic
ramenbellic deleted the fix/xmem-view-writecombine branch November 23, 2026 21:07
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…E_WRITECOMBINE and PAGE_NOCACHE (Wine refuses them; RT-5 boot on Proton)

Squashed from ProjectLeonida#7550 by ramenbellic, head 95df4e2 (security scan PASS).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
… one view, so the retail boot's 100,000-page XMemMapPhysicalPages fits the title's hang watchdog under Wine

Squashed from ItsNotRexed#7584 by gkissel, head 5ba2a7f (security scan PASS).

Merged cleanly on top of ItsNotRexed#7550 (view_protect still feeds the view's protection). Added the fix from the PR's review (dotaku22): after a partial unmap a guest run spans several host placeholders, and mapping the whole run again failed with ERROR_INVALID_PARAMETER; map_view now maps one view per placeholder. xmem_test gains that re-map check, which failed under Wine 11.22 before the fix and passes after (189 checks).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ts window's PAGE_NOACCESS

Squashed from ProjectLeonida#7693 by lisboon, head c54e232 (security scan PASS).

Conflict: view_protect, which ProjectLeonida#7550 changed to drop PAGE_WRITECOMBINE/PAGE_NOCACHE (and kept PAGE_NOACCESS -> PAGE_READWRITE). Kept both intents: the window's protection is returned as is (a 0x801 window maps PAGE_NOACCESS, ProjectLeonida#7693) minus the cache modifiers (ProjectLeonida#7550). xmem_test under Wine 11.22: 600 checks OK, including both PRs' cases.
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.

6 participants