svn commit: r346723 - in stable/12: sys/dev/tpm usr.sbin/acpi/acpidump
Marcin Wojtas
mw at FreeBSD.org
Fri Apr 26 01:29:02 UTC 2019
Author: mw
Date: Fri Apr 26 01:29:00 2019
New Revision: 346723
URL: https://svnweb.freebsd.org/changeset/base/346723
Log:
MFC r343438: Use ACPI TPM2 table to probe tpmtis and tpmcrb device
Sponsored by: Stormshield
Modified:
stable/12/sys/dev/tpm/tpm20.h
stable/12/sys/dev/tpm/tpm_crb.c
stable/12/sys/dev/tpm/tpm_tis.c
stable/12/usr.sbin/acpi/acpidump/acpi.c
Modified: stable/12/sys/dev/tpm/tpm20.h
==============================================================================
--- stable/12/sys/dev/tpm/tpm20.h Fri Apr 26 01:20:39 2019 (r346722)
+++ stable/12/sys/dev/tpm/tpm20.h Fri Apr 26 01:29:00 2019 (r346723)
@@ -93,6 +93,12 @@ __FBSDID("$FreeBSD$");
#define TPM_CDEV_NAME "tpm0"
#define TPM_CDEV_PERM_FLAG 0600
+
+#define TPM2_START_METHOD_ACPI 2
+#define TPM2_START_METHOD_TIS 6
+#define TPM2_START_METHOD_CRB 7
+#define TPM2_START_METHOD_CRB_ACPI 8
+
struct tpm_sc {
device_t dev;
Modified: stable/12/sys/dev/tpm/tpm_crb.c
==============================================================================
--- stable/12/sys/dev/tpm/tpm_crb.c Fri Apr 26 01:20:39 2019 (r346722)
+++ stable/12/sys/dev/tpm/tpm_crb.c Fri Apr 26 01:29:00 2019 (r346723)
@@ -104,26 +104,21 @@ char *tpmcrb_ids[] = {"MSFT0101", NULL};
static int
tpmcrb_acpi_probe(device_t dev)
{
- struct resource *res;
- int rid = 0;
- uint32_t caps;
+ int err = 0;
+ ACPI_TABLE_TPM23 *tbl;
+ ACPI_STATUS status;
if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids) == NULL)
return (ENXIO);
- /* Check if device is in CRB mode */
- res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (res == NULL)
- return (ENXIO);
+ /*Find TPM2 Header*/
+ status = AcpiGetTable(ACPI_SIG_TPM2, 1, (ACPI_TABLE_HEADER **) &tbl);
+ if(ACPI_FAILURE(status) ||
+ tbl->StartMethod != TPM2_START_METHOD_CRB)
+ err = ENXIO;
- caps = bus_read_4(res, TPM_CRB_INTF_ID);
- bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
-
- if ((caps & TPM_CRB_INTF_ID_TYPE) != TPM_CRB_INTF_ID_TYPE_CRB)
- return (ENXIO);
-
device_set_desc(dev, "Trusted Platform Module 2.0, CRB mode");
- return (BUS_PROBE_DEFAULT);
+ return (err);
}
static ACPI_STATUS
Modified: stable/12/sys/dev/tpm/tpm_tis.c
==============================================================================
--- stable/12/sys/dev/tpm/tpm_tis.c Fri Apr 26 01:20:39 2019 (r346722)
+++ stable/12/sys/dev/tpm/tpm_tis.c Fri Apr 26 01:29:00 2019 (r346723)
@@ -100,25 +100,20 @@ char *tpmtis_ids[] = {"MSFT0101", NULL};
static int
tpmtis_acpi_probe(device_t dev)
{
- struct resource *res;
- int rid = 0;
- uint32_t caps;
+ int err = 0;
+ ACPI_TABLE_TPM23 *tbl;
+ ACPI_STATUS status;
if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids) == NULL)
return (ENXIO);
+ /*Find TPM2 Header*/
+ status = AcpiGetTable(ACPI_SIG_TPM2, 1, (ACPI_TABLE_HEADER **) &tbl);
+ if(ACPI_FAILURE(status) ||
+ tbl->StartMethod != TPM2_START_METHOD_TIS)
+ err = ENXIO;
- /* Check if device is in TPM 2.0 TIS mode */
- res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (res == NULL)
- return (ENXIO);
-
- caps = bus_read_4(res, TPM_INTF_CAPS);
- bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
- if ((caps & TPM_INTF_CAPS_VERSION) != TPM_INTF_CAPS_TPM20)
- return (ENXIO);
-
device_set_desc(dev, "Trusted Platform Module 2.0, FIFO mode");
- return (BUS_PROBE_DEFAULT);
+ return (err);
}
static int
Modified: stable/12/usr.sbin/acpi/acpidump/acpi.c
==============================================================================
--- stable/12/usr.sbin/acpi/acpidump/acpi.c Fri Apr 26 01:20:39 2019 (r346722)
+++ stable/12/usr.sbin/acpi/acpidump/acpi.c Fri Apr 26 01:29:00 2019 (r346723)
@@ -970,7 +970,18 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp)
printf(END_COMMENT);
}
-
+static void acpi_handle_tpm2(ACPI_TABLE_HEADER *sdp)
+{
+ ACPI_TABLE_TPM2 *tpm2;
+
+ printf (BEGIN_COMMENT);
+ acpi_print_sdt(sdp);
+ tpm2 = (ACPI_TABLE_TPM2 *) sdp;
+ printf ("\t\tControlArea=%lx\n", tpm2->ControlAddress);
+ printf ("\t\tStartMethod=%x\n", tpm2->StartMethod);
+ printf (END_COMMENT);
+}
+
static const char *
devscope_type2str(int type)
{
@@ -1769,6 +1780,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp)
acpi_handle_wddt(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_LPIT, 4))
acpi_handle_lpit(sdp);
+ else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4))
+ acpi_handle_tpm2(sdp);
else {
printf(BEGIN_COMMENT);
acpi_print_sdt(sdp);
More information about the svn-src-stable-12
mailing list