Commit Graph

108 Commits

Author SHA1 Message Date
Hannah Lyons 04835bdcd1 feat(libkernel): support kern.rng_pseudo in sysctlbyname 2026-10-11 09:51:22 +02:00
MarcZX100 d8ba169df8 fix(libkernel): correct system version ABI layout 2026-10-11 09:43:02 +02:00
pushkarreddyy cbacc46ede fix(libkernel): return SCE_KERNEL_ERROR codes in sceKernelGetSystemSwVersion 2026-10-11 09:42:49 +02:00
pushkarreddyy 5890160278 feat(libkernel): implement sceKernelGetSystemSwVersion
(cherry picked from commit 7143d0b46e389254b0b3bd52812a196ace0c7a6b)
2026-10-11 09:42:49 +02:00
Adrià 75c979ad9f
Merge pull request #3056 from TheAggie/feat/libkernel-get-app-info
feat(libkernel): implement sceKernelGetAppInfo
2026-10-11 09:12:54 +02:00
Hannah Lyons 0e88f3014d fix(libkernel): name pthread_kill's errors and test the signal range edge 2026-10-10 21:11:29 -04:00
Hannah Lyons d8af71c0ca feat(libkernel): implement pthread_kill 2026-10-10 21:11:29 -04:00
Scott Schuster 3f32c12fd8 fix(libkernel): read sceKernelGetAppInfo's title id through AppMetadata
The title id now comes from GetAppTitleId, so param.json has one parser and
its validation (a missing file or titleId throws). Another pid returns EPERM
and a null info returns 0 without writing, as shadPS4 does. app_id stays 1,
the running title's id in libSceSystemService, which is inferred, not
measured.

guest_app_info runs the call without param.json in a child process and
checks that the field between app_id and the title id is left alone.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:11:18 +02:00
Scott Schuster a6520d0c8b feat(libkernel): implement sceKernelGetAppInfo
sceKernelGetAppInfo fills the app id and the title id of the calling
process: app id 1, the running title's id in libSceSystemService, and the
titleId of /app0/sce_sys/param.json at offset 0x10, up to 9 characters and a
terminator. Only those fields are written, since callers declare the
structure with different sizes. Another pid returns ESRCH and a null info
EFAULT.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:11:18 +02:00
Scott Schuster e5ae8dfcb0 fix(libkernel): keep the alarm state alive until the process exits
The detached alarm thread waits on a condition variable that was a
namespace-scope static. At exit its destructor ran with the thread still
waiting, and glibc's pthread_cond_destroy blocks then, so a process that
called alarm never exited on Linux. The mutex, condition variable, deadline
and started flag now live in one structure allocated once and never
destroyed.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:04:35 -05:00
Scott Schuster 383bffd8c7 feat(libc): implement alarm
RetroArch (PPSA99169) stops at alarm on main: `FAIL: unresolved ELF import DQXJraCc1rA from libSceLibcInternal.prx`.

alarm(seconds) arms one process-wide real-time alarm and returns the seconds left on the previous one, rounded up like FreeBSD's alarm.c (any partial second counts); alarm(0) cancels it. When it expires, SIGALRM's disposition as recorded by sigaction or signal applies: ignored, nothing happens; default, the process terminates as on FreeBSD (exit status 128 + 14); a guest handler throws, because asynchronous delivery to a guest handler is not implemented.

