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(+)
--
2.55.0