From 5088a3c77c49d267bac4049101e6e05b26ea21fe Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:35:32 +1100 Subject: [PATCH 1/2] soc: apple: sep: select the platform profile by SoC On T8122, T6040, T6041, T6050, T8132 and T8142 the SEP profile was chosen only for the boards it had been tried on (J613, J615, J614s, J616s, J614c, J616c, J714s, K116s, J716c, J713, J715, J813, J815). Every other board with the same SoC got no profile, and so no SEP and no Touch ID, although each profile holds only SoC facts: the SEP's shared memory and handshake, its DART window, and the SPI controller the SoC wires to the sensor. Select by the SoC compatible, as T8103, T8112, T6000/T6001, T6020/T6021 and T8140 already are. A board without a built-in sensor has nothing on that bus: the sensor probe finds no part and the SEP runs without biometrics, as on the M1 and M2 Mac minis. A device tree that does not describe the SEP at all (the T8142 J704 has no apple,sep node yet) now gets no profile, so module init keeps saying the SEP stays disabled instead of failing on the missing node. The KUnit selection test now checks that the board compatible does not matter, and the Touch ID list covers the boards this admits. The profiles were written by Scott Jones (T8122), Michal S. (J614s), Artyom Astafurov and Jos Dehaes (T6041), Diljit Singh (T6050), Jens Axboe (K116s), Erik Bourget (J713, J716c) and Nick (T8142). Fixes: 64ff4f1a3f3ec ("soc: apple: sep: add a T8122 (MacBook Air M3) platform profile") Signed-off-by: Ryan Murray --- drivers/soc/apple/profile.rs | 72 +++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/soc/apple/profile.rs b/drivers/soc/apple/profile.rs index 87904639a780f..e8f95db553301 100644 --- a/drivers/soc/apple/profile.rs +++ b/drivers/soc/apple/profile.rs @@ -648,8 +648,12 @@ fn t6020_profile() -> &'static PlatformProfile { /// Select the profile for the running machine. An unsupported SoC is refused /// rather than guessed at, so the driver cannot run a handshake with the wrong -/// geometry. +/// geometry. A device tree that does not describe the SEP (no `apple,sep` +/// node) gets no profile either: there is nothing to enable or bind. pub(crate) fn detect() -> Result<&'static PlatformProfile> { + if crate::dt::sep_node().is_none() { + return Err(ENODEV); + } select(&machine_has, &t6020_profile) } @@ -692,30 +696,31 @@ fn select( if has(b"apple,t8112") { return Ok(&T8112); } - // Only the boards whose ADTs were read: the other T8122 Macs (J433, J434, - // J504) share the SoC but their sensor wiring is unchecked. - if has(b"apple,t8122") && (has(b"apple,j613") || has(b"apple,j615")) { + // Every profile below is SoC facts: the SEP, its DART window and + // handshake, and the SPI controller the SoC wires to the Touch ID + // sensor. They hold on every board with the SoC, as they do for the + // SoCs above. Whether a board has a built-in sensor is not decided here: + // a sensor node the board's device tree describes is used as it is, and + // a board without a sensor (a Mac mini, Studio or iMac) has nothing on + // that bus, so the sensor probe finds no part and the SEP runs without + // biometrics, as on the M1 and M2 Mac minis. + if has(b"apple,t8122") { return Ok(&T8122); } - // The T6040 profile is tested on J614s and J616s. - if has(b"apple,t6040") && (has(b"apple,j616s") || has(b"apple,j614s")) { + if has(b"apple,t6040") { return Ok(&T6040); } - if has(b"apple,t6041") && (has(b"apple,j616c") || has(b"apple,j614c")) { + if has(b"apple,t6041") { return Ok(&T6041); } - if has(b"apple,t6050") - && (has(b"apple,j714s") || has(b"apple,k116s") || has(b"apple,j716c")) - { + if has(b"apple,t6050") { return Ok(&T6050); } - // Only the M4 MacBook Airs: the other T8132 Macs are unread. - if has(b"apple,t8132") && (has(b"apple,j713") || has(b"apple,j715")) { + if has(b"apple,t8132") { return Ok(&T8132); } - // The J815 and the J813, whose ADTs were read: both have the sensor (mesa) on spi2 - // at 0x3a5108000. - if has(b"apple,t8142") && (has(b"apple,j815") || has(b"apple,j813")) { + // The J815 and J813 ADTs have the sensor (mesa) on spi2 at 0x3a5108000. + if has(b"apple,t8142") { return Ok(&T8142); } Err(ENODEV) @@ -781,28 +786,34 @@ mod tests { select(&has, &|| &T6020).ok().map(|p| p.name) } + /// The profile follows the SoC compatible alone; the board compatible + /// next to it changes nothing. #[test] - fn t8132_selection_is_limited_to_the_m4_airs() { + fn selection_follows_the_soc() { assert_eq!(picked(&[b"apple,j713", b"apple,t8132"]), Some(T8132.name)); assert_eq!(picked(&[b"apple,j715", b"apple,t8132"]), Some(T8132.name)); - assert_eq!(picked(&[b"apple,j604", b"apple,t8132"]), None); - assert_eq!(picked(&[b"apple,t8132"]), None); - assert_eq!(picked(&[b"apple,j613", b"apple,t8132"]), None); - assert_eq!(picked(&[b"apple,j713", b"apple,t8122"]), None); + assert_eq!(picked(&[b"apple,j604", b"apple,t8132"]), Some(T8132.name)); + assert_eq!(picked(&[b"apple,t8132"]), Some(T8132.name)); + assert_eq!(picked(&[b"apple,j713", b"apple,t8122"]), Some(T8122.name)); assert_eq!(picked(&[b"apple,j613", b"apple,t8122"]), Some(T8122.name)); + assert_eq!(picked(&[b"apple,j504", b"apple,t8122"]), Some(T8122.name)); assert_eq!(picked(&[b"apple,j700", b"apple,t8140"]), Some(T8140.name)); assert_eq!(picked(&[b"apple,j616s", b"apple,t6040"]), Some(T6040.name)); - assert_eq!(picked(&[b"apple,t6040"]), None); assert_eq!(picked(&[b"apple,j614s", b"apple,t6040"]), Some(T6040.name)); + assert_eq!(picked(&[b"apple,j773s", b"apple,t6040"]), Some(T6040.name)); + assert_eq!(picked(&[b"apple,t6040"]), Some(T6040.name)); assert_eq!(picked(&[b"apple,j616c", b"apple,t6041"]), Some(T6041.name)); assert_eq!(picked(&[b"apple,j614c", b"apple,t6041"]), Some(T6041.name)); - assert_eq!(picked(&[b"apple,t6041"]), None); - assert_eq!(picked(&[b"apple,j713", b"apple,t6041"]), None); + assert_eq!(picked(&[b"apple,j713", b"apple,t6041"]), Some(T6041.name)); assert_eq!(picked(&[b"apple,j714s", b"apple,t6050"]), Some(T6050.name)); assert_eq!(picked(&[b"apple,k116s", b"apple,t6050"]), Some(T6050.name)); assert_eq!(picked(&[b"apple,j716c", b"apple,t6050"]), Some(T6050.name)); - assert_eq!(picked(&[b"apple,j716c", b"apple,t6041"]), None); - assert_eq!(picked(&[b"apple,t6050"]), None); + assert_eq!(picked(&[b"apple,j716s", b"apple,t6050"]), Some(T6050.name)); + assert_eq!(picked(&[b"apple,j716c", b"apple,t6041"]), Some(T6041.name)); + assert_eq!(picked(&[b"apple,j813", b"apple,t8142"]), Some(T8142.name)); + assert_eq!(picked(&[b"apple,j704", b"apple,t8142"]), Some(T8142.name)); + assert_eq!(picked(&[b"apple,j713"]), None); + assert_eq!(picked(&[b"apple,t6002"]), None); } /// Touch ID has one path for every Mac. The retry limits, the lock @@ -813,7 +824,7 @@ mod tests { /// profile naming one of the known Mesa revisions. #[test] fn every_touch_id_mac_gets_a_sensor_the_shared_path_decodes() { - let macs: [&[&[u8]]; 16] = [ + let macs: [&[&[u8]]; 25] = [ &[b"apple,j313", b"apple,t8103"], &[b"apple,j316s", b"apple,t6000"], &[b"apple,j316c", b"apple,t6001"], @@ -826,10 +837,19 @@ mod tests { &[b"apple,j614s", b"apple,t6040"], &[b"apple,j616s", b"apple,t6040"], &[b"apple,j616c", b"apple,t6041"], + &[b"apple,j504", b"apple,t8122"], + &[b"apple,j614c", b"apple,t6041"], &[b"apple,j713", b"apple,t8132"], + &[b"apple,j715", b"apple,t8132"], + &[b"apple,j604", b"apple,t8132"], &[b"apple,j700", b"apple,t8140"], &[b"apple,j714s", b"apple,t6050"], + &[b"apple,j716s", b"apple,t6050"], &[b"apple,j716c", b"apple,t6050"], + &[b"apple,k116s", b"apple,t6050"], + &[b"apple,j704", b"apple,t8142"], + &[b"apple,j813", b"apple,t8142"], + &[b"apple,j815", b"apple,t8142"], ]; for compatibles in macs { let has = |c: &[u8]| compatibles.iter().any(|x| *x == c); From b81e61bca81de5c339c26733e7cfae18c6f28509 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 14:37:31 +1100 Subject: [PATCH 2/2] soc: apple: sep: leave the SEP off where the board keeps its mailbox disabled With the profile picked by SoC alone, select() now also returns a profile on boards whose device tree describes no usable enclave, and the warm attach then enables the SEP node and its DART at module load. Most device trees leave both disabled for that path, so their status cannot say whether a board has an enclave. The SEP mailbox's status does: the SEP cannot be reached without it, and the device tree enables it (in the board file, or in the SoC .dtsi for every board of that SoC) where the SEP is described for the machine. enable_sep_and_dart() now leaves the SEP and its DART disabled when the mailbox is disabled. From the compiled DTBs of this tree: J773s (T6040), J575c (T6041), and J714c, J716s, J775c, J775d, J873s, K114c, K114s and K116c (T6050) keep the SEP mailbox disabled, so nothing is enabled or bound there. Every board whose mailbox is enabled attaches as before. The selection KUnit test also covers J773g, J815, K114s, J316s and J413, and checks that SoCs without a profile (T6002, T6031, T8152) are refused. Signed-off-by: Ryan Murray --- drivers/soc/apple/dt.rs | 21 +++++++++++++++++++++ drivers/soc/apple/profile.rs | 20 +++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/dt.rs b/drivers/soc/apple/dt.rs index d6f83b5586235..02f68e36ea0ec 100644 --- a/drivers/soc/apple/dt.rs +++ b/drivers/soc/apple/dt.rs @@ -11,6 +11,7 @@ use kernel::prelude::*; const SEP_COMPATIBLE: &CStr = c"apple,sep"; const IOMMUS_PROP: &CStr = c"iommus"; +const MBOXES_PROP: &CStr = c"mboxes"; const STATUS_PROP: &CStr = c"status"; const STATUS_OKAY: &CStr = c"okay"; @@ -185,6 +186,16 @@ pub(crate) fn preboot_uuid() -> Option<[u8; 16]> { Some(uuid.b) } +/// Enables the SEP and its DART for a warm attach, on boards whose device +/// tree describes a usable enclave. +/// +/// Most device trees leave the SEP node and its DART `disabled` for this +/// function to enable, so their status cannot say whether a board has a +/// usable enclave. The SEP mailbox's status does: the SEP cannot be reached +/// without it, and the device tree enables it (in the board file, or in the +/// SoC .dtsi for every board of that SoC) where the SEP is described for the +/// machine. A board that keeps the mailbox disabled is left untouched and the +/// module probes nothing. pub(crate) fn enable_sep_and_dart(window: &crate::profile::DartWindow) -> Result<()> { let sep = sep_node().ok_or_else(|| { pr_err!( @@ -194,6 +205,16 @@ pub(crate) fn enable_sep_and_dart(window: &crate::profile::DartWindow) -> Result ENODEV })?; + if !sep + .parse_phandle(MBOXES_PROP, 0) + .is_some_and(|mbox| mbox.is_available()) + { + pr_info!( + "apple_sep: the device tree leaves the SEP mailbox disabled on this board; the SEP stays disabled\n" + ); + return Ok(()); + } + let dart = sep.parse_phandle(IOMMUS_PROP, 0).ok_or_else(|| { pr_err!( "apple_sep: SEP node has no '{}' phandle; cannot find its DART\n", diff --git a/drivers/soc/apple/profile.rs b/drivers/soc/apple/profile.rs index e8f95db553301..27b4b8bd99713 100644 --- a/drivers/soc/apple/profile.rs +++ b/drivers/soc/apple/profile.rs @@ -703,7 +703,10 @@ fn select( // a sensor node the board's device tree describes is used as it is, and // a board without a sensor (a Mac mini, Studio or iMac) has nothing on // that bus, so the sensor probe finds no part and the SEP runs without - // biometrics, as on the M1 and M2 Mac minis. + // biometrics, as on the M1 and M2 Mac minis. Whether a board has an + // enclave to attach to is the board device tree's call: + // `dt::enable_sep_and_dart` leaves the SEP disabled where the board keeps + // the SEP mailbox disabled. if has(b"apple,t8122") { return Ok(&T8122); } @@ -793,6 +796,8 @@ mod tests { assert_eq!(picked(&[b"apple,j713", b"apple,t8132"]), Some(T8132.name)); assert_eq!(picked(&[b"apple,j715", b"apple,t8132"]), Some(T8132.name)); assert_eq!(picked(&[b"apple,j604", b"apple,t8132"]), Some(T8132.name)); + assert_eq!(picked(&[b"apple,j773g", b"apple,t8132"]), Some(T8132.name)); + assert_eq!(picked(&[b"apple,j613", b"apple,t8132"]), Some(T8132.name)); assert_eq!(picked(&[b"apple,t8132"]), Some(T8132.name)); assert_eq!(picked(&[b"apple,j713", b"apple,t8122"]), Some(T8122.name)); assert_eq!(picked(&[b"apple,j613", b"apple,t8122"]), Some(T8122.name)); @@ -809,13 +814,26 @@ mod tests { assert_eq!(picked(&[b"apple,k116s", b"apple,t6050"]), Some(T6050.name)); assert_eq!(picked(&[b"apple,j716c", b"apple,t6050"]), Some(T6050.name)); assert_eq!(picked(&[b"apple,j716s", b"apple,t6050"]), Some(T6050.name)); + assert_eq!(picked(&[b"apple,k114s", b"apple,t6050"]), Some(T6050.name)); assert_eq!(picked(&[b"apple,j716c", b"apple,t6041"]), Some(T6041.name)); assert_eq!(picked(&[b"apple,j813", b"apple,t8142"]), Some(T8142.name)); + assert_eq!(picked(&[b"apple,j815", b"apple,t8142"]), Some(T8142.name)); assert_eq!(picked(&[b"apple,j704", b"apple,t8142"]), Some(T8142.name)); + assert_eq!(picked(&[b"apple,j316s", b"apple,t6000"]), Some(T6000.name)); + assert_eq!(picked(&[b"apple,j413", b"apple,t8112"]), Some(T8112.name)); assert_eq!(picked(&[b"apple,j713"]), None); assert_eq!(picked(&[b"apple,t6002"]), None); } + /// SoCs without a profile are still refused, whatever the board. + #[test] + fn unprofiled_socs_are_refused() { + assert_eq!(picked(&[b"apple,j375d", b"apple,t6002"]), None); + assert_eq!(picked(&[b"apple,j514c", b"apple,t6031"]), None); + assert_eq!(picked(&[b"apple,j804", b"apple,t8152"]), None); + assert_eq!(picked(&[]), None); + } + /// Touch ID has one path for every Mac. The retry limits, the lock /// states, the password re-arm and the lift-gated capture read nothing /// from the profile; only the transport underneath (bus, nonce session,