feat(libSceSystemService): implement AppMessaging queue and event flags #17144

Open
fishingpvalues wants to merge 20 commits from upstream-pr/17144 into main
fishingpvalues commented 2026-11-08 11:12:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fishingpvalues on 2026-11-08T11:12:55Z.


What

The eight sceAppMessaging exports move from the PendingExports.cpp stubs into src/AppMessaging.cpp.

  • SendMsg, SendMsgToShellCore and SendMsgToShellUI validate the 8192-byte payload bound and accept the message. A null payload with a nonzero size or a size over the payload returns 0x80C50001. The sends are outgoing: no in-process component queues a message addressed to the calling title, so they never enter the receive queue, and appId, message type and flags are not retained.
  • ReceiveMsg blocks until a message arrives; no in-process producer exists yet, so it blocks indefinitely. TryReceiveMsg returns 0x80C50005 for the empty queue; a null output returns 0x80C50004 in both receive forms.
  • SetEventFlag ORs and ClearEventFlag clears the global 64-bit flag; TryGetEventFlag returns the masked value and optionally clears those bits, with a null output returning 0x80C50004.

tests/GuestSystemServiceAppMessaging.cpp is registered as guest_system_service_app_messaging, and docs/dev/debt/libSceSystemService.md records the chosen return codes and that the receive queue has no producer.

Tested

