Commit Graph
1068 Commits
Author SHA1 Message Date
Yunus Shaikh cfda40433c Merge main into fix/libkernel-udp-unreachable-port 2026-10-21 15:15:13 -07:00
frankea 41d551eb60 Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into ps5-measured-1340
# Conflicts:
#	core/libs/prx/libSceSystemService/Export.cpp
2026-10-21 17:37:31 -04:00
boykopovar a6dcea9279 Merge pull request #9137 from boykopovar/fix/funcs-abi-debt-2026-10-20
fix(libs): libs funcs abi debt 2026 10 20
Corrected signatures or behaviour of 1,702 existing exported functions across 96 libraries. Added 85 typed export wrappers. Unimplemented functions retain NotImplemented_nid_no_patch(__func__).
2026-10-22 00:32:11 +03:00
David 375b53d918 refactor(libkernel): move pselect into libkernel
The PS5 3.20 export lists have pselect in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys. The implementation moves unchanged to
libkernel/Socket/src/Pselect.cpp, beside select.
2026-10-21 22:30:43 +01:00
David 642c0d56ac docs(debt): list the ktimer calls under Functional 2026-10-21 22:27:24 +01:00
David 7820a5353a refactor(libkernel): move the ktimer calls into libkernel
The PS5 3.20 export lists have ktimer_* in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys. The implementation moves unchanged to
libkernel/Time/Ktimer.cpp.
2026-10-21 22:22:16 +01:00
Henryisdjfunkyho 476716546e fix(libkernel): preserve SCE timed sleep behavior 2026-10-21 14:21:16 -07:00
Henryisdjfunkyho bc0f1dc27e fix(libkernel): wake timed sleeps for thread cancellation 2026-10-21 14:11:23 -07:00
boykopovar 8b75d497c0 fix(kernel): reject unimplemented internal pool statistics 2026-10-21 21:56:05 +03:00
boykopovar f4447aa252 fix(kernel): restore coredump registration and file flag validation 2026-10-21 21:55:33 +03:00
boykopovar b9fb0d2897 fix(kernel): restore signed coredump attachment lengths 2026-10-21 21:55:32 +03:00
boykopovar ee76c0cd98 fix(kernel): restore coredump buffer validation and data type argument 2026-10-21 21:55:30 +03:00
boykopovar f414adb3d6 docs(kernel): close thread sanitizer signature debt 2026-10-21 21:54:17 +03:00
Adrià eaff87674c Merge pull request #8492 from xXPBSXx/fix/recv-after-shutdown-and-empty
fix(libkernel): answer a receive after SHUT_RD or with no buffer without the host
2026-10-21 20:39:37 +02:00
David 488bc0226e Merge remote-tracking branch 'origin/main' into feat/libkernel-jit-shared-memory-macos
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-10-21 22:17:40 +04:00
aarushkha 8cb0d985d7 Merge upstream main into feat/libkernel-equeue-regular-file-events-v2
Merge upstream main into feat/libkernel-equeue-regular-file-events-v2
2026-10-21 23:46:24 +05:30
Adrià 8e72738df6 Merge pull request #8437 from xXPBSXx/fix/mprotect-ignore-undefined-bits
fix(libkernel): drop undefined protection bits in mprotect
2026-10-21 20:08:57 +02:00
Adrià FranchandClaude 32f8205390 docs(libkernel): say the receive-after-SHUT_RD answer is Windows only
Co-Authored-By: Claude <[email protected]>
2026-10-21 20:01:26 +02:00
xXPBSXxandClaude Sonnet 5.5 ba8b881fa6 fix(libkernel): answer a receive after SHUT_RD or with no buffer without the host
soreceive_generic returns 0 for a socket whose receive side is shut and for a
zero-length receive on a connected stream socket (ENOTCONN when it is not
connected), without waiting. Winsock fails the first with WSAESHUTDOWN, which
reached the guest as EPIPE, and blocks the second until data arrives. recv and
recvfrom now answer both themselves.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 20:01:18 +02:00
Adrià 606297f34f Merge pull request #8474 from xXPBSXx/fix/recv-msg-waitall
feat(libkernel): accept MSG_WAITALL in recv, recvfrom and recvmsg on a stream socket
2026-10-21 20:00:45 +02:00
Kraken d324106dc7 docs(libkernel): record cleanup unwind and allocation limits 2026-10-21 18:45:42 +01:00
Dean Galvin 58ad4eda77 fix(libkernel): report app0 symlinks as their target type in getdirentries
On Linux sceKernelGetdirentries copied the host d_type, so a directory under app0 that is a host symlink was listed as a link, and a title that only descends into directory entries skipped it. Inside the app0 tree, report a symlink (or an entry of unknown type) as the type of its target; links elsewhere, and dangling links, stay links.
2026-10-22 06:20:04 +13:00
Emanueleandmugurc bfa5368657 fix(libkernel): report unwind information for guest and host addresses on macOS
Two unwind queries a title makes went wrong on macOS, so a C++ exception the title would catch ended the process instead: God of War Sons of Sparta (PPSA28997) stops on an IL2CPP exception it normally handles.

