feat(libkernel): report the host SoC and CPU temperature #4588
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4588"
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 Nixitov on 2026-10-12T16:23:29Z.
What
Report the SoC and CPU temperature from the host, for the libkernel exports Overdrive (PPSA99058) and LZ4-Compression (PPSA99420) import:
sceKernelGetCpuTemperature(previously theUnimplemented.cppstub)sceKernelGetSocSensorTemperatureBoth titles import the sensors and stop at start-up on
main:With this change they get past both sensors.
Behaviour:
sceKernelGetCpuTemperaturereports sensor 0.hwmonandthermalentries are read in sorted order and battery/power-supply (BAT*,AC,ucsi*) and network-adapter (iwl*,mt79*,ath*,rtw*,wlan*,wifi*) devices are skipped, so the board channel does not depend on directory order. On Linux the values come from/sys/class/hwmonand/sys/class/thermal; on Windows from the ACPI thermal zones (MSAcpi_ThermalZoneTemperatureover WMI) and the storage temperature of the first physical drive that answers (StorageDeviceTemperatureProperty, read with a struct mirroringSTORAGE_TEMPERATURE_DATA_DESCRIPTOR). A sensor the host does not expose (including any id above 2) returnsEINVALand leaves the output untouched; a null output returnsEFAULT.docs/dev/debt/libkernel.md.sceKernelGetCpuFrequencyis no longer part of this PR — it landed separately in #4466, so it was dropped after the rebase.Tested
Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Linux reviewer run on Arch (Intel Core Ultra).
guest_thermal_sensorspasses: it reads a synthetichwmon/thermallayout and checks the sensor mapping, that a battery and a Wi-Fi sensor are skipped and that the GPU die becomes the SoC channel when no CPU package sensor is present, a missing directory and a null root, and theEFAULT/EINVALpaths (including that an unsupported id leaves the output untouched).sceKernelGetSocSensorTemperature(2, …)returns 36 °C, matching the drive's own SMART/Health log (GET LOG PAGE0x02, read overStorageDeviceSpecificProperty): composite temperature 309 K = 36 °C. The descriptor offsets were confirmed against the Windows SDK'sntddstor.h(InfoCountat +12,TemperatureInfo[0].Temperatureat +26, the value in Celsius) and astatic_assertpins them; the earlier code checked the warning threshold (+10), read a reserved field (+14), used the pre-2004StorageDeviceTemperaturePropertyvalue and applied a Kelvin adjustment, all now removed.half144/overdrive-releasesv0.1.4, assetOverdrive-PPSA99058.zip) and LZ4-Compression (PPSA99420,theghostonline/PS5-LZ4-Compressionv1.4.2, assetLZ4-Compression-PPSA99420.zip),eboot.binunwrapped from their SELF and relinked with the built relinker--windows: onmainthey stop atzzKyvoELf4I(sceKernelGetSocSensorTemperature). With this change they pass both sensors; afterposix_spawnlanded onmainboth run to the 12-second harness timeout with no unresolved import.python tools/check_conventions.py --base origin/mainpasses.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:38:07Z.
Progress report (
2672a73→0f73f5f)📈 System libraries: 88.07% (+0.03%, +2 implemented functions)
✅ 2 implemented
sceKernelGetCpuTemperaturesceKernelGetSocSensorTemperatureImported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-12T16:52:01Z.
Thanks bot. A note on the overlaps this PR has, so you can pick whichever you prefer:
This PR implements the host CPU/thermal surface for PPSA99058 and PPSA99420, which import all three and stop at start-up on
main:sceKernelGetCpuTemperature(was theUnimplemented.cppstub)sceKernelGetSocSensorTemperaturesceKernelGetCpuFrequencySensor 0 = host CPU/package, 1 = first other, 2 = NVMe; values come from
/sys/class/hwmonand/sys/class/thermalon Linux, and from the ACPI thermal zones (MSAcpi_ThermalZoneTemperatureover WMI) and the storage temperature property on Windows. A host that exposes none reports the sensor as unsupported. Verified on Windows: the two titles get past all three and stop atposix_spawn_file_actions_init;guest_thermal_sensorspasses.Overlaps:
sceKernelGetCpuFrequencyalone (opened before this one). I'm happy to drop that one function here if you prefer #4466 — the sensors and the frequency are independent.sceKernelGetSocSensorTemperature(opened ~3 min after this one) as part of a broad symbol-export PR. If you'd rather take that one, I can drop the sensor from here and keep only what's left.The two titles need all three, so as long as each function lands in some PR they are unblocked either way. Happy to rebase or split on request.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T17:18:55Z.
Heads-up on the overlap the bot flagged: #4466 also exports
sceKernelGetCpuFrequency, for PS5SX2 (PPSA99203). It returns the host TSC rate thatsceKernelGetTscFrequencyalready measures, where this PR reads the host's nominal clock. PS5SX2 only prints the value at start-up, so either definition gets it past the import. Whichever PR merges second should drop its copy, and I'll do that on #4466 if this one lands first.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-12T18:53:51Z.
Thanks @babyhuey — agreed, and that's a clean plan.
sceKernelGetCpuFrequencyfrom this PR (and keep the two sensors).Same arrangement stands for #4592 and
sceKernelGetSocSensorTemperature: whichever merges first, the other drops its copy. Either way PS5SX2 / PPSA99058 / PPSA99420 are unblocked.For reference, this PR's
sceKernelGetCpuFrequencyreads the host's nominal clock (the~MHzregistry value on Windows, cpufreq sysfs //proc/cpuinfoon Linux), so if #4466's TSC-rate definition is preferred for PS5SX2 I'm happy to leave it to #4466.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:40:25Z.
Review: CHANGES_REQUESTED
Thanks for the PR. Two things to fix before this can merge:
sceKernelGetCpuFrequencyis already onmainsince #4466 (core/libs/prx/libkernel/Time/Time.cpp, returns the TSC ratesceKernelGetTscFrequencyreports, pinned byGuestCurrentCpu.cpp). Keeping this copy exports the symbol twice. As agreed with @babyhuey, please drop it fromThermalSensors.cpp, the test and TechnicalDebt (includingHostCpuFrequencyHzand the cpufreq/registry code), and keep the two sensors.main: TechnicalDebt entries now live indocs/dev/debt/libkernel.md(thesceKernelGetCpuTemperatureline is there, at the "imported by PPSA99902" entry). Rebase and move your line there, in the section where the old one was, not at the end.Also: #4592 (open) adds a throwing
sceKernelGetSocSensorTemperaturestub inUnimplemented.cpp. Whichever lands second must drop its copy; if #4592 lands first, remove the stub there when you rebase.Windows-only paths (WMI,
IOCTL_STORAGE_QUERY_PROPERTY) and the title start-ups remain untested on our side; the Windows CI job isn't run automatically, so please re-run your local Windows test after the rebase.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T04:09:18Z.
Runtime update, 2026-10-13: Before #4588, fresh PPSA99902 conversion on integration f1a3/main068 stops at unresolved
zzKyvoELf4Iafter 0.034 s (0xC0000139). With merged #4588 in a353/main021, that import-binding failure is absent; startup reaches the multisample-DCC graphics refusal after 32.560 s. The diagnostic replay confirms normal-render Mode 1, 8 samples, DCC enabled (31.577 s). Both post-merge runs restore originals/runtime/guest/user data with no cleanup errors.Adapted integration native validation: full build/checks, 18 selected groups x5 under both requested NVIDIA GPL modes (including CPU thermal tests), full NVIDIA 1092 passed / 0 failed / 8 skipped of 1100, max 24.3817 s. This confirms the title's import-binding prerequisite is resolved; it does not demonstrate sensor-call execution, host/console temperatures or units. No duplicate sensor PR. Earlier static caller evidence below retains its original scope.
Exact-main unit refresh (2026-10-16): the original
guest_thermal_sensorsfixture builds and passes 5/5 on main5d9dcc42d2ec5401aebd089028b8d4d7410a77b4on Windows 11 / WinLibs GCC 15.2 r7 (maximum 0.44 s) and Ubuntu 24.04 WSL2 / GCC 13.3 (0.01 s). Source and fixture include the post-merge changes; no local code fix. These checks cover synthetic sensor parsing/classification and unavailable/error output preservation, not accurate console sensor mapping or a new title run. The old bring-up backlog's "CPU temperature still refuses" statement has been corrected in place.Earlier static caller evidence
Additional static caller evidence from Sonic Unleashed Recompiled PPSA99902 01.003.000 for
zzKyvoELf4I(sceKernelGetSocSensorTemperature):0x29a5212passes sensor 0 in EDI and a stack output pointer in RSI.0x29a5372passes R14D, in a loop initialized to 1, incremented until 16: IDs 1–15.INT_MIN; immediately after the call the code checks the output against the accepted range 1–150, rather than testing the return code. This makes preserving the output on unsupported IDs relevant. Your fixture already checks ID3's error; checking that a sentinel remains unchanged for ID3 and ID15 would cover the unsupported part of this observed loop more directly.I rechecked the argument/loop instruction bytes against the original ELF today (SHA256
c34f5b0848ef49e96a855076d8254254047e966e4fe56589d0e504fe13828479), using independently decoded assembly, not inferred Ghidra names. These are potential telemetry calls, not demonstrated execution or a startup blocker in our run. They do not establish console sensor meanings, temperature units or correctness of the proposed host mapping. At the time of this earlier static check I had not built/tested the PR; later validation is recorded above. No duplicate sensor contribution planned.AI-assisted investigation/reporting: Codex. No game assets attached.
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T05:56:50Z.
Linux test (Arch, GCC 16.2.1, Release, Dell XPS 16 with an Intel Core Ultra), this PR merged onto
main7e181fcc3:guest_thermal_sensorspasses.ReadThermalSensors_nid_no_patch("/sys/class")from the builtlibkernel.prxgives a sane CPU value (coretemp) and storage value (nvme).The SoC value is the problem. It is the first
hwmonentry that is not CPU or NVMe, indirectory_iteratororder, which is unsorted. This laptop'shwmonentries with atemp1_input:and
/sys/class/hwmonlists them ashwmon8 hwmon6 hwmon4 hwmon2 hwmon0 hwmon9 hwmon7 hwmon5 hwmon3 hwmon1. So the "SoC" is the Dell embedded controller's sensor, the Wi-Fi card (iwlwifi_1) or the battery (BAT0), depending on that order and on which drivers are loaded. With a copy of the samename/temp1_inputfiles:soc= the Wi-Fi card's temperature;dell_ddv,dell_smmandiwlwifientries (a laptop without those drivers):soc= 31, the battery.A suggestion: skip
hwmondevices that are power supplies (BAT*,AC*,ucsi_source_psy_*; they have adevice/typeofBattery/Mains/USB, or sit underpower_supply) and network adapters (iwlwifi*and similar), sort the entries so the pick is stable, and fall back to the CPU package temperature (coretemp/x86_pkg_temp) for the SoC, since the PS5's SoC is the APU that holds the CPU. A GPU sensor (amdgpu'sedge,xe/i915) would be the other natural choice.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T07:38:08Z.
Review: CHANGES_REQUESTED
Thanks for dropping
sceKernelGetCpuFrequency. Remaining points:core/libs/prx/libkernel/System/src/ThermalSensors.cpp:62-73: the "other" sensor (id 1) is the firsthwmonentry that is not CPU or NVMe, indirectory_iteratororder, which is unsorted. @nicolasfalesy measured on Linux that it ends up being the battery, the Wi-Fi card or the embedded controller depending on order and loaded drivers. Please sort the entries so the pick is stable, skip power supplies (BAT*,AC*,ucsi_source_psy_*) and network adapters (iwlwifi*), and prefer a SoC-like sensor (GPUedge, or the CPU package) as the fallback.core/libs/tests/GuestThermalSensors.cpp: add a case where the layout has several non-CPU/NVMe entries (a battery plus another one) in a non-alphabetical directory order and pin which one is picked, and check that*outkeeps a sentinel for unsupported ids (3 and 15), as @Amoenus noted the title checks the output rather than the return code.maininUnimplemented.cpp(thesceKernelGetCpuTemperaturestub sits next to new lines); please rebase and rerunguest_thermal_sensors.Build and
guest_thermal_sensorspass here on the PR head. The Windows paths (WMI, storage IOCTL) were not run.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:00:10Z.
Thanks — you were right: the board channel was whichever entry
directory_iteratorhappened to yield first, so it could land on a battery, an EC sensor or the Wi-Fi card. The pick is now deterministic and role-based:hwmonandthermalentries are sorted before use.BAT*,AC,ACAD*,ucsi*) and network adapters (iwl*,mt79*,ath*,rtw*,wlan*,wifi*) are skipped by name.coretemp/k10temp/zenpower/*cpu*), falling back to the GPU die (amdgpu/i915/xe/radeon/nvidia) since the PS5 SoC is the APU; sensor 1 = the first remaining board/ambient sensor; sensor 2 = NVMe.x86_pkg_temp/cpu-thermal) and sensor 1 (acpitzetc.).guest_thermal_sensorsnow builds a layout withamdgpu,BAT0andiwlwifi_1and asserts the SoC channel is the GPU die while the battery and Wi-Fi entries are ignored. Thanks for the Linux run and the concrete suggestion.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:00:12Z.
Thanks — I read the title's usage the same way: the output is set to
INT_MINand then validated against 1..150 rather than keying off the return code, so an unsupported id must not touch it.sceKernelGetSocSensorTemperaturevalidates the id (< 0 || >= 3→EINVAL) before it reads or writes, and an id the host does not actually expose also returnsEINVALwithout assigning*outCelsius. The test now asserts that explicitly with a sentinel — id 15, and id 0 when the host exposes nothing — so the loop over 1..15 keeps seeing the untouchedINT_MINand treats those sensors as absent, which is the intended behaviour.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:06:36Z.
Review: CHANGES_REQUESTED
Thanks for the update; the sorted, role-based pick on Linux looks good. Remaining points:
core/libs/prx/libkernel/System/src/ThermalSensors.cpp:200-201:ReadStorageTemperaturereads the wrong offsets ofSTORAGE_TEMPERATURE_DATA_DESCRIPTOR(docs).Version/Sizeare 4 bytes each, thenCriticalTemperature(+8),WarningTemperature(+10),InfoCount(+12),Reserved0[2](+14),Reserved1[2](+16), andTemperatureInfo[0]starts at +24 (IndexWORD,TemperatureSHORT at +26). The code checks +10 (the warning threshold) as if it were the count and reads +14 (reserved, zero) as the temperature, so a drive that answers would report 0 °C as sensor 2. Please checkInfoCountat +12 and readTemperatureat +26 (astructmirroring the descriptor would also makereturnedbounds checks clearer), and requirereturned >= 28.ThermalSensors.hpp:4-6and the inline// StorageDeviceTemperatureProperty,// PropertyStandardQuery,// IOCTL_STORAGE_QUERY_PROPERTY,// some drivers report tenths of KelvininThermalSensors.cpp(use named constants instead).maininUnimplemented.cpp; please rebase.Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:09:31Z.
Rebased onto current
main(thesceKernelGetCpuTemperaturestub now conflicts with thesceCoredumpWriteUserDatamove; resolved by dropping the stub) and re-verified:guest_thermal_sensorspasses,check_conventions.pyis clean, and both Overdrive (PPSA99058) and LZ4-Compression run to the 12-second harness timeout with no unresolved import on the rebased head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:10:40Z.
Review: CHANGES_REQUESTED
Thanks for the rebase. The head still has the points from the previous review (only the conflict was addressed):
core/libs/prx/libkernel/System/src/ThermalSensors.cpp:200-201:ReadStorageTemperaturereads the wrong offsets ofSTORAGE_TEMPERATURE_DATA_DESCRIPTOR.InfoCountis at +12 andTemperatureInfo[0].Temperatureat +26 (Version/Sizeare 4 bytes, thenCriticalTemperature+8,WarningTemperature+10,InfoCount+12,Reserved0[2]+14,Reserved1[2]+16,TemperatureInfo[0]+24). The code checks +10 (the warning threshold) and reads +14 (reserved), so a drive that answers would report 0 °C. Check +12, read +26, requirereturned >= 28; a struct mirroring the descriptor would make the bounds clearer.ThermalSensors.hpp:4-6and the four inline comments inThermalSensors.cpp(StorageDeviceTemperatureProperty,PropertyStandardQuery,IOCTL_STORAGE_QUERY_PROPERTY, tenths of Kelvin). Use named constants instead.The Linux side (sorted entries, power/network skipped, unsupported id leaves the output untouched) looks good.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:11:03Z.
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)core/libs/prx/libkernel/CMakeLists.txtL62core/libs/prx/libkernel/CMakeLists.txtL78core/libs/prx/libkernel/CMakeLists.txtL78Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T14:30:36Z.
Fixed all three — and the offset review led me to the real reason the path never ran.
Descriptor offsets.
ReadStorageTemperaturenow reads a struct that mirrorsSTORAGE_TEMPERATURE_DATA_DESCRIPTOR:Version,Size,CriticalTemperature,WarningTemperature,InfoCount,Reserved0[2],Reserved1[2](ULONG[2]), thenTemperatureInfo[0](Index,Temperature,OverThreshold,UnderThreshold, the three changeable flags,Reserved0,Reserved1: ULONG). The bound isoffsetof(Descriptor, information) + offsetof(Information, temperature) + sizeof(SHORT)= 28, and astatic_assertpinsInfoCountto +12 andTemperatureto +26.Temperatureis signed Celsius, so the- 273adjustment is removed.It now actually runs. The old code also queried
PropertyId = 22. In the current SDKStorageDeviceIoCapabilityPropertyis pinned to48, which renumbers everything after it, soStorageDeviceTemperaturePropertyis 52 (22 was the value before Windows 10 2004). With 22 the IOCTL returnsERROR_INVALID_FUNCTIONon every drive — that, not the hardware, is why nothing ever ran. The code now queries 52 and falls back to 22.Hardware result. On this machine (WD_BLACK SN7100, NVMe) the built
sceKernelGetSocSensorTemperature(2, &value)returns 36 °C:Independently, the drive's own SMART / Health Information log (GET LOG PAGE
0x02, read overStorageDeviceProtocolSpecificProperty) reports composite temperature 309 K = 36 °C for the same drive. (The Windows machine here exposes no ACPI thermal zone, so sensors 0 and 1 stay unsupported on it and only sensor 2 reports a value.)Comments. Removed the
ThermalSensors.hppheader comment and the four inline comments (StorageDeviceTemperatureProperty,PropertyStandardQuery,IOCTL_STORAGE_QUERY_PROPERTY, tenths of Kelvin). The values are named constants now:kStorageDeviceTemperatureProperty,kLegacyStorageDeviceTemperatureProperty,kPropertyStandardQuery,kIoctlStorageQueryProperty.check_conventions.pypasses.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:46:46Z.
Review: APPROVED
Checked on this PR merged onto main: build and the libkernel/libs tests pass on Linux, including
guest_thermal_sensors; the descriptor offsets (+12InfoCount, +24TemperatureInfo[0], +26Temperature) and property ids 52/22 match the SDK; sensor selection is sorted and skips power/network devices; unsupported ids leave the output untouched. The Windows path is covered by the full Build. Merging.