Skip to content

macOS: hardcoded Apple Silicon CPU temperature keys are wrong or absent on M1, M3 and M5 #3534

Closed

Description

@dbwiddis

SmcUtil.SMC_KEYS_CPU_TEMP_AS (and its FFM twin) hardcodes one list for all Apple Silicon:

{ "Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D" }

Those keys were derived from live SMC enumeration on one machine. Cross-checking against iSMC's key map — 1077 entries tagged by chip family — shows the same FourCC means different things on different chips, so a single list cannot be right everywhere.

How iSMC classifies each of our five keys

key M1 M2 M3 M4 A18 M5
Tp09 Efficiency Core 1 Perf Core 3 – Perf Core 3 Perf Cluster Aggregate 1 –
Tp0T Efficiency Core 2 – Perf Cluster 1 Perf Core 8 – –
Tp01 Perf Core 1 Perf Core 1 – Perf Core 1 Perf Core 1 –
Tp05 Perf Core 2 Perf Core 2 Perf Core 1 Perf Core 2 Perf Core 2 –
Tp0D Perf Core 3 Perf Core 4 Perf Core 2 Perf Core 4 Perf Cluster Aggregate 2 –

Presence by family: M1 5/5, M2 4/5, M3 3/5, M4 5/5, A18 4/5, M5 0/5.

Two concrete consequences

1. No CPU temperature at all on M5. Its performance cores are an entirely different key set:

Tp0O Tp0R Tp0U Tp0X Tp0a Tp0d Tp0g Tp0j Tp0m Tp0p Tp0u Tp0y

None of our five appear. The report-m5-max.txt and report-m5-pro.txt sample dumps confirm it — none of our keys are present, so every read returns 0 and getCpuTemperature() reports unavailable.

2. An efficiency-core temperature reported as the CPU temperature on M1. Tp09 is tried first and is an Efficiency Core on M1, so smcGetFirstTemperature returns it whenever it is plausible. E-cores run cooler than P-cores, so M1 readings are biased low. Same shape on M3, where Tp0T is a cluster aggregate rather than a core.

Also worth noting: iSMC commit 7e229fa reworked the M4 performance-core mapping, adding the Tp1i/Tp1m/… family and cluster sensors. Their M4 list now runs to 60 perf-core entries.

Approaches, none obviously best

  • Per-chip key tables, selected from getProcessorIdentifier(). Most accurate, but needs a new table for every chip Apple ships, and iSMC's file shows how large that gets.
  • Union of all known keys, take the max plausible reading. No chip detection, degrades gracefully because an absent key returns 0 and is rejected by the plausibility guard from Reject implausible Apple Silicon SMC temperatures #3531. "Hottest core" is also a defensible definition of CPU temperature. Costs more SMC round-trips (~0.25 ms per key measured on an M2 Max), which matters little since the value is memoized.
  • Dynamic enumeration via SMC_CMD_READ_INDEX (already implemented in oshi-demo/SmcDump.java), filtering to Tp*/Te*, cached once per JVM. Self-adapting to unreleased chips, but 2409 keys is a slow first call.
  • Config override, e.g. oshi.os.mac.sensors.cputemperature.keys. Precedent exists — Sensors#getCpuTemperature already documents oshi.os.linux.sensors.hwmon.names and ...cputemperature.types for Linux. Useful as an escape hatch alongside any of the above.

The union-plus-max option looks like the best effort/robustness trade to me, but I have only an M2 Max to verify on.

Discovered while investigating #3529; the plausibility guard in #3531 is a prerequisite for the union approach, since it is what makes reading a key that is absent or idle-gated safe.

