From nobody Sun Nov 9 16:21:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551714605099301.0176053535937; Mon, 4 Mar 2019 07:50:05 -0800 (PST) Received: from localhost ([127.0.0.1]:56197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0pqp-0004yR-5P for importer@patchew.org; Mon, 04 Mar 2019 10:49:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0pp1-00040b-Uu for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0pov-0005oF-Oi for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:07 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40944 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 1h0pou-0005dG-UP for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:01 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x24FiWAI000849 for ; Mon, 4 Mar 2019 10:47:48 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r16k6ha30-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 04 Mar 2019 10:47:47 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Mar 2019 15:47:47 -0000 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 4 Mar 2019 15:47:44 -0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x24FlhSB10027106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Mar 2019 15:47:43 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4670EAC05B; Mon, 4 Mar 2019 15:47:43 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CEA7AC059; Mon, 4 Mar 2019 15:47:43 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 4 Mar 2019 15:47:43 +0000 (GMT) From: Stefan Berger To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2019 10:47:38 -0500 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190304154739.758486-1-stefanb@linux.vnet.ibm.com> References: <20190304154739.758486-1-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19030415-2213-0000-0000-0000035DA88C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010704; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01169541; UDB=6.00611163; IPR=6.00950169; MB=3.00025830; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-04 15:47:45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19030415-2214-0000-0000-00005D8EBFCE Message-Id: <20190304154739.758486-2-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-04_07:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=844 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903040114 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL v1 1/2] tpm_tis: fix loop that cancels any seizure by a lower locality 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" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick In tpm_tis_mmio_write() if the requesting locality is seizing access, any seizure by a lower locality is cancelled. However the loop doing the seizure had an off-by-one error and the locality immediately preceding the requesting locality was not being cleared. This is fixed by adjusting the test in the for loop to check the localities up to the requesting locality. Signed-off-by: Liam Merwick Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- 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 fd6bb9b59a..61a130beef 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -624,7 +624,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, } =20 /* cancel any seize by a lower locality */ - for (l =3D 0; l < locty - 1; l++) { + for (l =3D 0; l < locty; l++) { s->loc[l].access &=3D ~TPM_TIS_ACCESS_SEIZE; } =20 --=20 2.17.2 From nobody Sun Nov 9 16:21:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551714602097483.2437508515344; Mon, 4 Mar 2019 07:50:02 -0800 (PST) Received: from localhost ([127.0.0.1]:56195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0pqk-0004rl-VM for importer@patchew.org; Mon, 04 Mar 2019 10:49:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0pow-0003xV-MA for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0pov-0005nZ-3O for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41626 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 1h0pou-0005cQ-Qa for qemu-devel@nongnu.org; Mon, 04 Mar 2019 10:48:01 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x24Fir0Q121075 for ; Mon, 4 Mar 2019 10:47:47 -0500 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r15f8mkqk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 04 Mar 2019 10:47:47 -0500 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Mar 2019 15:47:46 -0000 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 4 Mar 2019 15:47:45 -0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x24FlisM22806780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Mar 2019 15:47:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 593B0AC05B; Mon, 4 Mar 2019 15:47:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A458AC059; Mon, 4 Mar 2019 15:47:44 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 4 Mar 2019 15:47:44 +0000 (GMT) From: Stefan Berger To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2019 10:47:39 -0500 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190304154739.758486-1-stefanb@linux.vnet.ibm.com> References: <20190304154739.758486-1-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19030415-0072-0000-0000-0000040442AC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010704; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01169541; UDB=6.00611163; IPR=6.00950169; MB=3.00025830; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-04 15:47:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19030415-0073-0000-0000-00004B5FF3EF Message-Id: <20190304154739.758486-3-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-04_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903040114 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL v1 2/2] tpm_tis: convert tpm_tis_show_buffer() to use trace event 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" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick cppcheck reports: [hw/tpm/tpm_tis.c:113]: (warning) %d in format string (no. 2) requires 'int= ' but the argument type is 'unsigned int' Rather than just converting the format specifier to use '%u", the tpm_tis_show_buffer() function is converted to use trace points and the two debug callers use the trace event infrastructure so that it's available in production cases also and not just when DEBUG_TIS is enabled. Signed-off-by: Liam Merwick Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_tis.c | 31 +++++++++++++++++++------------ hw/tpm/trace-events | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 61a130beef..fd183e8deb 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -106,17 +106,26 @@ static uint8_t tpm_tis_locality_from_addr(hwaddr addr) static void tpm_tis_show_buffer(const unsigned char *buffer, size_t buffer_size, const char *string) { - uint32_t len, i; + size_t len, i; + char *line_buffer, *p; =20 len =3D MIN(tpm_cmd_get_size(buffer), buffer_size); - printf("tpm_tis: %s length =3D %d\n", string, len); - for (i =3D 0; i < len; i++) { + + /* + * allocate enough room for 3 chars per buffer entry plus a + * newline after every 16 chars and a final null terminator. + */ + line_buffer =3D g_malloc(len * 3 + (len / 16) + 1); + + for (i =3D 0, p =3D line_buffer; i < len; i++) { if (i && !(i % 16)) { - printf("\n"); + p +=3D sprintf(p, "\n"); } - printf("%.2X ", buffer[i]); + p +=3D sprintf(p, "%.2X ", buffer[i]); } - printf("\n"); + trace_tpm_tis_show_buffer(string, len, line_buffer); + + g_free(line_buffer); } =20 /* @@ -143,9 +152,8 @@ static void tpm_tis_sts_set(TPMLocality *l, uint32_t fl= ags) */ static void tpm_tis_tpm_send(TPMState *s, uint8_t locty) { - if (DEBUG_TIS) { - tpm_tis_show_buffer(s->buffer, s->be_buffer_size, - "tpm_tis: To TPM"); + if (trace_event_get_state_backends(TRACE_TPM_TIS_SHOW_BUFFER)) { + tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "To TPM"); } =20 /* @@ -313,9 +321,8 @@ static void tpm_tis_request_completed(TPMIf *ti, int re= t) s->loc[locty].state =3D TPM_TIS_STATE_COMPLETION; s->rw_offset =3D 0; =20 - if (DEBUG_TIS) { - tpm_tis_show_buffer(s->buffer, s->be_buffer_size, - "tpm_tis: From TPM"); + if (trace_event_get_state_backends(TRACE_TPM_TIS_SHOW_BUFFER)) { + tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "From TPM"); } =20 if (TPM_TIS_IS_VALID_LOCTY(s->next_locty)) { diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events index 920d32ad55..f45dcd2209 100644 --- a/hw/tpm/trace-events +++ b/hw/tpm/trace-events @@ -36,6 +36,7 @@ tpm_emulator_pre_save(void) "" tpm_emulator_inst_init(void) "" =20 # hw/tpm/tpm_tis.c +tpm_tis_show_buffer(const char *direction, size_t len, const char *buf) "d= irection: %s len: %zu\nbuf: %s" tpm_tis_raise_irq(uint32_t irqmask) "Raising IRQ for flag 0x%08x" tpm_tis_new_active_locality(uint8_t locty) "Active locality is now %d" tpm_tis_abort(uint8_t locty) "New active locality is %d" --=20 2.17.2