Commit Graph
20 Commits
Author SHA1 Message Date
Dean a03cc0dde6 Merge pull request #14885 from oneandonlydean/carry-7135
fix(libkernel): follow kern_cpuset for the base cpuset, level checks and interrupt targets
2026-11-03 18:14:20 +13:00
Dean Galvin df788026b6 fix(libkernel): refuse cpuset sizes the console rejects and record the EPERM difference
cpuset_getaffinity and cpuset_setaffinity return ERANGE from 24 bytes, as a PS5 payload process did (rooklz sweep, #7135 comment 6391606624: 8 to 16 accepted, below 8 and from 24 up ERANGE), and throw for the unmeasured 17 to 23, as pthread_getaffinity_np does. The tests that used 32 bytes use 16 and pin 7, 24, 32 and 64 to ERANGE. The setter entry records that the console answers EPERM for a CPU outside the process's set where this clips and returns 0.
2026-11-03 15:15:35 +13:00
Dean Galvin cc73f16c59 fix(libkernel): answer CPU_LEVEL_ROOT and test the cpuset sizes the console accepts
cpuset_getaffinity at CPU_LEVEL_ROOT returns 0xffff, as a PS5 payload process read it (rooklz, #7135 comment 6390891591), instead of throwing; the target is checked as at the other levels. The level 2 base-set test now passes 8 and 16 bytes, which the console accepts (it returns ERANGE from 24 bytes), instead of depending on the 32 bytes it rejects. The debt entry records the root measurement and that the title root set is unmeasured.
2026-11-03 15:11:23 +13:00
Dean GalvinandAlexej Szpevák f82fb8a9c9 fix(libkernel): carry cpuset base-set and level handling
Carry #7135 by @AlexOfTheForest. Preserve current checked guest-memory copies and unrelated debt; remove the ten newly added unsupported-call throw assertions while retaining implemented success and error coverage.

Co-authored-by: Alexej Szpevák <[email protected]>
2026-11-02 08:21:01 +13:00
Yunus Shaikh 711f3a69f1 Merge main into fix/kernel-getaffinity-console-sizes
The conflict with #13908 in docs/dev/debt/libkernel.md keeps both sides: this branch's pthread_getaffinity_np entry, followed by #13908's sentence on the EFAULT fallback for a mask pointer that cannot be read or written.
2026-11-01 01:01:07 -08:00
DeveshB-1 51bd568169 fix(libkernel): return EFAULT from cpuset and pthread affinity for invalid memory 2026-11-01 08:18:41 +01:00
Yunus Shaikh 6093634622 fix(libkernel): follow the console's set sizes in pthread_getaffinity_np
rooklz measured on a PS5 that pthread_getaffinity_np accepts any set of 8 to
16 bytes, zero-fills it past byte 8, and returns ERANGE below 8 bytes and from
24 up. Sets of 17 to 23 bytes are not measured and still throw.
2026-10-31 15:58:18 +00:00
p3nicillinandClaude Opus 5.5 3d46b03a06 test(libkernel): stop pinning the unmeasured getaffinity set sizes
Set sizes below 32 bytes other than 8 and 16 are valid but unmeasured on
the console. pthread_getaffinity_np still throws for them, and the debt
entry records which sizes are measured, but the test no longer asserts
the unimplemented path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 12:18:00 +00:00
p3nicillinandClaude Opus 5.5 7c97d68937 fix(libkernel): throw for every set size the console was not measured with
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 12:18:00 +00:00
p3nicillinandClaude Opus 5.5 b4861eb197 fix(libkernel): answer pthread_getaffinity_np for the console's set sizes
PS5_PayloadSDK measured in a title (firmware 12.09) that
pthread_getaffinity_np answers sets of 8 and 16 bytes and returns ERANGE
for 32 bytes or more, so FreeBSD's 32-byte cpuset_t is refused. The call
accepted exactly 32 bytes and refused every other size. Sizes under 8
keep ERANGE; 17 to 31 bytes, between the measured sizes, throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 12:18:00 +00:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
JJenkx 7777219ee1 feat(libkernel): support cpuset affinity by guest thread ID 2026-10-15 15:25:34 -04:00
screammandClaude Opus 5.5 74c3fb6576 feat(libkernel): implement pthread_setaffinity_np
PS5CEMU-HAR (PPSA99360, ps5-payload-dev build, relinks with
--trap-sdk-syscall-stubs) imports pthread_setaffinity_np (5KWrg7-ZqvE)
from libkernel.prx. babyhuey's run with #3787 merged onto main e7c70a2d
(PR #3787, 2026-10-12T10:54:44Z) stops at it:

  Windows: FAIL: unresolved ELF import 5KWrg7-ZqvE (pthread_setaffinity_np) from libkernel.prx
  Linux: undefined symbol: 5KWrg7-ZqvE (pthread_setaffinity_np)

It follows FreeBSD 11.4 libthr thr_affinity.c (8c639945) over
kern_cpuset_setaffinity: another thread is looked up first (EINVAL for
null, ESRCH when unknown or finished, as _thr_find_thread without dead
threads), a size other than the 32-byte cpuset_t returns ERANGE, the
mask is clipped to sceKernelGetAvailableCpumask and an empty result
returns EDEADLK, as cpuset_setaffinity does. The affinity is stored on
the guest thread through scePthreadSetaffinity, for the caller and for
any live guest thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 16:39:07 +00:00
jagrat Singh 9efabff1cb feat(libkernel): return ESRCH and EINVAL for unsupported cpuset affinity targets
Allow calling threads to query and set affinity using their own thread ID in addition to -1. Return ESRCH for non-matching thread or process IDs and EINVAL for invalid level/which arguments instead of throwing NotImplemented, matching FreeBSD cpuset semantics.
2026-10-13 15:58:11 +05:30
Semir Kabir 2124cfba5f feat(libkernel): report the process affinity from cpuset_getaffinity 2026-10-11 16:43:36 +00:00
Dani 21f4be11ad fix(libkernel): inherit process affinity in new guest threads 2026-10-11 12:44:26 +02:00
Ramzi 45eb492335 feat(libkernel): implement pthread_getaffinity_np
Report the thread's affinity mask as a 32-byte FreeBSD cpuset_t, with
FreeBSD 11's errors: ERANGE for any other set size, ESRCH for a null
thread and EFAULT for a null set.

EVO-PLAYER (PPSA99039 v0.11.0) imports it (Jb2uGFMr688) and calls it
once with a 32-byte set on pthread_self().
2026-10-11 10:23:50 +02:00
Scott SchusterandClaude Opus 5.5 bb4b938e34 feat(libkernel): implement cpuset_setaffinity for the calling thread or process
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-11 02:31:57 -05:00
Hannah Lyons d2c160be76 feat(libkernel): implement cpuset_getaffinity for the calling thread 2026-10-10 12:40:56 -04:00
raghav314andClaude Opus 5.5 670ffb9da3 feat(libkernel): implement sceKernelGetAvailableCpumask
Returns the CPU mask threads get by default (DEFAULT_THREAD_AFFINITY,
0x1FFF), the value itself rather than an error code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-06 09:41:52 +05:30