feat(libc): add GuestPtr guest-pointer copies with fault tests #19266

Merged
Ethan-Hainline merged 2 commits from upstream-pr/19266 into main 2026-11-13 20:59:22 +00:00
Ethan-Hainline commented 2026-11-13 00:52:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ethan-Hainline on 2026-11-13T00:52:32Z.


What

GuestPtr<T> and GuestBytes for guest pointer parameters, using the internal-use shape accepted in #19123.

  • GuestPtr<T> copies a value or an array through GuestCopyIn_nid_no_patch / GuestCopyOut_nid_no_patch, returns false on a fault, and lets the export decide the answer. The const form cannot CopyOut.
  • A count or byte length of 0 is a successful no-op, including from a null guest pointer, matching the copy helper's own zero-byte behavior; an export that maps false to an EFAULT-style error therefore accepts a valid empty array.
  • GuestBytes does the same for a raw byte range (the event and status buffers in the conversion).
  • Array copies reject a count whose byte size would overflow.
  • Export signatures stay raw pointers at the ABI; the type is used inside the implementation.

No production code uses it in this PR. The libSceVideoOut conversion and its test follow separately.

Tested

Windows 11 Pro, Ryzen 5 7530U, AMD Radeon Vega 8, MinGW-w64 GCC 16.2, CMake/Ninja, Release, BUILD_TESTING=ON.

  • guest_ptr_tests builds and ctest -R '^guest_ptr$' passes.
  • Covers mapped value, array and byte copies in both directions; zero-length array and byte copies (non-null and null); rejection of 1, ~0xfff and null; the const form cannot write; and the array-size overflow guard.
  • python tools/check_conventions.py --base upstream/main --head HEAD passes.

Not tested: Linux and macOS; the CI jobs will run them.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5287943746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19266). Originally posted by [Ethan-Hainline](https://github.com/Ethan-Hainline) on 2026-11-13T00:52:32Z. --- ### What `GuestPtr<T>` and `GuestBytes` for guest pointer parameters, using the internal-use shape accepted in #19123. - `GuestPtr<T>` copies a value or an array through `GuestCopyIn_nid_no_patch` / `GuestCopyOut_nid_no_patch`, returns `false` on a fault, and lets the export decide the answer. The `const` form cannot `CopyOut`. - A count or byte length of 0 is a successful no-op, including from a null guest pointer, matching the copy helper's own zero-byte behavior; an export that maps `false` to an EFAULT-style error therefore accepts a valid empty array. - `GuestBytes` does the same for a raw byte range (the event and status buffers in the conversion). - Array copies reject a count whose byte size would overflow. - Export signatures stay raw pointers at the ABI; the type is used inside the implementation. No production code uses it in this PR. The `libSceVideoOut` conversion and its test follow separately. ### Tested Windows 11 Pro, Ryzen 5 7530U, AMD Radeon Vega 8, MinGW-w64 GCC 16.2, CMake/Ninja, Release, `BUILD_TESTING=ON`. - `guest_ptr_tests` builds and `ctest -R '^guest_ptr$'` passes. - Covers mapped value, array and byte copies in both directions; zero-length array and byte copies (non-null and null); rejection of `1`, `~0xfff` and null; the const form cannot write; and the array-size overflow guard. - `python tools/check_conventions.py --base upstream/main --head HEAD` passes. Not tested: Linux and macOS; the CI jobs will run them. ### 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) - [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
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!19266
No description provided.