Linux x86-64 (Debian 13, glibc 2.41, GCC 14.2.0), Release, BUILD_TESTING=ON, base main f9c2d92b91:

  • cmake --build build --target guest_system_service_app_messaging_tests --parallel 8: passed.
  • ctest --test-dir build -R '^guest_system_service_app_messaging$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • Merged main f9c2d92b91; no conflicts.
  • Not run: Windows, a console or a title.

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
  • 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:5210829937 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144). Originally posted by [fishingpvalues](https://github.com/fishingpvalues) on 2026-11-08T11:12:55Z. --- ### What The eight `sceAppMessaging` exports move from the `PendingExports.cpp` stubs into `src/AppMessaging.cpp`. - `SendMsg`, `SendMsgToShellCore` and `SendMsgToShellUI` validate the 8192-byte payload bound and accept the message. A null payload with a nonzero size or a size over the payload returns `0x80C50001`. The sends are outgoing: no in-process component queues a message addressed to the calling title, so they never enter the receive queue, and `appId`, message type and flags are not retained. - `ReceiveMsg` blocks until a message arrives; no in-process producer exists yet, so it blocks indefinitely. `TryReceiveMsg` returns `0x80C50005` for the empty queue; a null output returns `0x80C50004` in both receive forms. - `SetEventFlag` ORs and `ClearEventFlag` clears the global 64-bit flag; `TryGetEventFlag` returns the masked value and optionally clears those bits, with a null output returning `0x80C50004`. `tests/GuestSystemServiceAppMessaging.cpp` is registered as `guest_system_service_app_messaging`, and `docs/dev/debt/libSceSystemService.md` records the chosen return codes and that the receive queue has no producer. ### Tested Linux x86-64 (Debian 13, glibc 2.41, GCC 14.2.0), Release, `BUILD_TESTING=ON`, base `main` `f9c2d92b91`: - `cmake --build build --target guest_system_service_app_messaging_tests --parallel 8`: passed. - `ctest --test-dir build -R '^guest_system_service_app_messaging$' --output-on-failure`: 1/1 passed. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - Merged `main` `f9c2d92b91`; no conflicts. - Not run: Windows, a console or a title. ### 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 - [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
coptergui-ops commented 2026-11-08 12:30:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coptergui-ops on 2026-11-08T12:30:50Z.

Review: APPROVED


Reviewed at current head. All eight sceAppMessaging exports move from PendingExports stubs into src/AppMessaging.cpp: bounded 8192-byte payload copy with InvalidArgument (0x80C50001) on oversized or null-data-with-size, mutexed FIFO queue, blocking ReceiveMsg via condition_variable, Try forms returning 0x80C50005 on empty queue and 0x80C50004 on null output, global 64-bit event flag with Set/Clear/TryGet(mask, clear) semantics. Debt bullet states exactly what is modelled vs the PS5 console backend. Overlap verdict: PR 8651 (open, stale base conflicting with main) implemented sceAppMessagingTryReceiveMsg (and sceLncUtilInitialize, which this PR does not touch) - after this merges, 8651's TryReceiveMsg definition is superseded: close 8651, or rebase keeping only its sceLncUtilInitialize work. 14212 and 15947: different debt entries, no shared lines. Conventions checker: no new findings from this diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5817879672 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-5817879672). Originally posted by [coptergui-ops](https://github.com/coptergui-ops) on 2026-11-08T12:30:50Z. **Review:** APPROVED --- Reviewed at current head. All eight sceAppMessaging exports move from PendingExports stubs into src/AppMessaging.cpp: bounded 8192-byte payload copy with InvalidArgument (0x80C50001) on oversized or null-data-with-size, mutexed FIFO queue, blocking ReceiveMsg via condition_variable, Try forms returning 0x80C50005 on empty queue and 0x80C50004 on null output, global 64-bit event flag with Set/Clear/TryGet(mask, clear) semantics. Debt bullet states exactly what is modelled vs the PS5 console backend. Overlap verdict: PR 8651 (open, stale base conflicting with main) implemented sceAppMessagingTryReceiveMsg (and sceLncUtilInitialize, which this PR does not touch) - after this merges, 8651's TryReceiveMsg definition is superseded: close 8651, or rebase keeping only its sceLncUtilInitialize work. 14212 and 15947: different debt entries, no shared lines. Conventions checker: no new findings from this diff.
adriadam10 commented 2026-11-12 15:20:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-12T15:20:39Z.

Review: CHANGES_REQUESTED


Checked the diff against @oneandonlydean's review of 49113a2c57; both of his points still apply to this head:

  • src/AppMessaging.cpp:28-42,63-73: SendMsg, SendMsgToShellCore and SendMsgToShellUI push into the same queue that ReceiveMsg (:54) and TryReceiveMsg (:90) pop, so a title receives its own outgoing messages (sender 0 or appId). Keep the sends out of the receive queue (accept and drop them, or record them separately for tests) so receive only returns messages addressed to the title, and update GuestSystemServiceAppMessaging.cpp lines 22-34, which pin the loopback.
  • docs/dev/debt/libSceSystemService.md:172: name the source of 0x80C50001, 0x80C50004 and 0x80C50005 (firmware or SDK header), or say they are chosen values.

Once receive no longer sees sent messages, ReceiveMsg blocks until something is delivered; note that in the debt entry too.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5876996284 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-5876996284). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-12T15:20:39Z. **Review:** CHANGES_REQUESTED --- Checked the diff against @oneandonlydean's review of 49113a2c57; both of his points still apply to this head: - `src/AppMessaging.cpp:28-42,63-73`: `SendMsg`, `SendMsgToShellCore` and `SendMsgToShellUI` push into the same `queue` that `ReceiveMsg` (`:54`) and `TryReceiveMsg` (`:90`) pop, so a title receives its own outgoing messages (sender 0 or `appId`). Keep the sends out of the receive queue (accept and drop them, or record them separately for tests) so receive only returns messages addressed to the title, and update `GuestSystemServiceAppMessaging.cpp` lines 22-34, which pin the loopback. - `docs/dev/debt/libSceSystemService.md:172`: name the source of `0x80C50001`, `0x80C50004` and `0x80C50005` (firmware or SDK header), or say they are chosen values. Once receive no longer sees sent messages, `ReceiveMsg` blocks until something is delivered; note that in the debt entry too.
MarcZX10 commented 2026-11-20 13:27:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T13:27:11Z.

Review: COMMENTED


Reviewed — comments

Nothing blocks this review; the points below are optional.

What I ran

