Repository navigation
soc: apple: sep: Count sensor bring-up and frame failures; document the remaining SEP retries - #2363
Conversation
…ames The Touch ID sensor bring-up is retried at attach (five spaced attempts and a late round), before a verify (three attempts) and once more when the attach left the restored enrolment unproven. Each failed attempt is logged, but nothing counts them. A boot that needed four attempts looks the same in diag as one that needed a single attempt: sensor_attach reads "attached" in both cases. The failures themselves are real. On the J700, 7 boots in 29 needed a second attempt; on an M1 Pro, 2 in 4 lost the sensor before the attach was retried. In those attempts the sensor answers its first status reads and then falls silent part-way through the registration. Their cause is not known yet, so the retries stay. The same holds for capture frames that fail their checksum or advertise a length that cannot be a frame. The capture ends and the user is asked to touch again, which is the right recovery. A sensor whose frames keep arriving garbled still cannot be told apart from a user who keeps lifting their finger. Count both in diag: - sensor_bringup_failures: every failed attempt of every round, whether or not a later attempt brought the sensor up. - capture_frame_errors: every capture whose frame was refused for its checksum or its length. The enrol log lines for refused frames said "retrying", although the driver retries nothing itself. They now say "asking for another touch". The restore retry before a verify had its own copy of the restart rule: bring the sensor up, and if that failed, reset the stage to FRESH by hand and try again. Run it through registration::bring_up() with a two-attempt policy, registration::RESTORE, that counts on from the failed attach like the late round. On a profile without a nonce session the second attempt starts from a fresh registration, exactly as before. On a nonce-session profile retry_stage() now keeps the stage instead of forcing FRESH. That sends the same requests: such a profile identifies the sensor on every attempt, and the enclave is cleared whenever it holds the sensor, which it always does after the first attempt. The restore attempts are now logged and counted like every other round's. A verify that is cancelled between them no longer makes the second one. The ATTACH comment said the policy applied to nonce-session profiles only, but every profile has used it since commit 9c98cb5 ("soc: apple: sep: Retry the sensor attach on profiles without a nonce session"). The comment now says so, states what is known about the failure and links the tracking issue. The retry_stage() comment now says that its alternation is a hedge between two observed enclave behaviours, not a protocol step. KUnit: apple_sep_registration gains a case for the RESTORE policy and the stages its attempts start from. Link: #2322 Signed-off-by: Ryan Murray <[email protected]>
… skips Three places in the SEP driver look like a hack but are bounded or fail closed. Each now says why, and links an issue where a cause is still open. - EXCHANGE_TIMEOUT_MS (90 s) bounds two waits that end on the event itself: the EP_SKS advertisement and trusted_ready. A healthy boot never waits this long. The value comes from a J700 that advertised the key store about 43 s after boot (commit fdcf953 ("soc: apple: sep: wait for late J700 key-store discovery")). Regular-root boots now see the key store within about 2 s of attach on every Mac. Why the J700 was that slow, and whether an early initrd load still is, has not been found. Until it is, lowering the bound could break that path. The comment also points at the open issue about the trusted-key wait running inside key_construction_mutex. - KeyGrant's one retry after an outright EKEYREJECTED is not a step the protocol asks for. The operation runs where macOS runs it (after MATCH_CANCEL, before the evaluation is completed), and once more after the completion only because which point the enclave accepts has not been measured. At most one operation runs per match either way. - The xART guard skips a damaged one-time allowance and list entries that do not decode. Both fail closed. A damaged allowance grants nothing, and the file is emptied before it is read, so a later boot cannot use it either. An entry that does not decode lists nothing as Linux's, so a record it may have named stays protected. It still counts towards the list's bound and its load count. No functional change. Link: #2323 Link: #2324 Signed-off-by: Ryan Murray <[email protected]>
|
Blockers: 1.
Checked and fine:
HW row: after the fix, on this head, on the M1 Pro (J316s) and the J700. Read
Assisted-by: LLM (Claude:Opus 5.5) |
Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Both new sysfs counters promise counts since probe, but they live in the static sep_diag object and sep_diag_register() only resets trusted. A probe after another bind in the same driver lifetime can inherit stale failure counts. Please initialize the counters at the start of their documented lifetime or document and test the actual lifetime. The two zero-count boot rows establish exposure. Please also exercise a nonzero error path, and cover the nonce-session restore sequence now that it no longer unconditionally switches to FRESH on the second attempt.
sensor_bringup_failures and capture_frame_errors are documented as counts since probe, but they live in the static sep_diag object, and sep_diag_register() reset only the trusted-key state. A later bind in the same driver lifetime would have reported the earlier bind's failures. Reset both counters in sep_diag_register(), which runs before the mailbox and the sensor attach, next to the trusted-key reset. Reported by the aurora-silicon review of #2363. Signed-off-by: Ryan Murray <[email protected]>
|
Fixed in 2575740 (one commit, no force push), per the review at e031178: |
There was a problem hiding this comment.
Verdict: FINISH at 2575740
The two atomic resets in sep_diag_register() fix the stale counts at rebind. The posted zero-count boot rows predate this revision. Please exercise a nonzero failure followed by rebind and verify the count returns to zero. The nonce-session restore retry changed in this PR too. Please exercise the path that used to force FRESH on the second attempt and verify the expected session behavior.
|
On the two items from the review at 2575740:
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
A KUnit case for the diag shim: one registration on a test device, two failed bring-ups and a refused frame (the counts read 2 and 1), then a second registration in the same module lifetime, after which both read 0 and count on from there. Without the reset in sep_diag_register() it fails at the first read after the second registration. Asked for by the aurora-silicon review of #2363. Signed-off-by: Ryan Murray <[email protected]>
|
Added the agreed KUnit case in 6778a00: |
There was a problem hiding this comment.
Verdict: FINISH at 6778a00
The fixture exercises the requested nonzero-to-zero sequence, but it does so by registering two devices against the production sep_diag singleton. The second registration overwrites the first device's kernfs references without dropping them. On a KUnit-enabled Mac the test can also overwrite a real SEP device's state and notification pointers. Please exercise the reset against fixture-owned state and preserve the sysfs read assertions without touching the production singleton.
The diag shim test registered two KUnit devices against the production sep_diag singleton. The second registration overwrote the first device's kernfs references without dropping them, and on a KUnit-enabled Mac the test could overwrite a real SEP device's state. Put the two per-bind counts in their own struct sep_diag_bind_counts, with sep_diag_bind_counts_reset() (called from sep_diag_register()) and sep_diag_count_emit() (the sysfs formatting the attributes use). The test now runs the same nonzero-to-zero sequence on a fixture-owned struct, read back through sep_diag_count_emit(), and never touches sep_diag. Reported by the aurora-silicon review of #2363. Signed-off-by: Ryan Murray <[email protected]>
|
Fixed in 527de53, per the review at 6778a00: the test no longer touches the production singleton. The two per-bind counts now sit in |
There was a problem hiding this comment.
Verdict: MERGE at 527de53 after hosted and hardware validation.
Checked: the fixture owns its counters and uses the same reset and formatting helpers as production. It never registers a device or touches the live SEP singleton. Production registration still resets both counts before exposing sysfs, and each increment and read still targets its matching counter. The reported KUnit run and no-op-reset control cover the agreed sequence. Keep current-head validation outstanding.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
The sep-source host tests build diag_shim.c outside the kernel.
test_diag_policy extracts only the 'static struct { ... } sep_diag;' block,
so it lost the separately defined struct sep_diag_bind_counts.
test_diag_sensor compiles the whole file without the kernel's IS_BUILTIN()
and IS_ENABLED() macros, and broke on the KUnit include guard.
Declare the tagged struct inside the sep_diag block, with its two helpers
right after it, and guard the KUnit include with defined(CONFIG_KUNIT) &&
defined(CONFIG_APPLE_SEP_KUNIT_TEST): the same condition for this builtin
bool option.
Signed-off-by: Ryan Murray <[email protected]>
|
The hosted |
There was a problem hiding this comment.
Verdict: MERGE at c0c78ef after hosted and hardware validation.
Checked: the nested count struct preserves the existing fields and layout, the helpers move without changing their behavior, and the preprocessor guard retains the built-in KUnit and SEP test requirements. The reset fixture still uses private state. Keep the hosted rerun and current-head hardware validation outstanding.
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
What: SEP diag counts every failed Touch ID sensor bring-up attempt and every refused capture frame (new sysfs counters), and the restore-proof retry uses the shared restart rule.
Tested: J615 (M3 Air) and J473 (M2 mini) at 42ae50e, in one combined one-shot test kernel 7.3.0-aurora-dsw1 (main d8c6043 + this PR + 15 other drafts). This PR's files there are byte-identical to the current head e031178 (= 42ae50e + a clean merge of main). J615 and J473:
sensor_bringup_failures=0andcapture_frame_errors=0read back from the diag attributes. J615's sensor is attached; J473 has no built-in sensor and reportsnot-ready, as on the fleet kernel. 0 failed units, 0 WARN/BUG, one 15 s s2idle rc 0 on each.Risk: two-way · all Macs with Touch ID (new diag attributes, logs)
Not yet: a boot where the attach needs a retry, to see a non-zero counter
Evidence
git merge-treemerges of linux#2263 power: supply: macsmc: Report net discharge as discharging on every battery #2303 soc: apple: sep: Count sensor bring-up and frame failures; document the remaining SEP retries #2363 drm/apple: dcp: give each Type-C reconnect request its whole budget #2364 drm/apple: name the brightness and 180 Hz probe retry budgets and report their exhaustion #2387 drm/apple: stop the DCPLink when a start or swap ends the session #2460 drm/apple, kbuild, tools/aurora-sep: drop dead kill switches, Kconfig/Makefile leftovers and the login refresh unit #2464 btrfs: verify large data reads in parts #2493 soc: apple: display-gate: request T8122 storage by soc-device record #2682 drm/asahi: mmu: publish a binding without the VM reservation #2799 soc: apple: aop: refuse EPIC calls once the firmware has crashed #2800 soc: apple: sep: gate per-user key bags on a proven capability, not the create variant #2806 soc: apple: sep: read the pnon digest on the two-to-four-page SEPs #2810 PCI: apple: T6050: wait for the radio's port with a wait queue #2377 PCI: apple: t6050: write the gen5 shadow tunables into the 32 GT/s bank #2794 wifi: apple: centauri: T6050: don't veto s2idle for a failed or stopped N1 #2795, fleet89 config (+CONFIG_USB_BILLBOARD=m), LLVM 22.1.6 / rustc 1.97.1; build warnings are the same as main's (23 rustc dead-code warnings, all present on main).grub2-rebootone-shot, no Stage 2 or DTB change. Each Mac went back to its saved fleet kernel, the test kernel was removed, and production state was verified: saved entry, empty next_entry, Enforcing, 0 failed units.genpd_prepare -11, brcmfmac LPAS fallback), and the fleet kernel's own s2idle shows them too. On J615, dsw1's boot also had one brcmfmacring 4: r_ptr 0 outside depth 0line, not seen on 3 fleet boots. No PR in the batch touches brcmfmac.Merge main into hack/sep-retry(no conflicts).Original description
Problem
The Touch ID sensor bring-up in
drivers/soc/appleis retried in four places:registration::ATTACH, five attempts with pauses of 0.5, 1, 2 and 4 s.sbio.rsrun_late_attach.registration::VERIFY, three attempts.sbio.rsretry_restore_proof.The retries were added for real failures. On the J700, 7 boots in 29 needed a second attempt (6999914). On an M1 Pro, 2 boots in 4 lost the sensor with a single attempt (9c98cb5), and 2 in 12 failed after the session commit (73469f9). In each of those attempts the sensor answers its first status reads and then falls silent part-way through the registration. The SBIO endpoint is up and INIT_SBIO_COMMUNICATION has been accepted before any attempt, and the sensor has no power-good line, so the code shows no readiness event that the driver fails to wait for. The cause is open in #2322, which means the retries have to stay for now.
The retries also hide how often they are needed. Each failed attempt is logged, but diag only reports the final
sensor_attachstate, so a boot that took four attempts looks the same as one that took a single attempt. Capture frames refused for a bad checksum or an impossible length are not counted either.retry_restore_proof(from 01dd28c) also carried its own hand-written copy of the restart rule (reset the stage to FRESH and go again) instead of usingregistration::retry_stage.Change
Commit 1:
Documentation/ABI/testing/sysfs-driver-apple-sep. The diag ABI stays at 3, since only attributes are added.sensor_bringup_failurescounts every failed attempt of every round, whether or not a later attempt succeeded.capture_frame_errorscounts captures whose frame was refused for its checksum or its length.retry_restore_proofnow runs throughregistration::bring_upwith a two-attemptregistration::RESTOREpolicy, counting on from the failed attach the way the late round does.ATTACHandretry_stagecomments are corrected.ATTACHapplies to every profile, not only nonce-session ones. The alternating stage is a hedge between two enclave behaviours each seen on one machine, not a protocol step. Both comments link apple_sep: Touch ID sensor falls silent mid bring-up on some boots; attach and verify retries hide it #2322.Commit 2 changes comments only:
EXCHANGE_TIMEOUT_MS: both waits it bounds end on the event itself. The 90 s value comes from a J700 key store once advertised about 43 s after boot. The cause is open in apple_sep: EXCHANGE_TIMEOUT_MS is 90 s for a J700 key-store endpoint once seen at ~43 s; cause never found #2323, and the trusted-key wait underkey_construction_mutexis apple_sep: trusted-key callbacks wait up to 90 s under key_construction_mutex, and diag/keystore cannot be waited on #2313.KeyGrant's one retry after an outrightEKEYREJECTEDruns at a second call site only because it has not been measured which point the enclave accepts. That is apple_sep: touch-gated sep-key operation is tried before and after the evaluation completes; find the one the enclave accepts #2324. At most one operation runs per match either way.Every SoC the driver binds to runs the same code. Nothing changes on the wire.
retry_stagekeeps the stage instead of forcing FRESH. Those profiles identify the sensor on every attempt, and the enclave is cleared whenever it holds the sensor, which it always does after one attempt. So the requests are the same.The counters are read-only atomics.
Testing
make ARCH=arm64 LLVM=1 W=1 drivers/soc/apple/on the release arm64 config, which also builds the KUnit cases (CONFIG_APPLE_SEP_KUNIT_TEST=y):apple-sep.olinks. The warning set matches the base exactly, built the same way: 12 pre-existing Rust dead-code warnings, none indiag_shim.c.rustfmt --checkis clean onregistration.rsanddiag.rs.apple_sepsuite needs a full arm64 QEMU kernel (drivers/soc/apple/sep.kunitconfigpulls in Rust and DRM_ASAHI), which was not built here. The newapple_sep_registrationcase is underStill to run.Still to run
./tools/testing/kunit/kunit.py run --arch=arm64 --kunitconfig=drivers/soc/apple/sep.kunitconfig. Expectapple_sep_registrationto pass, includinga_restore_makes_two_attempts_the_second_from_a_fresh_registration.Hardware checks without a finger, on the J700 (MacBook Neo) and the J616s:
cat /sys/bus/platform/devices/*.sep/diag/{abi,sensor_attach,sensor_bringup_failures,capture_frame_errors}. Expect3,attached, a number (0 on a clean boot; it should match the count ofbring-up attempt N of M failedlines injournalctl -k -b), and0.journalctl -k -b | grep -E 'apple_sep.*(Touch ID: restored|bring-up attempt)'. ExpectTouch ID: restored N.fprintd-list $USER: lists the enrolled fingers.loginctl lock-session: works as before.Sites reviewed
ATTACH/VERIFY/bring_up, sbio.rs attach + late roundretry_stagealternationretry_restore_proofRESTOREthroughbring_upKeyGrantretryEXCHANGE_TIMEOUT_MSHardware rows (combined test kernel, 2026-11-20)
This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:
M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.
This PR: diag/sensor_bringup_failures and capture_frame_errors are present and read 0 on all four Macs (absent on production). Touch ID still reports restored.