Repository navigation
DirectStorage: a virtual destination is written without faulting - #705
requiemsnkrp wants to merge 1 commit into
Conversation
`execute` checks a virtual destination with `writable()` at its start, then reads the file or copies the source and inflates it, and only then writes the destination with `copy_nonoverlapping`. A destination the title unmapped in that time faulted in the xcl-dstorage worker and ended the process (the destination side of xcl-dev#476, found by brothernog in the review of xcl-dev#561). It is now written with `write_own` (NtWriteVirtualMemory on the process itself), the counterpart of the `read_own` the page arrays use: the request fails with E_ACCESS_VIOLATION instead. Not WriteProcessMemory: it first queries the region, which in the 4 GiB coherent window took 75-175 ms a call (measured) and stalled the title's first streaming (0 frames in 60 s). The test runs 20000 requests while another thread decommits and recommits the destination page: before, the test process ended with 0xc0000005 (5 of 5 runs); after, it passes (10 of 10). Assisted-by: Claude Code (Claude Opus 5.5)
|
Code audit + NVIDIA RTX 5080 test run on ReviewLooks clean — Tested
Not tested
AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above. |
|
Independent test report on Tested
Not tested
AI use
|
|
Test run of Tested
Review: Writing the destination with Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
Integrates upstream PR xcl-dev#705 while keeping Wine dirty-range notification: - Write virtual destinations via NtWriteVirtualMemory (write_own) so a destination unmapped during file read/inflate fails with E_ACCESS_VIOLATION instead of faulting the worker thread, without WriteProcessMemory's page-table walk stall.
# Conflicts: # crates/xcl/src/hle/dstorage.rs
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=4on d09f285: 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 base 91f9a5e differs 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