libkernel: setitimer is absent (PS5MC); branch ready on the alarm timer, never reporting an undelivered signal #3735

Closed
opened 2026-10-11 16:12:15 +00:00 by screamm · 2 comments
screamm commented 2026-10-11 16:12:15 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T16:12:15Z.


libkernel does not export setitimer (NID hPWDGx8ioXQ). PS5MC (PPSA99420) imports it (registry index 472, predicted FAIL: unresolved ELF import hPWDGx8ioXQ from libkernel.prx). The earlier #3293 was closed for reporting success without delivering the signal; this branch never does that.

Branch ready: screamm:feat/libkernel-setitimer (6bef7bf0, one commit on main a11c8f7f). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. getitimer is left to the open #3572; whichever merges second must read the interval this branch stores (alarms.interval), since #3572 reports it as always 0.

  • Built on the existing alarm timer thread, following FreeBSD 11.4 sys/kern/kern_time.c (sys_setitimer, kern_setitimer, realitexpire, itimerfix) and lib/libc/gen/alarm.c (8c639945): EINVAL for an unknown timer or a value/interval with a negative field, tv_usec >= 1000000 or more than INT32_MAX/2 seconds; a null value reads the timer (EFAULT when the output is null too, after the timer check as FreeBSD orders it); a zero value disarms and returns the previous remaining time and interval; a non-zero value arms, re-armed by it_interval on expiry; alarm now clears the interval as FreeBSD's does.
  • What throws, with the reason named: expiry with a guest SIGALRM handler installed (no path runs a guest handler here; alarm already throws the same way), expiry while SIGALRM is blocked (pending signals are not modelled; this also corrects alarm, which wrongly exited in that case), an interval below 1 ms (FreeBSD rounds to tick/16 and the console's hz is unknown), and arming ITIMER_VIRTUAL/ITIMER_PROF (CPU-time accounting is not modelled; reading or disarming them is exact at zero). SIG_IGN drops the expiry and the default disposition exits with 142, as before.
  • New guest_itimer (about 1 s) covers the error cases with the output untouched, disarm returning the previous value, the countdown, re-arm by interval, the CPU timers, the alarm interplay and the throw message at expiry (it_interval 0.250000 s) with the handler never running.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: guest_itimer and guest_signals 3/3 (guest_itimer 10/10 in the worktree); ctest -j8 -E "^agc_driver_|^video_out_flip" 534/537, the failures being the known windows_exceptions (#3411, fixed by #3415), guest_kernel_sys (#3510) and guest_filesystem (#3518); with main'

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5802808030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3735). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T16:12:15Z. --- libkernel does not export `setitimer` (NID `hPWDGx8ioXQ`). PS5MC (PPSA99420) imports it (registry index 472, predicted `FAIL: unresolved ELF import hPWDGx8ioXQ from libkernel.prx`). The earlier #3293 was closed for reporting success without delivering the signal; this branch never does that. **Branch ready:** [`screamm:feat/libkernel-setitimer`](https://github.com/screamm/AnyPS5/tree/feat/libkernel-setitimer) (`6bef7bf0`, one commit on `main` `a11c8f7f`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commit as is. `getitimer` is left to the open #3572; whichever merges second must read the interval this branch stores (`alarms.interval`), since #3572 reports it as always 0. - Built on the existing `alarm` timer thread, following FreeBSD 11.4 `sys/kern/kern_time.c` (`sys_setitimer`, `kern_setitimer`, `realitexpire`, `itimerfix`) and `lib/libc/gen/alarm.c` (`8c639945`): `EINVAL` for an unknown timer or a value/interval with a negative field, `tv_usec >= 1000000` or more than `INT32_MAX/2` seconds; a null value reads the timer (`EFAULT` when the output is null too, after the timer check as FreeBSD orders it); a zero value disarms and returns the previous remaining time and interval; a non-zero value arms, re-armed by `it_interval` on expiry; `alarm` now clears the interval as FreeBSD's does. - What throws, with the reason named: expiry with a guest `SIGALRM` handler installed (no path runs a guest handler here; `alarm` already throws the same way), expiry while `SIGALRM` is blocked (pending signals are not modelled; this also corrects `alarm`, which wrongly exited in that case), an interval below 1 ms (FreeBSD rounds to `tick/16` and the console's `hz` is unknown), and arming `ITIMER_VIRTUAL`/`ITIMER_PROF` (CPU-time accounting is not modelled; reading or disarming them is exact at zero). `SIG_IGN` drops the expiry and the default disposition exits with 142, as before. - New `guest_itimer` (about 1 s) covers the error cases with the output untouched, disarm returning the previous value, the countdown, re-arm by interval, the CPU timers, the `alarm` interplay and the throw message at expiry (`it_interval 0.250000 s`) with the handler never running. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: `guest_itimer` and `guest_signals` 3/3 (`guest_itimer` 10/10 in the worktree); `ctest -j8 -E "^agc_driver_|^video_out_flip"` 534/537, the failures being the known `windows_exceptions` (#3411, fixed by #3415), `guest_kernel_sys` (#3510) and `guest_filesystem` (#3518); with `main`'
ArekatlaNishanthchowdary commented 2026-10-11 17:44:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by ArekatlaNishanthchowdary on 2026-10-11T17:44:14Z.


Windows verification of screamm:feat/libkernel-setitimer (6bef7bf0b), cherry-picked unchanged onto main a11c8f7f7 as ArekatlaNishanthchowdary:feat/libkernel-setitimer (5d21483ae), authorship kept.

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release:

  • guest_itimer passes.
  • Full ctest: only guest_kernel_sys (#3510), windows_exceptions (#3411), agc_driver_emulated_color_compare and guest_filesystem (#3518) fail, the same as unmodified main on this host. tools/check_conventions.py --base origin/main passes. No title or homebrew run. Linux not run.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111850682 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3735#issuecomment-6111850682). Originally posted by [ArekatlaNishanthchowdary](https://github.com/ArekatlaNishanthchowdary) on 2026-10-11T17:44:14Z. --- Windows verification of `screamm:feat/libkernel-setitimer` (`6bef7bf0b`), cherry-picked unchanged onto `main` `a11c8f7f7` as [`ArekatlaNishanthchowdary:feat/libkernel-setitimer`](https://github.com/ArekatlaNishanthchowdary/AnyPS5/tree/feat/libkernel-setitimer) (`5d21483ae`), authorship kept. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: - `guest_itimer` passes. - Full `ctest`: only `guest_kernel_sys` (#3510), `windows_exceptions` (#3411), `agc_driver_emulated_color_compare` and `guest_filesystem` (#3518) fail, the same as unmodified `main` on this host. `tools/check_conventions.py --base origin/main` passes. No title or homebrew run. Linux not run. AI-assisted: yes (Claude Code).
MarcZX10 commented 2026-10-12 08:25:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T08:25:04Z.


I carried the offered setitimer implementation into PR #4382, preserving the source commit author. I integrated it with current main’s existing getitimer and alarm timer state. Linux Release GCC 12.2 builds of guest_itimer_tests and guest_signal_tests passed; both focused CTests passed 1/1, and conventions/diff checks passed. The PR leaves getitimer as implemented on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120533459 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3735#issuecomment-6120533459). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T08:25:04Z. --- I carried the offered `setitimer` implementation into [PR #4382](https://github.com/boykopovar/AnyPS5/pull/4382), preserving the source commit author. I integrated it with current `main`’s existing `getitimer` and alarm timer state. Linux Release GCC 12.2 builds of `guest_itimer_tests` and `guest_signal_tests` passed; both focused CTests passed 1/1, and conventions/diff checks passed. The PR leaves `getitimer` as implemented on main.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3735
No description provided.