Commit Graph
318 Commits
Author SHA1 Message Date
Dean 8982791bc3 Merge pull request #7654 from ionut27001/fix/libkernel-sysarch-i386-bases
fix(libkernel): answer sysarch I386_GET_FSBASE, I386_GET_GSBASE and undefined operations as measured on a PS5
2026-10-20 01:22:09 +13:00
Adrià ebf1a90270 Merge pull request #6825 from hugodearaujo/fix/report-implied-read-protection
fix(libkernel): report the read bit of every write bit in a mapping's protection
2026-10-19 14:04:45 +02:00
Adrià 62e946f114 Merge pull request #6833 from ErenYeager1836/feat/libkernel-sysconf-limits
feat(libkernel): support _SC_ARG_MAX, _SC_OPEN_MAX and _SC_IOV_MAX in sysconf
2026-10-19 13:37:44 +02:00
Adrià 3691f6ffc2 Merge pull request #6826 from hugodearaujo/fix/page-table-stats-console
fix(libkernel): count page-table entries the way the console does
2026-10-19 13:24:22 +02:00
Adrià 97d5d7a52a Merge pull request #6737 from fogydes/fix/libkernel-eventflag-deletion-and-multiwaiter-race
fix(libkernel): prevent use-after-free on event flag deletion and multi-waiter race
2026-10-19 13:05:18 +02:00
Dean 7f6ef06348 Merge pull request #7813 from whamre/fix/windows-stdio-stream-limit
fix(libkernel): raise the Windows stdio stream limit to RLIMIT_NOFILE
2026-10-19 23:52:59 +13:00
hugodearaujo 514b6849ec fix(libkernel): report the read bit of every write bit in a mapping's protection
A PS5 (firmware 13.60) reports CPU write 0x2 with CPU read 0x1, 0x80 with 0x40 and 0x200 with 0x100 after a map, sceKernelMprotect, sceKernelMtypeprotect or POSIX mprotect; GPU write 0x20 keeps GPU read 0x10 clear. sceKernelVirtualQuery and sceKernelQueryMemoryProtection now report the protection that way.
2026-10-19 12:05:39 +02: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
Adrià 48f436406b Merge pull request #6663 from karimibrahim07/feat/libkernel-ipv6-v6only
feat(libkernel): set and read IPV6_V6ONLY on a guest socket
2026-10-19 10:44:37 +02:00
Werner 4e5eb1c3be fix(libkernel): raise the Windows stdio stream limit to RLIMIT_NOFILE
The C runtime allows 512 stdio streams by default, so after about 509
guest fopen/fdopen streams every further stream failed with EMFILE,
including the std::ifstream APR opens for each read, while getrlimit
reports 8192 open files. Raise the limit to 8192 when libkernel loads,
as the Linux build raises RLIMIT_NOFILE.
2026-10-19 08:00:07 +00:00
Adrià 22410061d5 Merge pull request #6542 from wachi35676/fix/libkernel-windows-shared-file-mmap
feat(libkernel): map regular files with mmap on Windows
2026-10-19 08:37:27 +02:00
Doğukan Atlıhan 1ad6c746b8 fix(libkernel): replace anonymous Windows stack mappings 2026-10-19 06:42:30 +02:00
klosixgaming-arch 30cbb2fd66 fix(libkernel): refuse to detach or rejoin a thread that is being joined
PPSA34015 (EA SPORTS FC 27) stopped with "Joining guest thread: Access is
denied": scePthreadJoin waited on a thread that another call released
under it, and then waited on its closed handle. As FreeBSD 11.4's
thr_join.c and thr_detach.c do with the joiner field, scePthreadDetach
now returns EINVAL while a thread waits to join the target, a second
concurrent scePthreadJoin returns EOPNOTSUPP, a cancelled join backs out,
and a completed join leaves the thread detached.
2026-10-19 03:30:58 +02:00
Adrià bebc294607 Merge pull request #6443 from EagleBearerYS/fix/libkernel-host-stack-guard-page
fix(libkernel): keep a protected host stack's guard page, and protect the Linux main stack
2026-10-19 02:41:09 +02:00
Adrià 347c0a7934 Merge pull request #6420 from JJenkx/feat/kernel-error-conversion-upstream
feat(libkernel): convert guest POSIX error values
2026-10-19 02:40:46 +02:00
Muhammad Wasif Ali WasifandClaude Opus 5.5 ddb774ad26 feat(libkernel): map regular files with mmap on Windows
A shared mapping is a view of a file section created on the descriptor's
handle, read-write when the descriptor is, otherwise read-only. A private
mapping is a copy of the file read at mmap, as POSIX allows. Anonymous
shm_open objects and JIT shared memory descriptors are temporary files on
Windows, so mmap now maps them too (it failed with EOPNOTSUPP before).
mprotect of a mapped view above the view's protection fails with EACCES
before any bookkeeping changes. The cases Windows cannot represent are
listed in the libkernel debt.

