feat(libSceNpCommon): implement nine state helpers #12823

Merged
xdCloudy merged 2 commits from upstream-pr/12823 into main 2026-11-04 06:27:03 +00:00
xdCloudy commented 2026-10-29 11:27:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-29T11:27:07Z.


What

Implement nine libSceNpCommon state helpers reconstructed from PS5 firmware 13.60.

Seven functions query object state. Two implement clear/no-op behaviour.

Function NID Recovered behaviour
EventFlag::IsInit st-oQvV7HVI 32-bit field at +0x10 is nonzero
RingBuf::IsFull bvJ207-8qBQ 64-bit fields at +0x20 and +0x28 are equal
EventQueue::IsInit VI8AHrfLdqY 16-bit field at +0x98 is nonzero
Mutex::IsInit Yc+qj4TIEY0 Byte at +0x10 is nonzero
RingBufMemory::IsInit zdRXyt-65kA Pointer at +0x8 is non-null
IpmiClient::IsConnected prj9aMR74bA 32-bit field at +0x18 equals zero
Callout::IsTimedout xxOTJpEyoj4 Signed state at +0x10 is positive or -2
NpTitleSecret::Clear X0vEo7cZamA Clears 128 bytes beginning at +0x8
JsonNull::Clear 88GKkivBFhI No-op

All nine retain their existing NIDs.

Firmware evidence

  • Module: libSceNpCommon.sprx
  • Firmware: PS5 13.60
  • SHA-256: AB696280CAF5CF465C62E00D1785FB4348B59A7E376D7C6802453419E5765CD0
  • Method: Ghidra 12.1.4 static decompilation and instruction inspection

These are firmware-derived reconstructions. They have not been independently validated through console execution. No proprietary firmware artifacts are committed.

Implementation

  • Implement all nine functions with typed declarations.
  • Access guest object fields through existing guest-memory copy helpers.
  • Return defensive false results for null or unreadable predicate operands.
  • Ignore null clear targets.
  • Preserve observed normal-path comparisons and clear operations.
  • Add focused regression tests for valid states, invalid addresses, address overflow and cross-page clear operations.
  • Document recovered behaviour and known guest-memory limitations.
  • Remove nine obsolete technical-debt entries.

The defensive invalid-memory behaviour is an emulator compatibility choice, not a claim about native firmware faults.

GuestCopyOut_nid_no_patch may perform a partial write on an inaccessible destination, particularly through Linux process_vm_writev. Failed clears do not guarantee atomic rollback.

Upstream reconciliation

Merged current upstream main 5bae1a4bc2 into this branch. The net PR diff remains the same five intended files, preserving all nine exports and NIDs, the focused test and existing upstream implementations. Related #12852 deliberately leaves RingBuf::IsFull and RingBufMemory::IsInit to this PR; its adjacent shared-file edits may still need merge-order reconciliation.

Tested

Windows x86_64, WinLibs GCC, CMake/Ninja Release, head d4aee6eb2c:

  • Built guest_np_common_state_predicate_tests and guest_np_common_rtc_tests.
  • Both CTests passed (2/2) before and after current-main integration.
  • The new null/unreadable-address, address-overflow and cross-page cases are now runtime-tested on Windows.
  • Conventions and diff whitespace checks passed.

Linux partial-write behavior and console runtime remain unverified; the documented defensive-memory and partial-write limits remain. New-head hosted checks are pending.

