Skip to content

VFS: route MAXIMUM_ALLOWED opens through the overlay - #2694

Open
luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/vfs-maximum-allowed-overlay
Open

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/vfs-maximum-allowed-overlay

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2682. A title can request MAXIMUM_ALLOWED without an explicit write bit. The old VFS classifier sent that open to the original game file even though Windows can grant write access. This change sends the request through the copy-on-write overlay.

What is in it

  • Include MAXIMUM_ALLOWED in the VFS write-capable access mask.
  • Add a fixture that opens an existing game file with only that access bit and checks that the selected path is the overlay copy while the original bytes stay intact.

Tested

  • Windows 11 Home build 26200; AMD Radeon RX 6800M (driver 30.0.13002.13003); AMD Ryzen 9 5980HX; Rust 1.99.0 MSVC.
  • The focused VFS fixture failed on clean main by selecting the original and passed on c4d013199b705fcc6dcff070e2dd687834af0ada. All 13 VFS module tests passed on the committed head (0 failed, 0 ignored, 0 skipped) with XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, and one test thread. These VFS tests run on the CPU.
  • A native Windows CreateFileW probe confirmed that MAXIMUM_ALLOWED can grant a writable handle when the ACL allows it.
  • cargo build --locked --release -p xcl -j 1 passed on both clean main and the committed head.
  • scripts/test.ps1 completed the workspace and test-binary builds but the library harness exited with 0xc0000005 during the DXIL tests, before a full-suite summary. Its log shows 83 ok and one ignored progress lines before the abort; these are not complete suite counts.
  • With XCL_ADAPTER=6800M and XCL_REQUIRE_GPU unset, cargo test --locked --workspace --no-fail-fast -j 1 -- --test-threads=1 --show-output completed 36 targets: 125 passed, 1 failed, 20 ignored, and 4 explicit SKIPPED lines (two title debug-layer variants without d3d12SDKLayers.dll, one no heap windows, one texture-upload check without the D3D12 debug layer). The library target separately aborted with 0xc0000005 during raw_loads_in_root_windows_respect_exec_and_bounds after 85 ok and one ignored progress lines, so it has no final counts. The completed-target failure was offline_split_compute_pipeline_is_reused_by_a_second_process: its warm run expected five loaded driver-cache pipelines and reported zero.
  • A clean main control, cargo test --locked -p xcl --lib -j 1 -- --test-threads=1 --show-output with the same RX 6800M selection, also aborted with 0xc0000005 in that exact raw_loads_in_root_windows_respect_exec_and_bounds test after 85 ok and one ignored progress lines.
  • A second clean-main control, cargo test --locked -p xcl --test gpu_compute_e2e -j 1 offline_split_compute_pipeline_is_reused_by_a_second_process -- --exact --test-threads=1 --nocapture, reproduced the same warm-cache assertion on this RX 6800M: 0 passed, 1 failed, 0 ignored, 0 skipped; five pieces rebuilt and zero loaded. Both workspace failures therefore also occur without this VFS patch.
  • Independent RTX 3060 report on this exact clean head: cargo test --workspace --no-fail-fast -- --test-threads=4 completed with 1,436 passed, 0 failed, 47 ignored, and 25 explicit GPU skips. The VFS regression passed three repeated runs; a scratch mutation removing MAXIMUM_ALLOWED from WRITE_ACCESS made it fail by selecting the original game file. These are the independent reporter's results, not runs on our RX 6800M.

Regression run

  • scripts/smoke.ps1 -Game <owned title folder> -Seconds 60 with XCL_ADAPTER=6800M, separate fresh XCL data and DXIL cache directories, and clean exact-head release builds. Same title hash and duration. Main showed 759 frames and 14,513 MB peak commit; the patch showed 771 frames and 14,494 MB. These runs check general startup and presentation, not a proven MAXIMUM_ALLOWED open.

Main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 60
exit: 0x0
frames shown: 759 (PresentX 759)
presents per 2 s (last 3): 57 60 60
device removals: 0
crashes: 0
peak commit: 14513 MB

PR head:

xcl-smoke v1
commit: c4d013199b705fcc6dcff070e2dd687834af0ada
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 60
exit: 0x0
frames shown: 771 (PresentX 771)
presents per 2 s (last 3): 54 60 60
device removals: 0
crashes: 0
peak commit: 14494 MB

Copy-on-open cost

  • The VFS currently makes an overlay copy before a write-capable open of an existing game file. MAXIMUM_ALLOWED may grant write rights, so this patch uses that path even if the caller only reads. A large archive opened this way can therefore be copied in full and consume matching overlay space. The title smoke did not establish whether it opens archives with MAXIMUM_ALLOWED; that workload and cost remain unmeasured. Avoiding an eager copy would need a safe way to redirect a later write without giving the title a writable handle to the original game file.

Not tested

  • A title open that actually requests MAXIMUM_ALLOWED; the regression fixture tests routing and the retail smoke checks general startup behavior.
  • A complete passing GPU workspace suite on our RX 6800M. The independent RTX 3060 suite passed with 25 explicit GPU skips. Both head and clean main hit the same library access violation and warm split-driver-cache failure on our RX 6800M; the causes were not investigated in this VFS PR.

