feat(libkernel): report machdep.tsc_freq through sysctlbyname #5078
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5078"
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 p3n1cillin on 2026-10-13T10:56:05Z.
What
PS5SX2 (PPSA99203, catalog release) stops right after its "starting" notification on Windows:
The caller is its boot-time clock survey (guest 0x7428E, next to its
[cpuclk] boot: measured TSC ...and[console] CPU: %llu Hzstrings). Read with gdb atsysctlbynameand disassembled, it callssysctlbyname("machdep.tsc_freq", &u64, &len = 8, NULL, 0). It uses the value when the call returns 0 and the value is above 100 MHz; otherwise it measures the TSC against its monotonic clock for 50 ms. The repository's main-boot.cpp has the other call, which also readsmachdep.tsc_freqas anunsigned long long. That one runs only whensceKernelGetCpuFrequencyreturns 0, which AnyPS5's never does.machdep.tsc_freqis FreeBSD's 64-bitsysctl_machdep_tsc_freq, present on every amd64 kernel with a TSC.sysctlbynamenow reports the host TSC frequency thatsceKernelGetTscFrequencyalready measures, because guestrdtscreads the host counter. It uses the existingCopyOut, so a null buffer gets the length 8 and a short buffer gets a partial copy andENOMEM, assysctl_handle_64does. A write, which FreeBSD would take as a new frequency, throws. The console's value is unknown; this is recorded under Unknown function info indocs/dev/debt/libkernel.md.Tested
--trap-sdk-syscall-stubs(a forbidden inline syscall), so this run used that debugging flag; no trapped instruction was reached. Before, it stops as above within 1 s. After, it runs for the whole 90 s run and keeps rewriting itsdata/PCSX2/ps5sx2-alive.txtheartbeat; nothing else reached was checked.guest_system_configuration: the length query, the value (nonzero and equal tosceKernelGetTscFrequency, witherrnountouched), a 4-byte buffer (ENOMEM, 4 bytes copied, the rest untouched) and a throwing write. All 124 libkernel tests pass on Windows; Linux was not built locally.python tools/check_conventions.py --base origin/mainandtools/pr_overlap.pypass.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)--trap-sdk-syscall-stubs🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T11:59:08Z.
Linux run of this change: Ubuntu in WSL2, GCC 15.2.0, Ninja Release,
BUILD_TESTING=ON, full build. Built from a local integration heada14a49d8d, which ismain5d50886eewith this PR and my other open library PRs merged (#5013, #5009, #5061, #5078, #5098; no conflicts). All 121 libkernel tests and all 68 libc tests pass, includingguest_system_configuration,guest_getrlimitandguest_select. Not run alone on Linux; no title run on Linux.Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T12:48:30Z.
Tested on Linux x86-64 (Release build), with
46f3d779echerry-picked onto main14036cb0e:guest_system_configurationpasses.SystemConfiguration.cppand the PR's test it aborts withsysctlbyname_nid_postfix: unsupported name machdep.tsc_freqIt also cherry-picks cleanly together with #5098, which edits the same files.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T01:13:51Z.
Closing: same change as #4776, which came first and is now merged. Reopen if something here is still missing on current main.
Pull request closed