DirectStorage: read memory sources and lazy pages through read_own #2359

Open
github-bot wants to merge 1 commit from github-bot/gh-2359 into main AGit
Owner

@⁠safesearch77 on GitHub · 2026-11-25 16:30 UTC · original
safesearch77:fix/dstorage-read-own-lazy-source → main · +139 −8 · 1 files · 1 commits · draft

dstorage::writable and the routed ReadFile hook commit lazy physical pages (kernelx::lazy::ensure) first because kernel calls fail on uncommitted lazy reservations instead of faulting into the vectored handler, but dstorage::read_own (ReadProcessMemory) did not, and execute() still read virtual memory sources with gpu::shader::readable + ptr::copy_nonoverlapping. As a result, page arrays or memory sources overlapping untouched lazy physical pages and copies above 256 MiB failed with E_ACCESS_VIOLATION (0x89240009), memory sources above 64 KiB walked regions with VirtualQuery, and a memory source decommitted while queued faulted in the xcl-dstorage worker (0xC0000005).

What is in it

  • crates/xcl/src/hle/dstorage.rs: read_own checks for overflow (keeping 0-byte rejection unchanged) and commits lazy physical pages with kernelx::lazy::ensure before ReadProcessMemory; execute reads virtual memory sources through read_own.
  • crates/xcl/src/hle/dstorage.rs (tests): a_memory_source_and_page_array_in_lazy_pages_commit_instead_of_failing (deterministic red->green test) and a_memory_source_unmapped_under_the_worker_fails_the_request (decommit/commit race stress test modeled on #509).

Tested

  • Cross-typechecked on CachyOS Linux (x86_64, base 0829441, head 94fae46) with cargo check --offline --target x86_64-pc-windows-gnu --workspace --tests: 0 errors, 0 warnings in dstorage.rs.

Not tested

  • Not built or run on Windows yet (opened as Draft from Linux until Windows cargo test --workspace -- --test-threads=4 counts and paired scripts/smoke.ps1 regression runs are attached).
  • Wine / Proton throughput of large virtual memory-source requests through ReadProcessMemory, AMD / Intel GPUs, retail titles.

AI use

  • Antigravity (Gemini 4 Carbon) wrote the dstorage.rs fix, unit tests, and description; reviewed with Claude Opus 5.5.
**@⁠safesearch77** on GitHub · 2026-11-25 16:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2359) `safesearch77:fix/dstorage-read-own-lazy-source` → `main` · +139 −8 · 1 files · 1 commits · draft `dstorage::writable` and the routed `ReadFile` hook commit lazy physical pages (`kernelx::lazy::ensure`) first because kernel calls fail on uncommitted lazy reservations instead of faulting into the vectored handler, but `dstorage::read_own` (`ReadProcessMemory`) did not, and `execute()` still read virtual memory sources with `gpu::shader::readable` + `ptr::copy_nonoverlapping`. As a result, page arrays or memory sources overlapping untouched lazy physical pages and copies above 256 MiB failed with `E_ACCESS_VIOLATION` (`0x89240009`), memory sources above 64 KiB walked regions with `VirtualQuery`, and a memory source decommitted while queued faulted in the `xcl-dstorage` worker (`0xC0000005`). **What is in it** - `crates/xcl/src/hle/dstorage.rs`: `read_own` checks for overflow (keeping 0-byte rejection unchanged) and commits lazy physical pages with `kernelx::lazy::ensure` before `ReadProcessMemory`; `execute` reads virtual memory sources through `read_own`. - `crates/xcl/src/hle/dstorage.rs` (`tests`): `a_memory_source_and_page_array_in_lazy_pages_commit_instead_of_failing` (deterministic red->green test) and `a_memory_source_unmapped_under_the_worker_fails_the_request` (decommit/commit race stress test modeled on #509). **Tested** - Cross-typechecked on CachyOS Linux (`x86_64`, base `0829441`, head `94fae46`) with `cargo check --offline --target x86_64-pc-windows-gnu --workspace --tests`: 0 errors, 0 warnings in `dstorage.rs`. **Not tested** - Not built or run on Windows yet (opened as Draft from Linux until Windows `cargo test --workspace -- --test-threads=4` counts and paired `scripts/smoke.ps1` regression runs are attached). - Wine / Proton throughput of large virtual memory-source requests through `ReadProcessMemory`, AMD / Intel GPUs, retail titles. **AI use** - Antigravity (Gemini 4 Carbon) wrote the `dstorage.rs` fix, unit tests, and description; reviewed with Claude Opus 5.5.
ReadProcessMemory is a kernel call and fails on uncommitted lazy
physical pages (kernelx::lazy) instead of faulting into the vectored
handler, unlike dstorage::writable which calls lazy::ensure first.
Meanwhile, execute()'s virtual memory-source branch still checked
gpu::shader::readable and copied with ptr::copy_nonoverlapping: lazy
physical pages and copies above 256 MiB failed with E_ACCESS_VIOLATION
(0x89240009), sources above 64 KiB walked regions with VirtualQuery,
and a source decommitted while queued faulted in xcl-dstorage.

Commit lazy physical pages in read_own before ReadProcessMemory (while
preserving 0-byte and wrapping-range rejection) and route virtual
memory-source reads through read_own.

Assisted-by: Antigravity (Gemini 4 Carbon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:28:51 +00:00
Author
Owner

@⁠FIJI1299 on GitHub · 2026-11-25 17:42 UTC · original

Tested commit 94fae46 on Windows:

Environment

  • OS: Windows 11
  • GPU: NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.35, wave32)
  • DXC: 1.8.2502.11 (Windows SDK 10.0.26100.0)

Results

  • hle::dstorage tests (cargo test -p xcl --lib dstorage): 32 passed, 0 failed.
  • Full library test suite (.\scripts\test.ps1): 1201 passed, 4 failed, 26 ignored — the 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState E_OUTOFMEMORY 0x8007000E on this NVIDIA driver during the full single-process run).
  • GPU tests skipped on this adapter:
    • 13 (no wave64)
    • 3 (wave32, per-lane form: refused (unsupported V_CVT_F16_F32 / V_MUL_F16 / V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)))
    • 1 (cannot disable the driver cache (Windows Developer Mode is required): 0x887A002D)
