Add AppleT2Smc module: Apple T2 SMC over MMIO#71
Open
golirt1 wants to merge 2 commits into
Open
Conversation
On 2018-2020 Intel Macs the T2 chip intercepts the legacy SMC I/O-port protocol, so the SMC is only reachable through an MMIO window at 0xFE0B0000. This module maps that window and performs the SMC read/get-key/write handshake in kernel mode, exposing only SMC operations (no raw physical memory access). Writes are restricted by an allowlist to fan-control keys (F<n>Tg, F<n>Md, FS!). Register offsets, access widths and protocol follow the Linux T2 applesmc driver.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a module for the SMC on 2018–2020 Intel Macs with the Apple T2 chip.
On those machines the T2 intercepts the legacy SMC I/O-port protocol
(0x300/0x304), so the usual port handshake returns garbage under Windows. The T2
instead exposes the SMC through an MMIO window at physical
0xFE0B0000.The module maps that window with
io_space_mapand performs the SMCrequest/response handshake in kernel mode, exposing only SMC operations — it
never exposes raw physical memory access:
ioctl_smc_read— READ (0x10), GET_KEY_BY_INDEX (0x12), GET_KEY_TYPE (0x13)ioctl_smc_write— WRITE (0x11)Writes are restricted by an allowlist to fan-control keys only (
F<n>Tg,F<n>Md,FS!), so the module can't be used to poke arbitrary SMC state —only fan speed/mode, which is its purpose.
main()probesFNumand refuses toload (
STATUS_NOT_SUPPORTED) if the SMC doesn't respond, so it won't touch thisphysical range on non-Apple hardware.
Register offsets, access widths (control registers are 32-bit writes;
status/length/error are byte reads; the data buffer is byte-addressed), the
completion-status bit (0x20) and the exponential backoff mirror the Linux T2
applesmcdriver (MCMrARM/mbp2018-etc,applesmc_t2_kmod.c).GET_KEY_TYPE'sspecial MMIO result layout (type@0, datalen@5, flags@6) is repacked into the
conventional
[len, type, flags]form.Compiles cleanly with the repo CI. I'd appreciate a review of the access widths
and the write allowlist in particular. Thanks!