XGameSave: XCL_IMPORT_SAVE turns a PS5 story save into the Xbox container #665

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

@⁠MrCheese5 on GitHub · 2026-11-24 03:07 UTC · original
MrCheese5:xgamesave-ps5-import → main · +201 −2 · 4 files · 1 commits · open

The newer retail game's PS5 and Xbox builds store a story save in the same format. On PS5, the packed copy inside a decrypted save folder's chives.dat (SLAYER1 header, then an ASAV file) is byte for byte what the Xbox build keeps as a slot's Save Game Data blob: the same ASAV header, the same encrypted LZ4 payload and the same 32-byte signature. The title's own verify, decrypt and decompress steps accept it unchanged. The only thing missing is the Xbox build's 296-byte Save Game Header blob, which holds sizes and hashes.

XCL_IMPORT_SAVE=<folder>[;<folder>…] writes one container per folder when the title opens its save provider. The container is named after the ASAV slot (SARC0000, SARC0015, …) and gets the ASAV file as Save Game Data plus a computed Save Game Header. A slot that already exists is left alone unless XCL_IMPORT_SAVE_FORCE=1 is set. XCL decrypts, re-encrypts and signs nothing: the ASAV is copied as is, and the change contains no key.

Format, as the title reads it:

  • Save Game Header: u32 6 | u32 data size | u32 joaat of the data | u32 header hash | u64 time | u32 0 | u32 stored size (ASAV +0x18) | u32 unpacked size (ASAV +0x1c) | UTF-16 title (0x100 bytes). The header hash is a joaat chained over time, title, +0x18, +0x1c, +0x20 and +0x08. joaat here is Jenkins one-at-a-time over signed bytes.
  • The stored size must be non-zero for a compressed save. A zero tells the title the data is not compressed, so it parses the LZ4 stream as the plain save and fails to load it.
  • ASAV +0x160 is the joaat of the 0x170-byte header with that field zeroed, using a fixed seed. It is checked before anything is written.

What is in it

  • crates/xcl/src/hle/xgameruntime/save_import.rs: the hash, the header builder, the chives.dat reader and import_once, with unit tests on synthetic data
  • crates/xcl/src/hle/xgameruntime/gamesave.rs: open_provider calls import_once; enc and apply become pub(super) so the import writes through the same path as XGameSaveSubmitUpdate
  • README.md: the variable

Tested

  • RTX 4090 (driver 621.14), i9-14900K, Windows 11 26200, Rust stable-x86_64-pc-windows-msvc, debug tests, release smoke runs
  • cargo test -p xcl --lib save_import: 3 passed, 0 failed
  • cargo test --workspace -- --test-threads=4: 690 passed, 0 failed, 41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • With two real PS5 story saves, the newer retail game run with a separate data root lists both imported slots on its title screen, reads, verifies, decrypts and decompresses them, and starts loading the world.

Regression run
Both runs are without XCL_IMPORT_SAVE, the default path, to show that nothing else changes. Each uses its own fresh data root.

xcl-smoke v1
commit: bdab19492aeeb2c9ce1e05f0a15ada518d15992f
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 382 (PresentX 383)
presents per 2 s (last 3): 14 20 18
device removals: 0
crashes: 0
peak commit: 15650 MB
xcl-smoke v1
commit: 31978f61f67bfeed7143c738e6bbfd8395b2a446
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 395 (PresentX 395)
presents per 2 s (last 3): 23 22 18
device removals: 0
crashes: 0
peak commit: 15652 MB

