fix(libSceSaveData.native): accept bit 0 of the sceSaveDataUmount2 mode without the backup bit #24325

Merged
birdmarty merged 1 commit from upstream-pr/24325 into main 2026-11-20 19:55:42 +00:00
birdmarty commented 2026-11-20 14:11:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-20T14:11:48Z.


What

#23789 made sceSaveDataUmount2 throw on any mode other than 0, 0x10000 and 0x10001. Two titles unmount with 0x1, bit 0 without the backup bit, and now abort with sceSaveDataUmount2: unknown mode whenever they write a save:

  • Final Fantasy VII Rebirth (PPSA08668 01.080): about 35 s into a cold first run, and again on every save from the menu.
  • Dead Cells (PPSA15552 01.005, #9659): as soon as it reaches the menu on a cold run.

Before #23789 the mode was ignored, so this is a regression from that PR.

Bit 0 is now accepted with or without bit 16 and has no effect. Bit 16 (0x10000) still backs up and sends SAVE_DATA_EVENT_TYPE_UMOUNT_BACKUP, and a mode with any other bit still throws.

Why bit 0 is ignored rather than given a meaning:

  • KytyPS5 acts on bit 16 only and ignores the rest of the mode, and so does rps5e.
  • prosper captured Dead Cells calling sceSaveDataUmount2(0x1, "/savedata0"). It reports 0, 0x1 and 0x10001 across titles, and notes that Sonic Frontiers adds 0x10000 to another value under a runtime condition, so bit 16 is a separate flag.
  • FF7 Rebirth's call site compares the mount mode it stored for the save with 0x20 (SAVE_DATA_MOUNT_MODE_CREATE2) and passes the result: 0x1 after a CREATE2 mount, 0 after its read-only mounts. Lies of P also mounts with CREATE2 but unmounts with 0x10000, so bit 0 is a choice the title makes, not something CREATE2 requires.
  • Neither title waits for an event after a 0x1 unmount. Both go on rendering, so no backup completion is expected from bit 0 alone.

No source says what bit 0 does on a console; the debt entry says so. The name SAVE_DATA_UMOUNT_MODE_BACKUP_FORCE comes from #23789, not from an SDK source.

Changes

  • libSceSaveData.native/Export.cpp: sceSaveDataUmount2 throws only when the mode has a bit other than 0 and 16.
  • GuestSaveDataMountStatus.cpp:
    • 1 is no longer listed as an unknown mode. After a CREATE2 mount and a write, umount2(1) returns 0, unmounts, posts no event, makes no backup and keeps the data.
    • 2, 0x20000 and 0x10002 still throw.
  • docs/dev/debt/changes/fix-savedata-umount2-backup.md: the pending sceSaveDataUmount2 entry from #23789 now covers bit 0. That entry is still in a fragment, which a change fragment cannot target, so the fragment is edited directly. If it is folded first, I will rebase this onto a change fragment.

Tested

Windows 11 Pro (build 26300), AMD Radeon RX 6800 (AMD driver 26.10.1), MinGW-w64 GCC 15.3.0, Release build with tests, rebased onto main 0a025bd3c6 (branch commit fd214329eb).

Tests:

  • ctest -R savedata: 39 of 39 passed (13.25 s).
  • With main's Export.cpp under these tests, guest_savedata_mount_status aborts with sceSaveDataUmount2: unknown mode at the new umount2(1) case.
  • tools/check_conventions.py --base origin/main and tools/debt_fold.py --check: passed.
  • tools/pr_overlap.py --names sceSaveDataUmount2 and --branch fix/savedata-umount2-mode-bit0: no open pull request implements sceSaveDataUmount2, and no overlap with open pull requests.

Title runs (same code diff 460225403e on main 291739adca):

Final Fantasy VII Rebirth (PPSA08668 01.080):

  • Without this PR: a cold run aborts about 35 s in, right after creating and writing ff7rebirthcommon. A run that finds the save goes on, but aborts on the first save from the menu ("Saving game data...").
  • Diagnostic build with the mode added to the error text: sceSaveDataUmount2: unknown mode 0x1 (1).
  • With this PR, cold, 180 s:
    • Log: mount3 mode=0x20, then the write, then umount2 mode=0x1 -> 0.
    • It reads the save back and goes on rendering until the time cap (about 620 frames every 30 s).
  • With this PR, menu save & gameplay: umount2 mode=0x1 -> 0 succeeds on menu saves and New Game saves; in a longer run (~1,087 s, with the min-LOD AGC fix) the title saved, cleared the intro cutscenes, and reached gameplay.

Dead Cells (PPSA15552 01.005, #9659):

  • Without this PR: a cold run aborts with sceSaveDataUmount2: unknown mode at the menu.
  • With this PR, cold:
    • Log: umount2 mode=0x1 -> 0, then umount2 mode=0x10001 -> 0 twice, around writes of dc_options.json.
    • 60 fps (about 1,800 frames every 30 s) until the 150 s time cap.
    • A second run went into gameplay cleanly.

Not tested: what bit 0 does on a console, Linux, other GPUs.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA08668 #24321, PPSA15552 #9659
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5414743317 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24325). Originally posted by [birdmarty](https://github.com/birdmarty) on 2026-11-20T14:11:48Z. --- ### What #23789 made `sceSaveDataUmount2` throw on any mode other than `0`, `0x10000` and `0x10001`. Two titles unmount with `0x1`, bit 0 without the backup bit, and now abort with `sceSaveDataUmount2: unknown mode` whenever they write a save: - Final Fantasy VII Rebirth (PPSA08668 01.080): about 35 s into a cold first run, and again on every save from the menu. - Dead Cells (PPSA15552 01.005, #9659): as soon as it reaches the menu on a cold run. Before #23789 the mode was ignored, so this is a regression from that PR. Bit 0 is now accepted with or without bit 16 and has no effect. Bit 16 (`0x10000`) still backs up and sends `SAVE_DATA_EVENT_TYPE_UMOUNT_BACKUP`, and a mode with any other bit still throws. Why bit 0 is ignored rather than given a meaning: - [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/a1fc5ae438ea343480c9850f585d8c0afed06241/src/libs/libSaveData.cpp#L973-L997) acts on bit 16 only and ignores the rest of the mode, and so does rps5e. - [prosper](https://github.com/mattias800/prosper/blob/e35a74a20f4241ceaaa9974fd35cec92e868baea/prosper/src/hle/fs/savedata.cpp#L676-L740) captured Dead Cells calling `sceSaveDataUmount2(0x1, "/savedata0")`. It reports `0`, `0x1` and `0x10001` across titles, and notes that Sonic Frontiers adds `0x10000` to another value under a runtime condition, so bit 16 is a separate flag. - FF7 Rebirth's call site compares the mount mode it stored for the save with `0x20` (`SAVE_DATA_MOUNT_MODE_CREATE2`) and passes the result: `0x1` after a `CREATE2` mount, `0` after its read-only mounts. Lies of P also mounts with `CREATE2` but unmounts with `0x10000`, so bit 0 is a choice the title makes, not something `CREATE2` requires. - Neither title waits for an event after a `0x1` unmount. Both go on rendering, so no backup completion is expected from bit 0 alone. No source says what bit 0 does on a console; the debt entry says so. The name `SAVE_DATA_UMOUNT_MODE_BACKUP_FORCE` comes from #23789, not from an SDK source. #### Changes - `libSceSaveData.native/Export.cpp`: `sceSaveDataUmount2` throws only when the mode has a bit other than 0 and 16. - `GuestSaveDataMountStatus.cpp`: - `1` is no longer listed as an unknown mode. After a `CREATE2` mount and a write, `umount2(1)` returns 0, unmounts, posts no event, makes no backup and keeps the data. - `2`, `0x20000` and `0x10002` still throw. - `docs/dev/debt/changes/fix-savedata-umount2-backup.md`: the pending `sceSaveDataUmount2` entry from #23789 now covers bit 0. That entry is still in a fragment, which a `change` fragment cannot target, so the fragment is edited directly. If it is folded first, I will rebase this onto a `change` fragment. ### Tested Windows 11 Pro (build 26300), AMD Radeon RX 6800 (AMD driver 26.10.1), MinGW-w64 GCC 15.3.0, Release build with tests, rebased onto `main` `0a025bd3c6` (branch commit `fd214329eb`). Tests: - `ctest -R savedata`: 39 of 39 passed (13.25 s). - With `main`'s `Export.cpp` under these tests, `guest_savedata_mount_status` aborts with `sceSaveDataUmount2: unknown mode` at the new `umount2(1)` case. - `tools/check_conventions.py --base origin/main` and `tools/debt_fold.py --check`: passed. - `tools/pr_overlap.py --names sceSaveDataUmount2` and `--branch fix/savedata-umount2-mode-bit0`: no open pull request implements `sceSaveDataUmount2`, and no overlap with open pull requests. Title runs (same code diff `460225403e` on `main` `291739adca`): Final Fantasy VII Rebirth (PPSA08668 01.080): - **Without this PR:** a cold run aborts about 35 s in, right after creating and writing `ff7rebirthcommon`. A run that finds the save goes on, but aborts on the first save from the menu ("Saving game data..."). - **Diagnostic build** with the mode added to the error text: `sceSaveDataUmount2: unknown mode 0x1 (1)`. - **With this PR, cold, 180 s:** - Log: `mount3 mode=0x20`, then the write, then `umount2 mode=0x1 -> 0`. - It reads the save back and goes on rendering until the time cap (about 620 frames every 30 s). - **With this PR, menu save & gameplay:** `umount2 mode=0x1 -> 0` succeeds on menu saves and New Game saves; in a longer run (~1,087 s, with the min-LOD AGC fix) the title saved, cleared the intro cutscenes, and reached gameplay. Dead Cells (PPSA15552 01.005, #9659): - **Without this PR:** a cold run aborts with `sceSaveDataUmount2: unknown mode` at the menu. - **With this PR, cold:** - Log: `umount2 mode=0x1 -> 0`, then `umount2 mode=0x10001 -> 0` twice, around writes of `dc_options.json`. - 60 fps (about 1,800 frames every 30 s) until the 150 s time cap. - A second run went into gameplay cleanly. Not tested: what bit 0 does on a console, Linux, other GPUs. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA08668 #24321, PPSA15552 #9659 - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-20 14:29:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T14:29:49Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fd214329eb:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_savedata_mount_status_tests built cleanly.
  • CTest (guest_savedata_mount_status):
    1/1 Test #5178: guest_savedata_mount_status ......   Passed    0.97 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceSaveData.native/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #5178: guest_savedata_mount_status ......Subprocess aborted***Exception:   1.24 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified bitwise mask logic in Export.cpp umount2(): (mode & ~(SAVE_DATA_UMOUNT_MODE_BACKUP | SAVE_DATA_UMOUNT_MODE_BACKUP_FORCE)) == 0 properly permits combinations of bit 0 (0x1) and bit 16 (0x10000) while rejecting any other bits with std::runtime_error.
    • Verified backup triggering condition: unmountMountPoint is called with (mode & SAVE_DATA_UMOUNT_MODE_BACKUP) != 0, ensuring mode 1 alone does not trigger backup operations or SAVE_DATA_EVENT_TYPE_UMOUNT_BACKUP events.
    • Verified error code and exception behavior: sceSaveDataUmount2 throws std::runtime_error on invalid modes and preserves SAVE_DATA_ERROR_NOT_MOUNTED for unmounted mount points, consistent with existing tests and implementation.
    • Verified GuestSaveDataMountStatus.cpp tests: coverage includes unknown modes {2u, 0x20000u, 0x10002u}, mode 1 unmounted check, mode 1 unmount lifecycle with CREATE2, verify absence of backup event, absence of backup folder, data integrity, and clean deletion.
    • Verified AGENTS.md compliance: no comments in source code, technical debt fragment in docs/dev/debt/changes/fix-savedata-umount2-backup.md properly updated, and no extra/untracked files added.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5994242554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24325#pullrequestreview-5994242554). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T14:29:49Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `fd214329eb`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_savedata_mount_status_tests` built cleanly. - **CTest** (`guest_savedata_mount_status`): ``` 1/1 Test #5178: guest_savedata_mount_status ...... Passed 0.97 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceSaveData.native/Export.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #5178: guest_savedata_mount_status ......Subprocess aborted***Exception: 1.24 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified bitwise mask logic in Export.cpp umount2(): (mode & ~(SAVE_DATA_UMOUNT_MODE_BACKUP | SAVE_DATA_UMOUNT_MODE_BACKUP_FORCE)) == 0 properly permits combinations of bit 0 (0x1) and bit 16 (0x10000) while rejecting any other bits with std::runtime_error. - Verified backup triggering condition: unmountMountPoint is called with (mode & SAVE_DATA_UMOUNT_MODE_BACKUP) != 0, ensuring mode 1 alone does not trigger backup operations or SAVE_DATA_EVENT_TYPE_UMOUNT_BACKUP events. - Verified error code and exception behavior: sceSaveDataUmount2 throws std::runtime_error on invalid modes and preserves SAVE_DATA_ERROR_NOT_MOUNTED for unmounted mount points, consistent with existing tests and implementation. - Verified GuestSaveDataMountStatus.cpp tests: coverage includes unknown modes {2u, 0x20000u, 0x10002u}, mode 1 unmounted check, mode 1 unmount lifecycle with CREATE2, verify absence of backup event, absence of backup folder, data integrity, and clean deletion. - Verified AGENTS.md compliance: no comments in source code, technical debt fragment in docs/dev/debt/changes/fix-savedata-umount2-backup.md properly updated, and no extra/untracked files added. Looks Good To Me
MarcZX10 commented 2026-11-20 14:36:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:36:21Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation accepts bit 0 without triggering backup behavior, and the inspected tests cover the relevant accepted and rejected modes.

What I ran

Reviewed head fd214329eb6cdc9029260a4c71a572ace3d7b163. Read the prepared diff and all three changed files; inspected unmountMountPoint and the test context. No commands or tests were run.

Results

Check Result Note
Diff and changed files passed All three changed files read
Targeted source context passed Unmount behavior and tests inspected
Tests not run Author-reported results not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The PR description's build, test, convention, debt-fold, overlap, and title-run results were not independently verified. The remaining portions of Export.cpp and GuestSaveDataMountStatus.cpp, and all repository files outside the three changed files, were not read. Bit 0's effect on a physical console remains unknown, as documented by the author.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5994331007 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24325#pullrequestreview-5994331007). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T14:36:21Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation accepts bit 0 without triggering backup behavior, and the inspected tests cover the relevant accepted and rejected modes. ## What I ran Reviewed head `fd214329eb6cdc9029260a4c71a572ace3d7b163`. Read the prepared diff and all three changed files; inspected `unmountMountPoint` and the test context. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All three changed files read | | Targeted source context | passed | Unmount behavior and tests inspected | | Tests | not run | Author-reported results not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The PR description's build, test, convention, debt-fold, overlap, and title-run results were not independently verified. The remaining portions of `Export.cpp` and `GuestSaveDataMountStatus.cpp`, and all repository files outside the three changed files, were not read. Bit 0's effect on a physical console remains unknown, as documented by the author. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!24325
No description provided.