From nobody Sun Apr 28 03:59:48 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1510170452541327.05006565575616; Wed, 8 Nov 2017 11:47:32 -0800 (PST) Received: from localhost ([::1]:33679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCWJg-00085X-CW for importer@patchew.org; Wed, 08 Nov 2017 14:47:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCWIs-0007jW-EP for qemu-devel@nongnu.org; Wed, 08 Nov 2017 14:46:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCWIj-0004Qk-FR for qemu-devel@nongnu.org; Wed, 08 Nov 2017 14:46:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCWIj-0004PH-6C for qemu-devel@nongnu.org; Wed, 08 Nov 2017 14:46:17 -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 vA8JiGK7082524 for ; Wed, 8 Nov 2017 14:46:09 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e45b82meu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Nov 2017 14:46:08 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Nov 2017 14:46:07 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 8 Nov 2017 14:46:04 -0500 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA8Jk4gV37945368; Wed, 8 Nov 2017 19:46:04 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D258CAE03C; Wed, 8 Nov 2017 14:46:52 -0500 (EST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id C5FBAAE051; Wed, 8 Nov 2017 14:46:52 -0500 (EST) From: Stefan Berger To: qemu-devel@nongnu.org, marcandre.lureau@redhat.com Date: Wed, 8 Nov 2017 14:45:56 -0500 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 x-cbid: 17110819-2213-0000-0000-00000238549C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008033; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00943037; UDB=6.00475760; IPR=6.00723325; BA=6.00005679; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017915; XFM=3.00000015; UTC=2017-11-08 19:46:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110819-2214-0000-0000-000058198E62 Message-Id: <1510170356-16953-1-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-08_03:, , 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-1707230000 definitions=main-1711080258 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] tpm: 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: amarnath.valluri@intel.com, Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 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 backend every time the flag is read by accessing the REG_ACCESS register. Signed-off-by: Stefan Berger --- hw/tpm/tpm_tis.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 7402528..6b81bbf 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -95,6 +95,9 @@ struct TPMState { char *backend; TPMBackend *be_driver; TPMVersion be_tpm_version; + + unsigned int established_flag:1; + unsigned int established_flag_cached:1; }; =20 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS) @@ -529,6 +532,26 @@ static void tpm_tis_dump_state(void *opaque, hwaddr ad= dr) } #endif =20 +static void tpm_tis_reset_tpm_established_flag(TPMState *s, + uint8_t locty) +{ + s->established_flag_cached =3D 0; + + tpm_backend_reset_tpm_established_flag(s->be_driver, locty); +} + +static unsigned int tpm_tis_get_tpm_established_flag(TPMState *s) +{ + if (s->established_flag_cached) { + return s->established_flag; + } + + s->established_flag =3D !tpm_backend_get_tpm_established_flag(s->be_dr= iver); + s->established_flag_cached =3D 1; + + return s->established_flag; +} + /* * Read a register of the TIS interface * See specs pages 33-63 for description of the registers @@ -556,7 +579,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr = addr, if (tpm_tis_check_request_use_except(s, locty)) { val |=3D TPM_TIS_ACCESS_PENDING_REQUEST; } - val |=3D !tpm_backend_get_tpm_established_flag(s->be_driver); + val |=3D tpm_tis_get_tpm_established_flag(s); break; case TPM_TIS_REG_INT_ENABLE: val =3D s->loc[locty].inte; @@ -840,7 +863,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, =20 if (val & TPM_TIS_STS_RESET_ESTABLISHMENT_BIT) { if (locty =3D=3D 3 || locty =3D=3D 4) { - tpm_backend_reset_tpm_established_flag(s->be_driver, l= octy); + tpm_tis_reset_tpm_established_flag(s, locty); } } } --=20 2.5.5