Not tested

  • Playing from an imported save: once the world starts loading, the title stops at the same GPU watchdog as a new game (#505), so the loaded save is never seen in play.
  • Other titles' PS5 saves (the reader only accepts SLAYER1 + ASAV with a valid header checksum and warns otherwise), and saves other than story saves.
  • AMD and other NVIDIA GPUs (the change has no GPU code).

AI use

  • Claude Code with Claude Opus 5.5: worked out the header format from the title's save code, then wrote the code, the tests and this description. The in-title check above is a run on the machine named under Tested.

🤖 Generated with Claude Code

**@⁠MrCheese5** on GitHub · 2026-11-24 03:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/665) `MrCheese5:xgamesave-ps5-import` → `main` · +201 −2 · 4 files · 1 commits · open The newer retail game's PS5 and Xbox builds store a story save in the same format. On PS5, the packed copy inside a decrypted save folder's `chives.dat` (`SLAYER1` header, then an ASAV file) is byte for byte what the Xbox build keeps as a slot's `Save Game Data` blob: the same ASAV header, the same encrypted LZ4 payload and the same 32-byte signature. The title's own verify, decrypt and decompress steps accept it unchanged. The only thing missing is the Xbox build's 296-byte `Save Game Header` blob, which holds sizes and hashes. `XCL_IMPORT_SAVE=<folder>[;<folder>…]` writes one container per folder when the title opens its save provider. The container is named after the ASAV slot (`SARC0000`, `SARC0015`, …) and gets the ASAV file as `Save Game Data` plus a computed `Save Game Header`. A slot that already exists is left alone unless `XCL_IMPORT_SAVE_FORCE=1` is set. XCL decrypts, re-encrypts and signs nothing: the ASAV is copied as is, and the change contains no key. Format, as the title reads it: - `Save Game Header`: u32 6 | u32 data size | u32 joaat of the data | u32 header hash | u64 time | u32 0 | u32 stored size (ASAV +0x18) | u32 unpacked size (ASAV +0x1c) | UTF-16 title (0x100 bytes). The header hash is a joaat chained over time, title, +0x18, +0x1c, +0x20 and +0x08. joaat here is Jenkins one-at-a-time over **signed** bytes. - The stored size must be non-zero for a compressed save. A zero tells the title the data is not compressed, so it parses the LZ4 stream as the plain save and fails to load it. - ASAV +0x160 is the joaat of the 0x170-byte header with that field zeroed, using a fixed seed. It is checked before anything is written. **What is in it** - `crates/xcl/src/hle/xgameruntime/save_import.rs`: the hash, the header builder, the `chives.dat` reader and `import_once`, with unit tests on synthetic data - `crates/xcl/src/hle/xgameruntime/gamesave.rs`: `open_provider` calls `import_once`; `enc` and `apply` become `pub(super)` so the import writes through the same path as `XGameSaveSubmitUpdate` - `README.md`: the variable **Tested** - RTX 4090 (driver 621.14), i9-14900K, Windows 11 26200, Rust stable-x86_64-pc-windows-msvc, debug tests, release smoke runs - `cargo test -p xcl --lib save_import`: 3 passed, 0 failed - `cargo test --workspace -- --test-threads=4`: 690 passed, 0 failed, 41 ignored; SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - With two real PS5 story saves, the newer retail game run with a separate data root lists both imported slots on its title screen, reads, verifies, decrypts and decompresses them, and starts loading the world. **Regression run** Both runs are without `XCL_IMPORT_SAVE`, the default path, to show that nothing else changes. Each uses its own fresh data root. ``` xcl-smoke v1 commit: bdab19492aeeb2c9ce1e05f0a15ada518d15992f gpu: NVIDIA GeForce RTX 4090 title: Xbox seconds: 60 exit: 0x0 frames shown: 382 (PresentX 383) presents per 2 s (last 3): 14 20 18 device removals: 0 crashes: 0 peak commit: 15650 MB ``` ``` xcl-smoke v1 commit: 31978f61f67bfeed7143c738e6bbfd8395b2a446 gpu: NVIDIA GeForce RTX 4090 title: Xbox seconds: 60 exit: 0x0 frames shown: 395 (PresentX 395) presents per 2 s (last 3): 23 22 18 device removals: 0 crashes: 0 peak commit: 15652 MB ``` **Not tested** - Playing from an imported save: once the world starts loading, the title stops at the same GPU watchdog as a new game (#505), so the loaded save is never seen in play. - Other titles' PS5 saves (the reader only accepts `SLAYER1` + ASAV with a valid header checksum and warns otherwise), and saves other than story saves. - AMD and other NVIDIA GPUs (the change has no GPU code). **AI use** - Claude Code with Claude Opus 5.5: worked out the header format from the title's save code, then wrote the code, the tests and this description. The in-title check above is a run on the machine named under **Tested**. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The newer retail game's PS5 and Xbox builds share the story save format:
the packed copy in a PS5 save folder's chives.dat (SLAYER1 + ASAV) is the
Xbox slot's "Save Game Data" byte for byte - same ASAV header, same
encrypted LZ4-compressed payload, same 32-byte signature. The title's own
verify, decrypt and LZ4 decoder accept the PS5 data unchanged; XCL copies
it as is and neither decrypts nor signs anything.

