From nobody Mon Apr 29 13:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1510689872318413.32688949823796; Tue, 14 Nov 2017 12:04:32 -0800 (PST) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1eEhRO-0003Pc-9c; Tue, 14 Nov 2017 21:04:14 +0100 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eEhR8-0003Mf-Lz for seabios@seabios.org; Tue, 14 Nov 2017 21:04:13 +0100 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAEJx084125044 for ; Tue, 14 Nov 2017 15:03:57 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e81tps5yd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 15:03:56 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Nov 2017 13:03:55 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Nov 2017 13:03:53 -0700 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAEK3qjY4653394; Tue, 14 Nov 2017 13:03:52 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A991D136043; Tue, 14 Nov 2017 13:03:52 -0700 (MST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 4FF38136040; Tue, 14 Nov 2017 13:03:52 -0700 (MST) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Tue, 14 Nov 2017 15:03:47 -0500 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 x-cbid: 17111420-0020-0000-0000-00000CFF34D8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008066; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000240; SDB=6.00945878; UDB=6.00477402; IPR=6.00726175; BA=6.00005690; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018014; XFM=3.00000015; UTC=2017-11-14 20:03:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111420-0021-0000-0000-00005EE6CF08 Message-Id: <1510689827-3441-1-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711140266 X-Spam-Score: -3.0 (---) Subject: [SeaBIOS] [PATCH] tpm: Add support for TPM2 ACPI table X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add support for the TPM2 ACPI table. If we find it and its of the appropriate size, we can get the log_area_start_address and log_area_minimum_size from it. The latest version of the spec can be found here: https://trustedcomputinggroup.org/tcg-acpi-specification/ Signed-off-by: Stefan Berger --- src/std/acpi.h | 13 +++++++++++++ src/tcgbios.c | 52 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/std/acpi.h b/src/std/acpi.h index c2ea707..c01fa7b 100644 --- a/src/std/acpi.h +++ b/src/std/acpi.h @@ -307,4 +307,17 @@ struct tcpa_descriptor_rev2 #define TCPA_ACPI_CLASS_CLIENT 0 #define TCPA_ACPI_CLASS_SERVER 1 =20 +#define TPM2_SIGNATURE 0x324D5054 +struct tpm2_descriptor_rev2 +{ + ACPI_TABLE_HEADER_DEF + u16 platform_class; + u16 reserved; + u64 address_of_control_area; + u32 start_method; + u8 start_method_params[12]; + u32 log_area_minimum_length; + u64 log_area_start_address; +} PACKED; + #endif // acpi.h diff --git a/src/tcgbios.c b/src/tcgbios.c index 151707b..9348a23 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -48,15 +48,9 @@ struct { u8 * log_area_last_entry; } tpm_state VARLOW; =20 -static int -tpm_tcpa_probe(void) +static int tpm_set_log_area(u8 *log_area_start_address, + u32 log_area_minimum_length) { - struct tcpa_descriptor_rev2 *tcpa =3D find_acpi_table(TCPA_SIGNATURE); - if (!tcpa) - return -1; - - u8 *log_area_start_address =3D (u8*)(long)tcpa->log_area_start_address; - u32 log_area_minimum_length =3D tcpa->log_area_minimum_length; if (!log_area_start_address || !log_area_minimum_length) return -1; =20 @@ -69,6 +63,39 @@ tpm_tcpa_probe(void) return 0; } =20 +static int +tpm_tcpa_probe(void) +{ + struct tcpa_descriptor_rev2 *tcpa =3D find_acpi_table(TCPA_SIGNATURE); + if (!tcpa) + return -1; + + dprintf(DEBUG_tcg, "TCGBIOS: TCPA: LASA =3D %p, LAML =3D %u\n", + (u8 *)(long)tcpa->log_area_start_address, + tcpa->log_area_minimum_length); + + return tpm_set_log_area((u8*)(long)tcpa->log_area_start_address, + tcpa->log_area_minimum_length); +} + +static int +tpm_tpm2_probe(void) +{ + struct tpm2_descriptor_rev2 *tpm2 =3D find_acpi_table(TPM2_SIGNATURE); + if (!tpm2) + return -1; + + if (tpm2->length < 76) + return -1; + + dprintf(DEBUG_tcg, "TCGBIOS: TPM2: LASA =3D %p, LAML =3D %u\n", + (u8 *)(long)tpm2->log_area_start_address, + tpm2->log_area_minimum_length); + + return tpm_set_log_area((u8*)(long)tpm2->log_area_start_address, + tpm2->log_area_minimum_length); +} + /* * Extend the ACPI log with the given entry by copying the * entry data into the log. @@ -949,9 +976,12 @@ tpm_setup(void) "TCGBIOS: Detected a TPM %s.\n", (TPM_version =3D=3D TPM_VERSION_1_2) ? "1.2" : "2"); =20 - int ret =3D tpm_tcpa_probe(); - if (ret) - return; + int ret =3D tpm_tpm2_probe(); + if (ret) { + ret =3D tpm_tcpa_probe(); + if (ret) + return; + } =20 TPM_working =3D 1; =20 --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios