Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
packaging/arch/t1bridge/PKGBUILD export-ignore
packaging/arch/t1bridge-dkms/PKGBUILD export-ignore
kernel/uvcvideo-t1/upstream/*.patch whitespace=-blank-at-eol,-space-before-tab
kernel/appletbdrm-t1/upstream/*.patch whitespace=-blank-at-eol,-space-before-tab
packaging/arch/libfprint-t1bridge/*.patch whitespace=-blank-at-eol,-blank-at-eof,-space-before-tab
packaging/arch/fprintd-t1bridge/*.patch whitespace=-blank-at-eol,-blank-at-eof,-space-before-tab
kernel/uvcvideo-t1/uvc_v4l2.c whitespace=-blank-at-eof
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.PHONY: quality format lint test dependency-policy platform-c \
platform-c-sanitize touchbar-hw-c touchbar-hw-c-sanitize sep-probe \
sep-probe-sanitize pam kernel packaging uvc-upstream uvc-parser \
uvc-parser-sanitize
uvc-parser-sanitize appletbdrm-resume

KDIR ?= /lib/modules/$(shell uname -r)/build

quality: format lint test dependency-policy platform-c platform-c-sanitize \
touchbar-hw-c touchbar-hw-c-sanitize sep-probe sep-probe-sanitize \
pam uvc-parser uvc-parser-sanitize kernel packaging
pam uvc-parser uvc-parser-sanitize appletbdrm-resume kernel packaging

format:
cargo fmt --all --check
Expand Down Expand Up @@ -107,5 +107,8 @@ uvc-parser-sanitize:
kernel: uvc-upstream
$(MAKE) -C kernel/dkms KDIR=$(KDIR)

appletbdrm-resume:
$(MAKE) -C kernel/appletbdrm-t1 test sanitize

packaging:
$(MAKE) -C packaging/arch/t1bridge verify
3 changes: 3 additions & 0 deletions docs/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Diagnostics are **off by default**. Enable them to investigate import, Touch ID,
boot-service, or Touch Bar failures without removing redaction. Logging observes
existing work; it adds no sensor commands, retries, unlock attempts, or resets.

For the sustained keybag failure tracked in #14, see the
[current investigation and next evidence](relay-recovery.md).

## Enable

For one CLI command, put `--diagnostics` before the command:
Expand Down
25 changes: 25 additions & 0 deletions docs/hardware-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,31 @@ Expected outcome:
- the enrolled finger still matches; and
- the Touch Bar accepts input with no stuck synthesized keys.

Record the model, kernel, complete package cohort, sleep mode, cycle count,
sleep duration, and time until each function is usable. Check camera capture,
fresh ambient-light reports, and both Touch Bar rendering and touch input in
addition to standard fingerprint verification. Repeat idle and active-device
cases only during an agreed attended test, with password recovery available.
Record host suspend failures separately; a working LCD or display blanking
alone does not prove system suspend or T1 recovery.

For the display recovery follow-up to #18, distinguish these paths:

- A successful driver rearm restores the saved framebuffer on the existing DRM
device. The hardware service need not restart or log another `display-open`.
- A failed endpoint/rearm or DRM-mode restore marks only the display interface
for deferred USB-core reprobe. Confirm the DRM remove/add event, hardware
service reopening, renderer reconnection, and a full first frame. Check that
NCM/xART, camera and Touch ID remain available without a composite reset.
- If reprobe itself fails, record the first error and unavailable function;
do not substitute manual resets or declare recovery successful.

Synthetic fault tests cover the callback's fallback request. Actual USB-core,
udev/systemd ordering and repeated attended cycles still require evidence.
Do not inject hardware failures merely to exercise this fallback. The reported
MacBookPro14,2 dark-bar failure occurred on 0.1.7; retest a build containing the
fix before attributing a successful recovery to it.

## Guarded T1 USB cycle

Run `sudo t1bridge validate usb-cycle`. The command must discover the T1 from
Expand Down
73 changes: 73 additions & 0 deletions docs/relay-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Sustained keybag relay failures

Investigation for [#14](https://github.com/standardagents/t1bridge/issues/14),
updated 2026-09-14. The native wedge remains unresolved. The restart backoff
reduces repeated failures; it does not restore the Secure Enclave's state.

## What the current evidence establishes

The [0.1.9 MacBookPro14,3 report](https://github.com/standardagents/t1bridge/issues/14#issuecomment-5643314506)
records a successful restore, then a rejected promotion (`0x0d`) after a
successful load (`0x03`). Subsequent retries reject load itself. Both failures
carry outer status -1 and no valid inner status. Earlier reports on the same
model and MacBookPro14,2 include load-first failures. This happened under
ordinary lock-screen authentication cycling without system suspend; #18 is a
separate lifecycle failure. Reported recovery after full power-off is evidence
of that occurrence, not permission for automated resets or a proven root cause.

## Source findings and limits

| Boundary | Established behavior | Still unknown |
| --- | --- | --- |
| Relay startup | `sep_keybag.c::keybag_relay_callback` reads saved material, prepares shared bags, loads and promotes the biometric bag, then initializes ACM and publishes readiness. | Whether repeated native load/promotion consumes firmware resources. |
| Authentication handoff | Existing-only authentication uses the promoted bag, verifies its secret, resolves its UUID and checks final state. | Whether a relay may reuse that bag with the same guarantees without replaying the saved blob. |
| Load rejection | No accepted source handle is returned; startup ends before promotion/readiness. | Whether the firmware allocated anything before rejecting the request. |
| Promotion rejection | Load has already returned a transient source handle. Startup ends before ACM initialization/readiness. | Whether promotion consumes that handle on success or failure; whether an explicit release is required. |
| Local teardown | `sep_operation.c::close_product_session` cleans up active ACM state, destroys transport/session state and closes the SEP descriptor; the operation lock is then released. Remote ACM deletion errors propagate through `sep_session_acm_exchange`. | Transport close is not proof that the firmware has released a loaded keybag. |

No code in the relay callback rewrites the saved blob. Cancellation still runs
cleanup; `-103` alone does not demonstrate a leaked ACM context. The failure
sequence is consistent with a problem in repeated restore/promotion but does
not prove handle exhaustion, damaged saved material, or any particular release
selector. In particular, selector numbers from host macOS APIs must not be
assumed to identify equivalent T1 relay requests.

## Regression coverage

`sep-probe/test_sep_operation.c` now injects native rejections at load and
promotion through the real session parser and operation owner. Twelve cases
cover outer and inner rejections with successful cleanup, transport-destroy
failure, or SEP-descriptor-close failure. They verify:

- no readiness publication, notification lease or native retry after rejection;
- the original saved secret/blob is unchanged and persistence is never called;
- session and descriptor/lock cleanup still run;
- the primary remote failure remains the operation result while the separate
cleanup observer reports success or teardown failure.

The synthetic transport deliberately makes no assertion about firmware handle
allocation or lifetime. These tests protect failure handling; they do not
reproduce the hardware wedge or establish a native fix.

## Next evidence and decision

The cleanup observer landed in `02885e4` after v0.1.9. The next candidate build
must contain it before requesting new affected-machine cleanup evidence. During
ordinary use on an affected machine, retain the preceding healthy round, first
rejection, subsequent retry, and the corresponding `sep-cleanup` outcomes using
the [opt-in diagnostic procedure](diagnostics.md). Share only allowlisted
stage/status, versions, timing and restart counts. A healthy cleanup outcome
narrows the local teardown question; it does not settle firmware ownership.

Before adding an unload request or skipping restore, establish the T1-specific
load/promote ownership contract from reproducible source/protocol evidence.
Reuse would additionally need to verify that the active bag belongs to the
saved material, reject mismatch/locked/unknown state, and preserve the existing
cold-boot restore path. The existing encoder accepts secret verification with
no ACM external form, but encoder support alone is not hardware validation of
that proposed relay path.

Until those conditions are met, keep the native sequence unchanged. Do not
delete keybags, re-enroll, reset the T1, or manufacture repeated authentication
cycles to test a speculative fix. Downstream lock-screen backoff can reduce
cycling; it cannot establish that the native cause is repaired.
14 changes: 13 additions & 1 deletion kernel/appletbdrm-t1/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
KDIR ?= /lib/modules/$(shell uname -r)/build

.PHONY: all clean
.PHONY: all clean test sanitize

obj-m += appletbdrm.o

Expand All @@ -9,3 +9,15 @@ all:

clean:
$(MAKE) -C $(KDIR) M=$(CURDIR) clean

test:
@set -eu; binary=$$(mktemp); trap 'rm -f "$$binary"' EXIT; \
$(CC) -O2 -std=c17 -Wall -Wextra -Wpedantic -Werror \
test_appletbdrm_resume.c -o "$$binary"; "$$binary"

sanitize:
@set -eu; binary=$$(mktemp); trap 'rm -f "$$binary"' EXIT; \
gcc -O1 -g -std=c17 -Wall -Wextra -Wpedantic -Werror \
-fno-omit-frame-pointer -fno-sanitize-recover=all \
-fsanitize=address,undefined test_appletbdrm_resume.c \
-o "$$binary"; "$$binary"
24 changes: 23 additions & 1 deletion kernel/appletbdrm-t1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,32 @@ T1Bridge does not install the config-1 `apple-ib-drv` stack it modifies.

## Upstream status

The two-patch series in [`upstream/`](upstream/) is a private review draft and
The three-patch series in [`upstream/`](upstream/) is a private review draft and
has not been submitted. It is based on kernel.org stable tag `v7.1.8` (tag
object `1af9bbf117b680f903a81485cd74501c334bf538`, commit
`25c76bea853d0db65b51fb4697a47cbfd9e35e76`). Phase 1 hardware acceptance is
complete; suspend/resume was recorded as not run under the host-safety rule.
Owner DCO sign-off and validation against the eventual submission base remain
required before sending the series upstream.

## Failed resume recovery

The T1 resume callback checks both endpoint clear-halt operations and every
display rearm step before restoring the saved DRM mode. A rearm or mode-restore
failure returns its error and marks the display interface for USB core's
deferred unbind/reprobe at system PM completion. Returning an error alone does
not request that recovery. A successful resume retains the existing DRM device;
it need not produce a new userspace `display-open` diagnostic.

The fallback reprobes only the display interface. It does not reset the whole
T1 or change configuration, autosuspend policy, or protected state. Reprobe
recreates the DRM device so the packaged device-bound hardware service can
reopen it and renderers can reconnect. A failed probe leaves the device
unavailable rather than requesting an unbounded reset loop.

`make test sanitize` exercises the production resume callbacks with synthetic
USB and DRM boundaries, including failures at every rearm step and non-T1
behavior. This establishes error propagation and the deferred-rebind request,
not physical recovery. Attended system-suspend validation remains in
[#18](https://github.com/standardagents/t1bridge/issues/18); follow the
[hardware runbook](../../docs/hardware-validation.md#suspend-and-resume).
37 changes: 1 addition & 36 deletions kernel/appletbdrm-t1/appletbdrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,29 +853,6 @@ static void appletbdrm_t1_park(struct appletbdrm_device *adev)
appletbdrm_clear_display(adev);
}

static int appletbdrm_t1_rearm(struct appletbdrm_device *adev)
{
struct usb_device *udev = adev_to_udev(adev);
int ret;

usb_clear_halt(udev, usb_sndbulkpipe(udev, adev->out_ep));
usb_clear_halt(udev, usb_rcvbulkpipe(udev, adev->in_ep));

ret = appletbdrm_get_information(adev);
if (ret)
return ret;

ret = appletbdrm_signal_readiness(adev);
if (ret)
return ret;

ret = appletbdrm_clear_display(adev);
if (ret)
return ret;

return appletbdrm_clear_display(adev);
}

static int appletbdrm_suspend(struct usb_interface *intf, pm_message_t message)
{
struct appletbdrm_device *adev = usb_get_intfdata(intf);
Expand All @@ -888,19 +865,7 @@ static int appletbdrm_suspend(struct usb_interface *intf, pm_message_t message)
return ret;
}

static int appletbdrm_resume(struct usb_interface *intf)
{
struct appletbdrm_device *adev = usb_get_intfdata(intf);
int ret;

if (appletbdrm_is_t1(adev)) {
ret = appletbdrm_t1_rearm(adev);
if (ret)
drm_err(&adev->drm, "Failed to rearm T1 display (%d)\n", ret);
}

return drm_mode_config_helper_resume(&adev->drm);
}
#include "appletbdrm_resume.h"

static const struct usb_device_id appletbdrm_usb_id_table[] = {
{ USB_DEVICE_INTERFACE_CLASS(0x05ac, 0x8302, USB_CLASS_AUDIO_VIDEO) },
Expand Down
63 changes: 63 additions & 0 deletions kernel/appletbdrm-t1/appletbdrm_resume.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Private resume callbacks, included after the driver's USB/DRM operations.
* Kept together so fault tests exercise the production recovery sequence.
*/
#ifndef APPLETBDRM_RESUME_H
#define APPLETBDRM_RESUME_H

static int appletbdrm_t1_rearm(struct appletbdrm_device *adev)
{
struct usb_device *udev = adev_to_udev(adev);
int ret;

ret = usb_clear_halt(udev, usb_sndbulkpipe(udev, adev->out_ep));
if (ret)
return ret;
ret = usb_clear_halt(udev, usb_rcvbulkpipe(udev, adev->in_ep));
if (ret)
return ret;

ret = appletbdrm_get_information(adev);
if (ret)
return ret;
ret = appletbdrm_signal_readiness(adev);
if (ret)
return ret;
ret = appletbdrm_clear_display(adev);
if (ret)
return ret;

return appletbdrm_clear_display(adev);
}

static int appletbdrm_resume(struct usb_interface *intf)
{
struct appletbdrm_device *adev = usb_get_intfdata(intf);
int ret;

if (appletbdrm_is_t1(adev)) {
ret = appletbdrm_t1_rearm(adev);
if (ret) {
drm_err(&adev->drm, "Failed to rearm T1 display (%d)\n", ret);
goto rebind;
}
}

ret = drm_mode_config_helper_resume(&adev->drm);
if (!ret || !appletbdrm_is_t1(adev))
return ret;
drm_err(&adev->drm, "Failed to restore T1 display mode (%d)\n", ret);

rebind:
/*
* A failed resume callback alone does not request reprobe. USB core
* unbinds marked interfaces after resume and rebinds at PM completion,
* outside this callback's locks. Recreate only the display interface;
* never reset the composite device or leave a stale DRM node active.
*/
intf->needs_binding = 1;
return ret;
}

#endif
Loading