Reviewed head 43b9d261b9543ebeb5ce1aab420353829e2da10f. I read the prepared description, commit list, manifest, diff, and every included changed file. I did not run commands or tests; repo_read.py was unavailable as a command in this environment.

Results

Check Result Note
Changed source review passed Included changed files read
Build and tests not run Author reports Linux build and test pass
Excluded-file review not run No exclusions list was available

Findings

Blocking

None identified in the code read.

Non-blocking

  • The new event flags and receive queue are process-wide globals; appId is ignored by the flag APIs and the messages do not retain sender/type metadata. The debt note calls out the simplified global flag model, but this leaves per-application behavior unimplemented. Consider documenting the scope at the API boundary or implementing per-app state when the model is expanded. core/libs/prx/libSceSystemService/src/AppMessaging.cpp:29

Not verified

  • The reader exposed the five changed paths listed in the manifest, and all five were read. The referenced review/files.json was not available, so additional exclusions could not be confirmed.
  • Build, tests, conventions check, merged-preview behavior, Windows, and console/title behavior were not independently verified. Linux checks are author-reported only.

To get this to a good state

Nothing is required. Optional: clarify or expand the app-scoped event-flag behavior as the system-service model develops.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993408045 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-5993408045). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T13:27:11Z. **Review:** COMMENTED --- # Reviewed — comments Nothing blocks this review; the points below are optional. ## What I ran Reviewed head `43b9d261b9543ebeb5ce1aab420353829e2da10f`. I read the prepared description, commit list, manifest, diff, and every included changed file. I did not run commands or tests; `repo_read.py` was unavailable as a command in this environment. ## Results | Check | Result | Note | |---|---|---| | Changed source review | passed | Included changed files read | | Build and tests | not run | Author reports Linux build and test pass | | Excluded-file review | not run | No exclusions list was available | ## Findings ### Blocking None identified in the code read. ### Non-blocking - The new event flags and receive queue are process-wide globals; `appId` is ignored by the flag APIs and the messages do not retain sender/type metadata. The debt note calls out the simplified global flag model, but this leaves per-application behavior unimplemented. Consider documenting the scope at the API boundary or implementing per-app state when the model is expanded. `core/libs/prx/libSceSystemService/src/AppMessaging.cpp:29` ## Not verified - The reader exposed the five changed paths listed in the manifest, and all five were read. The referenced `review/files.json` was not available, so additional exclusions could not be confirmed. - Build, tests, conventions check, merged-preview behavior, Windows, and console/title behavior were not independently verified. Linux checks are author-reported only. ## To get this to a good state Nothing is required. Optional: clarify or expand the app-scoped event-flag behavior as the system-service model develops.
MarcZX10 commented 2026-11-22 22:35:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T22:35:50Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation follows the stated limited model; I found no verified blocking defect, but the review is incomplete because the removed export definitions and CMake registration context were not fully inspected.

What I ran

Reviewed head 143c36ff62285e7a16179fb5467f844f8deca773. No build or tests were run. The author reports Linux build, targeted test, and convention checks passed; those results were not independently verified.

Results

Check Result Note
Source review passed Implementation and added test read
Build and tests not run Author-reported results only
Console and Windows behavior not run Not independently confirmed

Findings

Blocking

None verified in the code read.

Non-blocking

  • The selected error codes and global event-flag model are explicitly documented as approximations rather than firmware-verified behavior. Keep that limitation visible to users of these exports.

Not verified

Read description.md, commits.md, manifest.json, diff.patch, src/AppMessaging.cpp, tests/GuestSystemServiceAppMessaging.cpp, CMakeLists.txt lines 340–382, and include/SystemService.hpp lines 1–200. The complete PendingExports.cpp, the declarations later in SystemService.hpp, and the rest of the repository context were not read. All changed paths are included in the review bundle; none were excluded per the manifest. No tests, build, negative control, Windows run, or console run was performed.

To get this to a good state

Nothing is required. Optional: verify the chosen return codes and per-application semantics against console behavior when that becomes available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014890780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-6014890780). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T22:35:50Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation follows the stated limited model; I found no verified blocking defect, but the review is incomplete because the removed export definitions and CMake registration context were not fully inspected. ## What I ran Reviewed head `143c36ff62285e7a16179fb5467f844f8deca773`. No build or tests were run. The author reports Linux build, targeted test, and convention checks passed; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Implementation and added test read | | Build and tests | not run | Author-reported results only | | Console and Windows behavior | not run | Not independently confirmed | ## Findings ### Blocking None verified in the code read. ### Non-blocking - The selected error codes and global event-flag model are explicitly documented as approximations rather than firmware-verified behavior. Keep that limitation visible to users of these exports. ## Not verified Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `src/AppMessaging.cpp`, `tests/GuestSystemServiceAppMessaging.cpp`, `CMakeLists.txt` lines 340–382, and `include/SystemService.hpp` lines 1–200. The complete `PendingExports.cpp`, the declarations later in `SystemService.hpp`, and the rest of the repository context were not read. All changed paths are included in the review bundle; none were excluded per the manifest. No tests, build, negative control, Windows run, or console run was performed. ## To get this to a good state Nothing is required. Optional: verify the chosen return codes and per-application semantics against console behavior when that becomes available.
MarcZX10 commented 2026-11-25 18:31:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:31:47Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the findings below are optional.

What I ran

Reviewed head 9bcdf3ea05765645d32a5bad6f40fbcf2578b563. I read the full text of all six changed files and the prepared description, commits, manifest, and diff; no commands or tests were run. The author reports Linux build, targeted CTest, and conventions checks passed.

Results

Check Result Note
Code review passed All changed files read
Build and tests not run Author-reported pass only
Conventions check not run Author-reported pass only

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceSystemService/src/AppMessaging.cpp:18 uses one process-global event flag value, and the set/clear functions ignore appId. The description and debt note disclose this approximation. Consider documenting the limitation at the API implementation or adding per-app state when behavior is modeled more fully.
  • Current tests cover event-flag behavior and send validation, but not a successful receive from an enqueued message. The implementation has no producer by design, so such a test needs a deliberate test seam or a future producer.

Not verified

No tests or build were run in this review. Windows, console and title behavior were not verified. review/files.json was not available through the reader; the manifest and file listing show six changed files, all included, and all six were read. No excluded changed files were identified.

To get this to a good state

Nothing is required. The optional points above are suggestions.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6062929078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-6062929078). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T18:31:47Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the findings below are optional. ## What I ran Reviewed head `9bcdf3ea05765645d32a5bad6f40fbcf2578b563`. I read the full text of all six changed files and the prepared description, commits, manifest, and diff; no commands or tests were run. The author reports Linux build, targeted CTest, and conventions checks passed. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | All changed files read | | Build and tests | not run | Author-reported pass only | | Conventions check | not run | Author-reported pass only | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceSystemService/src/AppMessaging.cpp:18` uses one process-global event flag value, and the set/clear functions ignore `appId`. The description and debt note disclose this approximation. Consider documenting the limitation at the API implementation or adding per-app state when behavior is modeled more fully. - Current tests cover event-flag behavior and send validation, but not a successful receive from an enqueued message. The implementation has no producer by design, so such a test needs a deliberate test seam or a future producer. ## Not verified No tests or build were run in this review. Windows, console and title behavior were not verified. `review/files.json` was not available through the reader; the manifest and file listing show six changed files, all included, and all six were read. No excluded changed files were identified. ## To get this to a good state Nothing is required. The optional points above are suggestions.
ligmaSec commented 2026-12-03 13:29:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:29:28Z.

Review: COMMENTED


The Linux integration build passed the registered app-messaging CTest.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170717394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17144#pullrequestreview-6170717394). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:29:28Z. **Review:** COMMENTED --- The Linux integration build passed the registered app-messaging CTest. 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/17144:upstream-pr/17144'
git switch 'upstream-pr/17144'

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