Skip to contentSkip to conversation

libacpi: Widen TPM detection

PATCH In review Jason Andryuk 3 participants 3 messages Jun 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libacpi: Widen TPM detection

The hardcoded tpm_signature is too restrictive to detect many TPMs. For instance, it doesn't accept a QEMU emulated TPM (VID 0x1014 DID 0x0001). Make the TPM detection match that in rombios which accepts a wider range.

With this change, the TPM's TCPA ACPI table is generated and the guest OS can automatically load the tpm_tis driver. It also allows seabios to detect and use the TPM. However, seabios skips some TPM initialization when running under Xen, so it will not populate any PCRs unless modified to run the initialization under Xen.

---
 tools/libacpi/build.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/libacpi/build.c +2 -4
index fa7d14e090..a61dd5583a 100644
@@ -351,7 +351,6 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
     struct acpi_20_waet *waet;
     struct acpi_20_tcpa *tcpa;
     unsigned char *ssdt;
-    static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
     void *lasa;
 
     /* MADT. */
@@ -413,9 +412,8 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt,
 
     /* TPM TCPA and SSDT. */
     if ( (config->table_flags & ACPI_HAS_TCPA) &&
-         (config->tis_hdr[0] == tis_signature[0]) &&
-         (config->tis_hdr[1] == tis_signature[1]) &&
-         (config->tis_hdr[2] == tis_signature[2]) )
+         (config->tis_hdr[0] != 0 && config->tis_hdr[0] != 0xffff) &&
+         (config->tis_hdr[1] != 0 && config->tis_hdr[1] != 0xffff) )
     {
         ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm), 16);
         if (!ssdt) return -1;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jason Andryuk

The hardcoded tpm_signature is too restrictive to detect many TPMs. For instance, it doesn't accept a QEMU emulated TPM (VID 0x1014 DID 0x0001). Make the TPM detection match that in rombios which accepts a wider range.

Quoted 7 lines

With this change, the TPM's TCPA ACPI table is generated and the guest OS can automatically load the tpm_tis driver. It also allows seabios to detect and use the TPM. However, seabios skips some TPM initialization when running under Xen, so it will not populate any PCRs unless modified to run the initialization under Xen.

This looks like it wants backporting, so CC'ing Paul for a 4.14 release ack.

#2 lore raw
Quoted 20 lines

-----Original Message-----
From: Andrew Cooper <[email protected]>
Sent: 11 June 2020 12:52
To: Jason Andryuk <[email protected]>; [email protected]
Cc: Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Subject: Re: [PATCH] libacpi: Widen TPM detection

Quoted 11 lines · Jason Andryuk

The hardcoded tpm_signature is too restrictive to detect many TPMs. For instance, it doesn't accept a QEMU emulated TPM (VID 0x1014 DID 0x0001). Make the TPM detection match that in rombios which accepts a wider range.

With this change, the TPM's TCPA ACPI table is generated and the guest OS can automatically load the tpm_tis driver. It also allows seabios to detect and use the TPM. However, seabios skips some TPM initialization when running under Xen, so it will not populate any PCRs unless modified to run the initialization under Xen.

Quoted 5 lines
Quoted 1 line

This looks like it wants backporting, so CC'ing Paul for a 4.14 release ack.

Agreed.