What the Xbox build adds is the 296-byte "Save Game Header": u32 6, data
size, joaat (signed bytes) of the data, a chained joaat over the header
fields, time, stored size (ASAV +0x18), unpacked size (ASAV +0x1c), title.
The stored size matters: zero tells the title the data is uncompressed, it
then parses the LZ4 stream as the plain save and fails to load it.

XCL_IMPORT_SAVE=<folder>[;...] writes each folder's slot when the title
opens its save provider, unless the slot exists (XCL_IMPORT_SAVE_FORCE=1).
The ASAV header checksum (+0x160: the signed joaat of the header with the
field zero, fixed seed) is checked before anything is written.

Checked with real saves in a separate data root: the title lists both
imported slots, reads, verifies and decompresses them and loads the world,
then stops at the same GPU watchdog as a new game (#505).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:49 +00:00
Author
Owner

@⁠RandomGithub12309 on GitHub · 2026-11-24 04:39 UTC · original

Test run and review of 31978f61f67bfeed7143c738e6bbfd8395b2a446 merged cleanly onto main (f4ce27c):

Tested

  • Hardware: NVIDIA GeForce RTX 5050 Laptop GPU (driver 32.0.16.2114, wave32, SM 6.6), Intel Core Ultra 7 255HX (20 cores), Windows 11 Build 26300, rustc 1.100.0 stable-x86_64-pc-windows-msvc, debug build
  • Note: Running cargo test --workspace -- --test-threads=4 directly on the PR's older base (bdab194) hung past 180s at gpu_uma_import_check_at_init and sibling GPU tests; on the clean merge onto main (f4ce27c) it completed cleanly.
  • Command: cargo build --workspace + cargo test --workspace -- --test-threads=4 (on merge onto f4ce27c)
  • Result: 704 passed, 0 failed, 41 ignored (hle::xgameruntime::save_import::tests::joaat_s_sign_extends_bytes, header_carries_sizes_and_chained_hashes, and chives_asav_checks_the_packed_copy pass)
  • SKIPPED: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)

Review

  • pub fn container_header(data: &[u8]) lacks bounds checks (crates/xcl/src/hle/xgameruntime/save_import.rs): chives_asav enforces size >= ASAV_HEADER (0x170), but container_header is pub and slices &data[0x20..0x28] / &data[0x28..0x128] directly, so callers passing fewer than 0x128 bytes panic.
  • Process-wide Once in import_once: Only the first XGameSave provider root imports saves if a title opens multiple providers with different configs, and import_once + gamesave::apply has no on-disk test.

Not tested

  • AMD / wave64, Intel GPU, importing a real PS5 chives.dat folder or loading the imported container in a retail title

AI use

  • Antigravity with Gemini 4 Hydrogen — merged 31978f6 onto f4ce27c, audited the diff, ran the workspace suite, and wrote this report.
