Commit Graph
366 Commits
Author SHA1 Message Date
Adrià 26ba9b6b71 Merge pull request #9499 from EagleBearerYS/fix/libkernel-signal-handler-mask
fix(libkernel): block a signal while its handler runs and honour SA_RESETHAND
2026-10-25 22:05:12 +01:00
Adrià aeff26bd97 Merge pull request #9573 from zaryabzip/feat/pthread-create-suspended
feat(libkernel_sys): create threads suspended and resume them
2026-10-25 20:21:07 +01:00
Adrià 08f2d02a56 Merge pull request #9171 from DavidSamir/feat/libkernel-sys-getlogin-futimesat
feat(libkernel): implement getlogin
2026-10-25 17:54:15 +01:00
zaryabzip 0b60e97834 feat(libkernel_sys): create threads suspended and resume them
Implement pthread_attr_setcreatesuspend_np, pthread_resume_np,
pthread_resume_all_np and pthread_multi_np with the sce forms
scePthreadAttrSetcreatesuspend, scePthreadResume, scePthreadResumeAll
and scePthreadMulti, following FreeBSD 11.4 libthr and the firmware
13.42 libkernel_sys module. A thread created suspended waits before its
start routine, outside any cancellation point, until it is resumed.
sceKernelRaiseException throws on Windows for a thread still suspended
at creation.
2026-10-25 21:51:02 +05:00
Yunus Shaikh f5757aab98 fix(libkernel): restore a handler's signal bit when the handler replaces the mask
A handler that read the mask and put it back with SIG_SETMASK stored its
own signal, which sigprocmask reports from the hold, in the process mask
and cleared the hold, so the signal stayed blocked after the handler
returned. pselect, setcontext and a siglongjmp inside the handler replace
the mask the same way. When the handler's own thread releases a hold, the
signal now gets back its bit from before the handler when the handler
returns, as FreeBSD's sigreturn puts back the mask from before it. A mask
another thread sets meanwhile is kept.
2026-10-25 09:49:35 -07:00
Adrià c661d9fae2 Merge pull request #9133 from fogydes/feat/libSceLibcInternal-posix-spawn
feat(libSceLibcInternal): implement posix_spawn process creation and reaping
2026-10-25 17:38:41 +01:00
Adrià FranchandClaude Sonnet 5.5 f63b27bdaa feat(libkernel): implement getlogin
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 15:07:38 +01:00
Yunus Shaikh 8be8dc83af Merge main into fix/libkernel-signal-handler-mask
Main's #10706 moves the declarations of exported functions and their types
into the libraries' public headers, and gives WaitForPendingInSet a
KernelTimespec timeout. The merge keeps this branch's DeliverUnblockedPending
and ChangeBlockedMask with main's KernelTimespec. It takes main's side of
the declarations in GuestSignalSets.cpp, whose setjmp and longjmp this
branch had added and libc's Api.hpp now declares. GuestSignalHandlerMask.cpp
includes the libkernel and libc public headers in place of its own
declarations and GuestSignalSet and GuestSigaction types, as the
public_headers audit requires.
2026-10-25 07:05:46 -07:00
fogydes 0514307ab8 fix(libkernel): translate waitpid child statuses to the guest numbering 2026-10-25 13:57:18 +01:00
fogydes 723d932f73 feat(libSceLibcInternal): implement posix_spawn process creation and reaping 2026-10-25 13:57:17 +01:00
David 5881575782 refactor(libkernel): export swapcontext from libkernel directly
The PS5 3.20 export lists have swapcontext in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys. The assembly entry in UserContext.cpp now is
swapcontext_nid_postfix, and the libkernel_sys jump stub is gone.
2026-10-25 13:04:08 +01:00
David ad0d4f5995 feat(libkernel_sys): implement swapcontext 2026-10-25 13:04:08 +01:00
MarcZX10 561ea1d4e9 fix(libkernel): check getrusage output pointers 2026-10-25 01:16:14 +00:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Yunus Shaikh 9e7b2ade4c Merge main into fix/libkernel-signal-handler-mask 2026-10-24 10:47:50 -07:00
Dean ebdfb92528 Merge pull request #8872 from ycbuzi/feat/libc-siginterrupt
feat(libc): implement siginterrupt through the sigaction libkernel registers
2026-10-25 06:39:00 +13:00
Yunus Shaikh b72ea79cf9 Merge main into fix/libkernel-signal-handler-mask 2026-10-24 09:56:48 -07:00
review ac2591a193 Merge commit 'refs/review/8742/head' into HEAD 2026-10-24 17:23:45 +02:00
Retr0 8083ae7209 Merge remote-tracking branch 'origin/main' into fix/sigaction-ignore-discards-pending
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-10-24 16:44:21 +03:00
Adrià 6cd36e6517 Merge pull request #9794 from Retr0G28/feat/sysctl-kern-boottime
feat(libkernel): answer kern.boottime in sysctl and sysctlbyname
2026-10-24 14:58:01 +02:00
Dean 9a1ea5de1b Merge pull request #10110 from BunnyFl/feat/libkernel-version-trace-queries
feat(libkernel): implement the system-ex version, lower-limit and trace memory queries
2026-10-25 01:53:38 +13:00
bluandClaude Opus 5.5 e040d1191b Merge branch 'boykopovar:main' into feat/libc-siginterrupt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 02:49:01 -07:00
Emanuele d93cdf402d fix(libkernel): defer raises while a thread holds the address-wait lock on Linux and macOS
On Linux and macOS, sceKernelRaiseException runs the guest handler in
the target's SIGUSR1 handler wherever the thread was interrupted. A
thread interrupted while it held the address-wait lock of
sceKernelSyncOnAddressWait, sceKernelSyncOnAddressWake or _umtx_op ran
the handler with the lock held, so a handler that waits, as a
stop-the-world collector's does, blocked every other thread that waits
on or wakes an address. #5756 fixed this on Windows.

The address-wait lock is now taken under DeliveryDeferral on every
host. On POSIX the deferral is a count per thread: while it is raised
the SIGUSR1 handler only records the signal, and DeliverDeferred sends
it to the thread again once the lock is released. An address waiter
waits on its own semaphore (sem_t, a dispatch semaphore on macOS) with
the lock released and the deferral lifted, so a raise reaches a thread
that waits for an address without a timeout.

The address-lock phases of guest_raise_exception now run on every
host, with a new phase that raises at a thread in an unbounded address
wait.
2026-10-24 08:40:37 +02:00
slopggobblercobbler81 2f1cfdfa1a fix(libkernel): enforce SESS_LEADER EPERM and negative pid ESRCH ordering in setpgid/setpgrp 2026-10-23 23:52:23 +02:00
slopggobblercobbler81 782637fce4 feat(libkernel): implement setpgid and setpgrp 2026-10-23 23:52:21 +02:00
Hermes Agent 950a21aec8 fix(libkernel): return ENOENT for unknown sysctl names 2026-10-23 12:27:30 -04:00
Dean 06fd07ab4a Merge pull request #8700 from nikowolf123/feat/libkernel-underscore-socket-signal-entries
feat(libkernel): export the underscore entry points of the socket, directory and signal calls
2026-10-24 00:53:04 +13:00
Dean 74f6fa8e31 Merge pull request #10076 from JJenkx/windows/raise-host-backoff
fix(libkernel): give a raise target time to run between host-code samples
2026-10-24 00:45:09 +13:00
BunnyFlandClaude Opus 5.5 9aa0f22dc7 feat(libkernel): implement the system-ex version, lower-limit and trace memory queries
sceKernelGetSystemExVersion, sysKernelGetLowerLimitSysexVersion,
sysKernelGetLowerLimitUpdVersion and sceKernelGetTraceMemoryStats were
NotImplemented stubs in libkernel_sys. libkernel, libkernel_sys and
libkernel_web of firmware 13.42 answer them without asking the kernel:
empty strings, a zero version and zero statistics, with the null checks
and return codes the firmware uses, including the plain 22 of
sceKernelGetSystemExVersion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:29:49 +02:00
Dean Galvin 2f741e737f Merge main into feat/libkernel-underscore-socket-signal-entries 2026-10-23 22:00:32 +13:00
Dean dd5b2a3869 Merge pull request #9736 from LeandroLP23/feat/libkernel-kern-proc-env
feat(libkernel): answer kern.proc.env for the calling process
2026-10-23 21:47:33 +13:00
JJenkxandClaude Opus 5.5 fcc01c57a6 fix(libkernel): give a raise target time to run between host-code samples
RaiseOn suspends the target, reads its context and, while it is in host
code, resumes it and samples again after SwitchToThread. On a 16-core
Ryzen 9 5950X (Windows 11 22H2) that resampled the writer of
guest_raise_in_host_code about every 10 us before it could run: in the
raise that hung, 4,989 samples over 50 ms all found it in ucrtbase, so
the 50 ms host-code limit ran out and the handler was redirected into
fwrite, where it deadlocked on the stream lock (the test timed out at
30 s on every run). In a passing raise the samples sat at one RIP for
14,695 of 14,703 samples and the raise took 145 ms.

