Date: Fri, 26 Apr 2019 01:20:40 +0000 (UTC) From: Marcin Wojtas <mw@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346722 - in stable/11: sys/dev/tpm usr.sbin/acpi/acpidump Message-ID: <201904260120.x3Q1Ket5002018@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mw Date: Fri Apr 26 01:20:39 2019 New Revision: 346722 URL: https://svnweb.freebsd.org/changeset/base/346722 Log: MFC r343438: Use ACPI TPM2 table to probe tpmtis and tpmcrb device Submitted by: Kornel Duleba <mindal@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Modified: stable/11/sys/dev/tpm/tpm20.h stable/11/sys/dev/tpm/tpm_crb.c stable/11/sys/dev/tpm/tpm_tis.c stable/11/usr.sbin/acpi/acpidump/acpi.c Modified: stable/11/sys/dev/tpm/tpm20.h ============================================================================== --- stable/11/sys/dev/tpm/tpm20.h Fri Apr 26 01:02:24 2019 (r346721) +++ stable/11/sys/dev/tpm/tpm20.h Fri Apr 26 01:20:39 2019 (r346722) @@ -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/11/sys/dev/tpm/tpm_crb.c ============================================================================== --- stable/11/sys/dev/tpm/tpm_crb.c Fri Apr 26 01:02:24 2019 (r346721) +++ stable/11/sys/dev/tpm/tpm_crb.c Fri Apr 26 01:20:39 2019 (r346722) @@ -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_TPM2 *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/11/sys/dev/tpm/tpm_tis.c ============================================================================== --- stable/11/sys/dev/tpm/tpm_tis.c Fri Apr 26 01:02:24 2019 (r346721) +++ stable/11/sys/dev/tpm/tpm_tis.c Fri Apr 26 01:20:39 2019 (r346722) @@ -100,25 +100,21 @@ 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_TPM2 *tbl; + ACPI_STATUS status; if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids) == NULL) return (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); + /*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; - 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/11/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/11/usr.sbin/acpi/acpidump/acpi.c Fri Apr 26 01:02:24 2019 (r346721) +++ stable/11/usr.sbin/acpi/acpidump/acpi.c Fri Apr 26 01:20:39 2019 (r346722) @@ -861,7 +861,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) { @@ -1656,6 +1667,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) acpi_handle_dmar(sdp); else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) acpi_handle_nfit(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4)) + acpi_handle_tpm2(sdp); else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904260120.x3Q1Ket5002018>