- sceKernelGetModuleInfoForUnwind found a relinked image and its PT_GNU_EH_FRAME header but left eh_frame_addr and eh_frame_size at zero, so the title's unwinder found no FDE for its own frame. The tables are now read with EhFrame::ReadTables over the image's load segments, as ModuleInfo does on Linux, and eh_frame_size includes the zero terminator, as on Linux.
- sceSysmoduleGetModuleInfoForUnwind read /proc/self/maps outside Windows and threw on every call on macOS. It now answers from mach_vm_region, with the image path from dladdr, as the Linux branch answers from the mapping.

guest_unwind_module_info now runs on macOS: the test executable carries the __APS5DATA,__meta program headers that the macOS dl_iterate_phdr reads from a relinked image. guest_sysmodule checks the macOS answers against mach_vm_region.

Co-authored-by: mugurc <[email protected]>
2026-10-21 18:39:48 +02:00
Claude 8f13fe70b9 feat(libkernel): implement pthread_rwlock_reltimedrdlock_np and pthread_rwlock_reltimedwrlock_np
Both were missing from libkernel.prx, so a title importing either
(dYv-+If2GPk, RRnSj8h8VR4) failed to load. They take a relative timeout
in microseconds and are scePthreadRwlockTimedrdlock and
scePthreadRwlockTimedwrlock with POSIX error numbers; a zero lock is
initialized as by pthread_rwlock_rdlock. The signature comes from
shadPS4, which registers one function for each NID and its
scePthreadRwlockTimed* twin; FreeBSD 11.4 has no such calls. The throwing
libkernel_sys copies are removed, as an export may live in one library
only. Recorded in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-21 15:27:52 +00:00
slopggobblercobbler81 d28c74af94 feat(libkernel): implement setresuid and setresgid
Follow FreeBSD 11.4 sys_setresuid and sys_setresgid (sys/kern/kern_prot.c):
accept real, effective, and saved user and group IDs for the guest process,
which is assumed to run as root with IDs 0. Setting an ID to 0 or -1 (unchanged)
is accepted without changing credentials and returns 0; any other value throws.
Cover both in guest_credentials test and update libkernel debt documentation.
2026-10-21 17:25:25 +02:00
NikoandClaude Opus 5.5 0ac2b0bc6f feat(libkernel): export the underscore entry points of the socket, directory and signal calls
The PS5 libkernel exports _accept, _bind, _connect, _getdirentries,
_getpeername, _getsockname, _getsockopt, _listen, _recvfrom, _recvmsg,
_sendmsg, _sendto, _setsockopt, _sigaction and _sigsuspend (PS5 3.20
export list, DNNDHH/PS5-3.20_Libs b2a77c0 libkernel.c), and main
exports none of them, so a title importing one fails at startup. Each
now forwards to the export without the underscore, as _close, _ioctl
and _nanosleep already do.

In FreeBSD 11.4 (8c639945a4) these are libc's plain system call
entries: lib/libc/amd64/SYS.h makes bind, getdirentries, getpeername,
getsockname, getsockopt, listen and setsockopt one stub under both
names, and lib/libc/sys/Makefile.inc gives accept, connect, recvfrom,
recvmsg, sendmsg, sendto, sigaction and sigsuspend a separate public
name that goes through libthr's interposing table, which adds the
cancellation points and the sigaction wrapper. The exports without the
underscore have no libthr layer here, so forwarding gives the system
call. docs/dev/debt/libkernel.md records what stays unverified: the
console is not measured, _sigaction shares the handler table of
sigaction, and a null set throws in _sigsuspend as in sigsuspend,
where FreeBSD's system call returns EFAULT.