Spin for 20 us before each new host-code sample, so the target gets to
leave host code. With that, guest_raise_in_host_code passes 5 of 5 runs,
no raise is redirected in host code, and the longest raise is 0.46 to
0.53 ms. Other samples keep SwitchToThread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 04:32:33 -04:00
Dean Galvin 2f45a312d0 Merge main into fix/setrlimit-nproc 2026-10-23 15:50:49 +13:00
Dean 5c8e38018d Merge pull request #8986 from MarcZX10/codex/getrlimit-pointer-safety
fix(libkernel): check getrlimit output pointers
2026-10-23 15:46:51 +13:00
Dean Galvin ee8d1fe266 Merge main into fix/sigaction-ignore-discards-pending 2026-10-23 14:11:53 +13:00
Dean 39e971a2ea Merge pull request #8985 from MarcZX10/codex/groups-pointer-safety
fix(libkernel): return EFAULT for invalid group pointers
2026-10-23 14:05:39 +13:00
Yunus Shaikh b463132a56 Merge main into fix/libkernel-signal-handler-mask
# Conflicts:
#	core/libs/prx/libkernel/System/src/Signals.cpp
#	docs/dev/debt/libkernel.md
2026-10-22 16:27:25 -07:00
Dean 895f47f4ee Merge pull request #8866 from ycbuzi/feat/libkernel-sigintr
feat(libkernel): export _sigintr and let signal honour it
2026-10-23 12:19:08 +13:00
Dean 8964c12d5c Merge pull request #9218 from slopggobblercobbler81/feat/libkernel-setresuid-setresgid
feat(libkernel): implement setresuid and setresgid
2026-10-23 11:10:12 +13:00
Dean fe8b9b5ddd Merge pull request #8906 from hypermoist/fix/coredump-set-user-data-type
fix(libkernel): give sceCoredumpSetUserDataType its signature and result
2026-10-23 09:41:20 +13:00
bluandClaude Opus 5.5 0017ed2660 Merge branch 'boykopovar:main' into feat/libc-siginterrupt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 10:56:17 -07:00
Retr0 124dc3b3ac feat(libkernel): answer kern.boottime in sysctl and sysctlbyname
FreeBSD 11.4 serves kern.boottime ({CTL_KERN, KERN_BOOTTIME}) from
sysctl_kern_boottime in sys/kern/kern_tc.c as a read-only 16-byte struct
timeval, so a size query reports 16, a short buffer gets a partial copy
and ENOMEM, and a write gets EPERM from sysctl_root. sysctl, sysctlbyname
and sysctlnametomib now answer it with the guest CLOCK_REALTIME minus
CLOCK_UPTIME, taken at the first read and kept. HotSpot reads it while
writing its error report, which aborted with "unsupported MIB 1.21".
2026-10-22 20:04:05 +03:00
LeandroLP23andClaude Opus 5.5 6e1df42286 feat(libkernel): answer kern.proc.env for the calling process
PS5VR (PPSA99177) reads sysctl {CTL_KERN, KERN_PROC, KERN_PROC_ENV, pid}
for its own pid at start-up and stopped on "unsupported MIB 1.14.35.<pid>".
The call now returns the empty start-up environment that environ and
libc's getenv also begin with, and follows FreeBSD 11's
sysctl_kern_proc_env for the errors: EINVAL for a MIB without exactly one
pid, ESRCH for another pid or -1, EPERM for a write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 14:57:08 +02:00
Yunus Shaikh 280849ebde Merge main into fix/libkernel-signal-handler-mask 2026-10-21 22:33:02 -07:00
Dean 2369fdd77a Merge pull request #8539 from billythemenace2/fix/kernel-raise-host-code-limit
fix(libkernel): retry a failed thread context read during a raise
2026-10-22 17:59:55 +13:00
hypermist 1f8d4769b4 Merge remote-tracking branch 'upstream/main' into fix/coredump-set-user-data-type
# Conflicts:
#	core/libs/prx/libkernel/System/src/Coredump.cpp
#	core/libs/tests/GuestCoredumpUserData.cpp
2026-10-22 15:54:42 +13:00
blu c08e752fef Merge branch 'boykopovar:main' into feat/libkernel-sigintr 2026-10-21 19:03:58 -07:00
blu b440d11cbb Merge branch 'boykopovar:main' into feat/libc-siginterrupt 2026-10-21 19:03:47 -07:00
Yunus Shaikh 56b2a6393f fix(libkernel): keep another thread's block of a signal a running handler also blocks
A handler's blocks are now holds kept apart from the mask sigprocmask sets, and released when the handler returns, so a sigprocmask(SIG_BLOCK) from another thread meanwhile survives even for a signal in the handler's sa_mask. sigprocmask reports the holds; SIG_UNBLOCK of a held signal releases its hold and SIG_SETMASK, which longjmp uses, releases them all, while sigsuspend's own restore keeps them.
2026-10-21 16:39:02 -07:00
Yunus Shaikh 780aa44726 fix(libkernel): block every word of a signal handler's mask while it runs
main now keeps all four words of the guest signal mask. A handler's sa_mask above signal 32 is added too, and SIGKILL and SIGSTOP stay unblocked, as sigprocmask leaves them.
2026-10-21 15:52:34 -07:00