feat(libkernel): report hw.model from sysctl #4667
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4667"
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-12T18:21:00Z.
What
sysctlandsysctlbynameanswerhw.model(MIB {6, 2},CTL_HW/HW_MODEL), which used to throwunsupported name hw.model. It returns the host CPU's name, built the way FreeBSD 11 buildshw.model: the CPUID brand string (leaves 0x80000002 to 0x80000004) with leading spaces removed (identcpu.c L683-L691). Trailing padding stays, as it does there, so an AMD host's name ends in spaces.hw.ncpuandhw.physmembeside it, which already report host values. What a PS5 reports is unknown, and that is recorded in TechnicalDebt.CopyOut, so a short buffer gets a truncated copy andENOMEM, as for the other names. A write returnsEPERM.PS5SX2 (PPSA99203) reads it once at start-up and only prints it (main-boot.cpp L1937-L1945):
Where a title reaches it
PS5SX2 relinks only with
--trap-sdk-syscall-stubs(#3804), and its earlier stops are in open PRs, so it reaches this only on a stack:main2a5eca11+ #4466, #4382, #4530, #3787, #4426, #4653 and #4569 (fork branchtest/verify-hmbase).On Linux, without this PR, it runs its start-up (USB scan, HEN config,
[elevate] already root), then throws insysctlbyname; gdb shows its firstsysctlbynamecall ishw.model. With this PR (test/verify-hmtop),hw.modeland thekern.sdk_versionread after it succeed, and it goes on tosceVideoOutOpen, as far as a headless run gets.On Windows, now that #4569 exports
fdopendirfrom libSceLibcInternal, the same stack (PS5SX2 build vk-285-162) dies 3.1 s in without this PR and keeps running to the 60 s limit with it; details in the comments.Tested
On the PR head
c69eb702, 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, the MIB and name reads, truncation withENOMEMand the write withEPERM.SystemConfiguration.cpporGuestSystemConfiguration.cpp;<cpuid.h>builds cleanly under MinGW too.check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)machdep.tsc_freq, which the current PS5SX2 build reads first) for PS5SX2 to reach it; #4530, #4466, #4426, #3800 (setitimer), #3787, #4653 and #4569 have merged. The change itself builds and passes alone onmainImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T19:24:43Z.
Code review location:
core/libs/prx/libkernel/System/src/SystemConfiguration.cpp; line 5This file is built for macOS too, including the project\u2019s
macos-15(Apple Silicon) target. Clang\u2019s bundledcpuid.hexplicitly errors unless__x86_64__or__i386__is defined, so this unconditional include breaks the arm64 macOS build beforehw.modelis used. Could the include and CPUID implementation be guarded for x86, with a platform-appropriate fallback (or explicit unsupported behavior) on arm64? The current PR checks skip the full build, so they would not catch this.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T20:21:04Z.
Thanks, you're right: Clang's
cpuid.herrors on anything but x86. Fixed inc69eb702(also rebased ontomain9f8a1080):<cpuid.h>include and the CPUID code are under#if defined(__x86_64__) || defined(__i386__). Elsewhere there is no brand string, sohw.modelthrows (the host CPU has no CPUID brand string for hw.model), and the technical-debt entry now says an Apple Silicon Mac throws.CheckModelSysctland its call have the same guard, soguest_system_configurationdoesn't expect a name on arm64.I can't build for macOS here, so I checked the file with
clang++ --target=aarch64-linux-gnu -fsyntax-only. The previous head fails oncpuid.h:14: error: this header is for x86 onlyand itsasmconstraints; this one gets nocpuid.herrors. The only remaining error comes from borrowing x86 glibc headers for that check (__float128), not from this file.guest_system_configurationstill passes 5/5 on Linux (GCC 13) and Windows (WinLibs GCC 15.2) onc69eb702, with no warnings in the two files.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T20:31:37Z.
Thanks for the fix. Guarding both the
cpuid.hinclude and the CPUID implementation, with an explicit unsupported result on non-x86 hosts, addresses the arm64 compile concern I raised. The cross-target syntax check is useful; I’ll leave native macOS build confirmation to the project’s macOS job, which is currently skipped on pull requests.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T20:38:41Z.
Windows evidence, now that #4569 exports
fdopendirfrom libSceLibcInternal (f3b8ef7a). Windows 11 (WinLibs GCC 15.2),--trap-sdk-syscall-stubs, PS5SX2 catalog build vk-285-162, onmain9f8a1080+ #4382, #4530, #3787, #4653 and #4569:test/verify-sx7base536603dd): it runs its start-up ([elevate] already root,[boot] t+402 ms: elevation took 0 ms) and dies 3.1 s in with 0xC0000409, the fail-fast of the unhandledsysctlbynamethrow.test/verify-sx7539a7bbd): it keeps running to the 60 s limit, creates/data/PCSX2/covers, rewrites/data/PCSX2/ps5sx2-alive.txtand writes 15 shader-cache files. No throw.One update for the newer catalog build, vk-285-163: it reads
sysctlbyname("machdep.tsc_freq")beforehw.model. On Linux that stack now stops there first; withmachdep.tsc_freqanswered as well, it readshw.modelandkern.sdk_versionand reachessceVideoOutOpen.