feat(libkernel): report machdep.tsc_freq from sysctlbyname #4776
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4776"
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 babyhuey on 2026-10-12T21:30:29Z.
What
sysctlbyname("machdep.tsc_freq")used to throwunsupported name machdep.tsc_freq. It now reports the TSC frequency as a 64-bit value, as FreeBSD 11'ssysctl_machdep_tsc_freqdoes. The value is the host TSC rate thatsceKernelGetTscFrequencyalready measures.OID_AUTO, so it has no fixed MIB and is only answered by name.CopyOut: a null buffer reports the 8-byte length, and a short buffer gets a truncated copy andENOMEM.EPERM. That difference is recorded indocs/dev/debt/libkernel.md.The current PS5SX2 build (PPSA99203, catalog vk-285-163) reads it into a 64-bit value at start-up. If the call fails or the value is 100 MHz or less, it measures the TSC with
rdtscitself, so it only needs the call not to throw. Its older build (vk-285-162) didn't read it.Tested
On the PR head
d39cb2c6(rebased ontomain7e181fccafter #4667 merged), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release:guest_system_configurationpasses 5/5 (--repeat until-fail:5) on both. The new check covers the length query, a read equal tosceKernelGetTscFrequency(), truncation withENOMEMand a write withEPERM.SystemConfiguration.cpporGuestSystemConfiguration.cpp.PS5SX2 vk-285-163 with
--trap-sdk-syscall-stubs(#3804):main7e181fccit starts running, then throwssysctlbyname_nid_postfix: unsupported name machdep.tsc_freq(Windows exits 0xC0000409; Linux shows the same throw). gdb on an earliermainshowedmachdep.tsc_freqis its firstsysctlbynamecall./data/PCSX2/bios. On Linux it gets past both sysctls and stops at the headlessDisplayWindowVulkan throw, as far as a headless run gets.check_conventions.pypasses.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)main)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T02:24:56Z.
Windows test: head
49b9952b7merged onto currentmain2a55cfe1e(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_system_configuration: guest_system_configuration passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-13T03:23:56Z.
Where this leads for PS5SX2 (PPSA99203, vk-285-163): with this PR and #4667 on
mainc13dc7e6, Windows 11 (RTX 3080, WinLibs GCC 15.2), it gets through its start-up and renders its frontend at 59.94 fps. It showsNo PS2 BIOS found ...and waits for the user's BIOS and games. Details are in #4850.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T06:04:58Z.
Linux test with a display (Arch, Intel Xe on Mesa 26.2.2 ANV, GCC 16.2.1, Release), head
d39cb2c62onmain7e181fcc3:guest_system_configurationpasses. PS5SX2 (PPSA99203, vk-285-163, relinked with--to-intel --trap-sdk-syscall-stubs) on plainmainthrowssysctlbyname_nid_postfix: unsupported name machdep.tsc_freq. With this PR it runs the full 60 s under Xwayland and draws its frontend: the "No PS2 BIOS found" banner and "No games in /data/PCSX2/games", the same screen as the Windows run above. So on Linux it also gets past the headlessDisplayWindowstop once a display is there.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:17:29Z.
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.
main)docs/dev/debt/libkernel.mdL140-141Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:59:08Z.
Checked the PR merged onto main:
guest_system_configurationpasses and fails without the change.sceKernelGetTscFrequencyexists, reads go throughCopyOut, the write case and the debt line are in the right place. The only red test,guest_current_cpu, is in a file this PR doesn't touch. Windows/Linux runs by @xXPBSXx and @nicolasfalesy agree; merging once the Windows build is green.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-13T20:09:08Z.
A title that needs this: PS5SX2 (PPSA99203, from the homebrew catalog) reads
machdep.tsc_freqat start-up. On Linux (Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti), onmain18c438b10it stops at 0 s:With the same
sysctlbynamechange it runs the whole 45 s run, compiling shaders and presenting frames, with no exception. I opened the same fix as #5387 without seeing this one first, so I'm closing mine in favour of this PR.AI-assisted: yes