fs, dstorage: a ReadFile into first-touch title memory commits the pages and reads again (RT-READFILE-NOACCESS) #555

Merged
Tyrannys merged 1 commit from upstream-pr/555 into main 2026-11-24 09:26:25 +00:00
Tyrannys commented 2026-11-24 07:50:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-24T07:50:55Z.


Claimed in #14 as RT-READFILE-NOACCESS.

What

xmem maps the title's physical pages as views of a reserve-only section, and its vectored handler commits each page the first time user-mode code faults on it. A kernel write raises no such fault. So a ReadFile into a page nobody has touched yet fails with ERROR_NOACCESS (998).

  • Title file reader: it treats any error except 6, 0x26 and 0x57 as transient, then calls Sleep(1) and ReadFile again forever. Seen by sampling the thread and reading its TEB last-error. The boot never gets past its first frame loop (one clear, one draw, PresentX).
  • DirectStorage: read_file_range reads into the same memory. The request completes with E_DSTORAGE_ACCESS_VIOLATION, and the title stops on an int3.

Fix

  • The file shims now serve ReadFile. On ERROR_NOACCESS it reads one byte of every 4 KiB page of the destination from user mode (the handler commits them), then calls ReadFile once more. Other errors and the normal path are unchanged.
  • dstorage.cpp's read_file_range does the same.

Tested

  • file_system_test: new check on a reserve-only section view with a first-touch commit handler. The host ReadFile fails with ERROR_NOACCESS; the shimmed one reads all 196,731 bytes, which match. 494 checks, 0 failures. dstorage_test passes.
  • Retail boot, native Windows 11, RTX 4070 SUPER, MSVC. Tested on main plus the open boot PRs (#375–#432, #445, #360, #219, #461, #404; see #321). Without this change, the file reader loops at 998 forever. With it, that loop is gone, the DirectStorage int3 is gone, and the title runs much further: about 190 slot-67 compute pipelines instead of about 40, and still running at 120 s. It is still not past the boot screen: the frames are still black. The DirectStorage half is checked only by that run; there's no unit test for it.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5468221925 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/555). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-24T07:50:55Z. --- Claimed in #14 as `RT-READFILE-NOACCESS`. ### What `xmem` maps the title's physical pages as views of a reserve-only section, and its vectored handler commits each page the first time user-mode code faults on it. A kernel write raises no such fault. So a `ReadFile` into a page nobody has touched yet fails with `ERROR_NOACCESS` (998). - **Title file reader:** it treats any error except 6, 0x26 and 0x57 as transient, then calls `Sleep(1)` and `ReadFile` again forever. Seen by sampling the thread and reading its TEB last-error. The boot never gets past its first frame loop (one clear, one draw, `PresentX`). - **DirectStorage:** `read_file_range` reads into the same memory. The request completes with `E_DSTORAGE_ACCESS_VIOLATION`, and the title stops on an `int3`. ### Fix - The file shims now serve `ReadFile`. On `ERROR_NOACCESS` it reads one byte of every 4 KiB page of the destination from user mode (the handler commits them), then calls `ReadFile` once more. Other errors and the normal path are unchanged. - `dstorage.cpp`'s `read_file_range` does the same. ### Tested - `file_system_test`: new check on a reserve-only section view with a first-touch commit handler. The host `ReadFile` fails with `ERROR_NOACCESS`; the shimmed one reads all 196,731 bytes, which match. 494 checks, 0 failures. `dstorage_test` passes. - **Retail boot, native Windows 11, RTX 4070 SUPER, MSVC.** Tested on `main` plus the open boot PRs (#375–#432, #445, #360, #219, #461, #404; see #321). Without this change, the file reader loops at 998 forever. With it, that loop is gone, the DirectStorage `int3` is gone, and the title runs much further: about 190 slot-67 compute pipelines instead of about 40, and still running at 120 s. It is still not past the boot screen: the frames are still black. The DirectStorage half is checked only by that run; there's no unit test for it. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sodove commented 2026-11-24 08:18:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T08:18:20Z.


Independent Windows 11 build 26100.7623 check of 779f901 against main 1c93c86, MSVC 19.44.35220 Release. The stock file_system and dstorage tests both passed on the PR.

I also exercised the file-backed DirectStorage queue with a synthetic reserve-only view and a first-touch commit handler. The destination was unaligned and crossed three pages. Each request read from a nonzero file offset.

Destination main #555 Pages committed by the handler on #555
Entirely uncommitted E_DSTORAGE_ACCESS_VIOLATION S_OK, 8000/8000 bytes matched 3
Middle page uncommitted E_DSTORAGE_ACCESS_VIOLATION S_OK, 8000/8000 bytes matched 1
Already committed S_OK, 8000/8000 bytes matched S_OK, 8000/8000 bytes matched 0

All three requests completed. The two failing main requests performed no user-mode page commits. Synthetic fixture only. No GPU required. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125972433 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/555#issuecomment-7125972433). Originally posted by [sodove](https://github.com/sodove) on 2026-11-24T08:18:20Z. --- Independent Windows 11 build 26100.7623 check of 779f901 against main 1c93c86, MSVC 19.44.35220 Release. The stock file_system and dstorage tests both passed on the PR. I also exercised the file-backed DirectStorage queue with a synthetic reserve-only view and a first-touch commit handler. The destination was unaligned and crossed three pages. Each request read from a nonzero file offset. | Destination | main | #555 | Pages committed by the handler on #555 | | --- | --- | --- | ---: | | Entirely uncommitted | E_DSTORAGE_ACCESS_VIOLATION | S_OK, 8000/8000 bytes matched | 3 | | Middle page uncommitted | E_DSTORAGE_ACCESS_VIOLATION | S_OK, 8000/8000 bytes matched | 1 | | Already committed | S_OK, 8000/8000 bytes matched | S_OK, 8000/8000 bytes matched | 0 | All three requests completed. The two failing main requests performed no user-mode page commits. Synthetic fixture only. No GPU required. AI-assisted verification.
QemmHD commented 2026-11-24 09:26:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T09:26:22Z.


Merging. Why merged: a ReadFile into first-touch title memory that fails with ERROR_NOACCESS (fs shim and DirectStorage reads) now touches the destination pages from user mode and retries once; every other error path is unchanged.
Why it's good: built with VS 2022 + Ninja on main 7430f59: file_system_test 490 checks / 1 failure (with the PR's test) -> 494 / 0 with the fix; dstorage_test passes; consistency 565/0. The DirectStorage half has no dedicated test yet.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7127413634 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/555#issuecomment-7127413634). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T09:26:22Z. --- Merging. Why merged: a ReadFile into first-touch title memory that fails with ERROR_NOACCESS (fs shim and DirectStorage reads) now touches the destination pages from user mode and retries once; every other error path is unchanged. Why it's good: built with VS 2022 + Ninja on main 7430f59: file_system_test 490 checks / 1 failure (with the PR's test) -> 494 / 0 with the fix; dstorage_test passes; consistency 565/0. The DirectStorage half has no dedicated test yet. AI-assisted (Claude Code, Claude Opus 5.5).
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!555
No description provided.