Commit Graph
20 Commits
Author SHA1 Message Date
MaxandClaude Opus 5.5 55ff5484d6 fix(libkernel): time out timed locks of a lock the caller already holds
scePthreadMutexTimedlock on a mutex the caller holds, and
scePthreadRwlockTimedrdlock and scePthreadRwlockTimedwrlock on a rwlock
it holds for writing, returned EDEADLK at once. The console returns
ETIMEDOUT, as the prosper console oracle measured. They now sleep until
the timeout and return ETIMEDOUT, as FreeBSD libthr does. The POSIX
timed locks call these and change with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 02:15:31 +02:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
MaxandClaude Opus 5.5 3ddaa64707 fix(libkernel): return EINVAL for the semaphore arguments the console rejects
The prosper console oracle measured SCE_KERNEL_ERROR_EINVAL for creating
a semaphore with an initial count above the maximum, a maximum of 0, a
negative initial count or a null name, for polling 0 or more than the
maximum, and for signalling 0. These threw, or polled past the maximum
returned EBUSY, and signalling 0 succeeded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 01:18:34 +02:00
orezraeyandClaude Opus 5.5 791990ad3e fix(libkernel): check the event flag name before the output as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 21:37:07 -03:00
orezraeyandClaude Opus 5.5 c416e3aca3 feat(libkernel): implement shared event flags and sceKernelCloseEventFlag
Measured on firmware 13.60: attribute 0x100 makes a flag openable by
name, and only such flags can be opened. Each open returns a new handle
on the same flag, which sceKernelCloseEventFlag releases. Closing a
creator handle and deleting through an opened one return EPERM. Two live
shared flags cannot share a name, names of 32 or more bytes return
ENAMETOOLONG, and a missing name returns ESRCH. After the creator
deletes the flag, an opened handle polls and waits with EACCES and sets,
clears and cancels with no effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:17:32 -03:00
orezraeyandClaude Opus 5.5 3e6c6bd71f test(libkernel): cover cancelling two event flag waiters
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 09:57:32 -03:00
orezraeyandClaude Opus 5.5 b779496315 fix(libkernel): match event flag attributes and error results to PS5
Measured on firmware 13.60: create accepts attribute bits 0x1, 0x2, 0x10,
0x20 and 0x100 and rejects 0x1|0x2; wait and poll ignore mode bits outside
the match and clear fields; EPERM, ECANCELED and EACCES write 0 to the
result pattern.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 09:56:48 -03:00
babyhuey b28198008c feat(libkernel): implement sceKernelOpenEventFlag
Return the handle of an event flag this process created under the
given name, or ENOENT. Twispero opens the shell's
SceShellCoreUtilAppFocus flag at start-up and treats a failed open as
unknown focus.
2026-10-19 20:52:47 -04:00
fogydes ee7280c873 fix(libkernel): prevent use-after-free on event flag deletion and multi-waiter race 2026-10-19 14:32:12 +05:30
fogydes 2210200232 fix(libkernel): reject unknown event flag creation attributes 2026-10-15 18:14:45 +05:30
hugodearaujoandClaude Opus 5.5 b9b5bcc190 fix(libkernel): return the console's errors from the SCE mutex calls
On a PS5 (firmware 13.60) the SCE mutex attribute calls return EINVAL
for a null or uninitialized attribute, scePthreadMutexattrSetprotocol
accepts 0 to 2, scePthreadMutexInit takes an uninitialized attribute as
the default one, and destroying a destroyed mutex returns EINVAL. Here
these threw, including for the priority protection protocol.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-11 21:06:55 -03:00
Lexroid 45a561aea5 fix(libkernel): accept a zero count in sceKernelSignalSema
sceKernelSignalSema threw invalid_argument for a count of 0. Marvel's
Wolverine (PPSA03671) signals with a count computed as min(a, b) - c,
which can be 0, and ignores the result, so the throw ended the title a
few minutes in. A zero count now adds no tokens and returns SCE_OK, as
in shadPS4 and Kyty. A null semaphore and a negative count still throw.

guest_kernel_errors signals 0 on a full and on an empty semaphore and
checks that the count is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7191d34c4d79622ba71087f0da2b75eb81ad2c23)
2026-10-10 16:12:43 +00:00
Aryan Sharma d77bc7c363 fix(libkernel): return EBUSY when destroying a locked mutex
scePthreadMutexDestroy threw when the mutex was locked. FreeBSD libthr,
which the console's libkernel follows, returns EBUSY and leaves the
mutex usable; PPSA28997 destroys a locked mutex during its intro and
was aborted.
2026-10-08 14:25:16 +05:30
ChadandClaude Opus 5.5 69973800a7 fix(libkernel): return EINVAL for unknown mutex attribute types
UFC 6 (PPSA23566) passes type 0 to pthread_mutexattr_settype during
startup. libkernel rejects it with EINVAL and leaves the attribute
unchanged, as fpPS4's decompiled body does, instead of aborting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-06 17:04:06 -05:00
Adrià FranchandClaude fe557fb0e2 feat(kernel): lazily initialize the adaptive static mutex initializer
Co-Authored-By: Claude <[email protected]>
2026-10-06 14:23:25 +02:00
PacukaandClaude Opus 5.5 6814cab9f9 fix(libkernel): map POSIX adaptive mutexes to the adaptive type
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 14:30:12 +02:00
PacukaandClaude Opus 5.5 98f050f879 fix(libkernel): default mutexes to error checking and add the adaptive type
The PS5 libthr (FreeBSD) creates error-checking mutexes by default and has
PTHREAD_MUTEX_ADAPTIVE_NP (type 4); relocking an error-checking or adaptive
mutex returns EDEADLK. Default mutexes were Normal and type 4 was mapped to
Normal, so a relock threw instead of returning EDEADLK, which aborted an
Unreal Engine title's recursive directory scan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 14:28:33 +02:00
RomainROCH 74586bab57 fix(libkernel): avoid semaphore count overflow 2026-10-02 06:19:39 +02:00
Dean Galvin 70bbd700e2 feat(libkernel): accept priority-inheritance mutexes
scePthreadMutexattrSetprotocol threw for SCE_PTHREAD_PRIO_INHERIT, so a
title creating its mutexes with priority inheritance stopped at the
first one.

Guest thread priorities are recorded (scePthreadSetprio/Getprio) but
never applied to host scheduling, so there is no priority for a waiter
to lend to the owner: an inheriting mutex locks, unlocks and reports
errors exactly like a PRIO_NONE one here, and the protocol is accepted.
The POSIX pthread_mutexattr_setprotocol wrapper already accepts it.
Priority protection (PRIO_PROTECT, with its ceilings) and unknown
protocols still throw.
2026-09-29 13:22:21 +13:00
QDarkRexandClaude Opus 5.5 97cae1458e fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-27 13:22:01 +07:00