Repository navigation
DirectStorage: a memory source is copied without faulting - #561
requiemsnkrp wants to merge 1 commit into
Conversation
A memory-source request's source was checked with `readable()` and then copied with `copy_nonoverlapping` on the xcl-dstorage worker, at the request's turn: a source the title unmapped between the two faulted in the worker and ended the process (the source side of xcl-dev#476, found by brothernog in the review of xcl-dev#509). It is now copied with `read_own` (ReadProcessMemory), as the page arrays are: the request fails with E_ACCESS_VIOLATION instead. The test runs 20000 memory-source requests while another thread decommits and recommits the source 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)
|
Tested
Thanks for picking this up. One more of the same shape, on the destination side (read only, not run): This review was AI-assisted. |
|
Test run of Tested
Review: Copying the source 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. |
|
Tested the same change on a retail title (Windows 11, RTX 4070 SUPER 12 GB, i7-14700K, NVIDIA driver current as of this week), applied on top of main 508a0c7 plus #533/#549/#567/#572/#551/#454. Before: the process ended with an access violation inside After replacing the Note: tested with a local equivalent of this patch, not this exact branch. |
`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 ivall#476, found by brothernog in the review of ivall#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) (cherry picked from commit d09f285)
|
Test report for this PR's head Tested
SKIPPED tests (the same on
|
`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)
# Conflicts: # crates/xcl/src/hle/dstorage.rs
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
A memory-source DirectStorage request's source was checked with
readable()and then copied withcopy_nonoverlappingon thexcl-dstorageworker at the request's turn. If the title unmapped the source between the two, the copy faulted in the worker and ended the process. It is now copied withread_own(ReadProcessMemory), as the page arrays are, so the request fails withE_ACCESS_VIOLATIONinstead. This is the source side of #476; @brothernog found it while reviewing #509. It is independent of #509: a different hunk ofexecute, branched frommain508a0c7.What is in it
crates/xcl/src/hle/dstorage.rs,execute: the memory source is copied withread_ownafter the existingreadable()check, which stays for the cheap refusals (empty or oversized sources)crates/xcl/src/hle/dstorage.rs, tests:a_memory_source_unmapped_under_the_worker_fails_the_requestruns 20000 memory-source requests while another thread decommits and recommits the source pageTested
--exact): 5 ×0xc0000005 STATUS_ACCESS_VIOLATION; with the fix: 10 of 10 passed;hle::dstoragetests: 14 passedcargo test --workspace -- --test-threads=4on c65cf2e: 681 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareRegression run
main:
PR:
Not tested
main508a0c7 without the change on this machine (the count above is for the PR head only)AI use