All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: "Daniel Golle" <daniel@makrotopia.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	Kane-Chen-AS <kane_chen@aspeedtech.com>,
	"jack wang" <163wangjack@gmail.com>,
	qemu-devel@nongnu.org
Subject: [PATCH 0/4] hw/misc/applesmc: Implement writes, the shutdown watchdog and get-key-type
Date: Wed, 19 Aug 2026 07:41:11 +0100	[thread overview]
Message-ID: <cover.1787114994.git.daniel@makrotopia.org> (raw)

QEMU's AppleSMC device only implements the SMC read command, so every
other command a guest issues fails with kSMCBadCommand. Tracing a macOS
guest shows it relies on two more: the write command (0x11) and
get-key-type (0x13). The missing write command delays boot (macOS retries
failed boot-time key writes) and produces a stream of
SMCWDT::setWatchdogTimer errors at shutdown; the missing get-key-type is
rejected dozens of times during boot.

This series implements what the guest actually uses, one command per
patch for reviewability:

  1/4  add trace events, so the SMC conversation can be observed with
       -trace 'applesmc*' (used to find exactly which commands and keys
       macOS issues).
  2/4  implement the write command (0x11): accept writes and return
       success, removing the boot delay and the shutdown errors.
  3/4  model the "NATi"/"NATJ"/"OSWD" keys as the SMC shutdown watchdog
       they represent, rather than silently accepting the writes: a write
       arms, refreshes or disarms a QEMUTimer whose expiry forces the
       machine down.
  4/4  implement get-key-type (0x13): give each key an SMC type and answer
       the type queries instead of rejecting them.

Traced against a macOS guest before and after: the boot-time key writes
(NTOK, MSDW, QENA, HE0N) now succeed, the shutdown "OSWD" write (a
watchdog disarm) is handled, and the get-key-type rejections become
correct replies (for example REV is reported as {rev, six bytes). The
traced guest only disarms the watchdog; the arm-and-fire path in patch 3
is the documented behaviour for a guest that arms it and was not observed
being triggered. get-key-by-index (0x12) is deliberately not implemented,
as macOS never issues it.

Daniel Golle (4):
  hw/misc/applesmc: Add trace events
  hw/misc/applesmc: Implement the write command
  hw/misc/applesmc: Emulate the SMC shutdown watchdog
  hw/misc/applesmc: Implement the get-key-type command

 hw/misc/applesmc.c   | 174 +++++++++++++++++++++++++++++++++++++++++--
 hw/misc/trace-events |  16 ++++
 2 files changed, 183 insertions(+), 7 deletions(-)


-- 
2.55.0


             reply	other threads:[~2026-08-19 12:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  6:41 Daniel Golle [this message]
2026-08-19  6:41 ` [PATCH 1/4] hw/misc/applesmc: Add trace events Daniel Golle
2026-08-19  6:41 ` [PATCH 2/4] hw/misc/applesmc: Implement the write command Daniel Golle
2026-08-19  6:41 ` [PATCH 3/4] hw/misc/applesmc: Emulate the SMC shutdown watchdog Daniel Golle
2026-08-19  6:41 ` [PATCH 4/4] hw/misc/applesmc: Implement the get-key-type command Daniel Golle
2026-08-19 13:29 ` [PATCH 0/4] hw/misc/applesmc: Implement writes, the shutdown watchdog and get-key-type Peter Maydell
2026-08-19 17:34   ` Daniel Golle

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=cover.1787114994.git.daniel@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=163wangjack@gmail.com \
    --cc=agraf@csgraf.de \
    --cc=clg@redhat.com \
    --cc=kane_chen@aspeedtech.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /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.