[PR #1972] [CLOSED] xmem: a slot-31 copy leaves the title's own mappings at the paired CPU range (RT-SLOT31-CPU-TWIN-TITLE-PAGES) #1980

Closed
opened 2026-11-26 21:19:37 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1972
Author: @kurrutako
Created: 11/25/2026
Status: ❌ Closed

Base: main ← Head: rt/slot31-cpu-twin-title-pages


📝 Commits (2)

  • ca00cc0 xmem: a slot-31 copy leaves the title's own mappings at the paired CPU range
  • 28fc026 d3d12_xs, test: say which route slot 31 remaps through; cover the retail route

📊 Changes

4 files changed (+138 additions, -5 deletions)

View changed files

📝 runtime/shims/d3d12_xs_device.cpp (+6 -0)
📝 runtime/shims/xmem.cpp (+42 -4)
📝 runtime/test/d3d12_xmem_placed_test.cpp (+77 -0)
📝 runtime/test/xmem_test.cpp (+13 -1)

📄 Description

Claimed in the coordination issue as: RT-SLOT31-CPU-TWIN-TITLE-PAGES

What and why

copy_page_mappings (queue slot 31, CopyPageMappingsBatchX) mirrors every page it maps or unmaps at a GPU-only destination onto the paired CPU range (title_gpu_views::to_cpu, from 255f17001). It did this even where the title had mapped that CPU page itself. A copy replaced the title's page, and an unmap (kind 2) left the title's CPU page only reserved. The title's next read of it was a fault in a window, left to the title, and the run ended. The commit that added the mirror names this risk: if the pairing is wrong, "the mirror replaces the title's own mappings in that CPU range".

The console's CopyPageMappingsBatchX edits only the GPU-only range's page table. So a CPU page that holds one of the title's own mappings (XMemMapPhysicalPages, XMemMapPhysicalPagesScatter, or a slot-31 copy onto that address) is now left as it is. Pages the mirror made itself, zero plants and pages with no mapping still follow the GPU-only range, so the D3D12 layer's reads at the CPU view still work. Each page left alone is counted, and the first ones are logged.

The unmaps on these paths now carry their own label in the read-fault report, instead of the default unmap:

  • CopyPageMappingsBatchX: unmap, paired CPU page, remap, hole
  • XMemMapPhysicalPagesScatter: unmap, remap

Tested

  • xmem_test (MSVC, RelWithDebInfo): test_copy_page_mappings_cpu_view gains two checks. A copy onto, and an unmap of, a GPU-only page whose paired CPU page the title mapped must keep the title's bytes at the CPU page. Both checks fail on the old code and the whole test passes with the fix.

  • Retail boot, own copy, RTX 5070: current main plus #1851, #1827, #1849, #1862 and #1886, Series S device type, same switches every time.

    Before (5 boots) With this change
    How the run ended 0xc0000005 or INT3 after 277–1,308 s Ran 940 s; I closed the window, exit code 0
    Reads by the title of a page the runtime had unmapped 1–8 per boot, the last one or two right before the crash 0
    Faults left to the title 5–33 1
    Mirror skipped a CPU page the title mapped — logged from the first streaming batches, all scatter mappings

    Before the change, each read fault's report matched a default-cause unmap of the same page 0.7–1.9 s earlier. The screen stays black at about 0.4 frames/s at this stage, as it did before the change. One boot is not proof that the crash is gone, but none of these reads came back.

GPUs tested: NVIDIA RTX 5070

AI-assisted.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1972 **Author:** [@kurrutako](https://github.com/kurrutako) **Created:** 11/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `rt/slot31-cpu-twin-title-pages` --- ### 📝 Commits (2) - [`ca00cc0`](https://github.com/ubiquitarianism/leonida/commit/ca00cc0e0338d27ff018f94d9a7e6e3da58abe7d) xmem: a slot-31 copy leaves the title's own mappings at the paired CPU range - [`28fc026`](https://github.com/ubiquitarianism/leonida/commit/28fc0262d2957412cecfbfa8dd679b8e9e7dbf53) d3d12_xs, test: say which route slot 31 remaps through; cover the retail route ### 📊 Changes **4 files changed** (+138 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_xs_device.cpp` (+6 -0) 📝 `runtime/shims/xmem.cpp` (+42 -4) 📝 `runtime/test/d3d12_xmem_placed_test.cpp` (+77 -0) 📝 `runtime/test/xmem_test.cpp` (+13 -1) </details> ### 📄 Description Claimed in the coordination issue as: [RT-SLOT31-CPU-TWIN-TITLE-PAGES](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7169000776) ### What and why `copy_page_mappings` (queue slot 31, `CopyPageMappingsBatchX`) mirrors every page it maps or unmaps at a GPU-only destination onto the paired CPU range (`title_gpu_views::to_cpu`, from 255f17001). It did this even where the title had mapped that CPU page itself. A copy replaced the title's page, and an unmap (kind 2) left the title's CPU page only reserved. The title's next read of it was a fault in a window, left to the title, and the run ended. The commit that added the mirror names this risk: if the pairing is wrong, "the mirror replaces the title's own mappings in that CPU range". The console's `CopyPageMappingsBatchX` edits only the GPU-only range's page table. So a CPU page that holds one of the title's own mappings (`XMemMapPhysicalPages`, `XMemMapPhysicalPagesScatter`, or a slot-31 copy onto that address) is now left as it is. Pages the mirror made itself, zero plants and pages with no mapping still follow the GPU-only range, so the D3D12 layer's reads at the CPU view still work. Each page left alone is counted, and the first ones are logged. The unmaps on these paths now carry their own label in the read-fault report, instead of the default `unmap`: - `CopyPageMappingsBatchX`: unmap, paired CPU page, remap, hole - `XMemMapPhysicalPagesScatter`: unmap, remap ### Tested - **`xmem_test` (MSVC, RelWithDebInfo):** `test_copy_page_mappings_cpu_view` gains two checks. A copy onto, and an unmap of, a GPU-only page whose paired CPU page the title mapped must keep the title's bytes at the CPU page. Both checks fail on the old code and the whole test passes with the fix. - **Retail boot, own copy, RTX 5070:** current `main` plus #1851, #1827, #1849, #1862 and #1886, Series S device type, same switches every time. | | Before (5 boots) | With this change | |---|---|---| | How the run ended | 0xc0000005 or INT3 after 277–1,308 s | Ran 940 s; I closed the window, exit code 0 | | Reads by the title of a page the runtime had unmapped | 1–8 per boot, the last one or two right before the crash | 0 | | Faults left to the title | 5–33 | 1 | | Mirror skipped a CPU page the title mapped | — | logged from the first streaming batches, all `scatter` mappings | Before the change, each read fault's report matched a default-cause unmap of the same page 0.7–1.9 s earlier. The screen stays black at about 0.4 frames/s at this stage, as it did before the change. One boot is not proof that the crash is gone, but none of these reads came back. GPUs tested: NVIDIA RTX 5070 AI-assisted. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:37 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1980
No description provided.