From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA40BC76196 for ; Tue, 28 Mar 2023 13:22:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph9H5-0005JX-HN; Tue, 28 Mar 2023 09:22:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph9Gz-0005Ed-1k for qemu-devel@nongnu.org; Tue, 28 Mar 2023 09:22:01 -0400 Received: from 1.mo552.mail-out.ovh.net ([178.32.96.117]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph9Gw-0004zn-I1 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 09:22:00 -0400 Received: from mxplan5.mail.ovh.net (unknown [10.108.20.52]) by mo552.mail-out.ovh.net (Postfix) with ESMTPS id B22D7293AA; Tue, 28 Mar 2023 13:21:54 +0000 (UTC) Received: from kaod.org (37.59.142.96) by DAG4EX2.mxp5.local (172.16.2.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 28 Mar 2023 15:21:53 +0200 Authentication-Results: garm.ovh; auth=pass (GARM-96R001f4b3c138-d4f7-4c1d-a8d2-661e5bd4dbcc, 5D21C2AA46E1B9891D174392918792ED1A5C90BB) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <1c6543c5-e924-b0f3-4f4e-5654a8aa9d29@kaod.org> Date: Tue, 28 Mar 2023 15:21:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] tests/avocado/aspeed: Add TPM TIS I2C test Content-Language: en-US To: Joel Stanley , , CC: Cleber Rosa , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , Wainer dos Santos Moschetta , Beraldo Leal , References: <20230328120844.190914-1-joel@jms.id.au> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <20230328120844.190914-1-joel@jms.id.au> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.96] X-ClientProxiedBy: DAG5EX2.mxp5.local (172.16.2.42) To DAG4EX2.mxp5.local (172.16.2.32) X-Ovh-Tracer-GUID: 9109d425-3a2c-4ab7-a1c5-be44c4fbd597 X-Ovh-Tracer-Id: 16857536357849205612 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehgedgieefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeefgfekteekgeelheeujeeghfetkeetleeiudeuffektefgkeehueffheevveekjeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppeduvdejrddtrddtrddupdefjedrheelrddugedvrdelieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegtlhhgsehkrghougdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjhhovghlsehjmhhsrdhiugdrrghupdhsthgvfhgrnhgssehlihhnuhigrdhisghmrdgtohhmpdhnihhnrggusehlihhnuhigrdhisghmrdgtohhmpdgtrhhoshgrsehrvgguhhgrthdrtghomhdpphhhihhlmhgusehlihhnrghrohdrohhrghdpfigrihhnvghrshhmsehrvgguhhgrthdrtghomhdpsghlvggrlhesrhgvughhrghtrdgtohhmpdhqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehhe dvpdhmohguvgepshhmthhpohhuth Received-SPF: pass client-ip=178.32.96.117; envelope-from=clg@kaod.org; helo=1.mo552.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 3/28/23 14:08, Joel Stanley wrote: > Add a new buildroot image based test that attaches a TPM emulator to the > I2C bus and checks for a known PCR0 value for the image that was booted. > > Note that this does not tear down swtpm process when qemu execution fails. > The swtpm process will exit when qemu exits if a connection has been > made, but if the test errors before connection then the swtpm process > will still be around. > > Signed-off-by: Joel Stanley Reviewed-by: Cédric Le Goater Stefan, Could you please take this patch through the TPM queue with the other TPM TIS I2C patches ? Thanks, C. > --- > tests/avocado/machine_aspeed.py | 42 +++++++++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 2 deletions(-) > > diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py > index 35723af4ede0..a4485a5c4d4d 100644 > --- a/tests/avocado/machine_aspeed.py > +++ b/tests/avocado/machine_aspeed.py > @@ -7,14 +7,18 @@ > > import time > import os > +import tempfile > +import subprocess > > from avocado_qemu import QemuSystemTest > from avocado_qemu import wait_for_console_pattern > from avocado_qemu import exec_command > from avocado_qemu import exec_command_and_wait_for_pattern > from avocado_qemu import interrupt_interactive_console_until_pattern > +from avocado_qemu import has_cmd > from avocado.utils import archive > from avocado import skipIf > +from avocado import skipUnless > > > class AST1030Machine(QemuSystemTest): > @@ -132,7 +136,7 @@ def test_arm_ast2500_romulus_openbmc_v2_9_0(self): > > self.do_test_arm_aspeed(image_path) > > - def do_test_arm_aspeed_buildroot_start(self, image, cpu_id): > + def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): > self.require_netdev('user') > > self.vm.set_console() > @@ -146,7 +150,7 @@ def do_test_arm_aspeed_buildroot_start(self, image, cpu_id): > self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) > self.wait_for_console_pattern('lease of 10.0.2.15') > # the line before login: > - self.wait_for_console_pattern('Aspeed EVB') > + self.wait_for_console_pattern(pattern) > time.sleep(0.1) > exec_command(self, 'root') > time.sleep(0.1) > @@ -229,6 +233,40 @@ def test_arm_ast2600_evb_buildroot(self): > '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff'); > self.do_test_arm_aspeed_buildroot_poweroff() > > + @skipUnless(*has_cmd('swtpm')) > + def test_arm_ast2600_evb_buildroot_tpm(self): > + """ > + :avocado: tags=arch:arm > + :avocado: tags=machine:ast2600-evb > + """ > + > + image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' > + 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img') > + image_hash = ('a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997') > + image_path = self.fetch_asset(image_url, asset_hash=image_hash, > + algorithm='sha256') > + > + socket = os.path.join(self.vm.sock_dir, 'swtpm-socket') > + > + subprocess.run(['swtpm', 'socket', '-d', '--tpm2', > + '--tpmstate', f'dir={self.vm.temp_dir}', > + '--ctrl', f'type=unixio,path={socket}']) > + > + self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') > + self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm') > + self.vm.add_args('-device', > + 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e') > + self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB') > + exec_command(self, "passw0rd") > + > + exec_command_and_wait_for_pattern(self, > + 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device', > + 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)'); > + exec_command_and_wait_for_pattern(self, > + 'cat /sys/class/tpm/tpm0/pcr-sha256/0', > + 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0'); > + > + self.do_test_arm_aspeed_buildroot_poweroff() > > class AST2x00MachineSDK(QemuSystemTest): >