From nobody Thu May 2 05:26:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594073707; cv=none; d=zohomail.com; s=zohoarc; b=EgBVpFvMeXWduK3HHfMgqVmPIWnc+gpqNVdRw+/KHwuU/OKQmd4keZvXXOM2fBmfVMyjHjCt4N2GXpwpL95ADeOdmCbSZ94kg0POIRgPnKgxQlUT2Hh3rSxkOImO9SjzQES3WJb3WiJMMf1MmTYXRCe+azzfZqVPDmjntmLo9nY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594073707; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zoo/1+y9TwBnvXDpnQhqKES7akrlvTIdoIo+YWPc9ak=; b=LvxhM8rhaSsB2DdP4TZmuXd24amNyM0DH/QWrcS3LtZyIemi8q1jjXXlt/jQIfxD4TXWdt3vBS7h1FlPSBFcWtQ8I0XQb/5OHQXP85TEWmTqJ/GHrToXPAIKNUy0PA7c4v6ExRHLwou++WVsyAywe3d2H7+09tfvRc+CvAVX5S8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.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 1594073707215504.6013720579962; Mon, 6 Jul 2020 15:15:07 -0700 (PDT) Received: from localhost ([::1]:55044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsZOD-0002o4-Tg for importer@patchew.org; Mon, 06 Jul 2020 18:15:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsZMr-0001JH-Ao; Mon, 06 Jul 2020 18:13:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33352) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsZMp-0000rt-E3; Mon, 06 Jul 2020 18:13:41 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 066M3QM1076574; Mon, 6 Jul 2020 18:13:32 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3248r75wa3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 18:13:32 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 066M4OVv078904; Mon, 6 Jul 2020 18:13:32 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3248r75w9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 18:13:32 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 066MAhcs027975; Mon, 6 Jul 2020 22:13:31 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03wdc.us.ibm.com with ESMTP id 322hd8b00x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 22:13:30 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 066MDUl353215602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Jul 2020 22:13:30 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F32537806B; Mon, 6 Jul 2020 22:13:29 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68C1A7806E; Mon, 6 Jul 2020 22:13:29 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 6 Jul 2020 22:13:29 +0000 (GMT) From: Stefan Berger To: qemu-ppc@nongnu.org, marcandre.lureau@redhat.com Subject: [PATCH 1/2] tpm: tpm_spapr: Exit on TPM backend failures Date: Mon, 6 Jul 2020 18:13:26 -0400 Message-Id: <20200706221327.3914491-2-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200706221327.3914491-1-stefanb@linux.vnet.ibm.com> References: <20200706221327.3914491-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-06_20:2020-07-06, 2020-07-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 impostorscore=0 cotscore=-2147483648 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007060150 Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=148.163.156.1; envelope-from=stefanb@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 17:55:09 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger , Stefan Berger , qemu-devel@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Exit on TPM backend failures in the same way as the TPM CRB and TIS device models do. Signed-off-by: Stefan Berger --- hw/tpm/tpm_spapr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c index cb4dfd1e6a..8288ab0a15 100644 --- a/hw/tpm/tpm_spapr.c +++ b/hw/tpm/tpm_spapr.c @@ -306,7 +306,10 @@ static void tpm_spapr_reset(SpaprVioDevice *dev) TPM_SPAPR_BUFFER_MAX); =20 tpm_backend_reset(s->be_driver); - tpm_spapr_do_startup_tpm(s, s->be_buffer_size); + + if (tpm_spapr_do_startup_tpm(s, s->be_buffer_size) < 0) { + exit(1); + } } =20 static enum TPMVersion tpm_spapr_get_version(TPMIf *ti) --=20 2.24.1 From nobody Thu May 2 05:26:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594073698; cv=none; d=zohomail.com; s=zohoarc; b=HalMgSTHOIDfAN/cRf53JFf2G/lFCSnEQGLnloVOenkHnKxnSyFUJDDSyOdq31Hb3QkWzdTUVrwJQ9rGJ3dBiIralaYXRlyFzsqXR8dZq8s17AV9OeF1rbwTce6FWPB4oLh7nUDHktOX/xZYF7iIa/KS4zjfJFrDeUE7+sKKlmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594073698; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ni5X+qmoFELx9sQRtIMkzWW+iyxHVmQ6cvgOVibAHVs=; b=iTKAFHS3FGlZt4ssPYOx/JvX2nC7t5GzJEs/ByavWJjU2QHYlR8PybMD/S41jY4lsAeYSHvIB03MnHed40ifc1PgQdtMcUiXOLvWeAifHJaxKZ3rG/Fso/vTew04q7t82x+sp9tXG4YZhD+JnuzFh/eFE/EdMtvAj3t3UugcN4s= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.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 15940736982791006.9826472081581; Mon, 6 Jul 2020 15:14:58 -0700 (PDT) Received: from localhost ([::1]:54470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsZO4-0002a3-1j for importer@patchew.org; Mon, 06 Jul 2020 18:14:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsZMs-0001JS-9x; Mon, 06 Jul 2020 18:13:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:22528) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsZMp-0000s6-SC; Mon, 06 Jul 2020 18:13:42 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 066M23RD050939; Mon, 6 Jul 2020 18:13:33 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 324bfg9n6k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 18:13:32 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 066M2pT3054667; Mon, 6 Jul 2020 18:13:32 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 324bfg9n6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 18:13:32 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 066MAMtT003549; Mon, 6 Jul 2020 22:13:32 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01wdc.us.ibm.com with ESMTP id 322hd8ax44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2020 22:13:31 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 066MDU8D59834744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Jul 2020 22:13:31 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE0AA7807C; Mon, 6 Jul 2020 22:13:30 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34C727806E; Mon, 6 Jul 2020 22:13:30 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 6 Jul 2020 22:13:30 +0000 (GMT) From: Stefan Berger To: qemu-ppc@nongnu.org, marcandre.lureau@redhat.com Subject: [PATCH 2/2] tests: Skip over first 14 bytes when comparing TPM PCRRead result Date: Mon, 6 Jul 2020 18:13:27 -0400 Message-Id: <20200706221327.3914491-3-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200706221327.3914491-1-stefanb@linux.vnet.ibm.com> References: <20200706221327.3914491-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-06_20:2020-07-06, 2020-07-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 cotscore=-2147483648 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007060146 Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=148.163.158.5; envelope-from=stefanb@linux.vnet.ibm.com; helo=mx0b-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 18:13:38 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger , Stefan Berger , qemu-devel@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Due to a change in the TPM 2 code the pcrUpdate counter in the PCRRead response is now different. The easiest way is to skip over the first 14 bytes and only compare the tail of the response. Signed-off-by: Stefan Berger --- tests/qtest/tpm-tests.c | 6 +++--- tests/qtest/tpm-util.c | 6 ++++-- tests/qtest/tpm-util.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c index a2f2838e15..8f6491a4b7 100644 --- a/tests/qtest/tpm-tests.c +++ b/tests/qtest/tpm-tests.c @@ -65,7 +65,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_fun= c *tx, "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" "\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde"; tpm_util_pcrread(s, tx, tpm_pcrread_resp, - sizeof(tpm_pcrread_resp)); + sizeof(tpm_pcrread_resp), 14); =20 qtest_end(); tpm_util_swtpm_kill(swtpm_pid); @@ -113,13 +113,13 @@ void tpm_test_swtpm_migration_test(const char *src_tp= m_path, "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" "\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde"; tpm_util_pcrread(src_qemu, tx, tpm_pcrread_resp, - sizeof(tpm_pcrread_resp)); + sizeof(tpm_pcrread_resp), 14); =20 tpm_util_migrate(src_qemu, uri); tpm_util_wait_for_migration_complete(src_qemu); =20 tpm_util_pcrread(dst_qemu, tx, tpm_pcrread_resp, - sizeof(tpm_pcrread_resp)); + sizeof(tpm_pcrread_resp), 14); =20 qtest_quit(dst_qemu); qtest_quit(src_qemu); diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index 34efae8f18..df85e23432 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -130,7 +130,8 @@ void tpm_util_pcrextend(QTestState *s, tx_func *tx) } =20 void tpm_util_pcrread(QTestState *s, tx_func *tx, - const unsigned char *exp_resp, size_t exp_resp_size) + const unsigned char *exp_resp, size_t exp_resp_size, + off_t offset) { unsigned char buffer[1024]; unsigned char tpm_pcrread[] =3D @@ -139,7 +140,8 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx, =20 tx(s, tpm_pcrread, sizeof(tpm_pcrread), buffer, sizeof(buffer)); =20 - g_assert_cmpmem(buffer, exp_resp_size, exp_resp, exp_resp_size); + g_assert_cmpmem(&buffer[offset], exp_resp_size - offset, + &exp_resp[offset], exp_resp_size - offset); } =20 bool tpm_util_swtpm_has_tpm2(void) diff --git a/tests/qtest/tpm-util.h b/tests/qtest/tpm-util.h index 3b97d69017..d6f4c17218 100644 --- a/tests/qtest/tpm-util.h +++ b/tests/qtest/tpm-util.h @@ -34,7 +34,8 @@ void tpm_util_tis_transfer(QTestState *s, void tpm_util_startup(QTestState *s, tx_func *tx); void tpm_util_pcrextend(QTestState *s, tx_func *tx); void tpm_util_pcrread(QTestState *s, tx_func *tx, - const unsigned char *exp_resp, size_t exp_resp_size); + const unsigned char *exp_resp, size_t exp_resp_size, + off_t offset); =20 bool tpm_util_swtpm_has_tpm2(void); =20 --=20 2.24.1