Repository navigation
soc: apple: sep: recover a failed Touch ID sensor registration at boot (CLEAR_STATE retry, stale-frame and stale-reply handling) - #325
Merged
Conversation
When the enclave did not register the sensor, the log said so and nothing else. Eight steps can fail on the way: an enclave refusal of REGISTER_SENSOR, REGISTER_SENSOR_SERIAL, the session share or its commit, and a failed serial read, nonce read or session exchange on the sensor side. Most of them returned false without a word, so a failure could not be told apart from any other. Name the step that failed with the enclave status or the error, and how long after the sensor was powered on. Then report what the sensor shows afterwards: its state, the patch acknowledgment, whether it presents an identifier and how long a frame it holds. The sensor data itself is never logged. The sensor_trace parameter also logs each step as it completes, with its time since power-on. The host test that runs wake_sensor() gets the new fields in its mock. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
On a profile with a nonce session, every registration identifies the sensor first: PLATFORM_IDENTITY, then REGISTER_SENSOR. The enclave state is only cleared once the bring-up stage reads ESTABLISHED. If a registration fails after REGISTER_SENSOR was accepted, the stage stays FRESH while the enclave holds the partial registration. Each retry then identified the sensor again without clearing it. On boot d1962b3a, all 42 retries over 800 s failed that way, and Touch ID stayed unusable until a reboot. Count the enclave as holding the sensor once REGISTER_SENSOR has been submitted, answered or not, since a lost or late reply does not mean the enclave did not act on it. Clear its sensor state before registering again whenever it may hold one. Restarting the bring-up from FRESH does not change that, because only CLEAR_STATE empties the enclave. Profiles without a nonce session keep their flow. The decision is a plain function, with KUnit tests for the first registration, the retry after a partial one, re-registration and the other profiles. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
A read of a sensor frame can fail on the bus in two ways. The bytes come back garbled, or the sensor does not take the frame. Either way it keeps offering the frame at the same length. Boot 0874c215 showed both: the nonce read failed its CRC, and afterwards the sensor still offered the complete 43-byte nonce frame with a valid CRC. On boot 7f0c01be the serial read succeeded but the serial frame was not taken. The nonce command that followed then waited behind it until it timed out. Check the CRC of the serial, nonce, session and challenge replies. The session and challenge replies were relayed unchecked, but they carry the same CRC; it held on every boot measured. The calibration module reply keeps its own handling. When a reply fails its CRC and the sensor still offers a frame of that length, read it again, at most twice. Before a command that expects a reply, take any stale frame the sensor still offers, so the reply is not queued behind it. Two such frames at most: if one is still on offer after that, fail the step rather than send the command, because a read does not prove the sensor took the frame. Report both, since either means an exchange went wrong on the bus. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
When the bring-up at attach failed, nothing retried it until the first verify, minutes later. That verify was then refused before it touched the sensor, and gdm offered no fingerprint at login. A bring-up that fails on the bus leaves nothing a new attempt cannot undo. Each attempt power-cycles the sensor and, after a failed one, clears the enclave partial registration first. That is the same path every verify takes, and it has never failed on an idle machine. Try up to three times at attach, logging each failed attempt. A power cycle that fails ends the attempt before registration: a sensor that was not reset may still hold the session of the attempt before. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
An SBIO reply is matched to the waiting exchange by opcode alone, and an error marker is matched before the opcode is checked. The receive work reads a reply before it takes the reassembly lock. If the requester times out in between and a retry begins the same opcode, the late reply completes the retry with the earlier attempt result. Bring-up now retries the registration, so the window is real. Number the exchanges. The receive work samples the number before it reads a reply and passes it with the chunk; a chunk sampled before the current exchange began is dropped. Replies to the current exchange can only arrive after it began, since its request is sent after that. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
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.
This fixes the MacBook Neo (J700) Touch ID boot-registration failure. On the unmodified release7 kernel, 7 of 16 boots ended without Touch ID until the next reboot. With this series, every one of 104 cold boots registers Touch ID.
Root cause of the permanent failure (ours). A failed first sensor registration was retried without CLEAR_STATE, so the enclave kept the half-done registration and every retry failed. One boot made 42 retries over 800 s. The first-attempt glitch itself is a sensor frame exchange getting out of step, which happens about 1 boot in 8 and correlates with boot-time load. A retry now clears the partial registration and re-registers in about 60 ms.
Commits:
Testing on the Neo (cold boots, one-shot test kernels)
checkpatch --strictshows only the house Assisted-by and MAINTAINERS notes.🤖 Generated with Claude Code