feat(libkernel): implement cpuset_getaffinity for the calling thread #2516

Closed
babyhuey wants to merge 1 commit from upstream-pr/2516 into main
babyhuey commented 2026-10-10 00:22:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T00:22:04Z.


What

Implements cpuset_getaffinity (Pdgml4rbxYk) in libkernel for the calling thread (CPU_LEVEL_WHICH, CPU_WHICH_TID, id -1): it copies the thread's guest affinity from scePthreadGetaffinity into the caller's set and zeroes the rest of the buffer. The set size must be at least the 8-byte KernelCpumask and at most 32 bytes (CPU_MAXSIZE 256 bits), otherwise ERANGE; a null set gives EFAULT. Other levels, which values and ids throw (NotImplemented_nid_no_patch).

Why

It is a title's next stop on current main: PPSA99082 OpenNOW PS5 0.0.7 stops on it.

Title main 2edaf7f4 (Linux) with this branch
PPSA99082 OpenNOW PS5 0.0.7 app.elf: symbol lookup error: app.elf: undefined symbol: Pdgml4rbxYk undefined symbol: V02oFv+-JzA (__isinf)

OpenNOW's only call site (eboot 0x1dca8) is cpuset_getaffinity(3, 1, -1, 8, set), so titles pass an 8-byte set and the 8-byte minimum accepts it. On failure it falls back to a 0x3f mask.

Tested

Linux (Ubuntu 24.04, GCC 13, Release): guest_available_cpumask passes with --repeat until-fail:3. It checks, from a guest thread, that an 8-byte set gets the thread's mask and nothing past it is written, a 32-byte set gets the mask with the tail zeroed, and that 4 and 33 bytes give ERANGE and a null set gives EFAULT. check_conventions.py passes. Windows: Thread.cpp compiles with MinGW-w64 (-Wall -Wextra -fsyntax-only).

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4807280341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2516). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-10T00:22:04Z. --- ### What Implements `cpuset_getaffinity` (`Pdgml4rbxYk`) in libkernel for the calling thread (`CPU_LEVEL_WHICH`, `CPU_WHICH_TID`, id `-1`): it copies the thread's guest affinity from `scePthreadGetaffinity` into the caller's set and zeroes the rest of the buffer. The set size must be at least the 8-byte `KernelCpumask` and at most 32 bytes (`CPU_MAXSIZE` 256 bits), otherwise `ERANGE`; a null set gives `EFAULT`. Other levels, `which` values and ids throw (`NotImplemented_nid_no_patch`). ### Why It is a title's next stop on current `main`: PPSA99082 OpenNOW PS5 0.0.7 stops on it. | Title | `main` 2edaf7f4 (Linux) | with this branch | |---|---|---| | PPSA99082 OpenNOW PS5 0.0.7 | `app.elf: symbol lookup error: app.elf: undefined symbol: Pdgml4rbxYk` | `undefined symbol: V02oFv+-JzA` (`__isinf`) | OpenNOW's only call site (eboot `0x1dca8`) is `cpuset_getaffinity(3, 1, -1, 8, set)`, so titles pass an 8-byte set and the 8-byte minimum accepts it. On failure it falls back to a `0x3f` mask. ### Tested Linux (Ubuntu 24.04, GCC 13, Release): `guest_available_cpumask` passes with `--repeat until-fail:3`. It checks, from a guest thread, that an 8-byte set gets the thread's mask and nothing past it is written, a 32-byte set gets the mask with the tail zeroed, and that 4 and 33 bytes give `ERANGE` and a null set gives `EFAULT`. `check_conventions.py` passes. Windows: `Thread.cpp` compiles with MinGW-w64 (`-Wall -Wextra -fsyntax-only`). ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-10 00:22:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T00:22:14Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091550751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2516#issuecomment-6091550751). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T00:22:14Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
github-actions[bot] commented 2026-10-10 00:22:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T00:22:26Z.


Progress report (1f0c9fe → d4ffa85)

📉 System libraries: 85.66% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel cpuset_getaffinity_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091552790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2516#issuecomment-6091552790). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T00:22:26Z. --- <!-- progress-report --> ### Progress report (1f0c9fe → d4ffa85) 📉 **System libraries**: 85.66% (-0.03%, +1 declared functions) <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libkernel | `cpuset_getaffinity_nid_postfix` | </details>

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