DirectStorage: a virtual destination is written without faulting #700
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/705"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by requiemsnkrp on 2026-11-24T03:55:58Z.
executechecks a virtual destination withwritable()at its start, then reads the file or copies the source and inflates it, and only then writes the destination withcopy_nonoverlapping. If the title unmapped the destination in that window (which spans the file read), the write faulted in thexcl-dstorageworker and ended the process. It is now written withwrite_own(NtWriteVirtualMemoryon the process itself), the counterpart of theread_ownthat the page arrays already use, so the request fails withE_ACCESS_VIOLATIONinstead. NotWriteProcessMemory: it first queries the region, and in the 4 GiB coherent window that took 75–175 ms a call (measured in the title: 64 KiB and 8-byte writes alike, whileReadProcessMemorytook 3–11 µs). A first version with it showed 0 frames in two 60 s regression runs, because the title's first streaming stalled. This is the destination side of #476; @brothernog found it in the review of #561. It is independent of #509 and #561 (a different hunk ofexecute), branched frommain91f9a5e.What is in it
crates/xcl/src/hle/dstorage.rs:write_own(NtWriteVirtualMemory, raw-dylib as the other ntdll calls), used for the virtual destination's write inexecute; thewritable()check at the start stays (it commits lazy pages and refuses early)crates/xcl/src/hle/dstorage.rs, tests:a_destination_unmapped_under_the_worker_fails_the_requestruns 20000 memory-source requests while another thread decommits and recommits the destination pageTested
--exact): 5 ×0xc0000005 STATUS_ACCESS_VIOLATION; with the fix: 10 of 10 passed;hle::dstoragetests: 14 passedcargo test --workspace -- --test-threads=4ond09f285: 693 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareRegression run
main:
(
main63cdc25; this branch's base91f9a5ediffers from it by README.md only)PR:
Not tested
memcpycalled fromxcl.exewhile the world streams, RTX 3060 12 GB) may be this; I could not match itsxcl.exeoffsets to a build, so that is a guessAI use
Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T04:05:43Z.
Code audit + NVIDIA RTX 5080 test run on
d09f285014c6262b35f6b412d46eb4cfd70b7b2c:Review
Looks clean —
NtWriteVirtualMemory(raw-dylibfromntdll) matches the x64 Win32 signature, checksat != 0,NT_SUCCESS(>= 0), anddone == data.len(), avoidingWriteProcessMemory's expensiveNtQueryVirtualMemorypage-table walk while failing cleanly withE_ACCESS_VIOLATIONif the title unmaps a virtual destination mid-request.Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 693 passed, 0 failed, 41 ignored.hle::dstorage::tests::a_destination_unmapped_under_the_worker_fails_the_request: passed.SKIPPEDGPU/D3D12 tests:gpu_geometry_wave32_prefix_count_over_a_mask/gpu_wave32_program_in_wave64_hardware(no wave64), plus 2 D3D12 debug-layer tests (no d3d12SDKLayers.dll).Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
Imported from ivall/xcl. Originally posted by lordon1a on 2026-11-24T04:07:48Z.
Independent test report on
d09f285:Tested
616.64, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200),rustc 1.100.0(x86_64-pc-windows-gnullvm), debug buildcargo test -p xcl --lib hle::dstorage::tests -- --nocapture0.19s(a_destination_unmapped_under_the_worker_fails_the_requestok)Not tested
AI use
d09f285in a detached worktree, audited the diff, ran the test suite, and posted this report.Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T04:08:02Z.
Test run of
d09f285014c6262b35f6b412d46eb4cfd70b7b2con AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED;a_destination_unmapped_under_the_worker_fails_the_requestpasses.Review: Writing the destination with
write_own(NtWriteVirtualMemoryon the own process) turns a destination unmapped during the file read intoE_ACCESS_VIOLATIONfor that request instead of a fault inxcl-dstorage, the write-side counterpart of #561. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T11:54:32Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main(crates/xcl/src/hle/dstorage.rs) — needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:58:47Z.
Triage (#1607) – head
d09f285#561 (same author) fixes the source side of the same race; this PR fixes the destination side, so they do not overlap. Main has since added
write_title(NtWriteVirtualMemory) indstorage.rs, but only for destinations in the sparse windows; other virtual destinations are still written withcopy_nonoverlappinginexecute, so this change is not on main.On rebase, reuse main's
write_titleinstead of declaring a thirdNtWriteVirtualMemory(main has one indstorage.rsand one indstorage/parallel.rs). The PR conflicts with main.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.