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

Manually merged
github merged 1 commit from gh-pr/555/head into gh-pr/555/base 2026-11-26 09:08:16 +00:00
Owner

@⁠Tyrannys on GitHub · 2026-11-24 07:50 UTC · original
Tyrannys:fix/readfile-noaccess → main · +118 −1 · 3 files · 1 commits · merged 2026-11-24 09:26 UTC

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

**@⁠Tyrannys** on GitHub · 2026-11-24 07:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/555) `Tyrannys:fix/readfile-noaccess` → `main` · +118 −1 · 3 files · 1 commits · merged 2026-11-24 09:26 UTC 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)
xmem maps the title's physical pages as views of a reserve-only section and commits each page in a vectored handler
when user-mode code first faults on it. A kernel write raises no such fault: ReadFile into a page nobody touched yet
fails with ERROR_NOACCESS (998). The retail title's file reader treats any error but 6, 0x26 and 0x57 as transient
and calls Sleep(1) and ReadFile again forever, so the boot never leaves its first frame loop; DirectStorage reads
into the same memory came back as E_DSTORAGE_ACCESS_VIOLATION and the title stopped on an int3.

The ReadFile import of the file shims, and DirectStorage's read_file_range, now read one byte of every page of the
destination from user mode on ERROR_NOACCESS (the handler commits them) and read again once. file_system_test checks
it on a reserve-only section with a first-touch handler: the host ReadFile fails with ERROR_NOACCESS, the shimmed one
reads every byte.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:08:14 +00:00
github manually merged commit 779f901084 into gh-pr/555/base 2026-11-26 09:08:16 +00:00
Author
Owner

@⁠sodove on GitHub · 2026-11-24 08:18 UTC · original

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.

**@⁠sodove** on GitHub · 2026-11-24 08:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/555#issuecomment-7125972433) 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.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 09:26 UTC · original

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).

**@⁠QemmHD** on GitHub · 2026-11-24 09:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/555#issuecomment-7127413634) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.