Received: by 2002:a19:cb43:0:0:0:0:0 with SMTP id b64csp3095815lfg; Wed, 26 Feb 2020 05:44:51 -0800 (PST) X-Google-Smtp-Source: APXvYqw10Yo9a4JhfAcAlKGLL6YtGQs7AsbavWtsGK4Wi3NDkAM4SXNzYZiggAPGyeX745F/utsK X-Received: by 2002:a05:620a:742:: with SMTP id i2mr5241246qki.226.1582724691504; Wed, 26 Feb 2020 05:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582724691; cv=none; d=google.com; s=arc-20160816; b=ypXnVI8oLzgUj0CmCUZmmY8+uM9W/DRtH8RUvi6e3fD2Rihklfgmj9oKt9aE/QsJbo 20/t1DHj+6RXn+5y8VVxv7+IbQe+UwHZAQ1lBRBqgNP3idvJai4HfUQffdyZCujdnKuh lLHfwkLY7qpTOmRS7INtQvcYgqlcJRxYVxntzlNCtc2wenQ5D4nHagtxQxbGosD9dlaq hYkWn5yjiu5Rvx95LGMhIcp5hGiO3yAcSzA8xoqJZO6r3iE08GZAsObxf8E9KwTZgeEH mFg742a5k3ai/o0opyVnhyFhKkg1TzEMR7PHaMbNg491hD/E+U1WfmVl0cYwXFtOkLDT 29rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject; bh=P5/COoz6j9ib1+i4Sco6MhFkl66MonZfztOOApDq7kM=; b=v+HGtJqlZyCJmyi+aTU8znpOh4h0AkWPDBoBpAcd72YziBth8P59scF/qzPYUwPLnn w0xQrnDOi+nsd2zHqfRU0i2I/HNw4YBsvaB936a03SHss4dYCldJHDoGqzs49ERVKxNU Unaxv+vPgnWKXsmhCHkfVUrxrPxcWgQTjQFUicGffOi5o+blsTLDbzG2AfMYVUhsosWQ JOtdyER29SGwGqDGE+ekU1ka0ux6imgIc6vm+MM2s6AC6rZD893xZMX5vNp6mp+MrNqB 5OknNs9J18B8Xil3m5C/5Xv/Gybwnqhf88mKd1cxktCaRBZYPKFJoauzkHITeVBWpwqV 4DAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n7si1201189qtl.44.2020.02.26.05.44.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Feb 2020 05:44:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:44530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6wza-0005OS-VL for alex.bennee@linaro.org; Wed, 26 Feb 2020 08:44:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6wzS-0005OJ-QF for qemu-arm@nongnu.org; Wed, 26 Feb 2020 08:44:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6wzR-0007AV-8t for qemu-arm@nongnu.org; Wed, 26 Feb 2020 08:44:42 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40304 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 1j6wzR-00075v-26; Wed, 26 Feb 2020 08:44:41 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01QDiCBH100936; Wed, 26 Feb 2020 08:44:39 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ydq5ynmn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2020 08:44:38 -0500 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 01QDicxp102386; Wed, 26 Feb 2020 08:44:38 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ydq5ynmma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2020 08:44:38 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01QDZKWi002313; Wed, 26 Feb 2020 13:44:37 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 2ydcmkpxgt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2020 13:44:37 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01QDiaiQ50070010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 13:44:36 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 265722805A; Wed, 26 Feb 2020 13:44:36 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C0442805E; Wed, 26 Feb 2020 13:44:36 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 26 Feb 2020 13:44:35 +0000 (GMT) Subject: Re: [PATCH v3 10/10] test: tpm-tis: Add Sysbus TPM-TIS device test To: Eric Auger , eric.auger.pro@gmail.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org References: <20200226102549.12158-1-eric.auger@redhat.com> <20200226102549.12158-11-eric.auger@redhat.com> From: Stefan Berger Message-ID: <626417fa-8cf3-5e0e-78ec-7f5b77fc0a9f@linux.ibm.com> Date: Wed, 26 Feb 2020 08:44:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200226102549.12158-11-eric.auger@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-26_04:2020-02-26, 2020-02-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 suspectscore=2 mlxscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002260102 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id 01QDiCBH100936 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, lersek@redhat.com, ardb@kernel.org, philmd@redhat.com Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 6aqQB/8RaCbV On 2/26/20 5:25 AM, Eric Auger wrote: > The tests themselves are the same as the ISA device ones. > Only the main() changes as the "tpm-tis-device" device gets > instantiated. Also the base address of the device is not > 0xFED40000 anymore but matches the base address of the > ARM virt platform bus. > > Signed-off-by: Eric Auger Reviewed-by: Stefan Berger > --- > tests/qtest/Makefile.include | 5 ++ > tests/qtest/tpm-tis-device-swtpm-test.c | 76 +++++++++++++++++++++ > tests/qtest/tpm-tis-device-test.c | 87 ++++++++++++++++++++++++= + > 3 files changed, 168 insertions(+) > create mode 100644 tests/qtest/tpm-tis-device-swtpm-test.c > create mode 100644 tests/qtest/tpm-tis-device-test.c > > diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.includ= e > index 44aac68b25..383b0ab217 100644 > --- a/tests/qtest/Makefile.include > +++ b/tests/qtest/Makefile.include > @@ -130,6 +130,8 @@ check-qtest-arm-y +=3D hexloader-test > check-qtest-arm-$(CONFIG_PFLASH_CFI02) +=3D pflash-cfi02-test > =20 > check-qtest-aarch64-y +=3D arm-cpu-features > +check-qtest-aarch64-$(CONFIG_TPM_TIS_SYSBUS) +=3D tpm-tis-device-test > +check-qtest-aarch64-$(CONFIG_TPM_TIS_SYSBUS) +=3D tpm-tis-device-swtpm= -test > check-qtest-aarch64-y +=3D numa-test > check-qtest-aarch64-y +=3D boot-serial-test > check-qtest-aarch64-y +=3D migration-test > @@ -302,7 +304,10 @@ tests/qtest/tpm-crb-swtpm-test$(EXESUF): tests/qte= st/tpm-crb-swtpm-test.o tests/ > tests/qtest/tpm-crb-test$(EXESUF): tests/qtest/tpm-crb-test.o tests/q= test/tpm-emu.o $(test-io-obj-y) > tests/qtest/tpm-tis-swtpm-test$(EXESUF): tests/qtest/tpm-tis-swtpm-te= st.o tests/qtest/tpm-emu.o \ > tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y) > +tests/qtest/tpm-tis-device-swtpm-test$(EXESUF): tests/qtest/tpm-tis-de= vice-swtpm-test.o tests/qtest/tpm-emu.o \ > + tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y) > tests/qtest/tpm-tis-test$(EXESUF): tests/qtest/tpm-tis-test.o tests/q= test/tpm-tis-util.o tests/qtest/tpm-emu.o $(test-io-obj-y) > +tests/qtest/tpm-tis-device-test$(EXESUF): tests/qtest/tpm-tis-device-t= est.o tests/qtest/tpm-tis-util.o tests/qtest/tpm-emu.o $(test-io-obj-y) > =20 > # QTest rules > =20 > diff --git a/tests/qtest/tpm-tis-device-swtpm-test.c b/tests/qtest/tpm-= tis-device-swtpm-test.c > new file mode 100644 > index 0000000000..7b20035142 > --- /dev/null > +++ b/tests/qtest/tpm-tis-device-swtpm-test.c > @@ -0,0 +1,76 @@ > +/* > + * QTest testcase for Sysbus TPM TIS talking to external swtpm and swt= pm > + * migration > + * > + * Copyright (c) 2018 IBM Corporation > + * with parts borrowed from migration-test.c that is: > + * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates > + * > + * Authors: > + * Stefan Berger > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or = later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include > + > +#include "libqtest.h" > +#include "qemu/module.h" > +#include "tpm-tests.h" > +#include "hw/acpi/tpm.h" > + > +uint64_t tpm_tis_base_addr =3D 0xc000000; > +#define MACHINE_OPTIONS "-machine virt,gic-version=3Dmax -accel tcg" > + > +typedef struct TestState { > + char *src_tpm_path; > + char *dst_tpm_path; > + char *uri; > +} TestState; > + > +static void tpm_tis_swtpm_test(const void *data) > +{ > + const TestState *ts =3D data; > + > + tpm_test_swtpm_test(ts->src_tpm_path, tpm_util_tis_transfer, > + "tpm-tis-device", MACHINE_OPTIONS); > +} > + > +static void tpm_tis_swtpm_migration_test(const void *data) > +{ > + const TestState *ts =3D data; > + > + tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, = ts->uri, > + tpm_util_tis_transfer, "tpm-tis-devi= ce", > + MACHINE_OPTIONS); > +} > + > +int main(int argc, char **argv) > +{ > + int ret; > + TestState ts =3D { 0 }; > + > + ts.src_tpm_path =3D g_dir_make_tmp("qemu-tpm-tis-device-swtpm-test= .XXXXXX", > + NULL); > + ts.dst_tpm_path =3D g_dir_make_tmp("qemu-tpm-tis-device-swtpm-test= .XXXXXX", > + NULL); > + ts.uri =3D g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path); > + > + module_call_init(MODULE_INIT_QOM); > + g_test_init(&argc, &argv, NULL); > + > + qtest_add_data_func("/tpm/tis-swtpm/test", &ts, tpm_tis_swtpm_test= ); > + qtest_add_data_func("/tpm/tis-swtpm-migration/test", &ts, > + tpm_tis_swtpm_migration_test); > + ret =3D g_test_run(); > + > + g_rmdir(ts.dst_tpm_path); > + g_free(ts.dst_tpm_path); > + g_rmdir(ts.src_tpm_path); > + g_free(ts.src_tpm_path); > + g_free(ts.uri); > + > + return ret; > +} > diff --git a/tests/qtest/tpm-tis-device-test.c b/tests/qtest/tpm-tis-de= vice-test.c > new file mode 100644 > index 0000000000..63ed36440f > --- /dev/null > +++ b/tests/qtest/tpm-tis-device-test.c > @@ -0,0 +1,87 @@ > +/* > + * QTest testcase for SYSBUS TPM TIS > + * > + * Copyright (c) 2018 Red Hat, Inc. > + * Copyright (c) 2018 IBM Corporation > + * > + * Authors: > + * Marc-Andr=C3=A9 Lureau > + * Stefan Berger > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or = later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include > + > +#include "io/channel-socket.h" > +#include "libqtest-single.h" > +#include "qemu/module.h" > +#include "tpm-emu.h" > +#include "tpm-util.h" > +#include "tpm-tis-util.h" > + > +/* > + * As the Sysbus tpm-tis-device is instantiated on the ARM virt > + * platform bus and it is the only sysbus device dynamically > + * instantiated, it gets plugged at its base address > + */ > +uint64_t tpm_tis_base_addr =3D 0xc000000; > + > +int main(int argc, char **argv) > +{ > + char *tmp_path =3D g_dir_make_tmp("qemu-tpm-tis-device-test.XXXXXX= ", NULL); > + GThread *thread; > + TestState test; > + char *args; > + int ret; > + > + module_call_init(MODULE_INIT_QOM); > + g_test_init(&argc, &argv, NULL); > + > + test.addr =3D g_new0(SocketAddress, 1); > + test.addr->type =3D SOCKET_ADDRESS_TYPE_UNIX; > + test.addr->u.q_unix.path =3D g_build_filename(tmp_path, "sock", NU= LL); > + g_mutex_init(&test.data_mutex); > + g_cond_init(&test.data_cond); > + test.data_cond_signal =3D false; > + > + thread =3D g_thread_new(NULL, tpm_emu_ctrl_thread, &test); > + tpm_emu_test_wait_cond(&test); > + > + args =3D g_strdup_printf( > + "-machine virt,gic-version=3Dmax -accel tcg " > + "-chardev socket,id=3Dchr,path=3D%s " > + "-tpmdev emulator,id=3Ddev,chardev=3Dchr " > + "-device tpm-tis-device,tpmdev=3Ddev", > + test.addr->u.q_unix.path); > + qtest_start(args); > + > + qtest_add_data_func("/tpm-tis/test_check_localities", &test, > + tpm_tis_test_check_localities); > + > + qtest_add_data_func("/tpm-tis/test_check_access_reg", &test, > + tpm_tis_test_check_access_reg); > + > + qtest_add_data_func("/tpm-tis/test_check_access_reg_seize", &test, > + tpm_tis_test_check_access_reg_seize); > + > + qtest_add_data_func("/tpm-tis/test_check_access_reg_release", &tes= t, > + tpm_tis_test_check_access_reg_release); > + > + qtest_add_data_func("/tpm-tis/test_check_transmit", &test, > + tpm_tis_test_check_transmit); > + > + ret =3D g_test_run(); > + > + qtest_end(); > + > + g_thread_join(thread); > + g_unlink(test.addr->u.q_unix.path); > + qapi_free_SocketAddress(test.addr); > + g_rmdir(tmp_path); > + g_free(tmp_path); > + g_free(args); > + return ret; > +}