**@⁠FIJI1299** on GitHub · 2026-11-25 17:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2359#issuecomment-7169888511) Tested commit `94fae46` on Windows: ### Environment * **OS:** Windows 11 * **GPU:** NVIDIA GeForce RTX 5070 (12 GB VRAM, driver `621.35`, `wave32`) * **DXC:** `1.8.2502.11` (Windows SDK `10.0.26100.0`) ### Results * **`hle::dstorage` tests (`cargo test -p xcl --lib dstorage`):** **32 passed, 0 failed**. * **Full library test suite (`.\scripts\test.ps1`):** **1201 passed, 4 failed, 26 ignored** — the 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` `E_OUTOFMEMORY` `0x8007000E` on this NVIDIA driver during the full single-process run). * **GPU tests skipped on this adapter:** * `13` (`no wave64`) * `3` (`wave32, per-lane form: refused (unsupported V_CVT_F16_F32 / V_MUL_F16 / V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))`) * `1` (`cannot disable the driver cache (Windows Developer Mode is required): 0x887A002D`)
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 18:37 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2359#issuecomment-7171168816) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 19:06 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
suite: 144/3 = the three known baseline failures on this lane (fuzz_validate_and_gpu_2 seed 1003, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed). Targeted run of the new memory-source/page-array tests: 2 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 19:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2359#issuecomment-7171819295) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). suite: 144/3 = the three known baseline failures on this lane (`fuzz_validate_and_gpu_2` seed 1003, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`). Targeted run of the new memory-source/page-array tests: 2 passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠throny on GitHub · 2026-11-26 02:18 UTC · original

Two contributors checked independently and found that #561 solves the same problem in a different way: #1607, group D115. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-26 02:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2359#issuecomment-7180670330) <!-- xcl-1607-hint:D115 --> Two contributors checked independently and found that #561 solves the same problem in a different way: #1607, group D115. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2359/head:github-bot/gh-2359'
git switch 'github-bot/gh-2359'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2359'
git switch 'github-bot/gh-2359'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2359'
git switch 'github-bot/gh-2359'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2359'
git switch 'main'
git merge --squash 'github-bot/gh-2359'
git switch 'main'
git merge --ff-only 'github-bot/gh-2359'
git switch 'main'
git merge 'github-bot/gh-2359'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.