Skip to content

hw/misc/applesmc: SMC shutdown watchdog and trace events

Daniel Golle qemu-devel qemu-trivial 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2hw/misc/applesmc: Add trace eventshw/misc/applesmc.c hw/misc/trace-events+24 -00 replies
2/2hw/misc/applesmc: Emulate the SMC shutdown watchdoghw/misc/applesmc.c hw/misc/trace-events+69 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] hw/misc/applesmc: SMC shutdown watchdog and trace events

These two patches are the part of my earlier AppleSMC series [1] that is not already covered by Matthew Jackson's Apple SMC v4 series [2], rebased on top of it.

Matthew's series is the more complete of the two -- besides the write and get-key-type commands (which we implemented independently) it also handles get-key-by-index and populates a full key table -- so I have dropped the overlapping patches from mine and kept only the two bits it does not cover:

1/2 trace events for the command dispatch and each handler, so the
SMC command/key conversation can be watched with -trace 'applesmc*'. This is how the exact set of commands and keys a macOS guest relies on was found in the first place.

2/2 the SMC shutdown watchdog: the "NATi"/"NATJ"/"OSWD" keys that patch
1/2 of Matthew's series accepts and discards are the watchdog macOS arms to force the machine down. Model them as a QEMUTimer that a write arms, refreshes or disarms.

Both apply on top of Matthew's v4 [2]; they touch only hw/misc/applesmc.c and hw/misc/trace-events and do not conflict with it.

Tested by booting a macOS 26 (Tahoe) guest on Matthew's v4 plus these two patches. It boots and shuts down cleanly; every SMC command the guest issues is accepted (0 rejected out of 77 in one boot+shutdown), the boot-time key writes (NTOK, MSDW, QENA, HE0N) succeed, get-key-type is answered for the 60+ keys the guest probes, and on shutdown the guest's "OSWD" write is handled as a watchdog disarm (trace_applesmc_wdt_disarm). The guest arms the watchdog only to disarm it on the way down; the arm-and-expiry path is the documented behaviour for a guest that does arm it.

[1] https://patchew.org/QEMU/[email protected]/
[2] https://patchew.org/QEMU/[email protected]/

Daniel Golle (2):
hw/misc/applesmc: Add trace events hw/misc/applesmc: Emulate the SMC shutdown watchdog

 hw/misc/applesmc.c   | 80 ++++++++++++++++++++++++++++++++++++++++++++
 hw/misc/trace-events | 13 +++++++
 2 files changed, 93 insertions(+)
Signature · 1 line
2.55.0