Checklist

  • One library and one focused functionality group
  • All nine NIDs preserved
  • Typed declarations and guest-memory handling included
  • Focused regression tests registered
  • Upstream snapshot changes preserved
  • Technical debt and defensive limitations documented
  • No new third-party dependencies or firmware artifacts
  • Depends on: none
  • Fixes: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5067139336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12823). Originally posted by [xdCloudy](https://github.com/xdCloudy) on 2026-10-29T11:27:07Z. --- ### What Implement nine `libSceNpCommon` state helpers reconstructed from PS5 firmware 13.60. Seven functions query object state. Two implement clear/no-op behaviour. | Function | NID | Recovered behaviour | |---|---|---| | `EventFlag::IsInit` | `st-oQvV7HVI` | 32-bit field at `+0x10` is nonzero | | `RingBuf::IsFull` | `bvJ207-8qBQ` | 64-bit fields at `+0x20` and `+0x28` are equal | | `EventQueue::IsInit` | `VI8AHrfLdqY` | 16-bit field at `+0x98` is nonzero | | `Mutex::IsInit` | `Yc+qj4TIEY0` | Byte at `+0x10` is nonzero | | `RingBufMemory::IsInit` | `zdRXyt-65kA` | Pointer at `+0x8` is non-null | | `IpmiClient::IsConnected` | `prj9aMR74bA` | 32-bit field at `+0x18` equals zero | | `Callout::IsTimedout` | `xxOTJpEyoj4` | Signed state at `+0x10` is positive or `-2` | | `NpTitleSecret::Clear` | `X0vEo7cZamA` | Clears 128 bytes beginning at `+0x8` | | `JsonNull::Clear` | `88GKkivBFhI` | No-op | All nine retain their existing NIDs. ### Firmware evidence - Module: `libSceNpCommon.sprx` - Firmware: PS5 13.60 - SHA-256: `AB696280CAF5CF465C62E00D1785FB4348B59A7E376D7C6802453419E5765CD0` - Method: Ghidra 12.1.4 static decompilation and instruction inspection These are firmware-derived reconstructions. They have not been independently validated through console execution. No proprietary firmware artifacts are committed. ### Implementation - Implement all nine functions with typed declarations. - Access guest object fields through existing guest-memory copy helpers. - Return defensive `false` results for null or unreadable predicate operands. - Ignore null clear targets. - Preserve observed normal-path comparisons and clear operations. - Add focused regression tests for valid states, invalid addresses, address overflow and cross-page clear operations. - Document recovered behaviour and known guest-memory limitations. - Remove nine obsolete technical-debt entries. The defensive invalid-memory behaviour is an emulator compatibility choice, not a claim about native firmware faults. `GuestCopyOut_nid_no_patch` may perform a partial write on an inaccessible destination, particularly through Linux `process_vm_writev`. Failed clears do not guarantee atomic rollback. ### Upstream reconciliation Merged current upstream main `5bae1a4bc2` into this branch. The net PR diff remains the same five intended files, preserving all nine exports and NIDs, the focused test and existing upstream implementations. Related #12852 deliberately leaves RingBuf::IsFull and RingBufMemory::IsInit to this PR; its adjacent shared-file edits may still need merge-order reconciliation. ### Tested Windows x86_64, WinLibs GCC, CMake/Ninja Release, head `d4aee6eb2c`: - Built `guest_np_common_state_predicate_tests` and `guest_np_common_rtc_tests`. - Both CTests passed (2/2) before and after current-main integration. - The new null/unreadable-address, address-overflow and cross-page cases are now runtime-tested on Windows. - Conventions and diff whitespace checks passed. Linux partial-write behavior and console runtime remain unverified; the documented defensive-memory and partial-write limits remain. New-head hosted checks are pending. ### Checklist - [x] One library and one focused functionality group - [x] All nine NIDs preserved - [x] Typed declarations and guest-memory handling included - [x] Focused regression tests registered - [x] Upstream snapshot changes preserved - [x] Technical debt and defensive limitations documented - [x] No new third-party dependencies or firmware artifacts - [x] Depends on: none - [x] Fixes: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:54:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:54:05Z.

Review: COMMENTED


Nine NpCommon state helpers in one PR (+269/-46). Please say what else the diff carries.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729937229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12823#pullrequestreview-5729937229). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:54:05Z. **Review:** COMMENTED --- Nine NpCommon state helpers in one PR (+269/-46). Please say what else the diff carries.
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!12823
No description provided.