From nobody Sun May 5 00:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510696647864913.8906544200017; Tue, 14 Nov 2017 13:57:27 -0800 (PST) Received: from localhost ([::1]:33716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEjCv-0005GN-2y for importer@patchew.org; Tue, 14 Nov 2017 16:57:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEj8e-00024g-K4 for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEj8b-00010P-5S for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:00 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40750 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eEj8J-0000lZ-AH for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:52:56 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAELnhcX057514 for ; Tue, 14 Nov 2017 16:52:35 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e87fw3cmq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 16:52:34 -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, 14 Nov 2017 16:52:34 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Nov 2017 16:52:32 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAELqWeQ39452884; Tue, 14 Nov 2017 21:52:32 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB432B2056; Tue, 14 Nov 2017 16:49:42 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id A8776B2052; Tue, 14 Nov 2017 16:49:42 -0500 (EST) From: Stefan Berger To: marcandre.lureau@gmail.com, qemu-devel@nongnu.org, amarnath.valluri@intel.com Date: Tue, 14 Nov 2017 16:52:27 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17111421-0008-0000-0000-000002A0C5E6 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.00945914; UDB=6.00477424; IPR=6.00726211; 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.00018016; XFM=3.00000015; UTC=2017-11-14 21:52:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111421-0009-0000-0000-0000374F4877 Message-Id: <1510696349-5151-2-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_11:, , 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-1711140291 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 for-2.11 1/3] tpm_emulator: Add a caching layer for the TPM Established flag X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a caching layer for the TPM established flag so that we don't need to go to the emulator every time the flag is read by accessing the REG_ACCESS register. Signed-off-by: Stefan Berger v1->v2: - move the caching to the backend layer since detecting the TPM 1.2 TSC_ResetEstablishmentBit() command is easier to do here. Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/tpm/tpm_emulator.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index e1a6810..b293db7 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -73,6 +73,9 @@ typedef struct TPMEmulator { Error *migration_blocker; =20 QemuMutex mutex; + + unsigned int established_flag:1; + unsigned int established_flag_cached:1; } TPMEmulator; =20 =20 @@ -287,16 +290,22 @@ static bool tpm_emulator_get_tpm_established_flag(TPM= Backend *tb) TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); ptm_est est; =20 - DPRINTF("%s", __func__); + if (tpm_emu->established_flag_cached) { + return tpm_emu->established_flag; + } + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_TPMESTABLISHED, &est, 0, sizeof(est)) < 0) { error_report("tpm-emulator: Could not get the TPM established flag= : %s", strerror(errno)); return false; } - DPRINTF("established flag: %0x", est.u.resp.bit); + DPRINTF("got established flag: %0x", est.u.resp.bit); + + tpm_emu->established_flag_cached =3D 1; + tpm_emu->established_flag =3D (est.u.resp.bit !=3D 0); =20 - return (est.u.resp.bit !=3D 0); + return tpm_emu->established_flag; } =20 static int tpm_emulator_reset_tpm_established_flag(TPMBackend *tb, @@ -327,6 +336,8 @@ static int tpm_emulator_reset_tpm_established_flag(TPMB= ackend *tb, return -1; } =20 + tpm_emu->established_flag_cached =3D 0; + return 0; } =20 --=20 2.5.5 From nobody Sun May 5 00:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510696538094133.76258143626205; Tue, 14 Nov 2017 13:55:38 -0800 (PST) Received: from localhost ([::1]:33701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEjB7-0003aE-8q for importer@patchew.org; Tue, 14 Nov 2017 16:55:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEj8h-00025x-Ed for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEj8b-00010T-4l for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:03 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eEj8N-0000pB-Le for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:52:56 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAELngO4051719 for ; Tue, 14 Nov 2017 16:52:40 -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 2e88dch0fr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 16:52:39 -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, 14 Nov 2017 16:52:36 -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, 14 Nov 2017 16:52:33 -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 vAELqXjr37290188; Tue, 14 Nov 2017 21:52:33 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7A22B2050; Tue, 14 Nov 2017 16:49:43 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id ABC10B204E; Tue, 14 Nov 2017 16:49:43 -0500 (EST) From: Stefan Berger To: marcandre.lureau@gmail.com, qemu-devel@nongnu.org, amarnath.valluri@intel.com Date: Tue, 14 Nov 2017 16:52:28 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17111421-0008-0000-0000-000002A0C5E7 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.00945914; UDB=6.00477424; IPR=6.00726211; 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.00018016; XFM=3.00000015; UTC=2017-11-14 21:52:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111421-0009-0000-0000-0000374F4878 Message-Id: <1510696349-5151-3-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_11:, , 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-1711140291 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 for-2.11 2/3] tpm_tis: Return TPM_VERSION_UNSPEC in case of BE failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In case the backend has a failure, such as the tpm_emulator's CMD_INIT failing, the TIS goes into failure mode and does not respond to reads or writes to MMIO registers. In this case we need to prevent the ACPI table from being added and the straight-forward way is to indicate that there's no known TPM version being used. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/tpm/tpm_tis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 7402528..fec2fc6 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1008,6 +1008,10 @@ TPMVersion tpm_tis_get_tpm_version(Object *obj) { TPMState *s =3D TPM(obj); =20 + if (tpm_backend_had_startup_error(s->be_driver)) { + return TPM_VERSION_UNSPEC; + } + return tpm_backend_get_tpm_version(s->be_driver); } =20 --=20 2.5.5 From nobody Sun May 5 00:36:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510696516179551.5365764157033; Tue, 14 Nov 2017 13:55:16 -0800 (PST) Received: from localhost ([::1]:33698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEjAd-00039L-2t for importer@patchew.org; Tue, 14 Nov 2017 16:55:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEj8h-00025z-GJ for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEj8b-00010a-6p for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:53:03 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eEj8Q-0000qD-Tl for qemu-devel@nongnu.org; Tue, 14 Nov 2017 16:52:56 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAELpAWc046504 for ; Tue, 14 Nov 2017 16:52:39 -0500 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e87t9aksm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Nov 2017 16:52:39 -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, 14 Nov 2017 16:52:37 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Nov 2017 16:52:34 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAELqYAM40501342; Tue, 14 Nov 2017 21:52:34 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEC78B2050; Tue, 14 Nov 2017 16:49:44 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id B8412B2046; Tue, 14 Nov 2017 16:49:44 -0500 (EST) From: Stefan Berger To: marcandre.lureau@gmail.com, qemu-devel@nongnu.org, amarnath.valluri@intel.com Date: Tue, 14 Nov 2017 16:52:29 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1510696349-5151-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17111421-0036-0000-0000-0000028C4469 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.00945914; UDB=6.00477424; IPR=6.00726211; 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.00018016; XFM=3.00000015; UTC=2017-11-14 21:52:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111421-0037-0000-0000-00004261E014 Message-Id: <1510696349-5151-4-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-14_11:, , 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-1711140291 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 for-2.11 3/3] tpm_tis: Return 0 for every register in case of failure mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rather than returning ~0, return 0 for every register in case of failure mode. The '0' is better to indicate that there's no device there. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index fec2fc6..42d647d 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -545,7 +545,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr = addr, uint8_t v; =20 if (tpm_backend_had_startup_error(s->be_driver)) { - return val; + return 0; } =20 switch (offset) { --=20 2.5.5