git: a343fc0ad029 - main - tpm: crb: Do not attach when no CRB interface answers

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Mon, 23 Nov 2026 07:39:02 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=a343fc0ad029ad569919c8d500f72566acf9b66e

commit a343fc0ad029ad569919c8d500f72566acf9b66e
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-11-22 20:41:26 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-11-23 07:33:46 +0000

    tpm: crb: Do not attach when no CRB interface answers
    
    Some firmware describes a CRB TPM that is not there: a Protectli FW6
    with coreboot 4.12 publishes a TPM2 table at 0xfed40000, but no PTT
    answers and the Intel ME interface is absent too.  Every register
    reads all-ones, so attach failed only after 0.6 s of state timeouts,
    with ready, idle and locality messages that hid the cause.
    
    Check INTF_ID once, as tpm_tis12_probe() does for TPM 1.2.
    
    Reviewed by:    kbowling
    Approved by:    kbowling
    MFC after:      1 week
    Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/128
---
 sys/dev/tpm/tpm_crb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/dev/tpm/tpm_crb.c b/sys/dev/tpm/tpm_crb.c
index bf0ff1bae9d4..e846eee8196c 100644
--- a/sys/dev/tpm/tpm_crb.c
+++ b/sys/dev/tpm/tpm_crb.c
@@ -433,6 +433,15 @@ tpmcrb_attach(device_t dev)
 		return (ENXIO);
 	}
 
+	/* Firmware can describe a TPM that is absent, e.g. with the ME off. */
+	if (crb_sc->has_locality &&
+	    rman_get_size(sc->mem_res) >= TPM_CRB_LOCALITY_SIZE &&
+	    bus_read_4(sc->mem_res, TPM_CRB_INTF_ID) == UINT32_MAX) {
+		device_printf(dev, "No CRB interface at the ACPI address\n");
+		tpmcrb_detach(dev);
+		return (ENXIO);
+	}
+
 	if (!tpmcrb_request_locality(crb_sc, 0)) {
 		device_printf(dev, "Failed to obtain locality\n");
 		tpmcrb_detach(dev);