fix(libkernel): answer the clock ids a PS5 measured invalid as it does #16437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16437"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by XatiX on 2026-11-06T17:38:48Z.
What
clock_gettimeandsceKernelClockGettimethrew for every clock id they do not map. This answers the ids that PS5 measurements of both exports settle, and leaves the rest throwing:EINVALfrom both exports, result left unwritten (firmware 11.60, a payload process, measured by xXPBSXx on this pull request);EINVALfrom the rawclock_gettimesystem call too (CFI-1216A, firmware 12.00, a system and a title process, #15725)EINVALbefore writing the resultEIOfrom both exports (errno5,0x80020005fromsceKernelClockGettime), result left unwrittenEIObefore writing the resultThis follows #15656, which was closed because its
EINVALhad not been measured. An earlier version of this pull request also failed 17, 18 and 20 withEINVALfrom the system call alone; the export measurements contradict that, and the code now follows them.The debt entry records what ids 20 and 21 read and closes when what they count is measured (and id 15, whose console reading left a doubt).
PlayFab Party (
Party.prxin PPSA18653) reads clock 20 at0x29be26and falls back togettimeofdaywhen the call fails. With id 20 still throwing, the title still aborts there, so this pull request does not unblock it.In
guest_freebsd_clocks,InvalidClockIdFailsGettimechecks ids -1, 999, 3, 6 and 22 to 31 through both exports (-1 withEINVAL,0x80020016fromsceKernelClockGettime, result untouched);ClockIoErrorIdschecks ids 16 to 19 through both exports (-1 witherrno5,0x80020005, result untouched);OmittedTimeIsFaultAfterClockValidationchecks that 3, 6, 22 and 31 with a null result giveEINVALand 16 and 19 giveEIOfromclock_gettime, andEFAULTfromsceKernelClockGettime, which checks the pointer first.Tested
90c86fb36aonmain1086833f9a:guest_freebsd_clocks,guest_cpu_time_clocks,guest_thread_cpu_clock, theguest_process_time*andguest_timespec_getres*tests,guest_time_conversion,guest_time_extras,guest_time_return,guest_np_common_clock,guest_nanosleep_timer_self_test,guest_mktimeandguest_strftimepass (22 of 22);guest_freebsd_clocksalone 3 of 3.tools/check_conventions.py --base upstream/main: all checks pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)clock_getres)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T23:27:08Z.
Review: COMMENTED
Read
41f70c5e1cagainstmain.Correctness. The new check runs before
ReadClockand before the copy-out, so the result is never written and a null result givesEINVAL. FreeBSD 11.4 does the same:sys_clock_gettimecopies out only whenkern_clock_gettimesucceeds (sys/kern/kern_time.c:237-239), and its default case fails unknown non-negative ids withEINVAL(:369-371). Ids 3 and 6 are unassigned in 11.4 (sys/sys/time.h:384-397), so for them the measurement and FreeBSD agree.IsCpuClockis checked first, so CPU-time clock ids are unaffected, and the id list matches the table on #15725 with nothing specific to one title.InvalidClockIdFailsGettimeaborts onmainat id 3.Debt closing condition.
docs/dev/debt/libkernel.md:372says the probe didn't call libkernel's own export, so a mapping there isn't ruled out, butCloses whenlists only ids 15, 16, 19 and 21, while the code now returnsEINVALfrom the export for 17, 18 and 20. "Closes when: ids 15, 16, 19 and 21 are measured, and libkernel's own clock_gettime export is measured for ids 16 to 21" would keep that gap open until it's measured.Open question, not a defect. On #15725 the console's libkernel is read as mapping 17 to 20 before the syscall. If so, the export here gives the syscall's answer for 17, 18 and 20; Party falls back, so this title wouldn't notice, but another caller of those ids would. Whether 17, 18 and 20 go in now or wait for the export measurement already requested there, with 3, 6 and 22 to 31 going in now, is a maintainer call.
Not run here; this is from reading the code.
AI-assisted: yes.