12 Commits
Author SHA1 Message Date
SAKIBUL HUDA ONNAYandClaude Opus 5.5 3e7033277d fix(libkernel): keep the ktimer state in a leaked singleton
Move the lock, condition, timer table and thread-started flag into one
KtimerState behind a never-destroyed function-local pointer, as Alarms()
does, so exit never destroys a condition the timer thread waits on.
Restore the SIGEV_NONE sentence in the debt entry and state that a timer's
thread id is taken to equal the guest thread id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:36:41 +06:00
SAKIBUL HUDA ONNAYandClaude Opus 5.5 993fab29f6 fix(libkernel): keep the ktimer lock and condition alive at exit
The timer thread can still be waiting on the condition when static
destructors run at process exit. Destroying it under the waiter hung
guest_kernel_sys_ktimer on Linux after the test returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:21:47 +06:00
SAKIBUL HUDA ONNAYandClaude Opus 5.5 015e3e30d7 Merge remote-tracking branch 'upstream/main' into feat/libkernel-ktimer-signal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:38:53 +06:00
Dean 2c158dc176 Merge pull request #13964 from FFwLo/fix/ktimer-efault
fix(libkernel): return EFAULT from ktimer_create and ktimer_gettime for unwritable pointers
2026-11-14 18:54:30 +13:00
SAKIBUL HUDA ONNAYandClaude Opus 5.5 80864c2898 feat(libkernel): deliver SIGEV_SIGNAL and SIGEV_THREAD_ID ktimer expiries
ktimer_create no longer throws for SIGEV_SIGNAL, SIGEV_THREAD_ID or a null
sigevent (SIGALRM with the timer id as sival, as kern_ktimer_create does).
A host timer thread runs realtimer_expire and itimer_fire from FreeBSD
stable/11 sys/kern/kern_time.c at 5ed7eb0d97ba4436218e810f61bd059acba984c2:
the expiry is queued on the existing guest pending set with SI_TIMER,
si_value, si_timerid and si_overrun; while that entry is still queued a
further expiry, or an interval missed by a late wake-up, counts an overrun
instead; taking the entry (sigtimedwait, sigwaitinfo, sigwait or handler
delivery on unblock) applies itimer_accept, and ktimer_getoverrun returns
it_overrun_last. ktimer_delete removes a queued entry as sigqueue_take does.
A SIGEV_THREAD_ID target that is not a live thread disarms the timer at
expiry, as sigev_findtd does. The sigevent is now copied in (EFAULT).

As with setitimer, an expiry for a thread that does not block the signal
throws, since guest handlers are not run from a host thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:59:31 +06:00
THEMANnt 2b64a3cb98 fix(libkernel): check timer settime guest buffers 2026-11-12 14:16:42 +03:00
MoandClaude Opus 5.5 9532e37a12 fix(libkernel): accept ktimer_settime flag bits other than TIMER_ABSTIME as FreeBSD 11.4 does
ktimer_settime returned EINVAL for any flag bit other than TIMER_ABSTIME. The
check cited FreeBSD's `if ((flags & ~TIMER_ABSTIME) != 0) return (EINVAL);`,
but in kern_time.c at 8c639945 that line (504) is in kern_clock_nanosleep.
sys_ktimer_settime, kern_ktimer_settime and realtimer_settime never reject
flags; they only test flags & TIMER_ABSTIME (line 1548). The test now pins that
flags 2, 4 and 0x7ffffffe arm a relative timer and that -1 arms an absolute one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:46:51 -08:00
FFwLoandClaude Opus 5.5 2b04038926 fix(libkernel): copy ktimer results out after dropping the timer lock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 18:24:23 +04:00
FFwLoandClaude Opus 5.5 6c415b7e9b fix(libkernel): return EFAULT from ktimer_create and ktimer_gettime for unwritable pointers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:54:50 +04:00
fogydes bdf916d924 fix(libkernel): reject invalid flags in ktimer_settime 2026-10-28 12:44:01 +05:30
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
David 7820a5353a refactor(libkernel): move the ktimer calls into libkernel
The PS5 3.20 export lists have ktimer_* in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys. The implementation moves unchanged to
libkernel/Time/Ktimer.cpp.
2026-10-21 22:22:16 +01:00