feat(libkernel): add clock_settime with FreeBSD argument checks #5183

Merged
p3n1cillin merged 1 commit from upstream-pr/5183 into main 2026-10-13 14:27:06 +00:00
p3n1cillin commented 2026-10-13 14:09:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:09:47Z.


What

Carries @nabilfp's clock_settime commit from nabilfp:feat/libkernel-chroot-clock-settime (53485d5a5, author kept), which they closed #4890 to free their PR slot and offered for anyone to carry. It follows FreeBSD 11.4 sys_clock_settime/kern_clock_settime for a privileged caller: EFAULT for a null time, and EINVAL for any clock other than CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to 999999999. A valid CLOCK_REALTIME request throws, since the host clock must not be set. The details are in the commit message and the debt entry.

Title evidence: PS5MC (PPSA99420, Kodi 22, catalog release) imports clock_settime (d7nUj1LOdDU). On current main with the open #4379 (chflags), #4374 (getpriority) and #4383 (sigpending), tools/import_audit.py lists it as the title's only absent import, so the loader stops on it:

FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

With this commit too, PS5MC loads and runs into Kodi's start-up, which then needs #5184, #5185 and #5186.

Tested

  • PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0), on main 3faa9cb40 with #4379, #4374, #4383 and #5184, #5185 and #5186 (vm.overcommit, _SC_CLK_TCK, FIOCLEX): it loads, starts Python, finds its add-ons and the Estuary skin, creates its GUI on the ps5 windowing system, and runs for the whole 90 s run. Without this commit it does not load.
  • guest_freebsd_clocks (from the commit) and all 125 libkernel tests pass on Windows; python tools/check_conventions.py --base origin/main passes. The commit applies to current main without changes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none to build; PS5MC also needs #4379, #4374 and #4383 to load
  • Unblocks: PS5MC (PPSA99420), part of #3632
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4844513695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5183). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:09:47Z. --- ### What Carries @nabilfp's `clock_settime` commit from `nabilfp:feat/libkernel-chroot-clock-settime` (`53485d5a5`, author kept), which they closed #4890 to free their PR slot and offered for anyone to carry. It follows FreeBSD 11.4 `sys_clock_settime`/`kern_clock_settime` for a privileged caller: `EFAULT` for a null time, and `EINVAL` for any clock other than `CLOCK_REALTIME` and for a negative `tv_sec` or a `tv_nsec` outside 0 to 999999999. A valid `CLOCK_REALTIME` request throws, since the host clock must not be set. The details are in the commit message and the debt entry. Title evidence: PS5MC (PPSA99420, Kodi 22, catalog release) imports `clock_settime` (`d7nUj1LOdDU`). On current `main` with the open #4379 (`chflags`), #4374 (`getpriority`) and #4383 (`sigpending`), `tools/import_audit.py` lists it as the title's only absent import, so the loader stops on it: ``` FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx ``` With this commit too, PS5MC loads and runs into Kodi's start-up, which then needs #5184, #5185 and #5186. ### Tested - PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0), on `main` `3faa9cb40` with #4379, #4374, #4383 and #5184, #5185 and #5186 (`vm.overcommit`, `_SC_CLK_TCK`, `FIOCLEX`): it loads, starts Python, finds its add-ons and the Estuary skin, creates its GUI on the `ps5` windowing system, and runs for the whole 90 s run. Without this commit it does not load. - `guest_freebsd_clocks` (from the commit) and all 125 libkernel tests pass on Windows; `python tools/check_conventions.py --base origin/main` passes. The commit applies to current `main` without changes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none to build; PS5MC also needs #4379, #4374 and #4383 to load - [x] Unblocks: PS5MC (PPSA99420), part of #3632 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 14:11:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:11:15Z.


Progress report (91ed4ce → ae9978a)

➖ System libraries: 88.04% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel clock_settime_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147500240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5183#issuecomment-6147500240). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T14:11:15Z. --- <!-- progress-report --> ### Progress report (91ed4ce → ae9978a) ➖ **System libraries**: 88.04% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `clock_settime_nid_postfix` | </details>
adriadam10 commented 2026-10-13 14:15:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:15:26Z.


Checked against FreeBSD 11.4 sys_clock_settime/kern_clock_settime: EFAULT for a null time, EINVAL for non-CLOCK_REALTIME, negative tv_sec or out-of-range tv_nsec, all match; a valid request throws and the debt entry documents it. Built and ran libs + libkernel ctest (146/146), guest_freebsd_clocks fails to link without the change and passes with it. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147584322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5183#issuecomment-6147584322). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:15:26Z. --- Checked against FreeBSD 11.4 `sys_clock_settime`/`kern_clock_settime`: EFAULT for a null time, EINVAL for non-`CLOCK_REALTIME`, negative `tv_sec` or out-of-range `tv_nsec`, all match; a valid request throws and the debt entry documents it. Built and ran libs + libkernel ctest (146/146), `guest_freebsd_clocks` fails to link without the change and passes with it. Merging once the full build is green.
github-actions[bot] commented 2026-10-13 14:19:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:19:57Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4374 docs/dev/debt/libkernel.md L168
#4379 docs/dev/debt/libkernel.md L168
#4725 docs/dev/debt/libkernel.md L168
#4968 docs/dev/debt/libkernel.md L168
#5096 core/libs/tests/GuestFreebsdClocks.cpp L6, L207, L210-211
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147684680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5183#issuecomment-6147684680). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T14:19:57Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4374 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/docs/dev/debt/libkernel.md#L168) | | | | #4379 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/docs/dev/debt/libkernel.md#L168) | | | | #4725 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/docs/dev/debt/libkernel.md#L168) | | | | #4968 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/docs/dev/debt/libkernel.md#L168) | | | | #5096 | `core/libs/tests/GuestFreebsdClocks.cpp` [L6](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/core/libs/tests/GuestFreebsdClocks.cpp#L6), [L207](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/core/libs/tests/GuestFreebsdClocks.cpp#L207), [L210-211](https://github.com/boykopovar/AnyPS5/blob/146f1715499c1f6346662cb45176ff33ec3ad445/core/libs/tests/GuestFreebsdClocks.cpp#L210-L211) | | |
p3n1cillin commented 2026-10-13 14:34:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:34:43Z.


Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, BUILD_TESTING=ON, full build of a local test head 838d4fd85. That head is main 3faa9cb40 with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including guest_system_configuration, guest_getrlimit, guest_kernel_fcntl, guest_freebsd_clocks, guest_kernel_sys and guest_filesystem. Not built alone on Linux; no title run on Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147990108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5183#issuecomment-6147990108). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:34:43Z. --- Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, `BUILD_TESTING=ON`, full build of a local test head `838d4fd85`. That head is `main` `3faa9cb40` with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including `guest_system_configuration`, `guest_getrlimit`, `guest_kernel_fcntl`, `guest_freebsd_clocks`, `guest_kernel_sys` and `guest_filesystem`. Not built alone on Linux; no title run on Linux.
Sign in to join this conversation.
No reviewers
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!5183
No description provided.