From patchwork Mon Feb 11 15:03:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10806057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DED117E0 for ; Mon, 11 Feb 2019 15:05:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E2012A1BC for ; Mon, 11 Feb 2019 15:05:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2253D2A641; Mon, 11 Feb 2019 15:05:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C27952A1BC for ; Mon, 11 Feb 2019 15:05:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:51420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD97-0006sX-2U for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 10:05:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD7V-0006q2-Ib for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtD7P-0002s1-Ni for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:41 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:35444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtD7N-00027S-C7 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:34 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1BF0hAm063326; Mon, 11 Feb 2019 15:03:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=z2RiYC117uKexXjMH8HHcZkCAJuohROsrzcs8Sd+VIk=; b=x91rPiCgYyfbWke8yrYZwYylA3XOAjGiB7+zLwO+ZbS/mLGlhwk9vtfzSkA7bSNGQJd0 IRYVLNqPIFZqKRww5atBQ/CTwuskl+Eoic8OEFOu30M3CZ07nopL1rCn2G/z9QM8CoeV ZPJ8kr9qPjnMd+3x9KPtbdVaacWPAq/raShTu2Tz96wnb/r0J9PsGzhOR23ZBUHS8tzY 0v7eahPzF7yrtMRq2bF4wt0d1t75gf5DMil40Vg1ne8Zbxt/1QD5wgBp+rAmrN0fyaSp yoaIzTObhHJ1l6IxzXVItKStRNgeIiPUJtMcL9D83ji78haylUqVI5vvFTJunGT98m5+ 6Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2qhre566ed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:14 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1BF3Djt001942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:13 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1BF3CiP013145; Mon, 11 Feb 2019 15:03:13 GMT Received: from ol7.nl.oracle.com (/10.175.19.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Feb 2019 07:03:12 -0800 From: Liam Merwick To: stefanb@linux.ibm.com, qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 15:03:03 +0000 Message-Id: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9164 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=638 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902110114 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v2 1/3] 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 fd6bb9b59a96..61a130beef35 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 addr, } /* cancel any seize by a lower locality */ - for (l = 0; l < locty - 1; l++) { + for (l = 0; l < locty; l++) { s->loc[l].access &= ~TPM_TIS_ACCESS_SEIZE; } From patchwork Mon Feb 11 15:03:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10806061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1FA313A4 for ; Mon, 11 Feb 2019 15:08:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E11AC2A969 for ; Mon, 11 Feb 2019 15:08:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4C512A988; Mon, 11 Feb 2019 15:08:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC6522A969 for ; Mon, 11 Feb 2019 15:08:32 +0000 (UTC) Received: from localhost ([127.0.0.1]:51504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtDCC-00020X-2i for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 10:08:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD8c-0007jB-ML for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:04:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtD8Y-0005z2-JX for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:04:50 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:35516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtD8J-0002HS-DS for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:04:37 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1BF0naX063387; Mon, 11 Feb 2019 15:03:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=R7BDI03hbQrO8rna3VXSWEhpuH65tbA7Jrn+T1/YkSA=; b=YkC4wExCKhIIc1lc9KaTvxW3zvXPLERsyTGshPs1ulmF+sIrXa8FhHXj30TqbHQ4bZIY 4UkuQtwWQsKu3N70Z/HRsPdkSXvBS/i7RWXSAMNhrcJE1Qvxeh6QPNdbcKlnF0URttSP yiM4UzjAvOERP3xWiDBTkRe+ymw9ao6TQD3iwIiCuYBi3MuEpET5wCCcETuAOWRm1zXm W/vX/IuUPd9gGnXVrFh0F7+sS5YQUkPr0yPkbfnzG41eo83ZCFpMUlF5mg/RGxuGyKMi UQ+4JWUtldvtkzo+F6ATXHFXfArSNd4csQh2DM2asT6sEOqK7MPnfGCr8ZOI93zF9x9J +w== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2qhre566ex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1BF3EDg008080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:14 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1BF3EqK021706; Mon, 11 Feb 2019 15:03:14 GMT Received: from ol7.nl.oracle.com (/10.175.19.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Feb 2019 07:03:13 -0800 From: Liam Merwick To: stefanb@linux.ibm.com, qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 15:03:04 +0000 Message-Id: <1549897385-10091-2-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com> References: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9164 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902110114 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v2 2/3] tpm_tis: assert valid addr passed to tpm_tis_locality_from_addr() 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Defensive check to prevent future caller passing incorrect address or catch if the MMIO address parameters were not all changed together. Signed-off-by: Liam Merwick --- I've been running static analysis tools on QEMU and one reports this check. While it's just theoretically correct (impossible to hit with current code), fixing this helps minimise noise and find other issues using those static analyzers as well as defending against the addition of future bugs. hw/tpm/tpm_tis.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 61a130beef35..860c2ace7d99 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -100,6 +100,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr, static uint8_t tpm_tis_locality_from_addr(hwaddr addr) { + assert(addr < TPM_TIS_ADDR_SIZE); return (uint8_t)((addr >> TPM_TIS_LOCALITY_SHIFT) & 0x7); } From patchwork Mon Feb 11 15:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10806055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 982E01575 for ; Mon, 11 Feb 2019 15:05:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8713B2A1BC for ; Mon, 11 Feb 2019 15:05:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AFBD2A641; Mon, 11 Feb 2019 15:05:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E8352A1BC for ; Mon, 11 Feb 2019 15:05:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:51463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD96-0008AB-Gq for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 10:05:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtD7T-0006ou-Tm for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtD7N-0002mF-J3 for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:39 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtD7J-00028g-Pb for qemu-devel@nongnu.org; Mon, 11 Feb 2019 10:03:31 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1BF0vrF054647; Mon, 11 Feb 2019 15:03:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=FA1JXFy188SAYGYnEMd5g0Qrv3PZpxRpH01x1icYUNA=; b=EsS58cbrOzh78nx8TBxtGLSpYzmani4BIlci9ASrBSy8L+vCHlbVvbjdr+KzALn+iO5V MUPuzPxdaIpIaASxK3J2/u/pXnB2NLWtXfosqGigr+M/k6I037ls37t/lEQjetcfdBH8 e+azy/zEPXQeoIZnbMAGvXTA3PtZvEltJrxVqIqxtEoGfJlWOYnv5/EF7upkdemlm/fe EpJzFedcSHf6slbu2vsfiL5GBcUOB3t4X/iKjQaGE4hU1qfcr6PP8gtJLCDOhyksysaw f/xdfaAg3aX/juJA1Yvr++PvszROi+0L03glZDEsjJieMRvP83P2C+Ut4iFTQE6ZfNSW bA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2qhrek66w7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:16 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1BF3GhZ002149 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Feb 2019 15:03:16 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1BF3FRd017212; Mon, 11 Feb 2019 15:03:15 GMT Received: from ol7.nl.oracle.com (/10.175.19.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Feb 2019 07:03:15 -0800 From: Liam Merwick To: stefanb@linux.ibm.com, qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 15:03:05 +0000 Message-Id: <1549897385-10091-3-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com> References: <1549897385-10091-1-git-send-email-liam.merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9164 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1902110114 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH v2 3/3] tpm_tis: fix format string specifier in tpm_tis_show_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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP cppcheck reports: [hw/tpm/tpm_tis.c:113]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int' Fix this by using %u instead of %d Signed-off-by: Liam Merwick Signed-off-by: Liam Merwick Reviewed-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 860c2ace7d99..395500e8a61d 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -110,7 +110,7 @@ static void tpm_tis_show_buffer(const unsigned char *buffer, uint32_t len, i; len = MIN(tpm_cmd_get_size(buffer), buffer_size); - printf("tpm_tis: %s length = %d\n", string, len); + printf("tpm_tis: %s length = %u\n", string, len); for (i = 0; i < len; i++) { if (i && !(i % 16)) { printf("\n");