Commit Graph

1100 Commits

Author SHA1 Message Date
Dean a31043146e
Merge pull request #5367 from MarcZX100/marc/sysctl-leaf-enotdir-5356
fix(libkernel): return ENOTDIR for trailing sysctl leaf components
2026-10-14 16:41:21 +13:00
Dean 21def5c6f8
Merge pull request #5597 from JJenkx/fix/thread-stack-retirement-order
fix(libkernel): retire stack metadata before releasing mappings
2026-10-14 16:41:01 +13:00
Dean a14ae8e232
Merge pull request #5186 from p3n1cillin/claude/carry-fioclex
fix(libkernel): handle FIOCLEX and FIONCLEX in ioctl
2026-10-14 16:31:08 +13:00
Dean 3e4fe4ce31
Merge pull request #5596 from tibzejoker/port/pr-637-main
fix(libc): track writes to singly mapped direct memory without faults on Windows
2026-10-14 15:53:44 +13:00
Dean 94f96c8e2c
Merge pull request #5255 from Nesyth/fix/libkernel-apr-read-past-eof-v2
fix(libkernel): zero-fill APR reads that reach the end of the file
2026-10-14 15:44:14 +13:00
Dean 9b6555bd47
Merge pull request #4796 from xXPBSXx/feat/socket-options-sol-socket
fix(libkernel): report SO_ERROR and the other SOL_SOCKET options like FreeBSD
2026-10-14 15:37:41 +13:00
p3nicillin dad29cac43 feat(libkernel): report vm.overcommit through sysctlbyname
The mimalloc in PS5MC (PPSA99420) reads vm.overcommit at start-up and
stopped on the unsupported name. It reports FreeBSD's default, 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:44:48 +13:00
Dean dff25dd604
Merge pull request #5098 from p3n1cillin/claude/sysctl-hw-realmem
feat(libkernel): report hw.realmem through sysctl
2026-10-14 14:44:32 +13:00
Dean 1ebf8410a9
Merge pull request #5351 from MarcZX100/marc/fix-pathname-sysctl-eperm-5340
fix(libkernel): return EPERM before validating pathname sysctl MIB
2026-10-14 14:26:31 +13:00
Dean 2c444bb9fb
Merge pull request #5241 from MarcZX100/fix/sigwait-error-return-5224
fix(libkernel): return error numbers from sigwait
2026-10-14 14:26:15 +13:00
Dean 488ccece53
Merge pull request #4980 from MarcZX100/codex/poll-precise-wait-1471
fix(libkernel): use precise waits for empty poll sets
2026-10-14 14:26:00 +13:00
Dean 2e7ab67e8d
Merge pull request #4917 from MarcZX100/codex/carry-directory-read-4912
fix(libkernel): fail reads on Windows directory descriptors
2026-10-14 14:25:43 +13:00
Dean 7937c97237
Merge pull request #4923 from MarcZX100/codex/carry-ftruncate-not-file-4921
fix(libkernel): reject ftruncate on non-file Windows handles
2026-10-14 14:25:27 +13:00
Dean 8a51486bd2
Merge pull request #5393 from yixx16/fix/libkernel-vnode-windows-delete
fix(libkernel): keep the Windows vnode watch when the watched file is deleted
2026-10-14 14:25:11 +13:00
Dean d1c4618729
Merge pull request #4864 from milescoviello/carry/readv-pipe-windows-4858
fix(libkernel): fill every buffer of readv from a pipe on Windows
2026-10-14 14:24:56 +13:00
Dean c101c91bbb
Merge pull request #5272 from milescoviello/carry/siglongjmp-stack-windows-5270
fix(libkernel): switch the host stack bounds in siglongjmp on Windows
2026-10-14 14:24:40 +13:00
Dean 979a4b9bb7
Merge pull request #5464 from milescoviello/fix/kernel-stat-null-buffer
fix(libkernel): fail sceKernelStat with EFAULT for a null buffer
2026-10-14 14:24:24 +13:00
p3nicillin fe54938490 feat(libkernel): report hw.realmem through sysctl
The dolphin_libretro core of RetroArch (PPSA99169) reads {CTL_HW,
HW_REALMEM} as the machine's memory size and stopped on the unsupported
MIB. It reports the same value as hw.physmem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:23:55 +13:00
Dean fc1e388ed2
Merge pull request #5185 from p3n1cillin/claude/sysconf-clk-tck
feat(libkernel): report _SC_CLK_TCK through sysconf
2026-10-14 14:22:06 +13:00
Dean b16a1a72f3
Merge pull request #4776 from babyhuey/feat/libkernel-sysctl-tsc-freq
feat(libkernel): report machdep.tsc_freq from sysctlbyname
2026-10-14 14:09:31 +13:00
thibaut 71da166a18 fix(libc): keep resident mappings to direct memory backings on Windows
Map made every singly mapped section page private resident memory. A JIT
or shm_open section is file backed and committed: its bytes live in the
file, and its alias descriptors map duplicated handles, which the physical
page slots do not match, so a resident copy diverged from the file, and
committing its view on a demote failed with access denied
(guest_jit_shared_memory). Only direct memory backings, mapped through the
new GuestArenaMapDirect, now become resident; other sections keep main's
shared views. Shared pages are committed only while their section page is
reserved, as on main.

The socket host write tests map their direct memory a second time, so the
write-protected shared path they check is still the one they exercise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1W4jdNSKTV7xwuS6xQPJV
2026-10-14 02:39:10 +02:00
DotDebian d9852df2a2 fix(libc): track writes to singly mapped direct memory without faults on Windows
A direct memory page mapped at one guest address now lives in private
MEM_WRITE_WATCH memory at that address, and its writes are collected with
GetWriteWatch like flexible memory: no fault is raised. A page mapped at a
second address moves its whole resident run into the section, behind a
read-only fence while it is copied, and every address becomes a view of it,
tracked by write protection. Unmapped resident pages that are not blank are
kept in a private reservation until they are mapped again, not in the
section.

Ported onto main's 4 KiB subpage tracking of shared views: resident runs
keep a per-page collected bit and enter the fresh ranges, so Fresh and
Armed collections select them like shared views; a demoted run carries its
collected bits into the views and reports every page once. MapAlias throws
through refuse() when a resident run extends outside the aliased range, and
the caller keeps main's fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1W4jdNSKTV7xwuS6xQPJV
2026-10-14 02:39:10 +02:00
JJenkx d1527840ea fix(libkernel): retire stack metadata before releasing mappings 2026-10-13 20:30:24 -04:00
Dean 014f3623a7
Merge pull request #4508 from jradelmo/feat/flexible-memory-budget
fix(kernel): honor the declared flexible memory budget
2026-10-14 13:13:03 +13:00
Dean d1670009fb
Merge pull request #5429 from Dripl1x/perf/windows-mutex-wake
perf(libkernel): wake guest mutex waiters on release on Windows
2026-10-14 12:31:24 +13:00
Evgeniy Kazarin 99eaf73102 perf(libkernel): wake guest mutex waiters on release on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 02:18:33 +03:00
Adelmo Junior 72211b70fe fix(kernel): honor the declared flexible memory budget
Read the optional aligned budget from param.json and apply it consistently to configured, available and mapped flexible memory. Add parser and allocation regression coverage.
2026-10-13 20:13:14 -03:00
Dean Galvin 296ff64ae9 fix(libkernel): share positioned transfer locks on Windows only
The per-descriptor lock exists only in the Windows transfer path, so ShareDescriptor calls SharePositionedTransfer under _WIN32 like GuestFileLockShare. Linux failed to link libkernel with an undefined reference to it.
2026-10-14 11:18:55 +13:00
ducloc080202 0b46b3080a test(libkernel): cover concurrent pread against seek and read 2026-10-14 11:18:07 +13:00
ducloc080202 3cab3c05ec fix(libkernel): use per-descriptor locks for positioned transfers and seeks 2026-10-14 11:18:07 +13:00
Anshika Gupta 3915f6dc09 fix(libkernel): serialize positioned file transfers on Windows 2026-10-14 11:18:01 +13:00
Hussein Kadhim 091438f99b fix(libkernel): fail sysctl with ENOTDIR when a leaf MIB has a trailing component
FreeBSD sysctl_find_oid returns ENOTDIR when the MIB continues below a leaf object. The supported hw.ncpu, hw.model, hw.physmem and kern.arandom MIBs threw an unsupported MIB error instead.

(cherry picked from commit 6968aea8af578c4d56dc614cbe449274bb6e76e7)
2026-10-13 21:33:25 +00:00
David 1ba0a81820 feat(libkernel): implement getpriority for the guest process
PS5MC (PPSA99420, Kodi 22) imports getpriority (miQ1wVwSexE) from
libkernel.prx, one reference, next to chflags in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import miQ1wVwSexE from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_resource.c sys_getpriority
(8c639945a44588f6cfdddfb057bb5aad88735da0) for the only guest process,
taken to run at nice 0 and to lead its own process group (as kill and
setsid already assume): PRIO_PROCESS and PRIO_PGRP with 0 or its pid,
and PRIO_USER with 0 or its uid 0, return 0; other ids give ESRCH and
an unknown which gives EINVAL. getpriority is a bare system call in
FreeBSD's libc (lib/libc/sys/Symbol.map), so errno is left unchanged
on success.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 63262245d274342b693fda146ae9feca3752b6e3)
2026-10-14 10:23:41 +13:00
Dean cf5f5b53b5
Merge pull request #4379 from MarcZX100/codex/carry-chflags-3632
feat(libkernel): carry chflags implementation
2026-10-14 10:22:02 +13:00
Dean 7d757bbf0a
Merge pull request #4383 from pushkarreddyy/feat/libkernel-sigpending-sigsuspend
feat(libkernel): implement sigpending
2026-10-14 10:21:01 +13:00
Dean ea2b2d364f
Merge pull request #4514 from kallmek3nny/feat/libkernel-pthread-setaffinity
feat(libkernel): implement pthread_setaffinity_np
2026-10-14 10:20:33 +13:00
MarcZX100 b6a10e91aa fix(libkernel): remove duplicate chflags error constant 2026-10-13 20:28:23 +00:00
milescoviello eb78c6a45f fix(libkernel): fail sceKernelStat with EFAULT for a null buffer
Crimson Desert (PPSA25286) calls sceKernelStat with a null buffer at
start-up, and main throws "sceKernelStat: sb is null", which ends the
title in its first second.

FreeBSD 11.4 looks the path up first and only then copies the result
out, so a null buffer gets EFAULT for a path that exists and the lookup
error for one that does not (sys/kern/vfs_syscalls.c, sys_stat):

	error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
	    &sb, NULL);
	if (error == 0)
		error = copyout(&sb, uap->ub, sizeof (sb));

sceKernelStat now does the same: the lookup and its errors are as
before, and a null buffer returns SCE_KERNEL_ERROR_EFAULT where the
status would be copied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:20:07 +00:00
David 4dd97f7dbe feat(libkernel): implement chflags through the guest path resolver
PS5MC (PPSA99420, Kodi 22) imports chflags (ixrw0h2tWuI) from
libkernel.prx, one reference. Predicted stop once the imports ahead of
it (pthread_getthreadid_np, sendfile, wcstok, pause, setrlimit and the
termios calls) are covered (not a run):

  FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 (8c639945a44588f6cfdddfb057bb5aad88735da0)