guest_underscore_entries calls every new export: a loopback TCP
connection, UDP datagrams with scatter, truncation and sender
addresses, a directory listing compared with getdirentries, a SIGTERM
handler set by _sigaction, and a pending SIGUSR1 that _sigsuspend
delivers before returning EINTR with the mask restored. It checks the
errors they pass on (EBADF, EINVAL, EFAULT, ENOPROTOOPT, EOPNOTSUPP)
and that outputs stay untouched on failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:02:54 +02:00
orezraeyandClaude Opus 5.5 aee2004a9c Merge main into fix/libkernel-sync-on-address-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 11:56:06 -03:00
Adrià f90a3f7297 Merge pull request #8523 from MarrasFederico/feat/kqueue-read-on-kqueue
feat(libkernel): watch a kqueue with EVFILT_READ
2026-10-21 16:03:30 +02:00
SebastianandClaude Opus 5.5 9497840de5 feat(libkernel): implement named POSIX semaphores
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-21 13:58:38 +00:00
Daniele Giovane f6d0623216 feat(libkernel_sys): implement pthread attribute and initial-thread queries 2026-10-21 15:50:39 +02:00
orezraeyandClaude Opus 5.5 39cc6af2b1 fix(libkernel): compare the search start before rounding it
Measured on firmware 13.60: a start whose rounding to 16 KiB overflows
finds nothing, and of two equal free ranges the lowest is returned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:41:28 -03:00
orezraeyandClaude Opus 5.5 4319a7a5e7 fix(libkernel): match sceKernelAvailableDirectMemorySize arguments to PS5
Measured on firmware 13.60: an alignment that is not zero or a power of
two returns EINVAL before anything else; bounds with nothing between
them return ENOMEM, a negative start searches from the bottom, only the
start is rounded up to 16 KiB and the end is used as given; null outputs
are skipped; errors leave both outputs untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:39:19 -03:00
Adrià 1ae3f38d9e Merge pull request #8400 from slider/feat/libkernel-mutex-np
feat(libkernel): add mutex ownership, relative lock and spin/yield accessors
2026-10-21 15:32:34 +02: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 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
xXPBSXxandClaude Sonnet 5.5 9abca4b9f9 docs(debt): say what the socketpair poll note still lacks after the peer closes
On Windows a pair end now reports POLLIN after the peer's shutdown or close.
The console also reports POLLHUP after close; the loopback connection cannot
tell a close from a shutdown.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 14:47:07 +02:00
Retr0 41709ae50e fix(libkernel): move events reported by sceKernelWaitEqueue behind the waiting ones
FreeBSD 11 kqueue_scan (sys/kern/kern_event.c) re-inserts a reported
knote without EV_CLEAR or EV_DISPATCH at the tail of kq_head, and
knote_enqueue puts a knote that fires again at the tail as well, so the
next scan starts with the events that were not reported yet.
sceKernelWaitEqueue scanned the event list in place, so with num smaller
than the number of ready events the first ones were reported on every
call and the later ones starved. Each reported event that stays
registered now moves to the end of the list, in the order reported.
2026-10-21 15:41:06 +03:00
Retr0 bbfa163722 fix(libkernel): discard a pending signal when sigaction or signal ignores it
FreeBSD 11's kern_sigaction (sys/kern/kern_sig.c) calls
sigqueue_delete_proc, which drops the signal from the process queue and
from every thread's queue, whenever the new handler is SIG_IGN, or
SIG_DFL on a signal whose sigprop has SA_IGNORE (SIGURG, SIGCONT,
SIGCHLD, SIGIO, SIGWINCH, SIGINFO). It does so whether or not the
signal is blocked. sigaction and signal now take the signal off the
pending set in those cases, so a later unblock or wait never sees it.
2026-10-21 15:35:32 +03:00
Retr0 f2bc1195f8 fix(libkernel): reject socket addresses longer than sockaddr_in or sockaddr_in6 with EINVAL
FreeBSD 11.4 getsockaddr sets sa_len to the length argument, and
tcp_usr_bind, tcp_usr_connect, in_pcbbind_setup, in_pcbconnect_setup,
in6_pcbbind and in6_pcbladdr answer EINVAL when it is not the size of
the socket family's address. udp6_bind and udp6_connect pass an
IPv4-mapped address to the IPv4 code without that check when
IPV6_V6ONLY is clear, and udp6_send always checks it. bind and connect
on AF_INET and AF_INET6 sockets, and sendto on AF_INET6 datagram
sockets, now fail a longer address with EINVAL.
2026-10-21 15:31:15 +03:00
xXPBSXxandClaude Sonnet 5.5 f1c8ae0ccb fix(libkernel): report a stream whose peer closed as readable in poll on Windows
WSAPoll reports POLLHUP alone for a stream socket whose peer has closed, so
poll never returned POLLIN for it and a caller waiting for POLLIN did not see
the end of the stream. sopoll_generic reports a socket that can receive no
more as readable and adds POLLHUP only once it can send no more either.
poll now adds the requested read bit and keeps POLLHUP only after the socket
shut its own sending side. A reset or refused connection keeps WSAPoll's flags.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 14:28:15 +02:00
Retr0 9bd2bb06cc fix(libkernel): return ENOTSOCK from sendfile on a descriptor that is not a socket
FreeBSD 11 sendfile checks the file descriptor first, then looks up the
socket with getsock_cap, which answers ENOTSOCK for an open descriptor
that is not a socket and EBADF for one that is not open
(sys/kern/kern_sendfile.c, sys/kern/uipc_syscalls.c).