**@⁠RandomGithub12309** on GitHub · 2026-11-24 04:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/665#issuecomment-7122222826) Test run and review of `31978f61f67bfeed7143c738e6bbfd8395b2a446` merged cleanly onto `main` (`f4ce27c`): **Tested** - Hardware: NVIDIA GeForce RTX 5050 Laptop GPU (driver `32.0.16.2114`, wave32, SM 6.6), Intel Core Ultra 7 255HX (20 cores), Windows 11 Build 26300, `rustc 1.100.0` `stable-x86_64-pc-windows-msvc`, debug build - Note: Running `cargo test --workspace -- --test-threads=4` directly on the PR's older base (`bdab194`) hung past 180s at `gpu_uma_import_check_at_init` and sibling GPU tests; on the clean merge onto `main` (`f4ce27c`) it completed cleanly. - Command: `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` (on merge onto `f4ce27c`) - Result: **704 passed, 0 failed, 41 ignored** (`hle::xgameruntime::save_import::tests::joaat_s_sign_extends_bytes`, `header_carries_sizes_and_chained_hashes`, and `chives_asav_checks_the_packed_copy` pass) - `SKIPPED`: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (`no wave64`) **Review** - **`pub fn container_header(data: &[u8])` lacks bounds checks (`crates/xcl/src/hle/xgameruntime/save_import.rs`)**: `chives_asav` enforces `size >= ASAV_HEADER` (`0x170`), but `container_header` is `pub` and slices `&data[0x20..0x28]` / `&data[0x28..0x128]` directly, so callers passing fewer than `0x128` bytes panic. - **Process-wide `Once` in `import_once`**: Only the first `XGameSave` provider `root` imports saves if a title opens multiple providers with different configs, and `import_once` + `gamesave::apply` has no on-disk test. **Not tested** - AMD / wave64, Intel GPU, importing a real PS5 `chives.dat` folder or loading the imported container in a retail title **AI use** - Antigravity with Gemini 4 Hydrogen — merged `31978f6` onto `f4ce27c`, audited the diff, ran the workspace suite, and wrote this report.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 04:02 UTC · original

Windows AMD test report for PR #665 at 31978f61f67bfeed7143c738e6bbfd8395b2a446

Setup: Windows 11 build 26200, AMD Radeon RX 6800M (driver 30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Checked out the PR's exact head in a clean worktree; XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, XCL_DIRECT_DXIL=0 for the focused runs.

Tested

  • cargo test --locked -p xcl --lib -j 2 save_import -- --test-threads=1 --show-output: 3 passed, 0 failed, 0 ignored. These are the PR's synthetic ASAV/hash/header tests.
  • Same command with filter gamesave: 10 passed, 0 failed, 0 ignored.
  • cargo build --locked --workspace -j 2: passed.
  • cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output --skip gpu::: 413 passed, 0 failed, 23 ignored across completed binaries; 295 library tests filtered out by the gpu:: skip. Three subcases printed SKIPPED (reserved cube support and missing D3D12 debug layer twice).

Full-suite limit: The same workspace test command without --skip gpu:: exited with STATUS_ACCESS_VIOLATION (0xc0000005) while the xcl library harness was in GPU tests, before it printed a library total. The other completed binaries had 40 passed, 0 failed, 20 ignored. This run does not establish a passing full suite, and I cannot attribute the process crash to this PR's save change from this evidence.

Not tested: Importing a real decrypted PS5 save, the resulting container in a retail title, XCL_IMPORT_SAVE_FORCE, or a paired title smoke. No private save or game data was uploaded.

AI assistance: OpenAI Codex (GPT-6) ran these checks and drafted this report.

**@⁠luckyteagirl** on GitHub · 2026-11-25 04:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/665#issuecomment-7152474801) ### Windows AMD test report for PR #665 at `31978f61f67bfeed7143c738e6bbfd8395b2a446` **Setup:** Windows 11 build 26200, AMD Radeon RX 6800M (driver `30.0.13002.13003`), Ryzen 9 5980HX, Rust `1.99.0` MSVC, DXC/DXIL `1.9.2609.5`. Checked out the PR's exact head in a clean worktree; `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=1`, `XCL_DIRECT_DXIL=0` for the focused runs. **Tested** - `cargo test --locked -p xcl --lib -j 2 save_import -- --test-threads=1 --show-output`: **3 passed, 0 failed, 0 ignored**. These are the PR's synthetic ASAV/hash/header tests. - Same command with filter `gamesave`: **10 passed, 0 failed, 0 ignored**. - `cargo build --locked --workspace -j 2`: passed. - `cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output --skip gpu::`: **413 passed, 0 failed, 23 ignored** across completed binaries; 295 library tests filtered out by the `gpu::` skip. Three subcases printed `SKIPPED` (reserved cube support and missing D3D12 debug layer twice). **Full-suite limit:** The same workspace test command *without* `--skip gpu::` exited with `STATUS_ACCESS_VIOLATION` (`0xc0000005`) while the `xcl` library harness was in GPU tests, before it printed a library total. The other completed binaries had 40 passed, 0 failed, 20 ignored. This run does not establish a passing full suite, and I cannot attribute the process crash to this PR's save change from this evidence. **Not tested:** Importing a real decrypted PS5 save, the resulting container in a retail title, `XCL_IMPORT_SAVE_FORCE`, or a paired title smoke. No private save or game data was uploaded. AI assistance: OpenAI Codex (GPT-6) ran these checks and drafted this report.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 06:24 UTC · original

Empirical test report (31978f61)

Hardware / environment

  • PR #665 at commit 31978f61f67bfeed7143c738e6bbfd8395b2a446, checked out detached.
  • Windows 11 Enterprise Evaluation build 26200 (10.0.26200), AMD Ryzen 7 3800X 8-Core Processor.
  • Rust 1.100.0 (0ef1bc386), Cargo 1.100.0 (3acc79c0c), x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad47). Unoptimized test profile with debug info and incremental compilation disabled.
  • Both focused runs set XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. The build and both runs used Cargo directly outside the Arc test wrapper.

