diff --git a/Documentation/ABI/testing/sysfs-driver-apple-sep b/Documentation/ABI/testing/sysfs-driver-apple-sep index b2d673ca52ef1..8d8e231086915 100644 --- a/Documentation/ABI/testing/sysfs-driver-apple-sep +++ b/Documentation/ABI/testing/sysfs-driver-apple-sep @@ -229,6 +229,11 @@ Description: ended without publishing /dev/sep-bio, or activation failed. Neither is retried before the next boot. + absent The device tree says the machine has no + fingerprint sensor (apple,no-biometric-sensor + on the SEP node): /dev/sep-bio is not + published. The keybag, trusted keys and + /dev/sep-bio-rearm work as elsewhere. ========= ============================================ There is no read-only install: the xart_writes and diff --git a/Documentation/devicetree/bindings/soc/apple/apple,sep.yaml b/Documentation/devicetree/bindings/soc/apple/apple,sep.yaml index 1a20d2ce27eb5..2f092e2674fb0 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,sep.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,sep.yaml @@ -71,6 +71,13 @@ properties: The signed local boot policy of the running boot, added by the bootloader, for the same purpose. + apple,no-biometric-sensor: + type: boolean + description: + The machine has no fingerprint sensor for the SEP, though the SoC has + the sensor's SPI bus (a desktop without built-in Touch ID). The SEP + runs without biometrics. + status: true required: diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index 235d7a2ab3af4..2e221216a5a24 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -37,6 +37,7 @@ disp0 = &display; disp0-piodma = &disp0_piodma; nvram = &nvram; + sep = &sep; }; chosen { @@ -2087,7 +2088,21 @@ #include "t6041-j575c-usbc-dcpext2.dtsi" #include "t6041-j575c-hdmi.dtsi" -/* Not described: the SEP (no Touch ID sensor). */ +/* + * The SEP, as on the J614c and J616c: iBoot hands it over booted (ADT sep + * sepfw-booted, iop-sep,ascwrap-v6) at the t604x.dtsi addresses and + * interrupts, behind dart-sep with the same vm-base and vm-size. The sep + * alias lets the loader reserve the SEP firmware; apple_sep enables the SEP + * and its DART. The ADT has no Touch ID sensor (no spi2/mesa): spi2 and the + * sensor node stay disabled. + */ +&sep { + apple,no-biometric-sensor; +}; + +&sep_mbox { + status = "okay"; +}; /* * The PMP, as the M4 Max MacBook Pros run it. The pmp alias lets the loader diff --git a/drivers/soc/apple/diag.rs b/drivers/soc/apple/diag.rs index 9260cc09151c2..89fa23289e41e 100644 --- a/drivers/soc/apple/diag.rs +++ b/drivers/soc/apple/diag.rs @@ -48,6 +48,7 @@ extern "C" { fn sep_diag_set_sensor_result(bind: c_uint, online: bool); fn sep_diag_set_bio_published(); fn sep_diag_set_touchid(started: bool); + fn sep_diag_set_touchid_absent(); fn sep_diag_set_sensor_attach(state: c_int); fn sep_diag_set_restore(state: c_int); fn sep_diag_set_xart_guard(level: c_uint, list_loaded: bool, matching: c_int); @@ -246,6 +247,12 @@ pub(crate) fn touchid(started: bool) { unsafe { sep_diag_set_touchid(started) }; } +/// The machine has no fingerprint sensor: `/dev/sep-bio` is not published. +pub(crate) fn touchid_absent() { + // SAFETY: no preconditions; updates one word. + unsafe { sep_diag_set_touchid_absent() }; +} + /// How far the attach of the sensor got, `SEP_DIAG_SENSOR_ATTACH_*`. pub(crate) fn sensor_attach(state: registration::AttachState) { // SAFETY: no preconditions; stores one word. diff --git a/drivers/soc/apple/diag_shim.c b/drivers/soc/apple/diag_shim.c index 51453c19297f0..439d9323417f2 100644 --- a/drivers/soc/apple/diag_shim.c +++ b/drivers/soc/apple/diag_shim.c @@ -63,6 +63,7 @@ #define SEP_DIAG_TOUCHID_UNAVAILABLE 2 #define SEP_DIAG_TOUCHID_STARTED 3 #define SEP_DIAG_TOUCHID_FAILED 4 +#define SEP_DIAG_TOUCHID_ABSENT 5 /* The SEP's endpoint numbers are one byte. */ #define SEP_DIAG_MAX_EP 256 @@ -358,6 +359,9 @@ static ssize_t touchid_show(struct device *dev, struct device_attribute *attr, case SEP_DIAG_TOUCHID_FAILED: state = "failed"; break; + case SEP_DIAG_TOUCHID_ABSENT: + state = "absent"; + break; default: state = "unknown"; break; @@ -986,6 +990,15 @@ void sep_diag_set_bio_published(void) sep_diag_notify_kn(&sep_diag.touchid_kn); } +/* No sensor on this machine: /dev/sep-bio is never published this boot. */ +void sep_diag_set_touchid_absent(void) +{ + if (atomic_cmpxchg(&sep_diag.touchid, SEP_DIAG_TOUCHID_PENDING, + SEP_DIAG_TOUCHID_ABSENT) == + SEP_DIAG_TOUCHID_PENDING) + sep_diag_notify_kn(&sep_diag.touchid_kn); +} + void sep_diag_set_touchid(bool started) { int state = started ? SEP_DIAG_TOUCHID_STARTED : SEP_DIAG_TOUCHID_FAILED; diff --git a/drivers/soc/apple/dt.rs b/drivers/soc/apple/dt.rs index 02f68e36ea0ec..adebb7c189b0f 100644 --- a/drivers/soc/apple/dt.rs +++ b/drivers/soc/apple/dt.rs @@ -24,6 +24,7 @@ const DMA_RANGE_PROP: &CStr = c"apple,dma-range"; const REGISTERED_PROP: &CStr = c"apple,sep-shmem-registered-iova"; const CHOSEN_PATH: &CStr = c"/chosen"; const PREBOOT_UUID_PROP: &CStr = c"apfs-preboot-uuid"; +const NO_SENSOR_PROP: &CStr = c"apple,no-biometric-sensor"; pub(crate) struct DtNode(*mut bindings::device_node); @@ -157,6 +158,14 @@ pub(crate) fn sep_node() -> Option { DtNode::find_compatible(SEP_COMPATIBLE) } +/// Whether the board's device tree says the machine has no fingerprint +/// sensor on the SEP (`apple,no-biometric-sensor`). The SoC's sensor bus and +/// sensor node can still be described there, disabled; without this property +/// a disabled sensor node is enabled at the first open of `/dev/sep-bio`. +pub(crate) fn no_biometric_sensor() -> bool { + sep_node().is_some_and(|sep| sep.has_property(NO_SENSOR_PROP)) +} + pub(crate) fn preboot_uuid() -> Option<[u8; 16]> { // SAFETY: the path is NUL-terminated; a non-NULL result owns one node // reference, which `DtNode` releases. diff --git a/drivers/soc/apple/sbio.rs b/drivers/soc/apple/sbio.rs index 1ce3134a42653..12e58bcc1498e 100644 --- a/drivers/soc/apple/sbio.rs +++ b/drivers/soc/apple/sbio.rs @@ -2348,7 +2348,18 @@ impl SepData { } // Either one was already persisted or one has just been. diag::keybag(diag::Keybag::Present); - if let Err(e) = self.register_bio() { + // With no sensor there is nothing to enrol or match: publishing + // /dev/sep-bio would only have its first open look for one. The keybag + // above still backs the trusted keys, /dev/sep-key and the per-user + // key bags on /dev/sep-bio-rearm. + if dt::no_biometric_sensor() { + dev_info_ratelimited!( + self.dev, + "bringup: the device tree describes no fingerprint sensor; /dev/{} is not published\n", + bio::DEVICE_NAME + ); + diag::touchid_absent(); + } else if let Err(e) = self.register_bio() { dev_err_ratelimited!( self.dev, "bringup: could not publish /dev/{} after SKS became ready: {:?}\n", diff --git a/drivers/soc/apple/shim.h b/drivers/soc/apple/shim.h index 86325f940adb5..344c128b055c9 100644 --- a/drivers/soc/apple/shim.h +++ b/drivers/soc/apple/shim.h @@ -233,6 +233,7 @@ unsigned int sep_diag_sensor_bind(void); void sep_diag_set_sensor_result(unsigned int bind, bool online); void sep_diag_set_bio_published(void); void sep_diag_set_touchid(bool started); +void sep_diag_set_touchid_absent(void); void sep_diag_set_sensor_attach(int state); void sep_diag_set_restore(int state); void sep_diag_set_xart_guard(unsigned int level, bool list_loaded,