Commit Graph
546 Commits
Author SHA1 Message Date
Dean df721d53f2 Merge pull request #7192 from Jev1337/feat/libkernel-host-fault-exception-handlers
feat(libkernel): deliver host faults to sceKernelInstallExceptionHandler handlers
2026-11-05 08:19:08 +13:00
Dean 92cdaf6337 Merge pull request #11624 from Felipebmaitan/feat/windows-guest-gs-state
feat(libkernel): maintain per-thread guest GS bases on Windows
2026-11-05 06:35:52 +13:00
Dean 6863f295a9 Merge pull request #10749 from ycbuzi/refactor/siginterrupt-libc-internal
refactor(libSceLibcInternal): serve siginterrupt from libSceLibcInternal
2026-11-05 06:35:30 +13:00
Dean Galvin ecfea85fcd Merge branch 'main' into fix/libc-syslog-program-name 2026-11-04 21:00:07 +13:00
Jevro1337andClaude Opus 5.5 2c7e139d93 perf(libkernel): find the object of a faulting address with _dl_find_object
dladdr1 searches the object's symbol table, which made every host fault
chained past an installed handler about 8 us slower on Linux. glibc 2.35
and later answer the same question with _dl_find_object, which is also
async-signal-safe; older glibc keeps dladdr1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 21:01:18 +01:00
Jevro1337andClaude Opus 5.5 ab363feecc feat(libkernel): deliver host faults to sceKernelInstallExceptionHandler handlers
A handler installed for SIGILL, SIGFPE, SIGBUS or SIGSEGV now receives
the faults raised in title code instead of the process ending, with
mc_trapno, mc_addr and mc_err filled as FreeBSD 11's amd64 trap() does.
On Windows the crash reporter's vectored handler offers unclaimed faults
to libkernel, which redirects the thread to a stub that runs the handler
outside the exception dispatcher; on Linux chained host signal handlers
classify faults by REG_TRAPNO.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 21:01:15 +01:00
Dean 723ee06871 Merge pull request #14799 from chitters2004/perf/guarded-committed-read
perf(agc): read committed guest pages directly on Windows
2026-11-04 08:10:59 +13:00
Felipebmaitan a0cea87294 fix(libkernel): retain shared guest copy semantics in sysarch 2026-11-03 14:34:35 -03:00
Felipebmaitan 41bbc32070 chore: refresh GS state with current main 2026-11-03 14:34:25 -03:00
bluandClaude Opus 5.5 24497b2406 Merge branch 'main' into refactor/siginterrupt-libc-internal
Resolves docs/dev/debt/libkernel.md: main's sigaction entry (SIGPIPE outside Windows) and this branch's signal entry, which points to libSceLibcInternal for siginterrupt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 10:23:38 -07:00
Dean Galvin a39b825599 Merge commit 'd1ae628bc2f62459cce1e9872ba5632c938c71f2' into HEAD
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-11-03 18:18:49 +13:00
Dean b955001c4d Merge pull request #15030 from Gruzzberry/fix/sysctl-overcommit-eperm
fix(libkernel): fail a vm.overcommit write with EPERM
2026-11-03 18:13:26 +13:00
Dean 48dd279a37 Merge pull request #13950 from pushkarreddyy/fix/usercontext-efault
fix(libkernel): return EFAULT from context operations for invalid memory pointers
2026-11-03 18:09:35 +13:00
Dean 4c1ceccd9b Merge pull request #14591 from ahmadmuj/fix/anyps5-sysctl-proc-name
fix(libkernel): resolve kern.proc.proc by name
2026-11-03 11:39:54 +13:00
pushkarreddyy 1b2d0d2ace fix(libkernel): copy in UC_COPY_SIZE bytes in setcontext matching FreeBSD 2026-11-02 22:17:28 +05:30
pushkarreddyy a7fa0e3fad fix(libkernel): return EFAULT from context operations for invalid memory pointers 2026-11-02 22:17:28 +05:30
Dean b052a9307b Merge pull request #12005 from akkadbakkad89/exception-drain-mailbox
fix(libkernel): post guest raises to the delivery drain mailbox on Windows
2026-11-03 01:29:04 +13:00
Dean a645efee3b Merge pull request #11851 from LeandroLP23/fix/alarm-precise-timed-wait
fix(libkernel): wait for alarm and setitimer expiries with the precise timed wait on Windows
2026-11-03 01:27:22 +13:00
bluandClaude Opus 5.5 dae55d9e12 Merge branch 'main' into refactor/siginterrupt-libc-internal
Resolves docs/dev/debt/libc.md: main's updated _Thrd entry, and siginterrupt stays documented in libSceLibcInternal.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 04:12:04 -07:00
GruzzberryandClaude Sonnet 5.5 0dd9641bab fix(libkernel): fail a vm.overcommit write with EPERM
vm.overcommit is a read-write sysctl without CTLFLAG_PRISON, so FreeBSD 11.4 sysctl_root asks priv_check for PRIV_SYSCTL_WRITE before the handler runs, and prison_priv_check denies it to a jailed root. Under the credential model agreed on #11216 a write through sysctlbyname now fails with EPERM, whatever the value or its length, instead of throwing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-02 10:48:01 +00:00
Dean ed08af6a2f Merge pull request #10953 from AZLisme/feat/batch2-libc-legacy-signals
fix(libSceLibcInternal): export sigvec through shared runtime
2026-11-02 23:25:28 +13:00
Dean b07388b060 Merge pull request #10552 from krishalivaibhav/fix/macos-libkernel-six
fix(libkernel): build the file, module and rtld calls on macOS hosts
2026-11-02 20:54:13 +13:00
bluandClaude Opus 5.5 d984a64ceb Merge branch 'main' into refactor/siginterrupt-libc-internal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 16:22:33 -07:00
JamieandClaude Opus 5.5 79ee45a6e2 perf(agc): read committed guest pages directly on Windows
Every committed copy and compare on Windows went through
ReadProcessMemory, so a page released during the read counts as
uncommitted instead of faulting. Revalidation issues that system call
for each compare, and it dominates the committer thread.

