fix(libSceHmd2): copy reprojection status, gaze results, and output buffers via GuestCopyIn/Out #19525

Open
PrivacyOnion wants to merge 2 commits from upstream-pr/19525 into main
PrivacyOnion commented 2026-11-13 13:26:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T13:26:06Z.


What

Copies reprojection status buffers, gaze result parameters/outputs, and pre-init output buffers in libSceHmd2 via GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch while preserving errno, replacing direct guest pointer dereferences in sceHmd2ReprojectionGetStatus, Hmd2GazeHandle, sceHmd2GazeGetResult, sceHmd2GazeGetResultForFoveatedRendering, Hmd2WriteStateTwo, Hmd2WriteSize0x2000Align0x100, Hmd2WriteFourConstants, Hmd2WriteSixHalvesThenInvalidHandle, and Hmd2WriteTwelveHalvesThenInvalidHandle.

Tested

  • cmake --build build --target guest_hmd2_tests guest_hmd2_gaze_tests guest_hmd2_gaze_args_tests -j 16
  • ctest --test-dir build -R "^guest_hmd2" --output-on-failure (3/3 Passed: guest_hmd2, guest_hmd2_gaze, guest_hmd2_gaze_args)
  • python tools/check_conventions.py --base upstream/main (Passed)
  • python tools/pr_overlap.py --branch fix/hmd2-guest-copy --jobs 1

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: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5296275556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19525). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-13T13:26:06Z. --- ### What Copies reprojection status buffers, gaze result parameters/outputs, and pre-init output buffers in `libSceHmd2` via `GuestCopyIn_nid_no_patch` and `GuestCopyOut_nid_no_patch` while preserving `errno`, replacing direct guest pointer dereferences in `sceHmd2ReprojectionGetStatus`, `Hmd2GazeHandle`, `sceHmd2GazeGetResult`, `sceHmd2GazeGetResultForFoveatedRendering`, `Hmd2WriteStateTwo`, `Hmd2WriteSize0x2000Align0x100`, `Hmd2WriteFourConstants`, `Hmd2WriteSixHalvesThenInvalidHandle`, and `Hmd2WriteTwelveHalvesThenInvalidHandle`. ### Tested - `cmake --build build --target guest_hmd2_tests guest_hmd2_gaze_tests guest_hmd2_gaze_args_tests -j 16` - `ctest --test-dir build -R "^guest_hmd2" --output-on-failure` (3/3 Passed: `guest_hmd2`, `guest_hmd2_gaze`, `guest_hmd2_gaze_args`) - `python tools/check_conventions.py --base upstream/main` (Passed) - `python tools/pr_overlap.py --branch fix/hmd2-guest-copy --jobs 1` ### 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](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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-21 02:28:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T02:28:08Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reviewed code routes the targeted gaze and reprojection buffers through checked guest copies and preserves errno.

What I ran

Reviewed head 1d8172e5301d5be589508cc3528ae0bce528c29b against base main using the prepared diff and pinned reader. No build or tests were run. The PR description reports a build, three passing guest_hmd2 tests, a conventions check, and an overlap check; these were not run during this review.

Results

Check Result Note
Diff and changed lines passed All three changed files read
Targeted source context passed Copy helper and affected exports read
Build and tests not run Only author-reported results available

Findings

Blocking

None.

Non-blocking

None.

Not verified

No commands, build, or tests were run. Console behavior for unmapped or unwritable pointers is documented as unmeasured. Read: core/libs/prx/libSceHmd2/Export.cpp (changed regions and affected buffer writers), core/libs/tests/GuestHmd2Gaze.cpp (changed lines and surrounding test functions), and docs/dev/debt/libSceHmd2.md (changed line). No changed files were excluded; review/files.json was not available as a review-folder file.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6002219122 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19525#pullrequestreview-6002219122). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T02:28:08Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reviewed code routes the targeted gaze and reprojection buffers through checked guest copies and preserves `errno`. ## What I ran Reviewed head `1d8172e5301d5be589508cc3528ae0bce528c29b` against base `main` using the prepared diff and pinned reader. No build or tests were run. The PR description reports a build, three passing `guest_hmd2` tests, a conventions check, and an overlap check; these were not run during this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All three changed files read | | Targeted source context | passed | Copy helper and affected exports read | | Build and tests | not run | Only author-reported results available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No commands, build, or tests were run. Console behavior for unmapped or unwritable pointers is documented as unmeasured. Read: `core/libs/prx/libSceHmd2/Export.cpp` (changed regions and affected buffer writers), `core/libs/tests/GuestHmd2Gaze.cpp` (changed lines and surrounding test functions), and `docs/dev/debt/libSceHmd2.md` (changed line). No changed files were excluded; `review/files.json` was not available as a review-folder file. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 16:20:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:20:26Z.

Review: COMMENTED


The reprojection status hunk conflicts with main, which now builds the result in local storage and uses GuestCopyOut while preserving errno. Please keep that existing path and rebase the remaining gaze or output changes around it.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6173790930 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19525#pullrequestreview-6173790930). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T16:20:26Z. **Review:** COMMENTED --- The reprojection status hunk conflicts with main, which now builds the result in local storage and uses `GuestCopyOut` while preserving errno. Please keep that existing path and rebase the remaining gaze or output changes around it. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/19525:upstream-pr/19525'
git switch 'upstream-pr/19525'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/19525'
git switch 'upstream-pr/19525'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/19525'
git switch 'upstream-pr/19525'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/19525'
git switch 'main'
git merge --squash 'upstream-pr/19525'
git switch 'main'
git merge --ff-only 'upstream-pr/19525'
git switch 'main'
git merge 'upstream-pr/19525'
git push origin 'main'
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!19525
No description provided.