Commit Graph
116 Commits
Author SHA1 Message Date
Dean c48f200127 Merge pull request #15431 from MarcZX10/r2/r52-equeue-dmem
fix(libkernel): catch host watch thread errors instead of terminating
2026-11-07 18:05:50 +13:00
Dean Galvin c67d506a75 Merge branch 'main' 2026-11-07 13:53:36 +13:00
Dean Galvin 171d1c1a11 Merge origin/main into pr14886 2026-11-07 11:08:06 +13:00
kenny soloandClaude Opus 5.5 d8afe4c68b feat(libkernel): always fire a socket read knote with NOTE_LOWAT below 1
A socket EVFILT_READ knote whose NOTE_LOWAT mark is below 1 is now always ready and reports the bytes in the receive buffer, 0 when it is empty, because FreeBSD 11.4 filt_soread returns kn_data >= kn_sdata and the bytes available are never negative. This holds for level-triggered and EV_CLEAR knotes and when EV_ADD changes the mark of an existing knote. A listening socket ignores the mark, as filt_solisten does. An EVFILT_WRITE mark below 1 still throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-11-06 21:48:24 +01:00
Dean Galvin 5c82bfc2de Merge branch 'main' 2026-11-07 08:33:00 +13:00
Dean Galvin 27dda5dc2f Merge branch 'main' into pr-14886
Keep both EVFILT_PROC (main) and EVFILT_SIGNAL (this PR) in Kqueue.cpp: the constants, the two knote functions, the filter check and the dispatch. Debt doc: main's EVFILT_PROC and pipe wording with the PR's signal text.
2026-11-07 08:07:09 +13:00
Dean Galvin 1de3c88c5c Merge branch 'main' 2026-11-06 21:59:04 +13:00
MarcZX10 1d87704f6a fix(libkernel): catch host watch thread errors instead of terminating
The EVFILT_VNODE host watch thread in AddVnodeEvent ran RunHostWatch
directly. RunHostWatch throws std::runtime_error on poll, inotify, kqueue
or change-notification failures, and an exception escaping a detached
std::thread calls std::terminate and aborts the whole process. The thread
entry now catches std::exception, reports the message on stderr and ends
the watch, which RunHostWatch has already closed on every throw path.
2026-11-03 08:26:30 +00:00
Dean Galvin b4a978715b Merge main 096c45570f into #9843 (9879cd3a82) 2026-11-03 09:03:03 +13:00
Dean 0b20efc578 Merge pull request #12741 from SHOnnay/feat-macos-kevent-edge-watch
feat(equeue): implement macOS edge watches
2026-11-03 02:39:21 +13:00
kenny solo 8303e23a41 feat(libkernel): accept EVFILT_FS in kevent
An EV_ADD of EVFILT_FS is now accepted instead of throwing, as FreeBSD 11.4 filt_fsattach accepts it: the knote gets EV_CLEAR, and fflags and data start at 0. It never fires, as nothing here signals a filesystem event. EV_ENABLE, EV_DISABLE and EV_DELETE act on the knote as on other knotes.
2026-11-01 18:04:44 -05:00
kenny soloandClaude Opus 5.5 0211640a74 feat(libkernel): accept EVFILT_SIGNAL in kevent
An EV_ADD of EVFILT_SIGNAL is now accepted instead of throwing, as FreeBSD 11.4 filt_sigattach accepts it: the knote gets EV_CLEAR, and data counts the signals with that number sent since the knote was last reported, ignored ones included, as tdsendsignal counts them before its ignore check. Signals sent by raise, kill, killpg and pthread_kill and the ITIMER_REAL expiry are counted. EV_ENABLE, EV_DISABLE and EV_DELETE act on the knote as on other knotes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-11-01 17:28:11 -05:00
kenny soloandClaude Opus 5.5 f5e1921254 feat(libkernel): accept EVFILT_PROC with NOTE_EXIT on the calling process
An EV_ADD of EVFILT_PROC on the calling process with NOTE_EXIT or no notes is now accepted instead of throwing, as FreeBSD 11.4 filt_procattach accepts it: the knote gets EV_CLEAR and does not fire while the process runs, and EV_ADD, EV_ENABLE, EV_DISABLE, EV_DELETE and EV_FORCEONESHOT then act on it as on other knotes. EVFILT_PROC on another process or with notes other than NOTE_EXIT still throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-11-01 14:54:20 -05:00
Dean Galvin efd499f60d Merge commit 'f1a7b02028ae50adaf6c5aaaef892a51841b25bf' into HEAD
# Conflicts:
#	core/libs/prx/libkernel/Equeue/Equeue.cpp
#	core/libs/tests/GuestEqueueEvents.cpp
#	docs/dev/debt/libkernel.md
2026-11-02 03:00:24 +13:00
SAKIBUL HUDA ONNAY 7298636d8e feat(equeue): implement macOS edge watches 2026-11-01 17:13:29 +06:00
Florent Combet a6fd9994f7 fix(libkernel): keep close observer registry alive through exit 2026-10-31 02:26:40 +01:00
Florent Combet 1caa5a7cab fix(libkernel): initialize close observer registry on first use 2026-10-30 23:18:28 +01:00
pista d64e85164b build(libs): let the system libraries compile with Emscripten
Emscripten targets wasm64 without x86 assembly, Linux-only headers or the
x87 long double. These changes add __EMSCRIPTEN__ paths beside the host
ones; native builds compile the same code as before.

- libc: long doubles in guest varargs and scanf go through
  GuestLongDouble, a plain copy where long double is the x87 format;
  APS5_EXPORT emits no assembler alias; the guest arena is one aligned
  allocation that zeroes pages when they are committed again; getifaddrs
  keeps its link-level entries on Linux; /proc lookups and the host
  stderr duplicate are left out.
- libkernel: file-backed mmap, EVFILT_VNODE watches, getcontext and
  setcontext throw; getdents replaces the raw getdents64 syscall;
  getdtablesize takes the resource limit alone.
- VideoOut leaves SDL, the display window and the HDR probe out,
  Sysmodule asks libkernel for unwind information and Net includes
  sys/time.h.
2026-10-30 10:50:57 +09:00
Adrià d820fef182 Merge pull request #12503 from babyhuey/fix/kevent-efault
fix(libkernel): return EFAULT from kevent for an unreadable changelist or timeout or an unwritable eventlist
2026-10-29 22:49:08 +01:00
Adrià 1aff97d3c8 Merge pull request #12093 from dantdmdarealguy/fix/kqueue-windows-snapshot-times
fix(libkernel): read a watched file's times again after its size on Windows
2026-10-29 21:20:39 +01:00
Adrià 0e5dad41c2 Merge pull request #9575 from DavidSamir/feat/libkernel-kqueue-evclear
feat(libkernel): support EV_CLEAR on a kqueue watched by another kqueue
2026-10-29 11:23:08 +01:00
babyhuey e73a56f8ab fix(libkernel): bound kevent's staging buffer at 1024 events
The staging buffer was sized by the guest's nevents, so a request for
INT_MAX events allocated about 64 GiB before the queue reported how many
were pending. It's now bounded at 1024 events; kevent may return fewer
than requested, and events left in the queue come back on the next call.
The test covers an INT_MAX request and a 1030-event queue, and moves away
from the end of StandardInput and the start of main, where #9575 and
#10014 also add tests.
2026-10-28 18:59:45 -04:00
babyhuey fea9dfb454 fix(libkernel): return EFAULT from kevent for an unreadable changelist or timeout or an unwritable eventlist
kevent read the changelist and the timeout and wrote the eventlist in
place, so a non-null pointer into unmapped or read-only memory crashed
the host. It now copies the timeout in first, as FreeBSD's sys_kevent
does, copies each change in with GuestCopyIn_nid_no_patch and copies
EV_ERROR entries out one at a time. Triggered events are collected by
the same single queue call as before into a host buffer (on the stack
up to 64 events) and copied out with GuestCopyOut_nid_no_patch, so
level-triggered events are still reported once per call. Any failed
copy returns EFAULT.
2026-10-28 10:08:31 -04:00
David ec708dbde2 fix(libkernel): take the watched kqueue's count and activations in one snapshot
A cleared kqueue watch read the watched queue's triggered count and its
activation counter under two separate locks, so an activation between the
reads was marked seen without making the watch active, and the wakeup was
lost. SnapshotTriggered now returns both under one lock. Every poll of an
active watch also rechecks the count, as kqueue_scan reruns filt_kqueue:
it drops when the watched queue empties and reports the current count.
EV_ADD and EV_ENABLE of an existing watch re-arm it. A separate
guest_kqueue_cleared_race test triggers the watched queue from another
thread while the watching queue waits.
2026-10-28 13:45:03 +01:00
David 4c77b6ab65 feat(libkernel): support EV_CLEAR on a kqueue watched by another kqueue
FreeBSD re-evaluates a kqueue's EVFILT_READ note from kqueue_wakeup,
which runs whenever the watched kqueue queues a note, so an EV_CLEAR
note fires again only after such an activation. The equeue now counts
activations, and the EV_CLEAR note fires when the count moves while
notes are queued.
2026-10-28 13:44:50 +01:00
AdriàandClaude Sonnet 5.5 735dd0bdd7 fix(libkernel): declare the unnamed ksem exports once in the public header
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 12:58:01 +01:00
David 0742c4f6b4 feat(libkernel): let other libraries observe closed guest descriptors 2026-10-28 12:56:30 +01:00
AdriàandClaude Sonnet 5.5 ace596224f fix(libkernel): bound the snapshot retry of a watched file on Windows
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 11:43:00 +01:00
dantdmdarealguy a793bd1341 fix(libkernel): read a watched file's times again after its size on Windows
TakeSnapshot read FileBasicInfo and then FileStandardInfo. A truncate or
write landing between the two left a snapshot with the new size and the
old LastWriteTime, and the next poll reported the same size with a newer
LastWriteTime as NOTE_WRITE. guest_kqueue's FileWatch aborts on Windows
when that happens after its ftruncate to 0.

