From nobody Tue Oct 28 20:56:44 2025 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 15139741149261.6302888007490992; Fri, 22 Dec 2017 12:21:54 -0800 (PST) Received: from localhost ([::1]:37021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSTpF-0004uK-NR for importer@patchew.org; Fri, 22 Dec 2017 15:21:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSTkM-00018F-R5 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 15:16:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSTkI-0000iv-CZ for qemu-devel@nongnu.org; Fri, 22 Dec 2017 15:16:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eSTkI-0000iF-3g for qemu-devel@nongnu.org; Fri, 22 Dec 2017 15:16:42 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBMKGfnq056278 for ; Fri, 22 Dec 2017 15:16:41 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2f18sr89a7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 22 Dec 2017 15:16:40 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Dec 2017 13:16:40 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 22 Dec 2017 13:16:37 -0700 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBMKGbs16226248; Fri, 22 Dec 2017 13:16:37 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 722E4BE039; Fri, 22 Dec 2017 13:16:37 -0700 (MST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 24171BE03B; Fri, 22 Dec 2017 13:16:37 -0700 (MST) From: Stefan Berger To: qemu-devel@nongnu.org Date: Fri, 22 Dec 2017 15:16:21 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1513973785-14427-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1513973785-14427-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17122220-0016-0000-0000-000008038DE9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008245; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00964064; UDB=6.00487777; IPR=6.00744051; BA=6.00005755; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018678; XFM=3.00000015; UTC=2017-12-22 20:16:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17122220-0017-0000-0000-00003CC04851 Message-Id: <1513973785-14427-7-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-22_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1712220285 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id vBMKGfnq056278 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL v1 06/10] tpm_tis: merge read and write buffer into single buffer 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: peter.maydell@linaro.org, Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we can only be in read or write mode, we can merge the buffers into a single buffer. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/tpm/tpm_tis.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 34bfc86..ad36347 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -70,8 +70,7 @@ typedef struct TPMState { ISADevice busdev; MemoryRegion mmio; =20 - unsigned char w_buffer[TPM_TIS_BUFFER_MAX]; - unsigned char r_buffer[TPM_TIS_BUFFER_MAX]; + unsigned char buffer[TPM_TIS_BUFFER_MAX]; =20 uint8_t active_locty; uint8_t aborting_locty; @@ -257,7 +256,7 @@ static void tpm_tis_tpm_send(TPMState *s, uint8_t locty) { TPMLocality *locty_data =3D &s->loc[locty]; =20 - tpm_tis_show_buffer(s->w_buffer, s->be_buffer_size, + tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "tpm_tis: To TPM"); =20 /* @@ -268,9 +267,9 @@ static void tpm_tis_tpm_send(TPMState *s, uint8_t locty) =20 s->cmd =3D (TPMBackendCmd) { .locty =3D locty, - .in =3D s->w_buffer, + .in =3D s->buffer, .in_len =3D locty_data->w_offset, - .out =3D s->r_buffer, + .out =3D s->buffer, .out_len =3D s->be_buffer_size, }; =20 @@ -422,7 +421,7 @@ static void tpm_tis_request_completed(TPMIf *ti) s->loc[locty].r_offset =3D 0; s->loc[locty].w_offset =3D 0; =20 - tpm_tis_show_buffer(s->r_buffer, s->be_buffer_size, + tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "tpm_tis: From TPM"); =20 if (TPM_TIS_IS_VALID_LOCTY(s->next_locty)) { @@ -442,10 +441,10 @@ static uint32_t tpm_tis_data_read(TPMState *s, uint8_= t locty) uint16_t len; =20 if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) { - len =3D MIN(tpm_cmd_get_size(&s->r_buffer), + len =3D MIN(tpm_cmd_get_size(&s->buffer), s->be_buffer_size); =20 - ret =3D s->r_buffer[s->loc[locty].r_offset++]; + ret =3D s->buffer[s->loc[locty].r_offset++]; if (s->loc[locty].r_offset >=3D len) { /* got last byte */ tpm_tis_sts_set(&s->loc[locty], TPM_TIS_STS_VALID); @@ -491,11 +490,11 @@ static void tpm_tis_dump_state(void *opaque, hwaddr a= ddr) "tpm_tis: result buffer : ", s->loc[locty].r_offset); for (idx =3D 0; - idx < MIN(tpm_cmd_get_size(&s->r_buffer), s->be_buffer_size); + idx < MIN(tpm_cmd_get_size(&s->buffer), s->be_buffer_size); idx++) { DPRINTF("%c%02x%s", s->loc[locty].r_offset =3D=3D idx ? '>' : ' ', - s->r_buffer[idx], + s->buffer[idx], ((idx & 0xf) =3D=3D 0xf) ? "\ntpm_tis: " := ""); } DPRINTF("\n" @@ -503,11 +502,11 @@ static void tpm_tis_dump_state(void *opaque, hwaddr a= ddr) "tpm_tis: request buffer: ", s->loc[locty].w_offset); for (idx =3D 0; - idx < MIN(tpm_cmd_get_size(s->w_buffer), s->be_buffer_size); + idx < MIN(tpm_cmd_get_size(s->buffer), s->be_buffer_size); idx++) { DPRINTF("%c%02x%s", s->loc[locty].w_offset =3D=3D idx ? '>' : ' ', - s->w_buffer[idx], + s->buffer[idx], ((idx & 0xf) =3D=3D 0xf) ? "\ntpm_tis: " := ""); } DPRINTF("\n"); @@ -569,7 +568,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr = addr, if (s->active_locty =3D=3D locty) { if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) { val =3D TPM_TIS_BURST_COUNT( - MIN(tpm_cmd_get_size(&s->r_buffer), + MIN(tpm_cmd_get_size(&s->buffer), s->be_buffer_size) - s->loc[locty].r_offset) | s->loc[locty].sts; } else { @@ -922,7 +921,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, =20 while ((s->loc[locty].sts & TPM_TIS_STS_EXPECT) && size > 0) { if (s->loc[locty].w_offset < s->be_buffer_size) { - s->w_buffer[s->loc[locty].w_offset++] =3D + s->buffer[s->loc[locty].w_offset++] =3D (uint8_t)val; val >>=3D 8; size--; @@ -937,7 +936,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, /* we have a packet length - see if we have all of it */ bool need_irq =3D !(s->loc[locty].sts & TPM_TIS_STS_VALID); =20 - len =3D tpm_cmd_get_size(&s->w_buffer); + len =3D tpm_cmd_get_size(&s->buffer); if (len > s->loc[locty].w_offset) { tpm_tis_sts_set(&s->loc[locty], TPM_TIS_STS_EXPECT | TPM_TIS_STS_VALID= ); --=20 2.5.5