Repository navigation
feat(libkernel): report hw.model from sysctl - #4667
Conversation
73914e8 to
ded2f40
Compare
| #include "prx/libkernel/DirectMemory/DirectMemory.hpp" | ||
| #include "prx/libkernel/KernelErrors.hpp" | ||
| #include <algorithm> | ||
| #include <cpuid.h> |
There was a problem hiding this comment.
This file is built for macOS too, including the project\u2019s macos-15 (Apple Silicon) target. Clang\u2019s bundled cpuid.h explicitly errors unless __x86_64__ or __i386__ is defined, so this unconditional include breaks the arm64 macOS build before hw.model is 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.
|
Thanks, you're right: Clang's
I can't build for macOS here, so I checked the file with |
ded2f40 to
c69eb70
Compare
|
Thanks for the fix. Guarding both the |
|
Windows evidence, now that #4569 exports
One update for the newer catalog build, vk-285-163: it reads |
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:main2a5eca1 + #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 c69eb70, 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; feat(libkernel): export sceKernelInternalMemoryGetAvailableSize #4530, feat(libkernel): export sceKernelGetMainSocId, sceKernelGetCpumode and sceKernelGetCpuFrequency #4466, feat(libc): export std::overflow_error type info, vtable and destructor #4426, feat(libkernel): add setitimer on the alarm timer #3800 (setitimer), feat(libkernel): implement the JIT shared memory calls #3787, feat(libc): query filesystem statistics by guest path #4653 and feat(libSceLibcInternal): implement fdopendir #4569 have merged. The change itself builds and passes alone onmain