The timer lives in libkernel next to the signal dispositions (GuestAlarm_nid_no_patch); libSceLibcInternal, which the titles import alarm from, forwards to it.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 17:59:58 -05:00
Adrià 7250918fea
Merge pull request #2827 from Get-fix/fix/libkernel-execvp
fix(libkernel): export execvp
2026-10-11 00:49:40 +02:00
Hannah Lyons 97e81c4224 feat(libkernel): implement sync 2026-10-10 18:12:21 -04:00
Dean 6c008c180e
Merge pull request #2935 from AchrafReyani/feat/libkernel-siglongjmp
feat(libkernel): implement siglongjmp
2026-10-11 09:09:18 +13:00
Achraf Reyani 0272f99ad3 feat(libkernel): implement siglongjmp
PokeMMO Prospero (PPSA98001) stops at siglongjmp (pebqbE5ws8s) from
libkernel. The title links its own FreeBSD sigsetjmp, so siglongjmp
follows FreeBSD's amd64 __siglongjmp and its sigjmp_buf layout: when the
save-mask flag at offset 88 is set it restores the mask saved at 72
through _sigprocmask, then reloads rbx, rsp, rbp, r12-r15 and the x87
control word and returns to the saved address with val, or 1 for 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:07 +09:00
LeandroLP23 df415ff1fd feat(libkernel): implement pthread_sigmask
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 19:45:28 +02:00
Get-fix d686f7057c fix(libkernel): export execvp
VLC (PPSA85300) imports execvp (0NJDcQ2B8vE) from libkernel and fails
to load because no library exports it. Replacing the process image is
not supported, so it throws if called, like sceSystemServiceLoadExec
does for executable replacement. VLC itself cannot reach the call: its
fork and vfork fail with ENOSYS, so the child that would call execvp is
never created.
2026-10-10 19:12:49 +03:00
overlordxrz-source 9a70477170 feat(libkernel): implement kill
ProsperoStore (PPSA99000) imports kill from libkernel and stops at it on
current main. Its crash reporter resets a crash signal to SIG_DFL and
sends it again with kill(getpid(), signal).

kill follows FreeBSD's kern_kill and killpg1 for the only guest process:
EINVAL for signals outside 0 to 128, signal 0 only checks the target,
and the caller's own pid, 0 and minus its pid deliver through raise.
Any other pid, and -1, which skips the caller, report ESRCH.
2026-10-10 11:06:12 +02:00
Adrià 9d249f365e
Merge pull request #2613 from oneandonlydean/fix/carry-2564
fix(libkernel): return every command-line argument as UTF-8 from getargv on Windows
2026-10-10 10:49:51 +02:00
Doston Abdullayev 5cb7de6ba9 fix(libkernel): return every command-line argument as UTF-8 from getargv on Windows
On Windows, getargc and getargv reported only the executable path, read
with GetModuleFileNameA in the ANSI code page, and dropped every other
argument. Linux returns the whole command line from /proc/self/cmdline,
and the relinker's Windows entry stub already passes the guest entry all
arguments converted to UTF-8.