Activity

  1. added
    bug?
    on Jul 27, 2026
  2. dbwiddis commented on Jul 27, 2026

    @dbwiddis
    MemberAuthor

    Tested the IOHIDEventSystem approach on an M2 Max (via fermion-star/apple_sensors, packaged in Issac-Lopez/mac_temp_sensor). It solves both halves of this issue, and supersedes the union-of-known-keys approach I suggested above.

    1. Sensors are self-describing — no per-chip key table

    IOHIDServiceClientCopyProperty(sc, CFSTR("Product")) returns readable names. On this M2 Max, 64 matching services:

    PMU tdie0 … PMU tdie10   (26 services)   die temperature
    PMU TP0s TP1g TP1s TP2g TP2s TP3g  (12)
    PMU tdev1 … PMU tdev8    (16)
    PMU tcal                  (2)  reads 51.9, looks like a calibration reference
    gas gauge battery         (6)
    NAND CH0 temp, noname     (2)  "noname" reads 0.0
    

    max(PMU tdie*) is a natural CPU die temperature and needs no FourCC mapping, so it should work on chips that don't exist yet. Names repeat across services (tdie1 appears 4×, most 2×), so grouping or a max is needed rather than assuming uniqueness.

    2. It has no idle-gating problem

    Same machine, same moment, genuinely idle:

    SMC (what OSHI reads today)          HID (IOHIDEventSystem)
      Tp09  6.7000   <- sentinel           PMU tdie0    38.0 .. 38.2
      Tp0T  (absent)                       PMU tdie1    38.1 .. 38.5
      Tp01  6.7000   <- sentinel           PMU tdie10   38.5 .. 38.6
      Tp05  4.6330   <- sentinel           PMU TP1g     38.3 .. 38.6
      Tp0D  4.6330   <- sentinel           PMU tdev1    36.7 .. 37.0
      getCpuTemperature() = unavailable    (all 26 tdie sensors ~38 C)
    

    The HID path reports real die temperatures exactly where the SMC reports parked sentinels. So it would also remove the "unavailable on an idle Mac" behaviour that #3531 necessarily introduced — #3531 is the correct fix for the SMC path, but this path does not need it.

    Caveats

    • Private API. <IOKit/hidsystem/IOHIDEventSystemClient.h> is not in the public SDK; IOHIDEventSystemClientCreate, IOHIDEventSystemClientSetMatching, IOHIDEventSystemClientCopyServices, IOHIDServiceClientCopyProperty, IOHIDServiceClientCopyEvent and IOHIDEventGetFloatValue all have to be hand-declared. Widely used (iSMC's hid/ package, macmon, stats) but a policy call for OSHI, and a different risk profile from the SMC path.
    • Matching page/usage may vary by chip. matching(0xff00, 5) worked here; the upstream comment says 0xff05 is the alternative and that 0xff00 is needed "for M1". Both should probably be tried, and confirmed on more hardware.
    • Needs filtering: noname (0.0) and probably PMU tcal.
    • Would need both FFM and JNA bindings.

    Next

    @dbwiddis is checking an M3 tomorrow. The useful things to capture there: whether matching(0xff00, 5) returns services or whether it needs 0xff05, and whether the PMU tdie* names appear with the same shape.

  3. dbwiddis commented on Jul 27, 2026

    @dbwiddis
    MemberAuthor

    M3 Pro results — HID sensor path confirmed

    Ran the IOHIDEventSystem probe from the handoff on an M3 Pro. Short version: it behaves the same as M2 Max on Q1–Q3, and Q4 is even more damning for the SMC-key approach than expected.

    Environment

    • Chip: Apple M3 Pro (machdep.cpu.brand_string)
    • macOS: 26.5.2
    • clang: Apple clang 21.0.0 — probe compiled clean, no warnings

    Q1 — matching pair

    matching(0xff00, 5) returned services immediately (same as M2 Max). 47 services total. 0xff05 was not needed.

    Q2 — HID sensor names (idle, with counts)

    PMU tdie1 .. PMU tdie10   (2 each = 20 services)   40.0 .. 41.7 °C
    PMU tdev1 .. PMU tdev8    (2 each = 16 services)    28.3 .. 37.0 °C
    PMU tcal                  (2)                       51.9 °C   (calibration ref — exclude)
    gas gauge battery         (6)                       27.0 .. 27.8 °C
    NAND CH0 temp             (1)                        29.0 °C
    noname                    (1)                         0.0 °C   (exclude)
    

    Differences from the M2 Max baseline:

    • No PMU tdie0 — the die sensors start at tdie1 and run to tdie10 (M2 Max had tdie0..tdie10).
    • No PMU TP* names at all (M2 Max had TP0s/TP1g/… ). So the TP* family isn't universal — a design must not depend on it.
    • Names still repeat across services (each tdie/tdev appears 2×), so a name is not a unique key — aggregate (e.g. max over PMU tdie*) as on M2 Max.

    Q3 — idle plausibility (the key check)

    PMU tdie* read 40.0–41.7 °C at idle — plausible, no sentinel collapse. Under all-core load (yes ×12) they rose to 40.4–43.8 °C. HID path is clean on M3 Pro, matching M2 Max.

    Q4 — SMC behaviour on M3 Pro

    This is the notable one. Via ismc (dkorunic/tap, v0.17.0):

    All five of OSHI's hardcoded keys are ABSENT on M3 Pro — not just 3-of-5 as the handoff predicted, but 0-of-5:

    Tp09 -> ABSENT   Tp0T -> ABSENT   Tp01 -> ABSENT   Tp05 -> ABSENT   Tp0D -> ABSENT
    

    The M3 Pro CPU keys are an entirely different set:

    CPU Performance Core 1..9   Tp06 Tp0E Tp0M Tp0c Tp0i Tp0o Tp1G Tp1S Tp10
    CPU Efficiency Core 1..5    Te06 Te0I Te0Q Te0T Te0U
    CPU Performance Cluster 1..3 Tp3P Tp3X Tp3T
    CPU Die Average TCMb / CPU Die Max TCMz
    

    At idle these read plausibly (perf cores 45–48 °C, TCMz 73 °C) and rose under load (perf cores 54–68 °C) — i.e. on M3 Pro the SMC keys that exist don't show the idle sentinel the M2 Max die sensors did; the problem here is simply that OSHI queries five keys that don't exist on this chip, so OSHI reports temperature unavailable on an M3 Pro regardless of the PR #3531 sentinel filter.

    Conclusion

    Q1–Q3 match M2 Max; the HID path is self-describing, idle-stable, and load-responsive on M3 Pro. Q4 reinforces that hardcoded FourCC keys are unmaintainable across chips (0/5 keys on M3 Pro, and per-chip meaning drift on the ones that do exist). The IOHIDEventSystem Product-name approach looks like the right direction.

    Remaining open question is the policy one flagged in the handoff: binding the private IOHIDEventSystemClient* / IOHIDServiceClient* / IOHIDEventGetFloatValue APIs (not in the public SDK, must be hand-declared) from both the FFM and JNA backends.

  4. added
    confirmed bug
    and removed
    bug?
    on Jul 27, 2026
  5. dbwiddis commented on Jul 27, 2026

    @dbwiddis
    MemberAuthor

    Proposed direction: IOHID primary, SMC aggregate keys as fallback

    After the M3 Pro results above, here's the design choice I'm leaning toward. Summarizing so it's captured before the detailed design.

    The reframe

    The scarce thing isn't keys, it's meaning — which key maps to which component on this particular silicon. The current bug (0/5 hardcoded keys exist on M3 Pro; per-chip meaning drift on the ones that do) is fundamentally a "we hardcoded meaning that varies per chip" problem. IOHID hands that meaning out for free at runtime via each sensor's Product string (PMU tdie*), generated by the OS for the exact chip you're on. That's the whole game.

    Plan

    1. Primary — IOHID. One memoized discovery of the sensor service list on first read (fits our shared-memoized-supplier pattern), matched with matching(0xff00, 5), filtered to PMU tdie*, aggregated with max. Confirmed self-describing, idle-stable, and load-responsive on both M2 Max and M3 Pro with the identical matching call — no chip detection, no config file, no key list to maintain. Names repeat (~2× per service) so we aggregate over the group rather than treat a name as a unique key.

    2. Fallback — SMC by aggregate key, not per-core enumeration. If IOHID is unavailable, prefer a single SMC-computed aggregate the firmware already provides — TCMz ("CPU Die Max"), with TCMb (average) / TCAD (package) as further fallbacks — rather than enumerating and pruning per-core keys. On M3 Pro TCMz exactly equalled the hottest performance cluster (Tp3X) at both idle and load, i.e. the SMC already computes the die-max for us. This sidesteps the entire "which core keys exist on this chip" mess that broke the current code. (Aggregate-key availability across chips still to be confirmed against iSMC's table.)

    3. Give up gracefully and report unavailable if both fail.

    What I'm explicitly not doing, and why

    Not maintaining a per-chip FourCC config table (the iSMC sensors.go approach — ~700 hand-maintained, auto-generated entries with per-platform meaning). It's the most work for the least robustness: it duplicates by hand, forever, data the OS already exposes at runtime through IOHID, and its only real value is as insurance for when IOHID is unavailable — but IOHID ships on every macOS. The failure mode it hedges (Apple changing the private API) is one where SMC FourCC meanings would likely drift too, so the table is a perpetual chase whether we maintain it or not.

    Not the "IOHID to discover, SMC to read" hybrid. PMU tdie0 (IOHID) and Tp06 (SMC) are different namespaces with no bridge, so discovering a sensor by name tells you nothing about which FourCC to read — it would need a name→key map anyway, collapsing back into the config table.

    Tradeoffs to weigh in the design

    1. The reported number changes. HID tdie reads ~40–44 °C where SMC Tp0* cores read ~60–75 °C — die diode vs. core-junction hotspot; they genuinely measure different things. Moving to HID makes OSHI report a materially lower CPU temperature than the old keys did when they worked. Defensible (die-max is a clean single "how hot is the chip" number) but a visible behavior change worth documenting — and an argument in favor of the TCMz SMC fallback, since that one is a hotspot-style max.

    2. Private-API policy. IOHID (IOHIDEventSystemClientCreate, ...SetMatching, ...CopyServices, IOHIDServiceClientCopyProperty, IOHIDServiceClientCopyEvent, IOHIDEventGetFloatValue) is undocumented and not in the public SDK — it must be hand-declared in both the FFM and JNA backends. Note the bar is already partly cleared: OSHI ships hand-declared SMC structs and calls IOConnectCallStructMethod today. IOHID is a step further out, not a new category — but it's a project-policy call, not just a technical one.

    Detailed design (binding surface for FFM + JNA, memoization/lifecycle, exact aggregation) to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions