From nobody Sat Apr 20 00:44:35 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 1518538136226542.2117700078786; Tue, 13 Feb 2018 08:08:56 -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 1eldAH-0002gh-Se; Tue, 13 Feb 2018 17:10:41 +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 1eldA2-0002eb-4b for seabios@seabios.org; Tue, 13 Feb 2018 17:10:40 +0100 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DG1dxc089198 for ; Tue, 13 Feb 2018 11:08:20 -0500 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g428nudcg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 11:08:19 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 11:08:18 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 11:08:16 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1DG8Fjf42533046; Tue, 13 Feb 2018 16:08:15 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A22D1B204E; Tue, 13 Feb 2018 11:05:09 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 8C8FBB2046; Tue, 13 Feb 2018 11:05:09 -0500 (EST) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Tue, 13 Feb 2018 11:08:04 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18021316-0040-0000-0000-000003F2D2DF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008527; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000253; SDB=6.00989182; UDB=6.00502256; IPR=6.00768536; BA=6.00005827; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019534; XFM=3.00000015; UTC=2018-02-13 16:08:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021316-0041-0000-0000-000007E84B71 Message-Id: <1518538087-28888-2-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-13_08:, , 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130191 X-Spam-Score: -6.0 (------) Subject: [SeaBIOS] [PATCH v2 1/4] x86: add readq() 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: , Content-Type: text/plain; charset="utf-8" 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 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger Tested-by: Stefan Berger --- src/x86.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/x86.h b/src/x86.h index 4aea65c..c7bb60d 100644 --- a/src/x86.h +++ b/src/x86.h @@ -211,6 +211,11 @@ static inline void writeb(void *addr, u8 val) { barrier(); *(volatile u8 *)addr =3D val; } +static inline u64 readq(const void *addr) { + u64 val =3D *(volatile const u64 *)addr; + barrier(); + return val; +} static inline u32 readl(const void *addr) { u32 val =3D *(volatile const u32 *)addr; barrier(); --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Sat Apr 20 00:44:35 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 1518538145323110.55840873125203; Tue, 13 Feb 2018 08:09:05 -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 1eldAU-0002jc-7l; Tue, 13 Feb 2018 17:10:54 +0100 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eldA4-0002ej-Gf for seabios@seabios.org; Tue, 13 Feb 2018 17:10:52 +0100 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DG23A2139070 for ; Tue, 13 Feb 2018 11:08:22 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g41skmerf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 11:08:22 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 11:08:19 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 11:08:17 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1DG8Gsb44171456; Tue, 13 Feb 2018 16:08:16 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A46DDB2054; Tue, 13 Feb 2018 11:05:10 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 98B4CB204D; Tue, 13 Feb 2018 11:05:10 -0500 (EST) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Tue, 13 Feb 2018 11:08:05 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18021316-0008-0000-0000-000002D0DFB6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008527; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000253; SDB=6.00989182; UDB=6.00502256; IPR=6.00768536; BA=6.00005827; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019534; XFM=3.00000015; UTC=2018-02-13 16:08:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021316-0009-0000-0000-0000383E6037 Message-Id: <1518538087-28888-3-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-13_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130191 X-Spam-Score: -6.0 (------) Subject: [SeaBIOS] [PATCH v2 2/4] tpm: generalize init_timeout() 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: , Content-Type: text/plain; charset="utf-8" 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 From: Marc-Andr=C3=A9 Lureau It seems both TIS & CRB devices share the same timeout. Make initialization function generic now. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger Tested-by: Stefan Berger --- src/hw/tpm_drivers.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c index a137e62..0daaef2 100644 --- a/src/hw/tpm_drivers.c +++ b/src/hw/tpm_drivers.c @@ -102,26 +102,31 @@ static TPMVersion tis_get_tpm_version(void) return TPM_VERSION_1_2; } =20 -static u32 tis_init(void) +static void init_timeout(int driver) { - if (!CONFIG_TCGBIOS) - return 1; - - writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0); - - if (tpm_drivers[TIS_DRIVER_IDX].durations =3D=3D NULL) { + if (tpm_drivers[driver].durations =3D=3D NULL) { u32 *durations =3D tpm_default_dur; memcpy(durations, tpm_default_durations, sizeof(tpm_default_durations)); - tpm_drivers[TIS_DRIVER_IDX].durations =3D durations; + tpm_drivers[driver].durations =3D durations; } =20 - if (tpm_drivers[TIS_DRIVER_IDX].timeouts =3D=3D NULL) { + if (tpm_drivers[driver].timeouts =3D=3D NULL) { u32 *timeouts =3D tpm_default_to; memcpy(timeouts, tis_default_timeouts, sizeof(tis_default_timeouts)); - tpm_drivers[TIS_DRIVER_IDX].timeouts =3D timeouts; + tpm_drivers[driver].timeouts =3D timeouts; } +} + +static u32 tis_init(void) +{ + if (!CONFIG_TCGBIOS) + return 1; + + writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0); + + init_timeout(TIS_DRIVER_IDX); =20 return 1; } --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Sat Apr 20 00:44:35 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 1518538143920264.0792734229059; Tue, 13 Feb 2018 08:09:03 -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 1eldAS-0002iy-Il; Tue, 13 Feb 2018 17:10:52 +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 1eldA5-0002fO-5x for seabios@seabios.org; Tue, 13 Feb 2018 17:10:51 +0100 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DG1Zv1050960 for ; Tue, 13 Feb 2018 11:08:22 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0b-001b2d01.pphosted.com with ESMTP id 2g42gjtew8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 11:08:21 -0500 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 11:08:21 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 11:08:18 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1DG8HkE49086492; Tue, 13 Feb 2018 16:08:17 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0BFDB2050; Tue, 13 Feb 2018 11:05:11 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 9B559B2046; Tue, 13 Feb 2018 11:05:11 -0500 (EST) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Tue, 13 Feb 2018 11:08:06 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18021316-0036-0000-0000-000002BD810A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008527; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000253; SDB=6.00989182; UDB=6.00502256; IPR=6.00768536; BA=6.00005827; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019534; XFM=3.00000015; UTC=2018-02-13 16:08:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021316-0037-0000-0000-000043525263 Message-Id: <1518538087-28888-4-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-13_08:, , 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130191 X-Spam-Score: -6.7 (------) Subject: [SeaBIOS] [PATCH v2 3/4] tpm: use get_tpm_version() callback 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: , Content-Type: text/plain; charset="utf-8" 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 From: Marc-Andr=C3=A9 Lureau As originally intended. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger Tested-by: Stefan Berger --- src/hw/tpm_drivers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c index 0daaef2..5cee9d8 100644 --- a/src/hw/tpm_drivers.c +++ b/src/hw/tpm_drivers.c @@ -346,6 +346,7 @@ struct tpm_driver tpm_drivers[TPM_NUM_DRIVERS] =3D { .durations =3D NULL, .set_timeouts =3D set_timeouts, .probe =3D tis_probe, + .get_tpm_version =3D tis_get_tpm_version, .init =3D tis_init, .activate =3D tis_activate, .ready =3D tis_ready, @@ -367,7 +368,7 @@ tpmhw_probe(void) if (td->probe() !=3D 0) { td->init(); TPMHW_driver_to_use =3D i; - return tis_get_tpm_version(); + return td->get_tpm_version(); } } return TPM_VERSION_NONE; --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Sat Apr 20 00:44:35 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 1518538143204945.9416782648208; Tue, 13 Feb 2018 08:09:03 -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 1eldAT-0002jC-HU; Tue, 13 Feb 2018 17:10:53 +0100 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1eldA5-0002f1-Mo for seabios@seabios.org; Tue, 13 Feb 2018 17:10:51 +0100 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DG35I4103168 for ; Tue, 13 Feb 2018 11:08:23 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g40xmxw6f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 11:08:22 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 11:08:21 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 11:08:19 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1DG8Ipw48758848; Tue, 13 Feb 2018 16:08:18 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF178B2052; Tue, 13 Feb 2018 11:05:12 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id A788BB2046; Tue, 13 Feb 2018 11:05:12 -0500 (EST) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Tue, 13 Feb 2018 11:08:07 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1518538087-28888-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18021316-0008-0000-0000-000002D0DFB7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008527; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000253; SDB=6.00989182; UDB=6.00502256; IPR=6.00768536; BA=6.00005827; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019534; XFM=3.00000015; UTC=2018-02-13 16:08:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021316-0009-0000-0000-0000383E6041 Message-Id: <1518538087-28888-5-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-13_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130191 X-Spam-Score: -5.7 (-----) Subject: [SeaBIOS] [PATCH v2 4/4] tpm: add TPM CRB device support 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: , Content-Type: text/plain; charset="utf-8" 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 From: Marc-Andr=C3=A9 Lureau The CRB device was introduced with TPM 2.0 to be physical-bus agnostic and defined in TCG PC Client Platform TPM Profile (PTP) Specification Family =E2=80=9C2.0=E2=80=9D Level 00 Revision 01.03 v22 It seems to be required with Windows 10. It is also a simpler device than FIFO/TIS. This patch only support locality 0 since also the CRB device in QEMU only supports this locality. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger Tested-by: Stefan Berger --- src/hw/tpm_drivers.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++= +++- src/hw/tpm_drivers.h | 26 +++++++ 2 files changed, 223 insertions(+), 1 deletion(-) diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c index 5cee9d8..24ce9b7 100644 --- a/src/hw/tpm_drivers.c +++ b/src/hw/tpm_drivers.c @@ -17,6 +17,8 @@ #include "util.h" // timer_calc_usec #include "x86.h" // readl =20 +#define MIN(x,y) ((x) < (y) ? (x) : (y)) + /* low level driver implementation */ struct tpm_driver { u32 *timeouts; @@ -36,7 +38,8 @@ struct tpm_driver { extern struct tpm_driver tpm_drivers[]; =20 #define TIS_DRIVER_IDX 0 -#define TPM_NUM_DRIVERS 1 +#define CRB_DRIVER_IDX 1 +#define TPM_NUM_DRIVERS 2 =20 #define TPM_INVALID_DRIVER 0xf =20 @@ -57,6 +60,11 @@ static const u32 tpm_default_durations[3] =3D { static u32 tpm_default_dur[3]; static u32 tpm_default_to[4]; =20 +static u32 crb_cmd_size; +static void *crb_cmd; +static u32 crb_resp_size; +static void *crb_resp; + /* if device is not there, return '0', '1' otherwise */ static u32 tis_probe(void) { @@ -338,6 +346,179 @@ static u32 tis_waitrespready(enum tpmDurationType to_= t) return rc; } =20 +/* if device is not there, return '0', '1' otherwise */ +static u32 crb_probe(void) +{ + if (!CONFIG_TCGBIOS) + return 0; + + u32 ifaceid =3D readl(CRB_REG(0, CRB_REG_INTF_ID)); + + if ((ifaceid & 0xf) !=3D 0xf) { + if ((ifaceid & 0xf) =3D=3D 1) { + /* CRB is active */ + return 1; + } + if ((ifaceid & (1 << 14)) =3D=3D 0) { + /* CRB cannot be selected */ + return 0; + } + /* write of 1 to bits 17-18 selects CRB */ + writel(CRB_REG(0, CRB_REG_INTF_ID), (1 << 17)); + /* lock it */ + writel(CRB_REG(0, CRB_REG_INTF_ID), (1 << 19)); + } + + /* no support for 64 bit addressing yet */ + if (readl(CRB_REG(0, CRB_REG_CTRL_CMD_HADDR))) + return 1; + + u64 addr =3D readq(CRB_REG(0, CRB_REG_CTRL_RSP_ADDR)); + if (addr > __UINT32_MAX__) + return 1; + + return 0; +} + +static TPMVersion crb_get_tpm_version(void) +{ + /* CRB is supposed to be TPM 2.0 only */ + return TPM_VERSION_2; +} + +static u32 crb_init(void) +{ + if (!CONFIG_TCGBIOS) + return 1; + + crb_cmd =3D (void*)readl(CRB_REG(0, CRB_REG_CTRL_CMD_LADDR)); + crb_cmd_size =3D readl(CRB_REG(0, CRB_REG_CTRL_CMD_SIZE)); + crb_resp =3D (void*)readl(CRB_REG(0, CRB_REG_CTRL_RSP_ADDR)); + crb_resp_size =3D readl(CRB_REG(0, CRB_REG_CTRL_RSP_SIZE)); + + init_timeout(CRB_DRIVER_IDX); + + return 0; +} + +static u32 crb_wait_reg(u8 locty, u8 reg, u32 time, u8 mask, u8 expect) +{ + if (!CONFIG_TCGBIOS) + return 0; + + u32 rc =3D 1; + u32 end =3D timer_calc_usec(time); + + for (;;) { + u8 sts =3D readl(CRB_REG(locty, reg)); + if ((sts & mask) =3D=3D expect) { + rc =3D 0; + break; + } + if (timer_check(end)) { + warn_timeout(); + break; + } + yield(); + } + return rc; +} + +static u32 crb_activate(u8 locty) +{ + if (!CONFIG_TCGBIOS) + return 0; + + return 0; +} + +static u32 crb_find_active_locality(void) +{ + if (!CONFIG_TCGBIOS) + return 0; + + return 0; +} + +#define CRB_CTRL_REQ_CMD_READY 0b1 +#define CRB_START_INVOKE 0b1 +#define CRB_CTRL_STS_ERROR 0b1 + +static u32 crb_ready(void) +{ + if (!CONFIG_TCGBIOS) + return 0; + + u32 rc =3D 0; + u8 locty =3D crb_find_active_locality(); + u32 timeout_c =3D tpm_drivers[CRB_DRIVER_IDX].timeouts[TIS_TIMEOUT_TYP= E_C]; + + writel(CRB_REG(locty, CRB_REG_CTRL_REQ), CRB_CTRL_REQ_CMD_READY); + rc =3D crb_wait_reg(locty, CRB_REG_CTRL_REQ, timeout_c, + CRB_CTRL_REQ_CMD_READY, 0); + + return rc; +} + +static u32 crb_senddata(const u8 *const data, u32 len) +{ + if (!CONFIG_TCGBIOS) + return 0; + + if (len > crb_cmd_size) + return 1; + + u8 locty =3D crb_find_active_locality(); + memcpy(crb_cmd, data, len); + writel(CRB_REG(locty, CRB_REG_CTRL_START), CRB_START_INVOKE); + + return 0; +} + +static u32 crb_readresp(u8 *buffer, u32 *len) +{ + if (!CONFIG_TCGBIOS) + return 0; + + u8 locty =3D crb_find_active_locality(); + if (readl(CRB_REG(locty, CRB_REG_CTRL_STS)) & CRB_CTRL_STS_ERROR) + return 1; + + if (*len < 6) + return 1; + + memcpy(buffer, crb_resp, 6); + u32 expected =3D be32_to_cpu(*(u32 *) &buffer[2]); + if (expected < 6) + return 1; + + *len =3D MIN(expected, *len); + + memcpy(buffer + 6, crb_resp + 6, *len - 6); + + return 0; +} + + +static u32 crb_waitdatavalid(void) +{ + return 0; +} + +static u32 crb_waitrespready(enum tpmDurationType to_t) +{ + if (!CONFIG_TCGBIOS) + return 0; + + u32 rc =3D 0; + u8 locty =3D crb_find_active_locality(); + u32 timeout =3D tpm_drivers[CRB_DRIVER_IDX].durations[to_t]; + + rc =3D crb_wait_reg(locty, CRB_REG_CTRL_START, timeout, + CRB_START_INVOKE, 0); + + return rc; +} =20 struct tpm_driver tpm_drivers[TPM_NUM_DRIVERS] =3D { [TIS_DRIVER_IDX] =3D @@ -355,6 +536,21 @@ struct tpm_driver tpm_drivers[TPM_NUM_DRIVERS] =3D { .waitdatavalid =3D tis_waitdatavalid, .waitrespready =3D tis_waitrespready, }, + [CRB_DRIVER_IDX] =3D + { + .timeouts =3D NULL, + .durations =3D NULL, + .set_timeouts =3D set_timeouts, + .probe =3D crb_probe, + .get_tpm_version =3D crb_get_tpm_version, + .init =3D crb_init, + .activate =3D crb_activate, + .ready =3D crb_ready, + .senddata =3D crb_senddata, + .readresp =3D crb_readresp, + .waitdatavalid =3D crb_waitdatavalid, + .waitrespready =3D crb_waitrespready, + }, }; =20 static u8 TPMHW_driver_to_use =3D TPM_INVALID_DRIVER; diff --git a/src/hw/tpm_drivers.h b/src/hw/tpm_drivers.h index 56fd9e8..adf1839 100644 --- a/src/hw/tpm_drivers.h +++ b/src/hw/tpm_drivers.h @@ -24,6 +24,32 @@ int tpmhw_transmit(u8 locty, struct tpm_req_header *req, enum tpmDurationType to_t); void tpmhw_set_timeouts(u32 timeouts[4], u32 durations[3]); =20 +/* CRB driver */ +/* address of locality 0 (CRB) */ +#define TPM_CRB_BASE_ADDRESS 0xfed40000 + +#define CRB_REG(LOCTY, REG) \ + (void *)(TPM_CRB_BASE_ADDRESS + (LOCTY << 12) + REG) + +/* hardware registers */ +#define CRB_REG_LOC_STATE 0x0 +#define CRB_REG_LOC_CTRL 0x8 +#define CRB_REG_LOC_STS 0xC +#define CRB_REG_INTF_ID 0x30 +#define CRB_REG_CTRL_EXT 0x38 +#define CRB_REG_CTRL_REQ 0x40 +#define CRB_REG_CTRL_STS 0x44 +#define CRB_REG_CTRL_CANCEL 0x48 +#define CRB_REG_CTRL_START 0x4C +#define CRB_REG_INT_ENABLE 0x50 +#define CRB_REG_INT_STS 0x54 +#define CRB_REG_CTRL_CMD_SIZE 0x58 +#define CRB_REG_CTRL_CMD_LADDR 0x5C +#define CRB_REG_CTRL_CMD_HADDR 0x60 +#define CRB_REG_CTRL_RSP_SIZE 0x64 +#define CRB_REG_CTRL_RSP_ADDR 0x68 +#define CRB_REG_DATA_BUFFER 0x80 + /* TIS driver */ /* address of locality 0 (TIS) */ #define TPM_TIS_BASE_ADDRESS 0xfed40000 --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios