feat(libSceSystemService): implement sceSystemServiceGetPlatformPrivacySetting #20896

Closed
simnJS wants to merge 1 commit from upstream-pr/20896 into main
simnJS commented 2026-11-15 17:44:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-11-15T17:44:44Z.


What

Implements sceSystemServiceGetPlatformPrivacySetting, which threw. Knowledge is Power: Decades (CUSA12435) calls it (discussion #9718, where the call-site evidence for this export was asked for). This PR brings the library's side of the contract instead: libSceSystemService.sprx of firmware 13.60, from my own console, export hvoLYhc4cq0 at 0x2970 (0xa0 bytes), read from disassembly and not measured on a console. The module isn't attached.

What the module does, and what this PR does:

  • It takes one argument, a pointer (rdi, kept in rbx), and always returns 0 (xor %eax,%eax on the only exit).
  • It calls sceKernelIsPs4Process; unless that returns 1 it returns without writing through the pointer.
  • For a PS4 process it opens the event flag SceUserServiceCommonEventFlag with sceKernelOpenEventFlag. If that fails it stores 0 (after a printf of the error, which this PR does not reproduce).
  • Otherwise it calls sceKernelPollEventFlag(flag, 1, 2, NULL) (bit 0, wait mode OR, no clear), closes the flag, and stores 1 when the poll returned 0, else 0. The store is 32 bits wide (mov %r12d,(%rbx)).

The implementation calls the same four kernel exports, so it follows whatever AnyPS5's event flags do. libSceSystemService now links libkernel_sys for sceKernelIsPs4Process, as libSceAudio3d does.

Not established: nothing in AnyPS5 creates SceUserServiceCommonEventFlag (the console's system owns it), so a PS4 title always reads 0 here; the value the console reports and what 0 and 1 mean are unknown. The CUSA12435 call site was not read by me (I don't own the title), so which value the title needs is not shown. Both are in the debt fragment.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, on head 6aa2186b0c85d837746e24f5e599c2af39b4bc14, based on main at b7aeb6f40619e03f03fed9a68d6be24176bec8c8.

  • Not built or run locally. The new test guest_system_service_platform_privacy_setting (ps4 and ps5 cases, title ID from app0/sce_sys/param.json) has only been compiled with -fsyntax-only; I am relying on the Windows job of this PR to build and run it, and will fix it here if it fails.
  • Syntax: g++ -std=c++20 -fsyntax-only -Wall -Wextra -I core/libs passes for core/libs/prx/libSceSystemService/PendingExports.cpp and core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp (only the existing unused-parameter warnings of the other stubs).
  • What the test checks: a PS5 process keeps its sentinel, with and without the flag; a PS4 process reads 0 without the flag, 0 with bit 0 clear (patterns 0 and 2), 1 with bit 0 set (patterns 1 and 3), the same value on a second call (the poll does not clear), and follows sceKernelSetEventFlag and sceKernelClearEventFlag.
  • Debt: python3 tools/debt_fold.py --check passes.
  • Conventions: python3 tools/check_conventions.py --base origin/main with this title and description: All conventions checks passed.
  • Overlap: pr_overlap cannot finish on my shallow clone (merge-base fails). A search of all pull requests for sceSystemServiceGetPlatformPrivacySetting returns none.

Not run on a console. Not run with CUSA12435.

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: CUSA12435 #9718 (the export it calls no longer throws; not run with the title)
  • GPUs tested: n/a
  • AI-assisted: yes

AI assistance: written with Claude Code, model Claude Mythos 5.2 (claude-mythos-5-2), which read the disassembly, wrote the code and the test and ran the checks above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5325402334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20896). Originally posted by [simnJS](https://github.com/simnJS) on 2026-11-15T17:44:44Z. --- ### What Implements `sceSystemServiceGetPlatformPrivacySetting`, which threw. Knowledge is Power: Decades (CUSA12435) calls it ([discussion #9718](https://github.com/boykopovar/AnyPS5/discussions/9718), where the call-site evidence for this export was asked for). This PR brings the library's side of the contract instead: `libSceSystemService.sprx` of firmware 13.60, from my own console, export `hvoLYhc4cq0` at `0x2970` (0xa0 bytes), read from disassembly and not measured on a console. The module isn't attached. What the module does, and what this PR does: - It takes one argument, a pointer (`rdi`, kept in `rbx`), and always returns 0 (`xor %eax,%eax` on the only exit). - It calls `sceKernelIsPs4Process`; unless that returns 1 it returns without writing through the pointer. - For a PS4 process it opens the event flag `SceUserServiceCommonEventFlag` with `sceKernelOpenEventFlag`. If that fails it stores 0 (after a `printf` of the error, which this PR does not reproduce). - Otherwise it calls `sceKernelPollEventFlag(flag, 1, 2, NULL)` (bit 0, wait mode OR, no clear), closes the flag, and stores 1 when the poll returned 0, else 0. The store is 32 bits wide (`mov %r12d,(%rbx)`). The implementation calls the same four kernel exports, so it follows whatever AnyPS5's event flags do. `libSceSystemService` now links `libkernel_sys` for `sceKernelIsPs4Process`, as `libSceAudio3d` does. Not established: nothing in AnyPS5 creates `SceUserServiceCommonEventFlag` (the console's system owns it), so a PS4 title always reads 0 here; the value the console reports and what 0 and 1 mean are unknown. The CUSA12435 call site was not read by me (I don't own the title), so which value the title needs is not shown. Both are in the debt fragment. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, on head `6aa2186b0c85d837746e24f5e599c2af39b4bc14`, based on `main` at `b7aeb6f40619e03f03fed9a68d6be24176bec8c8`. - **Not built or run locally.** The new test `guest_system_service_platform_privacy_setting` (`ps4` and `ps5` cases, title ID from `app0/sce_sys/param.json`) has only been compiled with `-fsyntax-only`; I am relying on the Windows job of this PR to build and run it, and will fix it here if it fails. - **Syntax:** `g++ -std=c++20 -fsyntax-only -Wall -Wextra -I core/libs` passes for `core/libs/prx/libSceSystemService/PendingExports.cpp` and `core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp` (only the existing unused-parameter warnings of the other stubs). - **What the test checks:** a PS5 process keeps its sentinel, with and without the flag; a PS4 process reads 0 without the flag, 0 with bit 0 clear (patterns 0 and 2), 1 with bit 0 set (patterns 1 and 3), the same value on a second call (the poll does not clear), and follows `sceKernelSetEventFlag` and `sceKernelClearEventFlag`. - **Debt:** `python3 tools/debt_fold.py --check` passes. - **Conventions:** `python3 tools/check_conventions.py --base origin/main` with this title and description: `All conventions checks passed.` - **Overlap:** `pr_overlap` cannot finish on my shallow clone (`merge-base` fails). A search of all pull requests for `sceSystemServiceGetPlatformPrivacySetting` returns none. Not run on a console. Not run with CUSA12435. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: CUSA12435 #9718 (the export it calls no longer throws; not run with the title) - [x] GPUs tested: n/a - [x] AI-assisted: yes AI assistance: written with Claude Code, model Claude Mythos 5.2 (`claude-mythos-5-2`), which read the disassembly, wrote the code and the test and ran the checks above on my machine.
PrivacyOnion commented 2026-11-16 02:08:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T02:08:57Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 6aa2186b0c:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_system_service_platform_privacy_setting_tests built cleanly.
  • CTest (guest_system_service_platform_privacy_setting_ps4, guest_system_service_platform_privacy_setting_ps5):
    1/2 Test #4719: guest_system_service_platform_privacy_setting_ps4 ...   Passed    0.04 sec
    2/2 Test #4720: guest_system_service_platform_privacy_setting_ps5 ...   Passed    0.04 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceSystemService/PendingExports.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #4720: guest_system_service_platform_privacy_setting_ps5 ...Subprocess aborted***Exception:   0.24 sec
    2/2 Test #4719: guest_system_service_platform_privacy_setting_ps4 ...Subprocess aborted***Exception:   0.26 sec
    0% tests passed, 2 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • Checked PR discussion and maintainer request from oneandonlydean regarding GuestCopyOut_nid_no_patch and errno preservation in core/libs/prx/libSceSystemService/PendingExports.cpp.
    • Checked sceSystemServiceGetPlatformPrivacySetting in core/libs/prx/libSceSystemService/PendingExports.cpp:1799-1809 for pointer safety and compliance with the maintainer's requested changes.
    • Checked core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp for coverage ofPS4/PS5 process paths, event flag bit patterns, and invalid output pointers.
    • Checked core/libs/prx/libSceSystemService/CMakeLists.txt for proper linking of libkernel_sys and test target setup across Linux and Windows.
    • Checked docs/dev/debt/changes/feat-system-service-platform-privacy-setting.md for technical debt fragment compliance.
  • Concerns:
    • core/libs/prx/libSceSystemService/PendingExports.cpp:1807: sceSystemServiceGetPlatformPrivacySetting dereferences the guest pointer directly with *setting = value; instead of copying out with GuestCopyOut_nid_no_patch while preserving errno, which crashes (SIGSEGV / access violation) when a PS4 process passes a null or unmapped pointer such as nullptr or reinterpret_cast<std::uint32_t*>(0x10) and leaves the maintainer's review request (oneandonlydean) unaddressed.
    • core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp:34-57: The PS4 test path does not exercise an invalid output pointer (such as reinterpret_cast<std::uint32_t*>(0x10)) or verify that errno is preserved as requested by maintainer oneandonlydean.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5914271764 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20896#pullrequestreview-5914271764). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T02:08:57Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `6aa2186b0c`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_system_service_platform_privacy_setting_tests` built cleanly. - **CTest** (`guest_system_service_platform_privacy_setting_ps4`, `guest_system_service_platform_privacy_setting_ps5`): ``` 1/2 Test #4719: guest_system_service_platform_privacy_setting_ps4 ... Passed 0.04 sec 2/2 Test #4720: guest_system_service_platform_privacy_setting_ps5 ... Passed 0.04 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceSystemService/PendingExports.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/2 Test #4720: guest_system_service_platform_privacy_setting_ps5 ...Subprocess aborted***Exception: 0.24 sec 2/2 Test #4719: guest_system_service_platform_privacy_setting_ps4 ...Subprocess aborted***Exception: 0.26 sec 0% tests passed, 2 tests failed out of 2 ``` Restoring the change makes it pass again. - **Code reading**: - Checked PR discussion and maintainer request from oneandonlydean regarding `GuestCopyOut_nid_no_patch` and `errno` preservation in `core/libs/prx/libSceSystemService/PendingExports.cpp`. - Checked `sceSystemServiceGetPlatformPrivacySetting` in `core/libs/prx/libSceSystemService/PendingExports.cpp:1799-1809` for pointer safety and compliance with the maintainer's requested changes. - Checked `core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp` for coverage ofPS4/PS5 process paths, event flag bit patterns, and invalid output pointers. - Checked `core/libs/prx/libSceSystemService/CMakeLists.txt` for proper linking of `libkernel_sys` and test target setup across Linux and Windows. - Checked `docs/dev/debt/changes/feat-system-service-platform-privacy-setting.md` for technical debt fragment compliance. - **Concerns**: - `core/libs/prx/libSceSystemService/PendingExports.cpp:1807`: `sceSystemServiceGetPlatformPrivacySetting` dereferences the guest pointer directly with `*setting = value;` instead of copying out with `GuestCopyOut_nid_no_patch` while preserving `errno`, which crashes (SIGSEGV / access violation) when a PS4 process passes a null or unmapped pointer such as `nullptr` or `reinterpret_cast<std::uint32_t*>(0x10)` and leaves the maintainer's review request (`oneandonlydean`) unaddressed. - `core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp:34-57`: The PS4 test path does not exercise an invalid output pointer (such as `reinterpret_cast<std::uint32_t*>(0x10)`) or verify that `errno` is preserved as requested by maintainer `oneandonlydean`. Requesting changes for the points above.
MarcZX10 commented 2026-11-23 05:11:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:11:12Z.

Review: APPROVED


Reviewed — looks good

The implementation follows the described disassembly behavior, and the changed files I read show no verified defect; compilation, runtime checks, and console behavior were not independently verified.

What I ran

Read prepared diff and repository context at head 6aa2186b0c85d837746e24f5e599c2af39b4bc14 using repo_read.py. No build or tests were run.

Results

Check Result Note
Diff review passed Four changed files read
Build and tests not run Only author-reported checks available
Console behavior not run No console or target title run

Findings

Blocking

None.

Non-blocking

  • The behavior is inferred from firmware disassembly and has not been confirmed on console or with CUSA12435. The PR documents this limitation and the unresolved meaning of the returned values.

Not verified

No changed files were excluded: files.json was unavailable, and the manifest lists all four changed files as included. I read core/libs/prx/libSceSystemService/CMakeLists.txt, core/libs/prx/libSceSystemService/PendingExports.cpp (including the changed function), core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp, and docs/dev/debt/changes/feat-system-service-platform-privacy-setting.md. I did not run the reported syntax check, debt check, conventions check, CI build/tests, or console/title behavior.

To get this to a good state

Nothing is required. Optional: validate the behavior on console and with CUSA12435 when available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016837696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20896#pullrequestreview-6016837696). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T05:11:12Z. **Review:** APPROVED --- # Reviewed — looks good The implementation follows the described disassembly behavior, and the changed files I read show no verified defect; compilation, runtime checks, and console behavior were not independently verified. ## What I ran Read prepared diff and repository context at head `6aa2186b0c85d837746e24f5e599c2af39b4bc14` using `repo_read.py`. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Four changed files read | | Build and tests | not run | Only author-reported checks available | | Console behavior | not run | No console or target title run | ## Findings ### Blocking None. ### Non-blocking - The behavior is inferred from firmware disassembly and has not been confirmed on console or with CUSA12435. The PR documents this limitation and the unresolved meaning of the returned values. ## Not verified No changed files were excluded: `files.json` was unavailable, and the manifest lists all four changed files as included. I read `core/libs/prx/libSceSystemService/CMakeLists.txt`, `core/libs/prx/libSceSystemService/PendingExports.cpp` (including the changed function), `core/libs/tests/GuestSystemServicePlatformPrivacySetting.cpp`, and `docs/dev/debt/changes/feat-system-service-platform-privacy-setting.md`. I did not run the reported syntax check, debt check, conventions check, CI build/tests, or console/title behavior. ## To get this to a good state Nothing is required. Optional: validate the behavior on console and with CUSA12435 when available.

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