All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Matthew Jackson <matthew@pq.io>, qemu-devel@nongnu.org
Cc: stefanha@redhat.com, peter.maydell@linaro.org
Subject: Re: [PATCH v3 2/2] hw/misc/applesmc: populate Apple SMC key table
Date: Mon, 20 Jul 2026 10:04:16 +0200	[thread overview]
Message-ID: <6807fbd7-542c-4e94-a3c7-e29e957655c9@oss.qualcomm.com> (raw)
In-Reply-To: <20260719152343.69536-3-matthew@pq.io>

On 19/7/26 17:23, Matthew Jackson wrote:
> With APPLESMC_GET_KEY_BY_INDEX_CMD now functional (previous
> patch), the modern macOS AppleSMC kext walks the device's key
> table at boot to discover what's available. The current key
> set (REV/OSK0/OSK1/NATJ/MSSP/MSSD) is sparse enough that
> several macOS subsystems retry-poll keys they expect to find,
> contributing to the same kSMCSpuriousData traffic the previous
> patch addresses.
> 
> This patch fills the key table out to a complete iMac20,1
> profile (94 additional keys plus the canonical #KEY count).
> Sensor values match a real iMac20,1 idle probe published at:
> 
>    https://linux-hardware.org/?probe=999fc708a4&log=sensors
> 
> Categories:
> 
>    * 28 temperature sensors in sp78 format with idle readings
>      from the probe: CPU 40 C (TC0P) / 45 C (TC0F) / 51 C
>      (TCXc), GPU 36 C (TG0P) / 42 C (TG0F/TG1F/TGDD), HDD
>      41 C (TH0P/TH1C/TH1F), LCD 28-29 C (TL0V/TL1V), memory
>      34-36 C (TM0V/TM0P), ambient 24 C (TA0V), PSU 33 C
>      (Tp00/Tp2F), generic sensors 33 C (Ts*S, TS0V), VRM
>      50 C (TVMD/TVmS/TVSL/TVSR; not in the probe, conservative
>      estimate). Battery sensors (TB0T/TB1T/TB2T) are
>      present-with-zero because iMacs have no battery; macOS's
>      "absent vs broken" distinction relies on the key being
>      registered even with a zero reading.
> 
>    * 4 fan keys (FNum/F0Ac/F0Mn/F0Mx) describing iMac20,1's
>      single chassis fan: 1 fan, current 1200 RPM (= F0Mn,
>      matching the probe-reported idle), min 1200, max 3600.
>      fpe2 encoding (raw = RPM * 4, big-endian).
> 
>    * 12 power-rail keys (PC0R/PCPC/PCPG/PCPT/PfCP/PfCT/PfGT/
>      PfHT/PfM0/PfST/PSTR/PHDC) for telemetry; present-with-
>      zero satisfies macOS without claiming a specific value.
> 
>    * 6 DIMM keys (DM0P/DM0S/DM1P/DM1S/MD1R/MD1W); same
>      rationale.
> 
>    * 11 SMC-internal bookkeeping keys (CLKH/DICT/RPlt/SBFL/
>      VRTC/WKTP plus 5 lower-case Apple-private bookkeeping
>      keys cePn/cmDU/maNN/mxT1/zEPD); same rationale.
> 
>    * 13 motion-sensor / wireless keys (MSAc/MSAf/MSAg/MSAi/
>      MSGA/MSHP/MSPA/MTLV/QCLV/QENA/WIr0/WIw0/WIz0). Present-
>      with-zero is the correct desktop-class answer.
> 
>    * 3 write targets that must also be readable: HE0N (iGPU
>      power; AGPM driver writes 1 on start), MSDW, NTOK.
> 
>    * 2 power-management gates required by AGPM and the
>      watchdog probe: HE2N (dGPU power enable), WDTC.
> 
>    * 8 platform-identity / probe keys (MPRO/MPRD/LGPB/BSLN/
>      EPCI/BEMB/$Adr/RGEN/DPLM/MSSW/OSWD): VirtualSMC-style
>      identity plus the early boot-time SMC probe keys.
> 
>    * 2 GPU temperature sensors (TGDD/TG0P) and #KEY (the
>      Apple-canonical total-keys count, computed by walking
>      the data_def list at realize time).
> 
>    * 1 VirtualSMC-compatible $Num key (some drivers prefer it
>      over #KEY).
> 
> After this patch, with the protocol fix from the previous
> patch in place, a Sequoia 15.7.5 guest boots without the SMC
> retry storm:
> 
>     Metric           | Before   | After
>     -----------------|---------:|------:
>     SMC errors / 5s  |   9,225  |     2
>     kernel_task CPU  |    70 %  |  ~2 %
>     WindowServer CPU |   509 %  |  ~6 %
> 
> Legacy macOS guests (10.11-10.13) that do not iterate the
> key space see no behavioural change beyond the corrected
> MSSD value (now 0x03 as on real iMac20,1 hardware) and the
> fact that READ on a previously-unknown key returns zeros
> instead of NOEXIST.
> 
> Signed-off-by: Matthew Jackson <matthew@pq.io>
> ---
>   hw/misc/applesmc.c | 169 ++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 168 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c
> index 2b5ef3c..d11fb32 100644
> --- a/hw/misc/applesmc.c
> +++ b/hw/misc/applesmc.c
> @@ -32,7 +32,7 @@
>   
>   #include "qemu/osdep.h"
>   #include "hw/isa/isa.h"
> -#include "hw/core/qdev-properties.h"
> +#include "hw/qdev-properties.h"

Something seems wrong in your tree.


      reply	other threads:[~2026-07-20  8:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  4:01 [PATCH 0/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX iteration and populate Apple SMC key set Matthew Jackson
2026-05-07  4:01 ` [PATCH 1/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX to return real keys, accept WRITE/TYPE commands Matthew Jackson
2026-05-07  4:01 ` [PATCH 2/2] hw/misc/applesmc: populate Apple SMC key table Matthew Jackson
2026-05-07 14:27   ` Peter Maydell
2026-05-07 15:20 ` [PATCH v2 0/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX iteration and populate Apple SMC key set Matthew Jackson
2026-06-01 15:28   ` [PATCH v3 0/3] " Matthew Jackson
2026-06-01 15:28     ` [PATCH v3 1/3] hw/misc/applesmc: fix GET_KEY_BY_INDEX to return real keys, accept WRITE/TYPE commands Matthew Jackson
2026-06-01 15:28     ` [PATCH v3 2/3] hw/misc/applesmc: populate Apple SMC key table Matthew Jackson
2026-07-20  8:02       ` Philippe Mathieu-Daudé
2026-06-01 15:28     ` [PATCH v3 3/3] MAINTAINERS: adopt hw/misc/applesmc.c Matthew Jackson
2026-05-07 15:20 ` [PATCH v2 1/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX to return real keys, accept WRITE/TYPE commands Matthew Jackson
2026-05-07 15:20 ` [PATCH v2 2/2] hw/misc/applesmc: populate Apple SMC key table Matthew Jackson
2026-07-19 15:23 ` [PATCH v3 0/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX iteration and populate Apple SMC key set Matthew Jackson
2026-07-20 16:49   ` [PATCH v4 " Matthew Jackson
2026-07-20 16:49     ` [PATCH v4 1/2] hw/misc/applesmc: implement GET_KEY_BY_INDEX, WRITE and TYPE commands Matthew Jackson
2026-08-19 17:35       ` Daniel Golle
2026-07-20 16:49     ` [PATCH v4 2/2] hw/misc/applesmc: populate Apple SMC key table Matthew Jackson
2026-08-19 17:36       ` Daniel Golle
2026-08-19 17:36     ` [PATCH 0/2] hw/misc/applesmc: SMC shutdown watchdog and trace events Daniel Golle
2026-08-19 17:36       ` [PATCH 1/2] hw/misc/applesmc: Add " Daniel Golle
2026-08-19 17:36       ` [PATCH 2/2] hw/misc/applesmc: Emulate the SMC shutdown watchdog Daniel Golle
2026-07-19 15:23 ` [PATCH v3 1/2] hw/misc/applesmc: fix GET_KEY_BY_INDEX to return real keys, accept WRITE/TYPE commands Matthew Jackson
2026-07-19 15:23 ` [PATCH v3 2/2] hw/misc/applesmc: populate Apple SMC key table Matthew Jackson
2026-07-20  8:04   ` Philippe Mathieu-Daudé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6807fbd7-542c-4e94-a3c7-e29e957655c9@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=matthew@pq.io \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.