dstorage: requests into physical pages write the title's pages (RT-DSTORAGE-DEST-PAGES) #969

Closed
DadaCap wants to merge 1 commit from upstream-pr/969 into main
DadaCap commented 2026-11-24 16:02:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-24T16:02:47Z.


Claim: RT-DSTORAGE-DEST-PAGES (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136979744).

A DirectStorage request with DestinationIsPhysicalPages runs into a staging buffer and its bytes then go to the 64 KiB pages XMemAllocatePhysicalPages gave out (rt::xmem::write_physical_pages), so every address they are mapped at sees them. Until now it answered E_NOTIMPL.

The page array is read when the request runs, not at enqueue. The retail title passes a pointer into its own page table: at enqueue the entries are 0, and they are filled by the time the request runs. Measured on 1.0.2.1 (in my prototype stack): with a copy taken at enqueue nearly every such request named page 0; read late, no request failed in a 240 s run that reaches the loading screen.

The xmem shim is called through a pointer, as dstorage_test does not link it; without it such a request stays E_NOTIMPL. Physical-page sources stay E_NOTIMPL (none has been seen).

Tested

  • dstorage_test: 341 checks, 0 failures (new: the table filled after enqueue, the offset, three pages, a page that is not live, a null and an unreadable array). xmem_test: 220 checks OK (new: writes across pages, into uncommitted ones, bad page numbers). Windows 11, MSVC, Release-with-debug-info, on main.
  • Retail package: only in my prototype stack, not on this branch alone (RTX 5080, driver 621.24, Windows 11).
  • No game data.

AI-assisted (Claude Code, Opus 5.5).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475753959 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/969). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-24T16:02:47Z. --- Claim: RT-DSTORAGE-DEST-PAGES (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136979744). A DirectStorage request with `DestinationIsPhysicalPages` runs into a staging buffer and its bytes then go to the 64 KiB pages `XMemAllocatePhysicalPages` gave out (`rt::xmem::write_physical_pages`), so every address they are mapped at sees them. Until now it answered `E_NOTIMPL`. **The page array is read when the request runs, not at enqueue.** The retail title passes a pointer into its own page table: at enqueue the entries are 0, and they are filled by the time the request runs. Measured on 1.0.2.1 (in my prototype stack): with a copy taken at enqueue nearly every such request named page 0; read late, no request failed in a 240 s run that reaches the loading screen. The xmem shim is called through a pointer, as `dstorage_test` does not link it; without it such a request stays `E_NOTIMPL`. Physical-page **sources** stay `E_NOTIMPL` (none has been seen). ### Tested - `dstorage_test`: 341 checks, 0 failures (new: the table filled after enqueue, the offset, three pages, a page that is not live, a null and an unreadable array). `xmem_test`: 220 checks OK (new: writes across pages, into uncommitted ones, bad page numbers). Windows 11, MSVC, Release-with-debug-info, on `main`. - Retail package: only in my prototype stack, not on this branch alone (RTX 5080, driver 621.24, Windows 11). - No game data. AI-assisted (Claude Code, Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Snooozs commented 2026-11-24 17:39:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T17:39:23Z.


Independent check: dstorage and xmem pass (dstorage_test, xmem_test rebuilt). I checked the page-count arithmetic: DestinationPageOffset is a UINT16 here, so offset + size cannot wrap and the copied page list always covers what write_physical_pages reads. With #968 there is a textual conflict in runtime/shims/xmem.h only (both add a hook at the end of the namespace).

Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto main 32950551e without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7139513432 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/969#issuecomment-7139513432). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-24T17:39:23Z. --- Independent check: `dstorage` and `xmem` pass (`dstorage_test`, `xmem_test` rebuilt). I checked the page-count arithmetic: `DestinationPageOffset` is a UINT16 here, so `offset + size` cannot wrap and the copied page list always covers what `write_physical_pages` reads. With #968 there is a textual conflict in `runtime/shims/xmem.h` only (both add a hook at the end of the namespace). Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto `main` 32950551e without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.
DadaCap commented 2026-11-25 02:40:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-25T02:40:30Z.


Closing this one: #984 brought another implementation of the same thing to main, and it covers the case this pull request was written for.

  • main's dstorage.cpp resolves a request's physical page numbers in xmem when the request runs (rt::xmem::transfer_physical), not when it is enqueued. That is the point of this branch too: the retail title passes a pointer into its own live page table, whose entries are still 0 at enqueue.
  • This branch now conflicts with main in 5 files (dstorage.cpp, xmem.cpp, xmem.h, dstorage_test.cpp, docs/directstorage.md) and adds nothing main lacks, so a merge would only put a second path beside the first.

The claim RT-DSTORAGE-DEST-PAGES can be dropped from the table. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7151030449 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/969#issuecomment-7151030449). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-25T02:40:30Z. --- Closing this one: #984 brought another implementation of the same thing to `main`, and it covers the case this pull request was written for. - `main`'s `dstorage.cpp` resolves a request's physical page numbers in xmem when the request runs (`rt::xmem::transfer_physical`), not when it is enqueued. That is the point of this branch too: the retail title passes a pointer into its own live page table, whose entries are still 0 at enqueue. - This branch now conflicts with `main` in 5 files (`dstorage.cpp`, `xmem.cpp`, `xmem.h`, `dstorage_test.cpp`, `docs/directstorage.md`) and adds nothing `main` lacks, so a merge would only put a second path beside the first. The claim RT-DSTORAGE-DEST-PAGES can be dropped from the table. AI-assisted (Claude Code).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!969
No description provided.