Ranges the guest arena owns are now read by leaf copy and compare
routines. A fault on one of their source loads resumes at a failure
return, and the read falls back to the existing page by page path, so
the result for released pages is unchanged. Host regions and addresses
outside the arena keep ReadProcessMemory.

Hosts with AVX2 take 64 bytes per pass, with 16-byte and byte tails;
others keep the 16-byte loop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 20:08:39 +00:00
Ahmad Mujahid 00f69414ba fix(libkernel): resolve kern.proc.proc by name
sysctl serves {1, 14, 8} since #13532, but sysctlbyname and sysctlnametomib still returned ENOENT for kern.proc.proc. Map the name to the same MIB, as FreeBSD's name lookup does.
2026-11-01 19:24:55 +04:00
akkadbakkad89 2189fb06ea fix(libkernel): retire delivery-drain posts against a finished target
QueueForDeliveryDrain ran after ResumeThread with no coordination with
the target's final ReapDeliveryDrain: a target could exit between resume
and enqueue, leaving the post in a box nothing would drain again and
retaining the QueuedDelivery reference.

Admission is now decided under drainBoxesLock against the target's
_finished flag, which is stored before the final reap in program order;
denied posts run their callback inline so the entry and the reference
are resolved exactly once on either path.

The GuestRaiseException regression arms a post hook, holds the producer
between resume and enqueue, lets the target finish and reap, then
completes the post and requires the drain to stay empty; the churn
rounds also assert the post hook observed mailbox posts alongside the
delivered raises.
2026-11-01 18:30:44 +05:30
Dean Galvin 09690aaa78 Merge commit 'd5ec8e6575be37f4340ded9c64c51b1d07076b51' into HEAD
# Conflicts:
#	core/libs/prx/libkernel/System/src/Process.cpp
#	core/libs/tests/write_watch/CMakeLists.txt
#	docs/dev/debt/libkernel.md
2026-11-01 23:40:31 +13:00
Dean Galvin ec3b5d9c46 Merge commit 'a644edf30c501a612d06f17d05ef1b7051350cef' into HEAD
# Conflicts:
#	docs/dev/debt/libkernel.md
2026-11-01 23:26:11 +13:00
AZLisme e7725d7111 feat(libc): implement shared legacy sigvec support 2026-11-01 17:21:10 +08:00
akkadbakkad89andDevin 7ff3b7091b fix(libkernel): post guest raises to the delivery drain mailbox on Windows
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-01 13:23:10 +05:30
GruzzberryandClaude Sonnet 5.5 5ba892d391 fix(libkernel): fail rtprio_thread, sched_setscheduler and setpriority with the jail privilege errors
A title is jailed (agreed on #11216). FreeBSD 11.4 prison_priv_check denies
PRIV_SCHED_RTPRIO, PRIV_SCHED_SET and PRIV_SCHED_SETPRIORITY to a jailed caller.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-01 07:56:25 +01:00
Adrià 4547df009b Merge pull request #13874 from DeveshB-1/fix/sysarch-efault
fix(libkernel): return EFAULT from sysarch for invalid memory pointers
2026-11-01 06:47:19 +01:00
Adrià f377753dd2 Merge pull request #13854 from DeveshB-1/fix/sysctlnametomib-efault
fix(libkernel): return EFAULT from sysctlnametomib for invalid memory pointers
2026-11-01 06:05:23 +01:00
DeveshB-1 5d736ad55b fix(libkernel): return EFAULT from sysarch for invalid memory pointers 2026-11-01 05:55:56 +01:00
Dean 90a01f0770 Merge pull request #13824 from zaryabzip/feat/sysutil-notification-with-text
feat(libSceSysUtil): send text notifications as firmware 13.42 does
2026-11-01 14:24:52 +13:00
Adrià 666d9b10a5 Merge pull request #13790 from DeveshB-1/fix/allowed-sdk-version-efault
fix(libkernel): return EFAULT from sceKernelGetAllowedSdkVersionOnSystem for an unwritable store
2026-11-01 02:23:24 +01:00
Adrià cd35d6103a Merge pull request #13798 from pushkarreddyy/fix/app-info-efault
fix(libkernel): return EFAULT from sceKernelGetAppInfo for invalid memory pointers
2026-11-01 02:22:03 +01:00
Adrià 8bf03654ed Merge pull request #13769 from Flamefusion/feat/libkernel-has-trinity-mode
feat(libkernel): implement sceKernelHasTrinityMode for a base PS5
2026-11-01 00:54:50 +01:00
Adrià 3f6c712b77 Merge pull request #13746 from Gruzzberry/fix/prot-group-pgid-errnos
fix(libkernel): match FreeBSD 11.4 getgroups size and setgroups limit
2026-11-01 00:53:56 +01:00
DeveshB-1 dca2c61801 fix(libkernel): return EFAULT from sceKernelGetAllowedSdkVersionOnSystem for an unwritable store 2026-10-31 23:49:53 +01:00
DeveshB-1 dd46d6ada3 fix(libkernel): return EFAULT from sysctlnametomib for invalid memory pointers 2026-10-31 15:02:53 +05:30
blu 68a0d205c0 Merge remote-tracking branch 'origin/main' into refactor/siginterrupt-libc-internal 2026-10-31 02:05:49 -07:00
krishalivaibhavandClaude Sonnet 5.5 74cfbed70d fix(libkernel): return null for an address outside every image on macOS
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 14:32:53 +05:30
0e145b86e1 fix(libkernel): build the file, module and rtld calls on macOS hosts
NativeStat, SharedMemory, Stdio, DynamicLoader, ModuleInfo and Rtld used
Linux-only APIs (st_atim, memfd_create, sys/vfs.h, link.h and dl_iterate_phdr),
so libkernel did not compile on macOS. Add macOS paths behind __APPLE__:
st_*timespec and a long-path fstatat walk, an unlinked temp file for shared
memory, statfs, dlopen/dladdr and Mach-O segment walks for module and rtld
queries. The Linux and Windows paths are unchanged.

Extracted from feat/macos-port (#8658).

Co-authored-by: Himansh Raj <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-31 14:32:53 +05:30
zaryabzip 520a8249a3 feat(libSceSysUtil): send text notifications as firmware 13.42 does
sceSysUtilSendSystemNotificationWithText builds the 0xc30-byte request
the 13.42 library builds (kind 5, the type at +0xc, at most 179
characters of text at +0x2d, an empty text for a null message) and
returns what sceKernelSendNotificationRequest returns. That call now
prints kind 5 requests as it prints kind 0 ones.

Replaces #9081 by @shanu337.
2026-10-31 13:13:56 +05:00
pushkarreddyy 16b53200f3 fix(libkernel): preserve caller errno across sceKernelGetAppInfo guest memory write 2026-10-31 12:58:28 +05:30
pushkarreddyy d60500a34b fix(libkernel): return EFAULT from sceKernelGetAppInfo for invalid memory pointers 2026-10-31 12:52:31 +05:30
Flamefusion 7b477b6d66 feat(libkernel): implement sceKernelHasTrinityMode for a base PS5
sceKernelHasTrinityMode returns 0, the answer of a base PS5, as
sceKernelIsTrinityMode already does. Two public readings of firmware
libkernel (OpenAGC for 11.60, Backport for 11.00 to 12.70) say it
compares hw.sce_main_socid with its low five bits cleared against
0x840fc0; the base PS5 SoC id recorded for sceKernelGetMainSocId,
0x840f80, fails that test. The prototype int (void) comes from the 23
calls in a UE5 title, each storing setne of the result in a guarded
static with no argument set up.

Titles import it from libkernel, but only the libkernel_sys placeholder
inventory exported it, as a throwing stub. The export moves to libkernel
next to sceKernelIsTrinityMode, and the inventory and its counts drop
the entry. guest_operation_mode checks the result.
2026-10-31 10:42:24 +05:30
Adrià d4627bad7b Merge pull request #13552 from pushkarreddyy/fix/system-version-efault
fix(libkernel): return EFAULT from system version queries for invalid memory
2026-10-31 05:10:40 +01:00
Adrià 69c43dd403 Merge pull request #13577 from pushkarreddyy/fix/login-efault
fix(libkernel): return EFAULT from getlogin_r and SetLogin for invalid memory pointers
2026-10-31 05:08:35 +01:00