Commands and results

  • cargo test --workspace --no-run exited 0 and built 15 test executables. It ran zero tests. The compiler emitted a deprecation warning for Atomic::fetch_update.
  • cargo test -p xcl --lib hle::xgameruntime::save_import::tests:: exited 0 with 3 passed, 0 failed, 0 ignored, 0 skipped, and 668 filtered out.
  • cargo test -p xcl --lib hle::xgameruntime::gamesave::tests:: exited 0 with 10 passed, 0 failed, 0 ignored, 0 skipped, and 661 filtered out.
  • The focused output contained zero lines beginning with the case-sensitive prefix SKIPPED .

Observed behavior

The new tests passed for signed-byte hashing, Xbox header size fields and hash changes after a payload edit, and ASAV extraction from a synthetic packed save. Extraction recovered the expected slot and exact payload, excluded trailing padding, and rejected a bad checksum and non-SLAYER1 input. Existing XGameSave unit tests passed for provider initialization, container and blob round trips, name matching, and deletion.

Not tested

Full GPU workspace suite, game smoke runs, retail save loading, and provider-driven import with force replacement.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr665-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/665#issuecomment-7154763466) ### Empirical test report (31978f61) **Hardware / environment** - PR #665 at commit `31978f61f67bfeed7143c738e6bbfd8395b2a446`, checked out detached. - Windows 11 Enterprise Evaluation build 26200 (10.0.26200), AMD Ryzen 7 3800X 8-Core Processor. - Rust 1.100.0 (`0ef1bc386`), Cargo 1.100.0 (`3acc79c0c`), x86_64-pc-windows-msvc. DXC 1.9.2609.5 (`01b62ad47`). Unoptimized test profile with debug info and incremental compilation disabled. - Both focused runs set `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. The build and both runs used Cargo directly outside the Arc test wrapper. **Commands and results** - `cargo test --workspace --no-run` exited 0 and built 15 test executables. It ran zero tests. The compiler emitted a deprecation warning for `Atomic::fetch_update`. - `cargo test -p xcl --lib hle::xgameruntime::save_import::tests::` exited 0 with 3 passed, 0 failed, 0 ignored, 0 skipped, and 668 filtered out. - `cargo test -p xcl --lib hle::xgameruntime::gamesave::tests::` exited 0 with 10 passed, 0 failed, 0 ignored, 0 skipped, and 661 filtered out. - The focused output contained zero lines beginning with the case-sensitive prefix `SKIPPED `. **Observed behavior** The new tests passed for signed-byte hashing, Xbox header size fields and hash changes after a payload edit, and ASAV extraction from a synthetic packed save. Extraction recovered the expected slot and exact payload, excluded trailing padding, and rejected a bad checksum and non-SLAYER1 input. Existing XGameSave unit tests passed for provider initialization, container and blob round trips, name matching, and deletion. **Not tested** Full GPU workspace suite, game smoke runs, retail save loading, and provider-driven import with force replacement. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr665-focused.log and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 12:21 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 12:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/665#issuecomment-7162256012) 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!
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/665/head:github-bot/gh-665'
git switch 'github-bot/gh-665'

Merge

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