Repository navigation
soc: apple: sep: implement xars shutdown unmount and flush barrier - #3296
RyanTheTide wants to merge 5 commits into
Conversation
Add a typed client for the Secure Enclave xART control endpoint (xars, endpoint 0x10) that runs the orderly shutdown durability barrier from a blocking reboot notifier (SYS_RESTART, SYS_HALT, SYS_POWER_OFF) before device_shutdown(). The client registers its two-page out-of-line buffers lazily on first use and sends nothing at boot, idle, display sleep or ordinary system sleep. During an orderly shutdown, while xarm remains live to service and fsync enclave-initiated writes, the barrier sends notify_storage_unmount (op 0x0d, zero OOL bytes) followed by non-forced flush_cached_state (op 0x0c, 1-byte false payload), and closes the host xART store only after both operations succeed. The sendable command set is closed to those two lifecycle operations (no raw selector, no forced flush, no seed erasure, no userspace ABI). Any timeout, refusal or malformed reply is treated as indeterminate: the barrier does not retry blindly, does not send flush after an indeterminate unmount, keeps xarm open until teardown and allows shutdown to proceed within a 10-second total budget (5 seconds per op). Expose passive status in diag/xars and report it in aurora-sep status, with KUnit coverage for discovery, wire encoding, reply validation, tag monotonicity and all shutdown-barrier state transitions. Signed-off-by: Ryan Murray <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Resolve the remove() conflict with the HDCP client (#3256): wake both the xars and hdcp waiters. The auto-merged parts keep the hdcp and xars OOL buffers and discovery hooks side by side. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged Review items: there are no review comments or requested changes on this PR yet. It still needs one approving review from Core or Omarchy Mac. pr-text: the Risk line now says two-way, as the readiness check asked. I edited the PR body; the code is unchanged. The red CI at Conflict: one conflict, in Overlap with #3275 (attach-only endpoints): the two PRs conflict with each other in Side note, not blocking: on this branch alone, Tested at
Hardware row: the PR's code is byte-identical to |
Picks up the revert of #3302 (fca33ed), whose host-test breakage came in with the previous main merge. Signed-off-by: Ryan Murray <[email protected]>
|
Merged main again at 715556a (main fca33ed). The previous main merge brought #3302, whose host-test breakage (apple-dcp, dcpext26-startup, hardware-defaults, backlight-coldboot: undeclared Tested: |
There was a problem hiding this comment.
Verdict: Changes requested at 715556a143e2.
The claimed ten-second shutdown bound starts after begin_closing() and register_ool(), and the final close_store() takes a mutex that can wait behind a callback doing filesystem sync without consulting the deadline. The RPC wait budget therefore does not bound the blocking notifier. Please account for registration and the final drain in the shutdown contract and test a delayed trailing write. Keep the write path available until it is safe to detach the store, including when the result is indeterminate.
The ten-second barrier budget started only after begin_closing() and OOL registration, and the final store close took the store mutex with no deadline, so it could wait behind an xarm callback that is still syncing a write. The blocking reboot notifier was therefore not bounded. Take the deadline when the notifier enters the barrier. The precondition check and the final close now take the store lock with a deadline-bounded try_lock loop; OOL registration sends a control request only while its whole reply timeout still ends by the deadline; both replies keep using the remaining budget. If the store is still held at the deadline, leave it open (xarm keeps servicing) and report the barrier as not completed. Add KUnit cases for a slow closing/registration and for a trailing xarm write that outlives the budget. Signed-off-by: Ryan Murray <[email protected]>
Conflict in drivers/soc/apple/shim.h: keep both the xars and the trusted diag state definitions. Signed-off-by: Ryan Murray <[email protected]>
|
Pushed a fix for the review finding and a forward merge. New head is 461da6d.
|
There was a problem hiding this comment.
Verdict: FINISH at 461da6d
Checked: The deadline now starts at notifier entry and the final store drain has a bounded path. register_ool_by still takes the slot mutex with an unconditional lock both before the request loop and after its last reply. The timeout check around the requests cannot bound either wait. Make both acquisitions deadline-aware, or prove the shutdown path excludes competing holders, and test a delayed registration lock. The existing provenance disposition is still open.
There was a problem hiding this comment.
Verdict: MERGE at 461da6d9b6be
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Code reviewed in the earlier App review at this head (6101680648).
Follow-ups (not blocking): deadline-aware slot mutex in register_ool_by (or prove no competing holder), delayed-lock test, provenance disposition
What
Implement a typed Linux kernel driver client for the Apple Secure Enclave xART control endpoint (
xars, endpoint0x10) to run the orderly shutdown durability barrier before power-off or reboot:drivers/soc/apple/xars.rs): Discoversxarsby endpoint name ("xars") and advertised buffer layout (0x02020202, two 16 KiB pages each way) with no SoC, board, or firmware version gates. Registers out-of-line buffers lazily on first use and sends zeroxarsmessages during boot, idle, display sleep, or ordinary system sleep (s2idle/suspend).drivers/soc/apple/pm_shim.c,pm.rs,sep.rs): Registers a blocking reboot notifier (SYS_RESTART,SYS_HALT,SYS_POWER_OFF) that runs beforedevice_shutdown()while the mailbox, DART, and NVMe gigalocker handle are still live. Whilexarmcontinues servicing and fsyncing enclave-initiated writes, the barrier transmits:notify_storage_unmount(op 0x0d, 0 OOL bytes), thenflush_cached_state(op 0x0c, 1-byte0x00payload),and closes the host xART store only after both operations succeed.
ShutdownOp::{NotifyStorageUnmount, FlushCachedState}— no raw opcode selector, no forced flush, no session-seed erasure, and no userspace ABI. Any timeout, refusal, or malformed reply after submission is treated as indeterminate (no blind retry, no flush after an indeterminate unmount,xarmstays open until normal teardown, bounded by 5 s per operation / 10 s total budget so shutdown never hangs).diag/xars(Documentation/ABI/testing/sysfs-driver-apple-sep,diag.rs,diag_shim.c) and updatestools/aurora-sep/aurora-sep(status) and its unit tests.Tested
Tested:
74651281458b6e): 328/328apple_sep*tests PASS, including 11/11apple_sep_xarssubtests (discovery/layout gating, request encoding, reply validation, monotonic tag tracking, clean unmount+flush barrier, indeterminate unmount/flush handling, read-only store gating, budget exhaustion). Zero new compiler warnings.sep-source.ymlsuite): 131/131 tests PASS (plus 13/13-Opasses), includingtest_aurora_sep_status.py,test_diag_policy.py, andtest_log_ratelimit.py.J473, T8112, warm SEP boot,variant5,xart_guard=1, default cmdline, exact commit74651281458b6e): 5 consecutive reboots + 12 ss2idle(rtc1) PASS. Livenetconsoleover wired Ethernet captured all 5 shutdown barriers completing cleanly in 1-5 ms;diag/xars=ready,diag/keystore=open,diag/xarm_failures=0,diag/unhandled_messages=0,hwrng32 B, and xART gigalocker healthy (170 slots, 12 live records, max revision 566, 0 malformed, 0 duplicate, 0 repaired) on every cycle.J316s, T6000, cold SEP boot,sepos13,xart_guard=0, Touch ID active, default cmdline, exact commit74651281458b6e): 5 consecutive reboots + 12 ss2idle(rtc1) PASS.aurora-sep statusPASS (pass 27 warn 1 fail 0) on all 5 cycles; 2 enrolled Touch ID identities survived all 5 reboots (diag/touchid=ready,diag/restore=restored,diag/matching=usable),diag/xars=ready,diag/xarm_failures=0,diag/unhandled_messages=0, and xART gigalocker healthy (170 slots, 16 live records, max revision 6430, 0 malformed, 0 duplicate, 0 repaired) on every cycle.Detailed test logs and netconsole shutdown barrier captures
J473 (T8112, warm SEP boot,
xart_guard=1) — 5 reboots +s2idleLive
netconsoleshutdown captures across all 5 consecutive reboots (7.3.0-aurora-sepxars1+, commit74651281458b6e):Cycle 1
s2idle(rtcwake -d rtc1 -m freeze -s 12):Every cycle (1-5):
J316s (T6000, cold SEP boot,
xart_guard=0, Touch ID active) — 5 reboots +s2idleCycle 1-5
aurora-sep status:Cycle 1
s2idle(rtcwake -d rtc1 -m freeze -s 12):Every cycle (1-5):
Arm64 QEMU KUnit (
apple_sep*)Risk
Risk: two-way · all Macs with Apple SEP (
apple_sep) that advertisexars. Low-to-moderate (touches SEP shutdown ordering); reverting restores the previous shutdown path.SYS_RESTART,SYS_HALT,SYS_POWER_OFF), never on panic, emergency restart, or suspend. Strictly gated on endpoint discovery ("xars"with layout0x02020202) and writable xART store. Bounded by 5 s per operation / 10 s total budget; any error or timeout fails closed without retrying or hanging shutdown, and keepsxarmalive until teardown.xart_guard.Not yet
op 0x02, used by macOS only when deleting an APFS volume group) is intentionally omitted until a dedicated, explicitly gated OS-uninstall flow requires it.xarmwrite counts drained inside the barrier) is not yet exercised in this automated reboot loop; the interleavedxarm-during-barrier path is covered by KUnit and verified against the live single-threadedrx_workFIFO design.