Skip to content

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

Merged
QemmHD merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:fix/readfile-noaccess
Nov 24, 2026
Merged

QemmHD merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:fix/readfile-noaccess

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

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

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…ges and reads again (RT-READFILE-NOACCESS)

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 <noreply@anthropic.com>
@sodove

sodove commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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
QemmHD merged commit 902e8f6 into ProjectLeonida:main Nov 24, 2026
1 check passed
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…h title memory commits the pages and reads again (RT-READFILE-NOACCESS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants