Page MenuHomeFreeBSD

tpm_tis: Close interrupt wait races
AcceptedPublic

Authored by kbowling on Fri, Aug 28, 12:55 AM.
Tags
None
Referenced Files
F168592342: D59241.diff
Sat, Aug 29, 4:33 AM
Unknown Object (File)
Fri, Aug 28, 1:19 PM
Unknown Object (File)
Fri, Aug 28, 1:18 PM
Unknown Object (File)
Fri, Aug 28, 12:41 PM
Unknown Object (File)
Fri, Aug 28, 8:58 AM
Unknown Object (File)
Fri, Aug 28, 8:52 AM
Unknown Object (File)
Fri, Aug 28, 5:17 AM
Unknown Object (File)
Fri, Aug 28, 5:17 AM
Subscribers

Details

Summary
The TIS interrupt handler can acknowledge and signal an event after
the waiter checks the device status but before it enters tsleep().
Since the handler is MPSAFE, the command lock does not close this
window.  A lost wakeup can delay a completed command for its full
timeout, up to 40 seconds for long TPM 2.0 operations.

Publish the expected event under an interrupt mutex and use a generation
counter to record matching interrupts.  Recheck the device predicate
without the mutex because register access may sleep on a SPI transport,
then compare the generation before atomically waiting on a condition
variable.  This closes the check-to-sleep race without placing sleeping
bus operations under a mutex.

Use an absolute deadline while retrying the predicate after wakeups.
Apply the same scheme to locality acquisition, which had an equivalent
race.  Leave the expected event published while polling so the
attach-time test can still prove that an advertised interrupt arrived.

Regression-tested the polling fallback on two TPM 2.0 FIFO systems with
200 concurrent PCR reads per system and repeated device suspend/resume.
Neither ACPI device exposes an IRQ, so the interrupt-mode path remains
hardware-unvalidated.

MFC after:      2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped