fix(agc): hash small storage images at unwatch when no upload copy proves their bytes #17791

Closed
klosixgaming-arch wants to merge 1 commit from upstream-pr/17791 into main
klosixgaming-arch commented 2026-11-09 16:05:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-11-09T16:05:13Z.


What

Small storage images (up to GenerationBaselineBytes) prove their guest bytes with the copy taken at upload. Two cases leave such an image with no usable copy:

  • the upload ran without taking one;
  • the image stored results, so the copy no longer matches.

When the image's range then leaves the write watch while results are pending, writeBackLayers has no proof of the guest bytes and throws: "storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented (unit 0 of 1: its bytes differ from the copy taken at its upload)".

Cyberpunk 2077 (PPSA03974) hits this right after the title screen, and the game aborts.

This change gives those small images the same proof that large images already use, a hash taken when the range leaves the watch:

  • upload marks a small image uploaded without a copy as one to hash at unwatch.
  • A write-back that stamps a new generation over an image whose copy exists marks it too, because that copy is now stale.
  • hashBeforeUnwatch and hashedAtUnwatch take marked images.
  • baselineMiss checks the unwatch hash of the current generation before the upload copy.

Tested

Windows, NVIDIA GeForce RTX 5090.

  • Cyberpunk 2077 (PPSA03974): main (d34caa9dbe) with #16974 aborts after the title with the error above. With this change added, it gets through the title, the lifepath menu and the character creator's Body Type screen without the error, and the frame dumps look right.
  • Tests: all 34 tests matching ^agc_(storage|unwatch|untracked|heap_mirror|sparse_heap|address_space|driver_untracked|driver_depth_plane_cpu) pass. These include agc_storage_pending_after_unwatch, agc_storage_baseline_settled, agc_untracked_forget and agc_driver_untracked_snapshot_hint.
  • No new test: I have not yet built a reduced case for a small image left without an upload copy.

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
  • 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 (Cyberpunk 2077 also needs #16974 to boot)
  • Fixes: none
  • Unblocks: PPSA03974
  • GPUs tested: NVIDIA GeForce RTX 5090, Windows
  • AI-assisted: yes

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5226951905 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17791). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-11-09T16:05:13Z. --- ### What Small storage images (up to `GenerationBaselineBytes`) prove their guest bytes with the copy taken at upload. Two cases leave such an image with no usable copy: - the upload ran without taking one; - the image stored results, so the copy no longer matches. When the image's range then leaves the write watch while results are pending, `writeBackLayers` has no proof of the guest bytes and throws: "storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented (unit 0 of 1: its bytes differ from the copy taken at its upload)". Cyberpunk 2077 (PPSA03974) hits this right after the title screen, and the game aborts. This change gives those small images the same proof that large images already use, a hash taken when the range leaves the watch: - `upload` marks a small image uploaded without a copy as one to hash at unwatch. - A write-back that stamps a new generation over an image whose copy exists marks it too, because that copy is now stale. - `hashBeforeUnwatch` and `hashedAtUnwatch` take marked images. - `baselineMiss` checks the unwatch hash of the current generation before the upload copy. ### Tested Windows, NVIDIA GeForce RTX 5090. - Cyberpunk 2077 (PPSA03974): `main` (d34caa9dbe) with #16974 aborts after the title with the error above. With this change added, it gets through the title, the lifepath menu and the character creator's Body Type screen without the error, and the frame dumps look right. - Tests: all 34 tests matching `^agc_(storage|unwatch|untracked|heap_mirror|sparse_heap|address_space|driver_untracked|driver_depth_plane_cpu)` pass. These include `agc_storage_pending_after_unwatch`, `agc_storage_baseline_settled`, `agc_untracked_forget` and `agc_driver_untracked_snapshot_hint`. - No new test: I have not yet built a reduced case for a small image left without an upload copy. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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 (Cyberpunk 2077 also needs #16974 to boot) - [x] Fixes: none - [x] Unblocks: PPSA03974 - [x] GPUs tested: NVIDIA GeForce RTX 5090, Windows - [x] AI-assisted: yes AI-assisted: yes. Written with AI assistance and reviewed by me.

Pull request closed

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!17791
No description provided.