DirectStorage: EnqueueRequest reads its page array and file vtable without sizing regions #322
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!322
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/322/head"
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?
@Cattn on GitHub · 2026-11-23 23:26 UTC · original
Cattn:dstorage-enqueue-reads→main· +12 −3 · 1 files · 1 commits · merged 2026-11-24 00:03 UTCIDStorageQueueX::EnqueueRequestchecked two small inputs withgpu::shader::readable: the destination page array of a request withDEST_PHYS_PAGES, and the file object's vtable pointer.readablecallsVirtualQueryfor each region the range touches.VirtualQuerysizes the region around the address by walking it, and a retail title keeps its page arrays inside very large reservations with scattered committed pages. While the title streams its world it enqueues thousands of requests a second from one thread, so the check costs far more than the read.What is in it
dstorage.rs:snapshot_page_arraycopies the array withReadProcessMemoryon the current process. That copies the bytes or fails on memory that isn't readable, which is what the check was for, without sizing the region. Unreadable memory still refuses the request withE_ACCESS_VIOLATION.readableitself is unchanged; other callers keep it.Tested
cargo build --workspacethen release and debug tests.cargo test --workspace --no-fail-fast -- --test-threads=4: 656 passed, 0 failed, 40 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.readableand 0.4 µs throughReadProcessMemory.7a033c8+ #203, #187, #208a7ffb2f, #244, #252, #283, #269, #292, #289.EnqueueRequestcall on that stack before the change took 5–13 ms, small requests too. This change removes one part of that cost; I did not identify the rest.Regression run
main:
PR:
(
gpu:names a virtual monitor's adapter; the title ran on the RTX 4070. #282 changes what smoke.ps1 prints there.)Not tested
AI use
@mastrr9 on GitHub · 2026-11-23 23:38 UTC · original
Static code audit of
c8e3ca0againstcrates/xcl/src/hle/dstorage.rsonmain(not tested on Windows; no game files):Looks clean and is a strict safety + performance improvement over
readable()+ raw deref:snapshot_page_arrayreturns early whenbyte_len == 0(dstorage.rs:699), soread_ownis only called withcount >= 1(bytes >= 8).ReadProcessMemory(GetCurrentProcess(), ...)copies intoVec<usize>/vt: usizewithoutVirtualQuery's region-walk cost, closes the TOCTOU window betweenreadable()and reading the bytes, and avoids potential unaligned pointer UB from the previousslice::from_raw_parts(ptr as *const usize, count)and*(f as *const *const usize).at != 0plusdone == lenproperly rejects null, partial, unmapped,PAGE_NOACCESS, andPAGE_GUARDreads withE_ACCESS_VIOLATION/E_FILE_HANDLEas before.AI use: static code review of
c8e3ca0with Antigravity (Gemini 4 Neon).@throny on GitHub · 2026-11-23 23:58 UTC · original
Test report for
c8e3ca0, merged onto currentmain2b4bb43(clean merge, merge commitd55c8e8): pass.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace && cargo test --workspace -- --test-threads=4: 670 passed, 0 failed, 41 ignored (lib: 630 / 0 / 21)SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)dstoragetests that enqueueDEST_PHYS_PAGESrequests throughsnapshot_page_arraypass, including the one where a stack table's entry is filled in after enqueue and an all-zero table is refused withE_ACCESS_VIOLATION.Reviewed (read the whole diff)
byte_len == 0returns beforeread_own, andcountcomes from au32size, so the newvec![0usize; count]is at most ~0.5 MB, the same size the oldto_vecallocated.E_ACCESS_VIOLATION, a source pointer that is not readable →E_FILE_HANDLE) have no test in the suite, before or after this PR. A test with aPAGE_NOACCESSpage for each would cover whatread_ownreplaces.Not tested
scripts/smoke.ps1) on a title, noXCL_SAMPLE_*game-data tests.AI use
@ivall on GitHub · 2026-11-24 00:03 UTC · original
Merged (
a6f5f7a). Checked on an RX 9070 (RDNA4) on maina6f5f7a, together with #335, #322, #331, #330, #338, #318 and #332:cargo test --workspace -- --test-threads=4- 636 unit tests passed, 0 failed; the retail game reaches its menu and draws it (frame dump) and goes on past it.