Parse GetCommandLineW with CommandLineToArgvW and convert each argument
to UTF-8 with WC_ERR_INVALID_CHARS, as the entry stub does, so getargv
matches the entry's argv and the Linux behaviour. The Linux path is
unchanged.
2026-10-10 21:20:29 +13:00
AlxcBTW bc8587a6fe fix(libc): end the process without detach routines in _Exit on Windows
On Windows std::_Exit ends in ExitProcess, which still runs every module's
DLL_PROCESS_DETACH and TLS callbacks after the other threads are gone. A
static destructor that joins a worker then waits forever: a title that calls
_Exit while libSceVideoOut's flip queue runs (ps5-opengl's retirement
fail-stop) stays alive in FlipQueue's destructor. _Exit and libkernel's _exit
now terminate the process with TerminateProcess, as _exit ends a POSIX
process: no atexit handlers, stream flushes or module destructors.
2026-10-10 21:20:29 +13:00
LuisBiceps 918bc0a49c feat(libkernel): report no child processes from waitpid
waitpid returns -1 with ECHILD, or EINVAL for an option FreeBSD does not know, and leaves the status unwritten: AnyPS5 runs the title as one process and exports nothing that creates a child. VLC PPSA85300 stops on main at this import.
2026-10-10 10:11:04 +02:00
Scott Schuster 570aac4677 fix(libkernel): accept SCHED_OTHER in sched_get_priority_max/min
SDL queries the SCHED_OTHER range before it sets a thread priority. It gets
the same 256 to 767 range as SCHED_FIFO and SCHED_RR, which
pthread_setschedparam applies regardless of policy. The console's answer is
unverified and recorded in TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 00:47:11 -05:00
Dean ad0b5ba586
Merge pull request #2090 from LeandroLP23/feat/libkernel-environ
feat(libkernel): export environ as an empty environment
2026-10-10 17:43:44 +13:00
Jan Šlégl c26c1cae5b fix(libkernel): block guest signals by FreeBSD's bit n - 1
sigprocmask keeps the first word of the title's set as it is, where
FreeBSD keeps signal n at bit n - 1 (_SIG_BIT), but Dispatch tested bit
n. A title that blocked SIGTERM with a FreeBSD-built set (bit 14) was
not protected, and a set with bit 15 blocked SIGTERM instead of SIGURG.
Dispatch now tests bit n - 1; the stored mask and the set returned by
sigprocmask are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 01:30:55 +02:00
Adrià 76bff21fbe
Merge pull request #1421 from popcoder565/fix/kernel-raise-exception-ntcontinue
fix(libkernel): stop losing and deadlocking sceKernelRaiseException deliveries on Windows
2026-10-10 01:23:17 +02:00
john.maia e462d0602a refactor(libkernel): size the delivered signal handler table like the dispositions
Assisted by Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DwFnKjMxmwGDWiuYYf1v4D
2026-10-09 23:42:43 +01:00
john.maia cfe4a277c4 feat(libkernel): implement sigaction
EVO-PLAYER (PPSA99039) v0.11.0 stops at sigaction once its earlier
imports resolve: it installs a crash handler for SIGSEGV, SIGBUS and
SIGABRT and a quit handler for SIGTERM, SIGINT and SIGHUP at start-up.

sigaction records the handler, flags and mask of signals 1 to 128 and
reports them back, with FreeBSD's EINVAL cases. signal shares the table
and records SA_RESTART, as FreeBSD's libc does. Plain handlers on the
signals signal already delivers run as signal handlers do; SA_SIGINFO
handlers and other signals are recorded only, and raise of such a
signal throws.

Assisted by Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DwFnKjMxmwGDWiuYYf1v4D
2026-10-09 23:42:43 +01:00
popcoder565 5dc7021c38 Merge remote-tracking branch 'origin/main' into fix/kernel-raise-exception-ntcontinue
Keeps both new TechnicalDebt entries: this branch's note that a raise
can still reenter host code it interrupted, and #2107's sigaltstack note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 18:07:20 -04:00
Adrià 6642559456
Merge pull request #1675 from Recapi/feat/libkernel-getrlimit
feat(libkernel): implement getrlimit for RLIMIT_DATA
2026-10-10 00:00:57 +02:00
Adrià 7331a123e9
Merge pull request #2107 from LeandroLP23/feat/libkernel-sigaltstack
feat(libkernel): implement sigaltstack
2026-10-09 23:56:02 +02:00
Adrià db06355f84
Merge pull request #1859 from overlordxrz-source/feat/libkernel-system
feat(libkernel): implement system
2026-10-09 23:55:09 +02:00
Adrià 8d47cfba88
Merge pull request #1807 from SleglJan/feat/libkernel-sandbox-random-word
feat(libkernel): implement sceKernelGetFsSandboxRandomWord
2026-10-09 23:52:40 +02:00
Adrià d724cad38c
Merge pull request #1748 from danielradosa/feat/libkernel-seteuid-setegid
feat(libkernel): implement seteuid and setegid
2026-10-09 23:23:34 +02:00
LeandroLP23 a3f0120da2 feat(libkernel): export environ as an empty environment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 23:22:58 +02:00
Adrià 870ac041c5
Merge pull request #1685 from overlordxrz-source/feat/libkernel-sysctl-hw-ncpu
feat(libkernel): implement sysctl and sysctlbyname for hw.ncpu
2026-10-09 23:20:13 +02:00
LeandroLP23 c54143dbb9 feat(libkernel): implement sigaltstack
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 23:16:18 +02:00
Adrià 27cb335be1
Merge pull request #1650 from Pedroj-64/feat/libkernel-uid-gid
feat(libkernel): implement getuid, geteuid, getgid, getegid and issetugid
2026-10-09 23:04:27 +02:00
Adrià 4c36741929
Merge pull request #1641 from SleglJan/feat/libkernel-sigset
feat(libkernel): implement the sigset functions
2026-10-09 22:58:56 +02:00
popcoder565 570e7affdb Merge remote-tracking branch 'origin/main' into fix/kernel-raise-exception-ntcontinue
Keeps this branch's CONTEXT_FULL | CONTEXT_SEGMENTS read, context-first
order and bounded retry in RaiseOn, and adds #1478's ymm save fields to
both deliveries. The test keeps both phase sets; the vectors phase runs
after the continuing, selfing and looping phases and counts their
deliveries. The TechnicalDebt entry about ymm upper halves is dropped,
since #1478 preserves them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 16:04:14 -04:00
Dean 87e773689e
Merge pull request #1478 from awake-devel/fix/guest-signal-delivery
fix(libkernel): keep ymm upper halves across a redirected raise
2026-10-10 08:05:04 +13:00
Dean fffb830363
Merge pull request #1477 from awake-devel/fix/current-cpu-in-guest-mask
fix(libkernel): report the current CPU within the thread's guest affinity
2026-10-10 08:04:50 +13:00
Daniel Radosa 1414b27d29 feat(libkernel): implement seteuid and setegid
The guest process is assumed to run as root. Under FreeBSD's
sys_seteuid and sys_setegid, id 0 is then accepted without a privilege
check and changes no credential, so both return 0. Any other id would
change the effective credential, which is not modelled, and throws.