Read FileBasicInfo again after FileStandardInfo and retry until both
reads agree. The window NTFS itself leaves, a truncate's new
LastWriteTime shown before its new size, stays and is listed in the
libkernel debt.
2026-10-28 11:42:55 +01:00
AdriàandClaude Sonnet 5.5 149ec09adf fix(libkernel): give the descriptor checks C linkage so libkernel_sys can import them
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 08:43:15 +01:00
AdriàandClaude Sonnet 5.5 f87b6289ac fix(libkernel): export the kqueue descriptor check to libkernel_sys
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 08:43:15 +01:00
Adrià a40ad89e2c Merge pull request #11236 from orezraey/fix/libkernel-kqueue-timer-readd-measured-ps5
fix(libkernel): accept EVFILT_TIMER re-adds with a time unit or on a disabled timer as measured on a PS5
2026-10-27 14:28:05 +01:00
Adrià 62b3ba2522 Merge pull request #11125 from MarcZX10/marc/fix-equeue-close-during-measure
fix(libkernel): wait for an in-flight file measurement before closing a watched descriptor
2026-10-27 13:30:54 +01:00
MarcZX10 9b9f9b4af8 fix(libkernel): retire an in-flight file measurement on every exit with a guard
MeasureFiles registered the descriptors it measures in m_measuring and removed them only on the normal path, so an exception between unlocking and relocking left them there and every later RemoveDescriptorEvents for one of them waited forever. Both vectors are reserved before anything is registered, and a guard owns the registration: on every exit it relocks if needed, removes the entries and notifies.
2026-10-27 04:46:00 +00:00
MarcZX10 de2b96d8bd fix(libkernel): wait for an in-flight file measurement before closing a watched descriptor 2026-10-27 04:46:00 +00:00
Evrim Cicek 3f67bbcd4e Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into fix/recvmsg-after-shut-rd
# Conflicts:
#	core/libs/prx/libkernel/Socket/src/Udp.cpp
#	docs/dev/debt/libkernel.md
2026-10-27 01:04:45 +03:00
Dean ade9b32167 Merge pull request #11029 from orezraey/fix/libkernel-event-error-measured-ps5
fix(libkernel): add 0x80020000 to any event fflags in sceKernelGetEventError as measured on a PS5
2026-10-27 05:38:39 +13:00
orezraeyandClaude Opus 5.5 4c9e31f18c Merge main into fix/libkernel-kqueue-timer-readd-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 12:13:12 -03:00
Dean f92497d1e5 Merge pull request #9780 from Retr0G28/fix/kevent-rotate-reported-knotes
fix(libkernel): move every knote kevent reports behind the waiting ones
2026-10-26 14:12:10 +13:00
orezraeyandClaude Opus 5.5 c7392b3fca fix(libkernel): accept EVFILT_TIMER re-adds with a time unit or on a disabled timer as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 19:21:25 -03:00
Evrim Cicek 1c5e876164 fix(libkernel): report EV_EOF and wake read waiters when a socket is shut for reading 2026-10-26 01:09:17 +03:00
orezraeyandClaude Opus 5.5 2d339842eb fix(libkernel): add 0x80020000 to any event fflags in sceKernelGetEventError as measured on a PS5
On PS5 firmware 13.60 sceKernelGetEventError returns 0x80020000 plus the
event's fflags in 32 bits for every non-zero fflags, including values
above 0xFFFF, where it used to throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 11:25:04 -03:00
Adrià c2e087b2a6 Merge pull request #7049 from blawesom/followup/6510
fix(libkernel): retire an EV_ONESHOT note through its delete callback and follow Windows $Deleted paths
2026-10-25 12:38:21 +01:00
Dean Galvin 9dad4138a2 Merge main into ws/pr-8596 2026-10-25 11:52:51 +13:00
boykopovar 53a65ec210 fix(sdk): sync declarations with latest main 2026-10-24 23:17:48 +03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean d003e64fcf Merge pull request #9099 from aarushkha/feat/libkernel-equeue-regular-file-events-v2
feat(libkernel): answer sceKernelAddReadEvent and sceKernelAddWriteEvent on regular files
2026-10-25 06:33:30 +13:00
Dean ce16645691 Merge pull request #9127 from Retr0G28/fix/equeue-rotate-level-events
fix(libkernel): move events reported by sceKernelWaitEqueue behind the waiting ones
2026-10-25 04:17:49 +13:00
Dean Galvin 5fbebabb47 Merge main into ws/pr-8596 2026-10-25 02:28:06 +13:00
blawesom 681cfa1170 fix(libkernel): refuse a timer modify with fflags and pin the disabled timer's enable re-arm
- a timer change with EV_ADD unset and data 0 keeps the period; one that set
  fflags was silently ignored, where FreeBSD 11's kqueue_register copies it
  onto the note: it now throws with the other re-adds, waiting for the
  measured rules
- EV_ENABLE on a disabled timer reports the expiries missed while disabled in
  one step and keeps the note's phase, as FreeBSD 11's filt_timerexpire counts
  a disabled note and keeps its p_nexttime; TimerDisableEnableRearm pins it
  (5 serial runs and 3 rounds of 8 parallel copies pass)
- the next-wait abort from the review round was observed before main's
  5cbc46029b wait refactor and does not reproduce
2026-10-24 11:13:43 +02:00