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

Closed
opened 2026-11-26 20:18:25 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/555
Author: @Tyrannys
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: fix/readfile-noaccess


📝 Commits (1)

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

📊 Changes

3 files changed (+118 additions, -1 deletions)

View changed files

📝 runtime/shims/dstorage.cpp (+23 -1)
📝 runtime/shims/file_system.cpp (+36 -0)
📝 runtime/test/file_system_test.cpp (+59 -0)

📄 Description

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


🔄 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/555 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/readfile-noaccess` --- ### 📝 Commits (1) - [`779f901`](https://github.com/ubiquitarianism/leonida/commit/779f901084774418f1f83d55c6d7fa075e71e98b) fs, dstorage: a ReadFile into first-touch title memory commits the pages and reads again (RT-READFILE-NOACCESS) ### 📊 Changes **3 files changed** (+118 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/dstorage.cpp` (+23 -1) 📝 `runtime/shims/file_system.cpp` (+36 -0) 📝 `runtime/test/file_system_test.cpp` (+59 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:25 +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#600
No description provided.