feat(libkernel): report the clock resolutions a PS5 measured #17958
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17958"
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 AlfaRojo on 2026-11-10T01:00:09Z.
What
clock_getresandsceKernelClockGetresreported the host clock's resolution: on Windows 100 ns for the realtime clocks, the QPC tick for the monotonic ones and the clock interrupt period (15.6 ms by default) for CPU time, on Linux whatever the host'sclock_getressays. On #15725, spluton measured the rawclock_getressystem call on a PS5 (CFI-1216A, firmware 12.000.043, from a system process and a retail title process, identical answers; comment). On the same PR, xXPBSXx measured libcclock_getresfrom C in a PS5 payload process (firmware 11.60; comment): ids 3, 6, 16 to 20 and 22 to 31 return -1 withEINVALand leave the result untouched, ids 1000 andINT_MAXalso fail withEINVAL, -1 gives 1 µs and a null result returns 0 even for id 3; the values agree with #15725 where both measured. Both exports now answer as those measurements did:EINVAL, whileclock_gettime(15)succeedsEINVALlike the ids below,clock_gettime(15)unchangedEINVAL, result untouched (11.60 libc probe; not probed on 12.00)EINVAL(0x80020016fromsceKernelClockGetres), result left unwrittenINT_MAX:EINVAL(11.60)EINVAL, as #14557 made it onmainThe host-resolution helpers (
CpuTimeResolutionNanos,ProcessCpuResolutionNanos, the QPC frequency query and the POSIXclock_getresswitch) are removed. Encoded CPU clocks (bit 31) still answer as id 14, as FreeBSD 11.4'skern_clock_getresdoes for negative ids; a null result still returns 0 before the id is checked. The null result and -1 now agree with the 11.60 probe; the libkernel export itself was not measured (the probe went through the system call;clock_gettime's export differs from the system call for id 20, per #16437). The debt entry indocs/dev/debt/libkernel.mdis cut to those gaps and to the host granularity the clock values keep. #15725 stays open: what ids 20 and 21 count is still unknown.Tests:
guest_freebsd_clocks(ResolutionsAreTheConsoles) checks every measured id through both exports with the exact value and an untouched errno, every id from 3 to 31 without a resolution (15 included) withEINVAL/0x80020016and an untouched result whileclock_gettime(15)still succeeds, ids 32, 100 andINT_MAXwithEINVALand an untouched result (OutOfRangeResolutionIsInvalid, formerlyUnsupportedResolutionStillThrows), and adds id 21 to the null-result ids; itsResolutionNanoshelper and the resolution checks thatResolutionsAreTheConsolesnow covers are removed.guest_cpu_time_clockschecks id 14 at 1 µs and id 15 withEINVALthrough both exports instead of accepting any sub-second value for both.guest_thread_cpu_clock(encoded CPU clocks answer as id 14) andguest_timespec_getres*(libc'stimespec_getresforwards tosceKernelClockGetres(0)) are unchanged.Tested
Windows 11 Pro (10.0.26200), WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release,
BUILD_TESTING=ON, onmain5a6eb85be8(headf4460abecd).guest_freebsd_clocks: 3 of 3 runs passed; with the test change alone against the previousTime.cppit fails (clock_getres_nid_postfix: unsupported clock_id 3)guest_cpu_time_clocks: 3 of 3 runs passedguest_thread_cpu_clockpassed;guest_timespec_getres_unsupported,guest_timespec_getres_forwarding,guest_timespec_getres_errors,guest_timespec_getres_integrationpassedpublic_headerspassed (70 of 70 tests of the regression run)tools/check_test_registration.py: 0 built and not run as recorded, none new; every core/libs/prx source that defines an APS5_VABI function is compiledtools/check_conventions.py --base upstream/main: All conventions checks passed.tools/pr_overlap.pylists #12418 (moves theclock_getresbody into a helper and addsEFAULTfor an unwritable result; same function, other topic, whichever lands second resolves the conflict) and #14557 (EINVALfor ids 32 and above inclock_getres, merged since; its behaviour is kept, see the last entry) as touching the same lines ofTime.cppwith no shared exports; of the PRs it could not compare because they conflict withmain, #5021 and #12642 change other parts ofTime.cpp(clock_gettimeand the TSC exports; pthread suspend) and the rest, #14212 among them, onlydocs/dev/debt/libkernel.md; #17125 is a test-only audit in a new file. None implements the same change.Linux and macOS not run. The resolutions are constants now, so the removed host-specific code (QueryPerformanceFrequency, POSIX clock_getres) no longer matters per platform.
7bc8353088(merged with upstream/main60c460cc55, which brought #18466'sclock_gettimefor id 20; this PR leavesclock_gettime(20)as main has it and only makesclock_getres(20)returnEINVAL, as measured):guest_freebsd_clocks,guest_cpu_time_clocks,guest_thread_cpu_clock,guest_kernel_clock,guest_kernel_clocks_nanosleepand theguest_timespec_getrestests (9 tests) pass in 3/3 runs;check_test_registration.pyandcheck_conventions.py --base upstream/mainpass. Main'sWallAndUptimeClocksReportSubsecondResolutionscheck is replaced byResolutionsAreTheConsoles, which pins the same nine clocks to 81 ns.f16baf10cc(merged withupstream/mainafter #14557 landed): the only conflict wasclock_getres_nid_postfixinTime.cpp, where #14557 had addedEINVALfor ids 32 and above to the old code. The table keeps that: ids 32 and above (and any id without a measured resolution) setEINVALand return -1,sceKernelClockGetresreturns0x80020016, so the last throw inclock_getresis gone. The debt line indocs/dev/debt/libkernel.mdnow says ids 32 and above fail withEINVAL. #14557'sguest_kernel_sys_timetest merged unchanged.guest_freebsd_clocks,guest_cpu_time_clocks,guest_kernel_sys_time,guest_thread_cpu_clock,guest_kernel_clockandguest_kernel_clocks_nanosleeppass in 3/3 runs;check_test_registration.pyandcheck_conventions.py --base upstream/mainpass.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)