AI use

  • Codex (GPT-6.2 Sol) implemented and tested the patch. Codex reviewed it against the issue, Windows access behavior, and neighboring PRs.
  • OpenAI Codex (GPT-6.2 Astra) verified the independent exact-head report and added its linked results to this description.

Related

Treat maximum allowed access as potentially writable so opens of original game files follow the existing copy-on-write path. Cover the routing decision using a synthetic file and verify the original bytes remain intact.

Assisted-by: Codex (GPT-6.2 Sol)
@luckyteagirl
luckyteagirl marked this pull request as ready for review November 26, 2026 06:47
@fromthemoonx

Copy link
Copy Markdown

A complete GPU workspace suite (listed under Not tested): passes on NVIDIA, and the new test fails without the MAXIMUM_ALLOWED bit. One question about the cost, below.

Tested: c4d0131 (its base is current main b49be18, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 1436 passed, 0 failed, 47 ignored; 25 SKIPPED lines; the library process ran to the end (no 0xc0000005 here)
vfs::tests::maximum_allowed_open_uses_an_overlay_copy, 3 runs 3 of 3
scratch: MAXIMUM_ALLOWED taken out of WRITE_ACCESS again fails: open_decision returns the game folder's data\hello.txt instead of the overlay path

A question about the cost: with this, an OPEN_EXISTING open with MAXIMUM_ALLOWED and no write bit takes the copy-on-write path, so the whole file is copied into the overlay when it is opened (the test checks the copy has original right after open_decision). If a title uses MAXIMUM_ALLOWED to open its large archives just for reading, each such file would then be copied to the data folder on its first open. Is that intended? Another option is to open the original with read rights in that case, or to copy only on the first write. I have not checked whether the retail title opens files this way.

Not tested: a title that opens files with MAXIMUM_ALLOWED, a release build, AMD.

AI use: Claude Code (Claude Opus 5.5) ran the suite and the scratch change, read open_decision, and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor Author

Thanks for the full GPU suite and mutation check. Yes: with the current VFS copy-on-open design, MAXIMUM_ALLOWED takes the write-capable path and eagerly copies an existing game file, even if this caller only reads. That preserves the game folder when Windows grants write access, but could be expensive for a large archive. My 12-second title smoke did not show whether the title uses this access mask on archives, so I have added this cost and the missing measurement to the PR description. A lazy copy would need to intercept a later write while keeping the original file unwritable through the returned handle; the current path cannot safely defer it. AI-assisted response with Codex.

@upipibi

upipibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

NVIDIA test report for c4d0131: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.

  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 (head as-is, on b49be18): 1301 passed, 0 failed, 27 ignored, and the process ran to the end (no 0xc0000005). 25 SKIPPED: 21 no wave64, 3 wave32 per-lane forms the translator refuses (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), 1 pso_measurement_compiles_an_exact_synthetic_record without Developer Mode. None is in vfs.rs.
  • vfs::tests::maximum_allowed_open_uses_an_overlay_copy, --exact --test-threads=1 --nocapture, 3 runs: 3/3 passed, 0 SKIPPED (a CPU-only test).
    Lib tests only; no title run.
    AI-assisted (Claude Code, Claude Opus 5.5).

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…t, readonly-aware delete)

Port upstream xcl-dev#2708 (live head 15393dc): the MAXIMUM_ALLOWED bit itself
landed earlier via xcl-dev#2694 (91e37a8); this takes the remaining regression
test a_maximum_allowed_open_takes_the_write_path verbatim into vfs.rs,
pinning the write-path overlay copy plus the read-only-bit read path.

Port upstream xcl-dev#2809 (live head 80cf435): whiteout_original_file(rel,
check_readonly) verbatim into shared vfs.rs (Linux containment via
checked_original_path), with delete_file delegating the hide-original
half with check_readonly=false (move-retire keeps its policy, as
upstream). The Windows-native hook half (MAX_PATH/extended-prefix
juggling, native DeleteFileW sharing checks) stays out; the Linux twin
vfs_hooks_linux::delete_file carries the readonly-check shape
(symlink_metadata dir/readonly gates, overlay remove + commit, else
whiteout_original_file(rel, true)), and kernelx_linux DeleteFileA/W
route Game deletes through it. Close-time/best-effort removals and
move_impl retire keep Vfs::delete_file directly (no readonly gate).

Tests: vfs::tests +1, vfs_hooks_linux::tests +1 (Linux twin of the
cfg(windows) vfs_readonly_delete: readonly original/overlay denied and
still visible, writable paths unchanged, retire-after-move unaffected).
Failing-first: readonly delete returned Ok before (scratch test), both
upstream artifacts absent (grep 0).

Gates: both checks 0 errors; lib 766/0/1 threads=4 (+2); title e2e 12
unique FAILs all D3D12.X 0 non-GPU; retail fresh root SIGSEGV
exe+0x2237320 fault 0x0 unmapped stubs 20 xgr exactly 3 HOLDS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VFS: a MAXIMUM_ALLOWED open of a game file is treated as a read and bypasses the overlay

3 participants