sendfile replaced the errno that Lookup had already set with EBADF. It
now reports the errno Lookup chose, so an open non-socket gives ENOTSOCK
and a closed descriptor still gives EBADF. The sentence about this gap
is cut from the sendfile debt entry and guest_sendfile covers both cases.
2026-10-21 15:16:35 +03:00
aarushkhaandClaude Opus 5.5 7bff640073 feat(libkernel): answer sceKernelAddReadEvent and sceKernelAddWriteEvent on regular files
Both threw for a regular file. They now follow FreeBSD 11.4's
filt_vfsread and filt_vfswrite: a read event reports the file size less
the descriptor's offset and fires while that is not 0; a write event
always fires with data 0. A wait holding such an event polls it again
every millisecond, as no host call reports every file change. A size
above 1 and other vnode types still throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:40:45 +05:30
Adrià e335d5b5ba Merge pull request #7974 from DavidSamir/feat/libkernel-file-mmap-macos
feat(libkernel): map files through the guest's mmap on macOS hosts
2026-10-21 13:46:41 +02:00
Adrià de4ef842b5 Merge pull request #7850 from mugurc/feat/libkernel-sockets-macos
feat(libkernel): UDP sockets and name resolution on macOS hosts
2026-10-21 13:36:21 +02:00
xXPBSXxandClaude Sonnet 5.5 0e2252f638 fix(libkernel): accept flock on a directory descriptor on Windows
FreeBSD 11.4's sys_flock only requires a vnode descriptor, so flock on a directory descriptor succeeds. On Windows the call reached LockFileEx, which rejects a directory handle with ERROR_INVALID_PARAMETER, and flock_nid_postfix turned that into a runtime_error that aborted the process. A directory descriptor now returns 0 without taking a lock; the new guest_file_lock_directory case covers it and the debt entry records that no lock is held.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 13:35:39 +02:00
Federico Marras cc7b9a7652 Merge remote-tracking branch 'upstream/main' into feat/kqueue-read-on-kqueue
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-10-21 13:17:12 +02:00
Dean 3e91c8edf5 Merge pull request #8850 from UnhealthyKraken/feat/libkernel-cfsetspeed
feat(libkernel): implement cfsetspeed
2026-10-22 00:13:16 +13:00
JJenkxandClaude Opus 5.5 2fc26b970f fix(libkernel): return ESRCH for a null semaphore handle
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 05:18:18 -04:00
Dean Galvin 0f7241f3a7 Merge origin/main into PR 6519 2026-10-21 21:35:27 +13:00
MarcZX10 a4bda973a9 Merge current main for getresid EFAULT follow-up 2026-10-21 08:08:27 +00:00