Dusklight (PPSA99305) uses SQLite in WAL mode, which maps its -shm file.
On Windows main f0634088b every start logged "Failed to start
transaction: disk I/O error" for its Dawn and pipeline caches (3 of 3
runs); with this change the caches initialise and their WAL files fill
(4 of 4 runs). The title reaches its menu either way.

A shared mapping may end inside the 16 KiB page that holds the end of
the file, as POSIX mmap allows: the view ends with the file's last 4 KiB
host page, which Windows zero-fills past the end, the rest of the guest
page is private zero pages, and the file never grows. A mapping that
reaches a whole page past the end still fails with EOPNOTSUPP.

PS5LM Plus (PPSA99581) loads its model with llama.cpp, which maps the
whole GGUF file shared and read-only. With a 491,400,032-byte model,
Windows main 5de7a46e0 and this change without the last page logged
"llama_model_load: error loading model: mmap failed: Operation not
supported" (3 of 3 runs); now the model loads and the completion of
"The capital of France is" starts with " Paris" (3 of 3 runs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 05:02:25 +05:00
Adrià 9d4966c265 Merge pull request #6343 from klosixgaming-arch/feat/kevent-standard-input
feat(libkernel): accept a kevent read event on descriptor 0
2026-10-19 01:46:19 +02:00
Adrià ccf0f58785 Merge pull request #6228 from Ondra97/codex/fix-windows-directory-renames
fix(libkernel): preserve directory identity across Windows renames
2026-10-18 22:20:22 +02:00
Adrià b8cd204a3f Merge pull request #6220 from DavidSamir/fix/libkernel-sysctl-kern-ostype
feat(libkernel): answer the uname sysctl names
2026-10-18 21:56:01 +02:00
Adrià 4b4385cb7f Merge pull request #6201 from bruceblake/libkernel-getdtablesize
feat(libkernel): implement getdtablesize
2026-10-18 21:26:33 +02:00
ionut27001 bd22a701f5 fix(libkernel): answer sysarch I386_GET_FSBASE, I386_GET_GSBASE and undefined operations as measured on a PS5
In a payload process on a PS5 (firmware 12.70), I386_GET_FSBASE (7) and
I386_GET_GSBASE (9) wrote 4 bytes, the low 32 bits of the FS and GS
bases, and failed with EFAULT for a null argument; both threw here. On
Linux x86-64 hosts they now do the same.

The nine operation numbers tried that FreeBSD 11's amd64 sysarch has no
case for (2, 5, 6, 12, 127, 133, 134, 1000 and -1), each with a null
argument, failed with EINVAL there, as its default case does, and threw
here. Every such number now returns EINVAL on every host.

Threads made with pthread_create and scePthreadCreate started with their
creator's GS base there; the test now checks that a guest thread does so
on Linux. The sysarch debt entry records these measurements and what
AMD64_GET_XFPUSTATE and I386_GET_XFPUSTATE returned there; both still
throw here.
2026-10-18 22:25:09 +03:00
MarcZX100 0751dffcb1 fix(libkernel): match FreeBSD port-zero stream connects 2026-10-18 18:23:39 +00:00
Hussein Kadhim f571b37f5a fix(libkernel): limit the port 0 check to connect on an unconnected datagram socket 2026-10-18 18:23:39 +00:00
Hussein Kadhim b10f1310df fix(libkernel): fail connect and sendto to port 0 with EADDRNOTAVAIL 2026-10-18 18:23:38 +00:00
Adrià a0f3dc4014 Merge pull request #6091 from Ondra97/codex/fix-cond-canceled-signal
fix(libkernel): preserve condition signals across cancellation
2026-10-18 17:33:22 +02:00
Adrià 50fafac3d8 Merge pull request #5993 from Get-fix/ps4/param-sfo
feat(libkernel): read param.sfo when param.json is absent
2026-10-18 16:50:34 +02:00
Karim Ibrahim 267cb56a0d fix(libkernel): report the precommitted stack of an adopted thread on Windows
An adopted thread (the main thread, or a host thread that calls
scePthreadSelf) reported its whole Windows stack reservation, and so
did sceKernelIsStack on a host thread before adoption. A relinked
executable reserves 0x210000 bytes for its main thread and commits the
top 0x200000, so the lowest 64 KiB of the reported stack hold only
reserved pages and Windows' guard pages. mprotect fails there, so
HotSpot in Java 25 LAN / DNS (PPSA99869) could not create the main
thread's stack guard pages ("Attempt to allocate stack guard pages
failed").

When everything above the bottom allocation granule is committed
read-write, the host stack is now reported from there, as created
guest threads report only their committed stack. Other host stacks
keep the whole range. The committed-pages walk is shared with
StartNativeThread and throws when VirtualQuery fails.
2026-10-18 16:24:10 +02:00
Alexej Szpevák b40e0bfb80 fix(libkernel): report the accept queue length for a listening socket's read event
A read event on a listening socket took its data from FIONREAD, which a listening socket refuses on Linux, so kevent and sceKernelAddReadEvent reported 0 connections while saying one was ready. FreeBSD 11.4 gives a listening socket filt_solisten, which reports so_qlen, the completed connections waiting for accept. Ready now checks SO_ACCEPTCONN and on Linux reads a TCP listener's accept backlog from TCP_INFO, where tcp_get_info puts it in tcpi_unacked; with no host call for the count (Windows, macOS, a listener that is not TCP) it reports 1, the lower bound the readiness already implies.
2026-10-18 13:35:15 +02:00
Maz bd0caa451b Merge upstream/main into fix/windows-junction
Keep the drive-absolute junction note and the updated setitimer debt from main.
2026-10-18 12:57:10 +04:00
Maz 7212dae71a fix(libkernel): reject Windows volume mount points in junction reads
A mounted folder uses the junction reparse tag and would otherwise be returned as a relative Volume GUID path. Only a drive path is reported, through the absolute-link text helpers.
2026-10-18 12:53:48 +04:00
Dean 1c523bdb48 Merge pull request #6437 from fma-rc/fix/libkernel-amm-range-256
fix(libkernel): report a 256 GiB AMM range starting on a 64 GiB boundary
2026-10-18 20:03:09 +13:00
Dean Galvin e1dc3c0593 Merge main into fix/select-kqueues-and-devices 2026-10-18 16:55:09 +13:00
Dean Galvin 67e7043332 Merge main into feat/poll-files 2026-10-18 16:04:36 +13:00
Dean 55366489fb Merge pull request #7276 from T3cm0/bionic/coredump-exports
feat(libkernel): implement three coredump exports from the console module
2026-10-18 13:26:40 +13:00
Dean 3954aed289 Merge pull request #7289 from LaunchDoesntCode/fix/itimer-sigalrm-pending
fix(libkernel): leave a blocked SIGALRM expiry pending
2026-10-18 12:18:09 +13:00
Dean 51cee90311 Merge pull request #7295 from ionut27001/fix/libkernel-pshared-private-only
fix(libkernel): reject PTHREAD_PROCESS_SHARED as the PS5 does and add the missing pshared accessors
2026-10-18 12:02:32 +13:00
HQasperandClaude Opus 5.5 6d4c7c3150 fix(libkernel): select on kqueues as kqueue_poll answers
A kqueue descriptor is readable while one of its events is triggered and
is never writable or exceptional, as FreeBSD's kqueue_poll answers, on
both hosts. On Windows select threw for it, and on Linux its /dev/null
placeholder was reported readable and writable.

A descriptor that stops being a socket, a kqueue or a pipe during the
wait now fails the call with EBADF when it was closed and is selected
again with the rest of the timeout when its number was reused, as
FreeBSD's kern_select looks every descriptor up again in each pass,
instead of throwing. On Windows a host descriptor that is not a pipe
throws when select starts, before waiting.

Depends on #7139.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:45:57 +02:00
Alexej Szpevák 74629458d3 feat(libkernel): poll descriptors 0 to 2 with the console model select uses
select takes descriptors 0 to 2 as a console title's terminal with no input: 0 is never readable and 1 and 2 are always writable. poll threw for them unless the host happened to attach a pipe, so the same title could select on its standard streams but not poll them. poll now gives the same answer, with POLLOUT, the one bit ttydev_poll reports for a writable terminal, for 1 and 2 and nothing for 0.
2026-10-18 00:45:56 +02:00
Alexej Szpevák aabd0e77aa fix(libkernel): answer select on files and the random device as FreeBSD's poll routines do
selscan asks a descriptor once, with the flags of every set it is in (POLLRDNORM for the read set, POLLWRNORM for the write set, POLLRDBAND for the exception set, plus POLLHUP and POLLERR), and marks each set whose flags the answer shares. A seeded random device's randomdev_poll narrows a request with POLLRDNORM to that bit and returns any other request whole, so in the read set it is readable and in no other set, and otherwise it is in each write and exception set it was asked in; select reported it readable and writable together and never exceptional. A regular file or directory went to the host poll, which on Windows threw; vop_stdpoll makes it readable and writable and never exceptional, which select now answers in process on every host, as poll does.
2026-10-18 00:45:55 +02:00
Alexej Szpevák d0c338561a feat(libkernel): poll the random device as randomdev_poll does
poll threw for /dev/random and /dev/urandom, which select already treats as ready. FreeBSD 11.4's randomdev_poll, once the device is seeded, narrows a request that has POLLIN or POLLRDNORM to those bits and returns any other request whole, POLLOUT and the band bits included. poll now answers that, and the test that relied on the random device throwing uses a kqueue descriptor, which poll still does not support.
2026-10-18 00:45:54 +02:00
Alexej Szpevák 7e26c1a4ea feat(libkernel): poll regular files and directories as vop_stdpoll does
poll threw for any descriptor that is neither a socket nor a pipe, so a title polling a file it also reads stopped there. FreeBSD 11.4 hands a vnode to VOP_POLL, and both vop_stdpoll and vop_nopoll return POLLIN, POLLRDNORM and POLLOUT of the requested events for every event poll accepts and never POLLPRI, POLLRDBAND or POLLWRBAND. A file, a directory or a file read from app0.zar now answers that without a host call. File::IsVnode tells such a descriptor apart from the host file type without throwing, so a host socket lent by libSceNet still reaches its own path.
2026-10-18 00:45:27 +02:00
Dean fbb76ae3e6 Merge pull request #7095 from milescoviello/feat/sysarch-gsbase
feat(libkernel): read and set the GS base through sysarch
2026-10-18 11:18:15 +13:00
ionut27001andClaude Opus 5.5 c00c58ae34 fix(libkernel): reject PTHREAD_PROCESS_SHARED in pthread_condattr_setpshared and add pthread_condattr_getpshared
On a PS5 (firmware 12.70), of the values 0, 1, 2 and -1,
pthread_condattr_setpshared accepts only 0 and leaves the attribute
unchanged otherwise. pthread_condattr_getpshared reports 0 and returns
EINVAL for a null, uninitialized or destroyed attribute, also with a
null output. With an initialized attribute a null output crashes the
console; here it throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:50:09 +03:00
ionut27001andClaude Opus 5.5 bdf3adb379 feat(libkernel): add pthread_rwlockattr_getpshared and pthread_rwlockattr_setpshared
Measured on a PS5 (firmware 12.70): the getter reports 0, and of the
values 0, 1, 2 and -1 the setter accepts only 0 and checks the value
before the attribute. A null or uninitialized attribute, or a null
output, crashes the console; here it throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:50:09 +03:00
ionut27001andClaude Opus 5.5 db504f6b9c fix(libkernel): reject PTHREAD_PROCESS_SHARED in pshared setters as the PS5 does
On a PS5 (firmware 12.70), of the values 0, 1, 2 and -1,
pthread_spin_init, pthread_barrierattr_setpshared and
pthread_mutexattr_setpshared accept only PTHREAD_PROCESS_PRIVATE (0);
1, 2 and -1 return EINVAL and leave the attribute unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:49:58 +03:00
klosixgaming-arch ce5b0c395b feat(libkernel): accept a kevent read event on descriptor 0
PPSA34015 (EA SPORTS FC 27) registers EVFILT_READ for descriptor 0 in a
new kqueue at start-up, ignores the result, and stopped with "kevent:
EVFILT_READ on a non-socket descriptor not implemented". A read event on
the host stream on descriptor 0 is now accepted and never triggers, as
select never reports descriptor 0 readable.
2026-10-17 21:34:51 +00:00
LaunchDoesntCodeandClaude Opus 5.5 1bc029da6d fix(libkernel): leave a blocked SIGALRM expiry pending
An ITIMER_REAL or alarm expiry while SIGALRM is blocked is marked on the
pending set of sigtimedwait instead of throwing, as kern_psignal leaves a
blocked signal pending. sigwait, sigwaitinfo and sigtimedwait take it,
repeated expiries merge into one pending signal, and unblocking it runs a
guest handler on the unblocking thread or, with the default disposition,
exits the process with status 142 as FreeBSD's default action does.

The expiry rechecks the mask after marking the signal, so an unblock that
races it does not leave SIGALRM pending while unblocked, and TakePending
clears the bit with the value it read so one signal is taken once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:22:59 -05:00
Ondra97 739e451332 fix(libkernel): preserve directory identity across Windows renames 2026-10-17 23:17:39 +02:00
T3cm0andClaude Opus 5.5 70ff799fdb feat(libkernel): implement three coredump exports from the console module
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:17:05 -05:00
Dean af7972ce91 Merge pull request #7229 from nicolasfalesy/feat/libkernel-export-nmount
feat(libkernel): export nmount
2026-10-18 10:10:15 +13:00