sys/kern/vfs_syscalls.c kern_chflagsat and setfflags, and
sys/ufs/ufs/ufs_vnops.c ufs_setattr, for a root caller: the lookup
through the guest resolver gives EFAULT, ENOENT and ENOTDIR (also for a
file reached through a trailing slash or used as a directory), a bit
outside the 17 UFS flags of sys/sys/stat.h (VNOVAL included) gives
EOPNOTSUPP, and SF_SNAPSHOT gives EPERM, since the snapshot flag cannot
be toggled. No host keeps BSD file flags and stat reports st_flags 0,
so flags 0 succeed without touching the file and any other flag throws
with the flags named. UF_READONLY and the other Windows-attribute flags
are not mapped to FILE_ATTRIBUTE_READONLY and its siblings: UFS stores
them without enforcing them, and on Windows the read-only attribute is
already the owner write bit of chmod.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 16e5b7ccd04e6467a5a282b6cfc9271304f42244)
2026-10-13 18:54:05 +00:00
Jesus 50b06110bb fix(libkernel): keep the Windows vnode watch when the watched file is deleted
Windows 10 1903 deletes a file with open handles by moving it into
$Extend\$Deleted until the last handle closes, so the next snapshot of a
watched file that a title (or the test) deleted saw a new path, tried to
watch that directory's changes, got ERROR_ACCESS_DENIED and threw from
the watch thread, which aborts the process; the path change was also
reported as NOTE_RENAME next to NOTE_DELETE. A snapshot with a pending
delete or no links now reports NOTE_DELETE alone and drops the parent
directory watch instead of replacing it, as the file has no directory
to be renamed or removed from any more.
2026-10-13 13:41:05 -05:00
Hussein Kadhim 2096410b29 fix(libkernel): report EPERM before EINVAL when writing kern.proc.pathname
FreeBSD sysctl_root rejects a write to a read-only node with EPERM before the node handler checks the MIB length, so a write with a short or long kern.proc.pathname MIB fails with EPERM. sysctlbyname for kern.proc.pathname now goes through sysctl with its 3-component MIB so it follows the same order.
2026-10-13 17:39:56 +00:00
Dean 9baec8793f
Merge pull request #3870 from yash27git/clean/Direct-Memory-Exception
fix(libkernel): harden DirectMemory validation and tests
2026-10-14 05:55:11 +13:00
Dean 40047f46bd
Merge pull request #4377 from MarcZX100/codex/carry-pthread-atfork-3628
feat(libkernel): implement pthread_atfork registration
2026-10-14 05:54:54 +13:00
screamm 74c3fb6576 feat(libkernel): implement pthread_setaffinity_np
PS5CEMU-HAR (PPSA99360, ps5-payload-dev build, relinks with
--trap-sdk-syscall-stubs) imports pthread_setaffinity_np (5KWrg7-ZqvE)
from libkernel.prx. babyhuey's run with #3787 merged onto main e7c70a2d
(PR #3787, 2026-10-12T10:54:44Z) stops at it:

  Windows: FAIL: unresolved ELF import 5KWrg7-ZqvE (pthread_setaffinity_np) from libkernel.prx
  Linux: undefined symbol: 5KWrg7-ZqvE (pthread_setaffinity_np)

It follows FreeBSD 11.4 libthr thr_affinity.c (8c639945) over
kern_cpuset_setaffinity: another thread is looked up first (EINVAL for
null, ESRCH when unknown or finished, as _thr_find_thread without dead
threads), a size other than the 32-byte cpuset_t returns ERANGE, the
mask is clipped to sceKernelGetAvailableCpumask and an empty result
returns EDEADLK, as cpuset_setaffinity does. The affinity is stored on
the guest thread through scePthreadSetaffinity, for the caller and for
any live guest thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 16:39:07 +00:00
Hussein Kadhim ac82f3c6a9 fix(libkernel): switch the host stack bounds in siglongjmp on Windows
longjmp moves the Windows stack bounds onto the stack of the target jump buffer so that exceptions and stack probes keep working after a jump between guest stacks. siglongjmp restored the same registers without that step, so a jump from a context stack back to the thread stack left the thread bounds describing the stack it had left.
2026-10-13 16:09:27 +00:00
Adrià 3e8d0793b7
Merge pull request #4588 from Nixitov/feat/libkernel-host-hardware
feat(libkernel): report the host SoC and CPU temperature
2026-10-13 17:49:54 +02:00
Hussein Kadhim 13b4de565b fix(libkernel): return the error number from sigwait
FreeBSD's sigwait hands the error number back as its return value and leaves errno alone; the guest export returned -1 and set errno.

(cherry picked from commit b627f6c9443dd94a6392959f33e52d837ee4cae4)
2026-10-13 15:49:28 +00:00
Adrià 6679168360
Merge pull request #5210 from ErenYeager1836/carry/libkernel-coredump-user-file
feat(libkernel): answer the coredump user-file attach calls
2026-10-13 17:42:50 +02:00
Adrià 068ab2aba6
Merge pull request #4638 from MarcZX100/codex/carry-win-getdents-throw-3327
fix(libkernel): throw for oversized directory entries
2026-10-13 17:32:31 +02:00
Adrià 9c05bf25f5
Merge pull request #4585 from jagrat04/feat/libkernel-cpuset-affinity-errors-pr
feat(libkernel): return ESRCH and EINVAL for unsupported cpuset affinity targets
2026-10-13 17:23:01 +02:00