Part of #1578.
2026-10-09 19:14:02 +02:00
Renan Pires 851f3b7a10 feat(libkernel): implement getrlimit for RLIMIT_DATA 2026-10-08 23:52:33 -03:00
overlordxrz-source 8f09ec3616 feat(libkernel): implement system 2026-10-08 18:15:49 -04:00
Jan Šlégl 7785933807 feat(libkernel): implement sceKernelGetFsSandboxRandomWord
Returns the name of the directory under which a title's sandbox exposes
system files, which homebrew SDKs splice into paths such as
/<name>/common/cert/CA_LIST.cer and /<name>/common/lib/libc.sprx. The
name is fixed here; recorded in TechnicalDebt together with the fact
that nothing is mounted under it.

Registers guest_sandbox_random_word.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 21:39:11 +02:00
overlordxrz-source 18798620e8 feat(libkernel): implement sysctl and sysctlbyname for hw.ncpu
ScreenTester5 (PPSA69420) stops at start-up on the unresolved sysctlbyname
import and also imports sysctl. hw.ncpu (CTL_HW.HW_NCPU) reports the same
processor count as sysconf(_SC_NPROCESSORS_ONLN). Other names and MIBs throw.
2026-10-08 12:23:05 -04:00
Jan Šlégl e6a9b50512 feat(libkernel): implement the sigset functions
Add sigemptyset, sigfillset, sigaddset, sigdelset and sigismember with
FreeBSD 11 semantics (lib/libc/gen/sigsetops.c): a 128-bit set of four
32-bit words, signal n at bit n - 1, signals 1 to 128 valid. sigfillset
sets every bit. An invalid signal returns -1 with errno EINVAL and leaves
the set untouched; sigismember returns 1 or 0. A null set throws.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 17:45:57 +02:00
Pedro a294b80d29 feat(libkernel): implement getuid, geteuid, getgid, getegid and issetugid
Part of #1578.
2026-10-08 10:39:06 -05:00
Adrià 29e533aca0
Merge pull request #1469 from arvindfroi/refactor/coredump-stopinfo-gpu-name
refactor(libkernel): name the Jrs7UUkGOFo Coredump stub by its NID
2026-10-08 16:37:04 +02:00