Repository navigation
HLE/dstorage: a plain read the kernel refuses into guarded title memory is copied through a buffer - #426
Open
YeokiNoewChi wants to merge 1 commit into
Open
HLE/dstorage: a plain read the kernel refuses into guarded title memory is copied through a buffer#426YeokiNoewChi wants to merge 1 commit into
YeokiNoewChi wants to merge 1 commit into
Conversation
…ry is copied through a buffer A plain DirectStorage read (options 0, file source, address destination) lands through ReadFile into title memory. `kernel_will_write` opens the write guard's blocks first, but the GPU side's check can make a block read-only again before the read lands; ReadFile then fails with ERROR_INVALID_USER_BUFFER (0x800706f8), the request fails, and the title stops on its own breakpoint shortly after (int3 at +0x23d8f03 here: an allocator result checked for null). On those two errors (and ERROR_NOACCESS), when the destination is committed and accessible, read into our own buffer and store the bytes with plain writes, which fault into the guard's handler like the title's own. Anything else keeps the kernel's error. RTX 3070 Ti 8 GB, Ryzen 5 5600X, Windows 11, Series X profile: three cold starts (fresh shader cache) in a row ended on that breakpoint, each right after "dstorage: request failed: copying ... hr=0x800706f8"; with this change three runs on new builds (shaders translated afresh) reached the world; the fallback copied one refused read in two of them, the third had none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On cold starts (fresh shader cache) the title kept stopping on its own breakpoint during the world load:
0x80000003at+0x23d8f03, where it checks an allocator's result for null and traps. Each time, the log showed this a moment before:0x800706f8isERROR_INVALID_USER_BUFFER. A plain request (options 0: file source, address destination) is read withReadFilestraight into title memory.into_destinationcallskernel_will_writefirst, which opens the write guard's blocks. However, the GPU side's check can make a block read-only again (watch::protect) before the kernel's write lands. The kernel then refuses the read, the request fails, and the title's load fails with it.Change
dstorage.rsonly, plain copies only:ReadFilereturnsERROR_INVALID_USER_BUFFERorERROR_NOACCESSfor an address destination, and the whole destination is committed and notPAGE_NOACCESSor a guard page (VirtualQuery), the read goes into our own buffer instead. The bytes are then stored with plain writes, which fault into the guard's handler like the title's own writes and are noted written as usual.dstorage: a read the kernel refused into guarded title memory was copied through a bufferat the 1st, 2nd, 4th, 8th... occurrence.Tested
RTX 3070 Ti 8 GB, Ryzen 5 5600X (6 cores), 32 GB, Windows 11, Series X profile:
copyingrequest above.cargo test -p victory-hle dstorage: 14 passed.cargo clippy -p victory-hle -- -D warnings: clean.The race is more likely on machines where the GPU side's checks compete with the title for CPU, like this 6-core one during shader warm-up. That may be why it shows on some machines and not others.
Related, not overlapping: #329 (diagnostics for page-destination write failures) and #403 (DirectStorage file lifetime).
AI-assisted (Claude Code); counts, offsets and hashes only, nothing from the game.
🤖 Generated with Claude Code