From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381760; cv=none; d=zohomail.com; s=zohoarc; b=IuQVZ2zmRA5VSbdvFytM/j0Sbi54MAw5TCMbVNnoDfAJZvbJoUJbuNxbJlObvyaoAgnuF2IIp063NQbyAFKQ+zFRTbeWQRSGVgQ7ypg73yfylNAeAImgT/jGYFZe47CeK8xL4/vZ1edOP7Pm5rhi5l6n98NB3l0OFkEYPeF9jvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381760; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4NVviGlb5bh+PXwzPd4clx4ddjYk8AJvga6aJCpuk8A=; b=ntWnx+m0sibsFadL4nVA6lSbkHNSNz3ErxUOd5X63ir/9h202KMXoF65omCTxUChuFwI9SBSAbSsVHeOFqNAC/JX/9RVZu2aW8c+F4RiB5uue8nsjt1aY9zfjBuqcJQdf2VtfK6dDdX16pC5BaKHG5B68atPU7HGoy7DWIDaxRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777381760437770.2894365681128; Tue, 28 Apr 2026 06:09:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAM-0006Yr-Ee; Tue, 28 Apr 2026 09:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA5-0006Sz-2E for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA2-0001Jl-Rm for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:36 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63S87CjF2932084; Tue, 28 Apr 2026 13:07:30 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn9r5jpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCwAmx010502; Tue, 28 Apr 2026 13:07:28 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ds7xq9wfj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:28 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7RCL40960634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:28 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFBC75805A; Tue, 28 Apr 2026 13:07:27 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B4CD58052; Tue, 28 Apr 2026 13:07:27 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:27 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=4NVviGlb5bh+PXwzP d4clx4ddjYk8AJvga6aJCpuk8A=; b=DhDkocj4QW0iiEsnpn23ZcsU7Z1vRYkn+ SqxaymmoaqV7zcruJ2VEke/BtsTTZMEYKc7p3mHG5qE52induYnZOYLObpTSWrwY 4d/F67QjhrX1qA3QLOwzdbMERswR5RP2qzxQFg92GoQ6iFU0AO0yhj3Zgg/TgAKZ 78MHSQ5QHWZPdjOlIHlsG5UlEKKh914K2+lWjTmir6tVNFVmFzCpnb0Ahn9BtPNH ToNLKz7lEgXr8a5XKJzCdKT1a5nG5WVyu5ZtiA+qW0QTflP26VOFtIKstCEQPDDT UzfChDEEf7kxuhrjbXkKIXDeVI3tKTLFDHTN+doFq+sO660k1qAxg== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 1/6] tests: Move TPM I2C bus read/write functions to common files Date: Tue, 28 Apr 2026 13:07:13 +0000 Message-ID: <20260428130718.1325177-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VCyFsJgVuz4ZoCC4ynXetmwng-NRz9Hu X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfX1cNIhkfCVqKc EpAswt6Z3OLmLe/B0yzpKDmiCCZOe22aAwyO8nOHqIjRZZzVMRqsudThyZSWRjhCLvR7fkynHTU /9u2WBTHm6ysbT2Oen8p+cdRss1e/cBhMdqfBSnbofVdqJu0JqJUSaQlAExIsLWShPrxivVRBDV oQ8k/19S+G/HY3t+fwhFMUg2S0bI0tSQ8gyN0afM3FrS19RZ1iSPj1VeK2eJ8r2kLYAbbIKREaf ZupdG7kADFB334eCh2Pzo/Haucm+IcOTRYSRKHdumgxj/ZJg1PNh7SFUuc00G9YJ8Tx1sF4i8qZ TUH196f08oDgtrkZbNsdIEslrz8yEHL6ywxQ62DztcAuSpVo79kh1WAnO03zyvpz+Leu9/yS3Xr vUAc18yCSWnWUEaZ6r/HbguRkIA8j5kc8bdscMkb8DtT8C6DX8tdj1xcIy/9BFb4VefWkHwxvJj B/sJ8SooIIkoEoHrUOQ== X-Authority-Analysis: v=2.4 cv=Kc7idwYD c=1 sm=1 tr=0 ts=69f0b111 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=8hQrII4DcMiSDO2ebf0A:9 X-Proofpoint-ORIG-GUID: VCyFsJgVuz4ZoCC4ynXetmwng-NRz9Hu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=stefanb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381764006154100 Content-Type: text/plain; charset="utf-8" Move functions for reading from and writing to the Aspeed I2C device into a file so they can be reused by other functions. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/meson.build | 2 +- tests/qtest/tpm-tis-i2c-test.c | 50 +------------------------- tests/qtest/tpm-tis-i2c-util.c | 64 ++++++++++++++++++++++++++++++++++ tests/qtest/tpm-tis-i2c-util.h | 30 ++++++++++++++++ 4 files changed, 96 insertions(+), 50 deletions(-) create mode 100644 tests/qtest/tpm-tis-i2c-util.c create mode 100644 tests/qtest/tpm-tis-i2c-util.h diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index b735f55fc4..823be192e7 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -397,7 +397,7 @@ qtests =3D { 'tpm-crb-test': [io, tpmemu_files], 'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-test': [io, tpmemu_files, 'tpm-tis-util.c'], - 'tpm-tis-i2c-test': [io, tpmemu_files, 'qtest_aspeed.c'], + 'tpm-tis-i2c-test': [io, tpmemu_files, 'tpm-tis-i2c-util.c', 'qtest_aspe= ed.c'], 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'virtio-net-failover': test_migration_files, diff --git a/tests/qtest/tpm-tis-i2c-test.c b/tests/qtest/tpm-tis-i2c-test.c index 3a1af026f2..02ddf76c2c 100644 --- a/tests/qtest/tpm-tis-i2c-test.c +++ b/tests/qtest/tpm-tis-i2c-test.c @@ -20,6 +20,7 @@ #include "hw/pci/pci_ids.h" #include "qtest_aspeed.h" #include "tpm-emu.h" +#include "tpm-tis-i2c-util.h" =20 #define DEBUG_TIS_TEST 0 =20 @@ -36,58 +37,9 @@ #define DPRINTF_STS \ DPRINTF("%s: %d: sts =3D 0x%08x\n", __func__, __LINE__, sts) =20 -#define I2C_SLAVE_ADDR 0x2e -#define I2C_DEV_BUS_NUM 10 - static const uint8_t TPM_CMD[12] =3D "\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00"; =20 -static uint32_t aspeed_bus_addr; - -static uint8_t cur_locty =3D 0xff; - -static void tpm_tis_i2c_set_locty(uint8_t locty) -{ - if (cur_locty !=3D locty) { - cur_locty =3D locty; - aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, - TPM_I2C_REG_LOC_SEL, locty); - } -} - -static uint8_t tpm_tis_i2c_readb(uint8_t locty, uint8_t reg) -{ - tpm_tis_i2c_set_locty(locty); - return aspeed_i2c_readb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); -} - -static uint16_t tpm_tis_i2c_readw(uint8_t locty, uint8_t reg) -{ - tpm_tis_i2c_set_locty(locty); - return aspeed_i2c_readw(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); -} - -static uint32_t tpm_tis_i2c_readl(uint8_t locty, uint8_t reg) -{ - tpm_tis_i2c_set_locty(locty); - return aspeed_i2c_readl(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); -} - -static void tpm_tis_i2c_writeb(uint8_t locty, uint8_t reg, uint8_t v) -{ - if (reg !=3D TPM_I2C_REG_LOC_SEL) { - tpm_tis_i2c_set_locty(locty); - } - aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); -} - -static void tpm_tis_i2c_writel(uint8_t locty, uint8_t reg, uint32_t v) -{ - if (reg !=3D TPM_I2C_REG_LOC_SEL) { - tpm_tis_i2c_set_locty(locty); - } - aspeed_i2c_writel(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); -} =20 static void tpm_tis_i2c_test_basic(const void *data) { diff --git a/tests/qtest/tpm-tis-i2c-util.c b/tests/qtest/tpm-tis-i2c-util.c new file mode 100644 index 0000000000..07b1eeba69 --- /dev/null +++ b/tests/qtest/tpm-tis-i2c-util.c @@ -0,0 +1,64 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest utilities for TPM TIS over I2C + * + * Copyright (c) 2018, 2026 IBM Corporation + * + * Authors: + * Stefan Berger + * + */ + +#include "qemu/osdep.h" +#include "hw/acpi/tpm.h" +#include "libqtest-single.h" +#include "qtest_aspeed.h" +#include "tpm-tis-i2c-util.h" + +uint32_t aspeed_bus_addr; + +static uint8_t cur_locty =3D 0xff; + +static void tpm_tis_i2c_set_locty(uint8_t locty) +{ + if (cur_locty !=3D locty) { + cur_locty =3D locty; + aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, + TPM_I2C_REG_LOC_SEL, locty); + } +} + +uint8_t tpm_tis_i2c_readb(uint8_t locty, uint8_t reg) +{ + tpm_tis_i2c_set_locty(locty); + return aspeed_i2c_readb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); +} + +uint16_t tpm_tis_i2c_readw(uint8_t locty, uint8_t reg) +{ + tpm_tis_i2c_set_locty(locty); + return aspeed_i2c_readw(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); +} + +uint32_t tpm_tis_i2c_readl(uint8_t locty, uint8_t reg) +{ + tpm_tis_i2c_set_locty(locty); + return aspeed_i2c_readl(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); +} + +void tpm_tis_i2c_writeb(uint8_t locty, uint8_t reg, uint8_t v) +{ + if (reg !=3D TPM_I2C_REG_LOC_SEL) { + tpm_tis_i2c_set_locty(locty); + } + aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); +} + +void tpm_tis_i2c_writel(uint8_t locty, uint8_t reg, uint32_t v) +{ + if (reg !=3D TPM_I2C_REG_LOC_SEL) { + tpm_tis_i2c_set_locty(locty); + } + aspeed_i2c_writel(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); +} diff --git a/tests/qtest/tpm-tis-i2c-util.h b/tests/qtest/tpm-tis-i2c-util.h new file mode 100644 index 0000000000..dfe626b43d --- /dev/null +++ b/tests/qtest/tpm-tis-i2c-util.h @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest TPM TIS I2C: Common test functions used for TPM I2C on Aspeed bus + * + * Copyright (c) 2026 IBM Corporation + * + * Authors: + * Stefan Berger + * + */ + +#ifndef TESTS_TPM_TIS_I2C_UTIL_H +#define TESTS_TPM_TIS_I2C_UTIL_H + +#include "qemu/osdep.h" + +extern uint32_t aspeed_bus_addr; + +#define I2C_SLAVE_ADDR 0x2e +#define I2C_DEV_BUS_NUM 10 + +uint8_t tpm_tis_i2c_readb(uint8_t locty, uint8_t reg); +uint16_t tpm_tis_i2c_readw(uint8_t locty, uint8_t reg); +uint32_t tpm_tis_i2c_readl(uint8_t locty, uint8_t reg); + +void tpm_tis_i2c_writeb(uint8_t locty, uint8_t reg, uint8_t v); +void tpm_tis_i2c_writel(uint8_t locty, uint8_t reg, uint32_t v); + +#endif /* TESTS_TPM_TIS_I2C_UTIL_H */ --=20 2.43.0 From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381720; cv=none; d=zohomail.com; s=zohoarc; b=G9NSrpAELSRc1d6hJhOCJlWKVBdau6CUJVwn0tbyDT+L6bqbUYdcw6WA9hyWltr25q7VLlEZrENndfqrnHFC11N+eF17rFNaBbhgBto9zNbpDZP2u7K13mv+qkv7nv+b17KHXRc0Lzs930lPq/lviqnchTNZWSp6T/fp08TKiEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381720; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2Jbe5vvHnNLP38Kulch2Ry4UhiSSV8bgumVKRuTFO4A=; b=nIizVC8escdrmW7WyKJn2SQ+3aVRqABcs71NMrvH1gVM+lebswNuY/gvAmh3tG5KxtbDoaMqTm4JVLmpXPZMm5+YYlnwH6iqxtRaOze+KJRHdVnNGEMe0UeUn81Gr8W7XOciVWAXcWtta1dP1AzRFDO4j/rvtDFP6vE19z9Gsys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777381720184632.0631150290959; Tue, 28 Apr 2026 06:08:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAI-0006X9-Pp; Tue, 28 Apr 2026 09:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA5-0006TA-UG for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA2-0001K8-RS for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:37 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63RN1SjN1914783; Tue, 28 Apr 2026 13:07:30 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drnb55jpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:30 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCw80E020119; Tue, 28 Apr 2026 13:07:29 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8avsvm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7SvL34538162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:28 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C0A45805E; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E743558064; Tue, 28 Apr 2026 13:07:27 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:27 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=2Jbe5vvHnNLP38Kul ch2Ry4UhiSSV8bgumVKRuTFO4A=; b=PyLkPcoQlxLQZhvNLFyUAagF7P4l6Y9kq AZFgbQiju+Kr0bfSIWVHxcUM6JEKFv1UJS4SIpFC7Pij5cyqQxJh+Fq5dPQ7iaTI syQpEEQMfpFLd34TSqTBfHCisbrO2mDIdNpuOt6LfTNAl0j+1y+cT6o6n1jk/RAG rUpH5QK0SjxVgo3maYPWNDEuowxB6pCuJOFWP55KRFBKahvbcxX562GE6UJaN8UO 021k7FhnZ7wQb0wtdZBBUVapAAeAS4CD+hx9Yp0Z8lyTvFeJqSD/4oZVjgjKUoA2 hdeJHVz+hr76W4lUHhssHVmMUuXhWnCRxqhgAJ59O7rIeFo6sdQQA== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 2/6] tests: Have TPM I2C read/write functions take QTestState as first parameter Date: Tue, 28 Apr 2026 13:07:14 +0000 Message-ID: <20260428130718.1325177-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=AqDeGu9P c=1 sm=1 tr=0 ts=69f0b112 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=cp_pve3XC55RmFQTQzQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfXy4oob/YHz7HI 13WtF0lAc+IeiDyTPc7Q25R3rnvagQP4mqFzAuUHNYuJW3JvQX6ve41D0WoR+bSfhpPlJU9G8Lm SWk3zWCx2MucS3nUpXsKjubEYDQ+r/Un/pCsPUoYNVuGupyZT3HuewxnoP4+BhtQ9dnN1rfVj5A roPoxptyZLrr1Z+A/rexoxw2tmqAJOQgGQ9BN7uXtD7I6YKsJprUh9XW4m49IVWDfZbo3cXyy6l riMOWPYqhKdJ2m5uhZ87ja5pvyOCVfSNFRlBawzrg8QVOC2yIEbRO2VzPQVwjk2ts+fGuj6Fafw p6yTzfjCODRoam87np62Z6B0Q7GHArJ9dmA7uDRUdyDhzidAyzh+/UR85yOMNXJZ74mLPthqWSI VmiWCfP2j3TMOEDFfhjBy/ZVNtS/ousW4ifRbk5y6RSX2CYi+2nD1eGEC5cCIadALZQEWDR36WR LYGc9LmLWV97Oo1AyqA== X-Proofpoint-GUID: YSTpdAW6PWEGb8LYZLte01nTtTCCORY0 X-Proofpoint-ORIG-GUID: YSTpdAW6PWEGb8LYZLte01nTtTCCORY0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 phishscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=stefanb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381723568154100 Content-Type: text/plain; charset="utf-8" Pass the QTestState as first parameter to the TPM I2C functions. Use global_qtest in existing test cases. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/tpm-tis-i2c-test.c | 171 +++++++++++++++++---------------- tests/qtest/tpm-tis-i2c-util.c | 32 +++--- tests/qtest/tpm-tis-i2c-util.h | 10 +- 3 files changed, 110 insertions(+), 103 deletions(-) diff --git a/tests/qtest/tpm-tis-i2c-test.c b/tests/qtest/tpm-tis-i2c-test.c index 02ddf76c2c..f614f888f3 100644 --- a/tests/qtest/tpm-tis-i2c-test.c +++ b/tests/qtest/tpm-tis-i2c-test.c @@ -50,62 +50,64 @@ static void tpm_tis_i2c_test_basic(const void *data) * All register accesses below must work without locality 0 being the * active locality. Therefore, ensure access is released. */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); - access =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_ACCESS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* read interrupt capability -- none are supported */ - v =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_INT_CAPABILITY); + v =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_INT_CAPABILITY); g_assert_cmpint(v, =3D=3D, 0); =20 /* try to enable all interrupts */ - tpm_tis_i2c_writel(0, TPM_I2C_REG_INT_ENABLE, 0xffffffff); - v =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_INT_ENABLE); + tpm_tis_i2c_writel(global_qtest, 0, TPM_I2C_REG_INT_ENABLE, 0xffffffff= ); + v =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_INT_ENABLE); /* none could be enabled */ g_assert_cmpint(v, =3D=3D, 0); =20 /* enable csum */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_CSUM_ENABLE, TPM_DATA_CSUM_ENAB= LED); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE, + TPM_DATA_CSUM_ENABLED); /* check csum enable register has bit 0 set */ - v =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + v =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE); g_assert_cmpint(v, =3D=3D, TPM_DATA_CSUM_ENABLED); /* reading it as 32bit register returns same result */ - v =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + v =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE); g_assert_cmpint(v, =3D=3D, TPM_DATA_CSUM_ENABLED); =20 /* disable csum */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_CSUM_ENABLE, 0); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE, 0); /* check csum enable register has bit 0 clear */ - v =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + v =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE); g_assert_cmpint(v, =3D=3D, 0); =20 /* write to unsupported register '1' */ - tpm_tis_i2c_writel(0, 1, 0x12345678); - v =3D tpm_tis_i2c_readl(0, 1); + tpm_tis_i2c_writel(global_qtest, 0, 1, 0x12345678); + v =3D tpm_tis_i2c_readl(global_qtest, 0, 1); g_assert_cmpint(v, =3D=3D, 0xffffffff); =20 /* request use of locality */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_ACCESS, + TPM_TIS_ACCESS_REQUEST_USE); =20 /* read byte from STS + 3 */ - v =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_STS + 3); + v =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_STS + 3); g_assert_cmpint(v, =3D=3D, 0); =20 /* check STS after writing to STS + 3 */ - v =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); - tpm_tis_i2c_writeb(0, TPM_I2C_REG_STS + 3, 0xf); - v2 =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + v =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_STS + 3, 0xf); + v2 =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); g_assert_cmpint(v, =3D=3D, v2); =20 /* release access */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); =20 /* select locality 5 -- must not be possible */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_LOC_SEL, 5); - v =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_LOC_SEL); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_LOC_SEL, 5); + v =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_LOC_SEL); g_assert_cmpint(v, =3D=3D, 0); } =20 @@ -118,11 +120,12 @@ static void tpm_tis_i2c_test_check_localities(const v= oid *data) uint32_t rid; =20 for (locty =3D 0; locty < TPM_TIS_NUM_LOCALITIES; locty++) { - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 - capability =3D tpm_tis_i2c_readl(locty, TPM_I2C_REG_INTF_CAPABILIT= Y); + capability =3D tpm_tis_i2c_readl(global_qtest, locty, + TPM_I2C_REG_INTF_CAPABILITY); i2c_cap =3D (TPM_I2C_CAP_INTERFACE_TYPE | TPM_I2C_CAP_INTERFACE_VER | TPM_I2C_CAP_TPM2_FAMILY | @@ -131,15 +134,15 @@ static void tpm_tis_i2c_test_check_localities(const v= oid *data) TPM_I2C_CAP_DEV_ADDR_CHANGE); g_assert_cmpint(capability, =3D=3D, i2c_cap); =20 - didvid =3D tpm_tis_i2c_readl(locty, TPM_I2C_REG_DID_VID); + didvid =3D tpm_tis_i2c_readl(global_qtest, locty, TPM_I2C_REG_DID_= VID); g_assert_cmpint(didvid, =3D=3D, (1 << 16) | PCI_VENDOR_ID_IBM); =20 - rid =3D tpm_tis_i2c_readl(locty, TPM_I2C_REG_RID); + rid =3D tpm_tis_i2c_readl(global_qtest, locty, TPM_I2C_REG_RID); g_assert_cmpint(rid, !=3D, 0); g_assert_cmpint(rid, !=3D, 0xffffffff); =20 /* locality selection must be at locty */ - l =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_LOC_SEL); + l =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_LOC_SEL); g_assert_cmpint(l, =3D=3D, locty); } } @@ -151,23 +154,23 @@ static void tpm_tis_i2c_test_check_access_reg(const v= oid *data) =20 /* do not test locality 4 (hw only) */ for (locty =3D 0; locty < TPM_TIS_NUM_LOCALITIES - 1; locty++) { - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* request use of locality */ - tpm_tis_i2c_writeb(locty, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, locty, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); =20 - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* release access */ - tpm_tis_i2c_writeb(locty, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, locty, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); } @@ -186,14 +189,14 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) for (locty =3D 0; locty < TPM_TIS_NUM_LOCALITIES - 1; locty++) { pending_request_flag =3D 0; =20 - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* request use of locality */ - tpm_tis_i2c_writeb(locty, + tpm_tis_i2c_writeb(global_qtest, locty, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); @@ -201,14 +204,14 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) /* lower localities cannot seize access */ for (l =3D 0; l < locty; l++) { /* lower locality is not active */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | pending_request_flag | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* try to request use from 'l' */ - tpm_tis_i2c_writeb(l, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); =20 @@ -216,7 +219,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) * requesting use from 'l' was not possible; * we must see REQUEST_USE and possibly PENDING_REQUEST */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_REQUEST_USE | @@ -227,17 +230,17 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) * locality 'locty' must be unchanged; * we must see PENDING_REQUEST */ - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_= ACCESS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_PENDING_REQUEST | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* try to seize from 'l' */ - tpm_tis_i2c_writeb(l, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_SEIZE); /* seize from 'l' was not possible */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_REQUEST_USE | @@ -245,7 +248,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* locality 'locty' must be unchanged */ - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_= ACCESS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_PENDING_REQUEST | @@ -264,14 +267,14 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) */ for (l =3D locty + 1; l < TPM_TIS_NUM_LOCALITIES - 1; l++) { /* try to 'request use' from 'l' */ - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); =20 /* * requesting use from 'l' was not possible; we should see * REQUEST_USE and may see PENDING_REQUEST */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_REQUEST_USE | @@ -282,7 +285,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) * locality 'l-1' must be unchanged; we should always * see PENDING_REQUEST from 'l' requesting access */ - access =3D tpm_tis_i2c_readb(l - 1, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l - 1, TPM_I2C_REG_= ACCESS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | @@ -290,10 +293,11 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* try to seize from 'l' */ - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_SEIZE= ); + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, + TPM_TIS_ACCESS_SEIZE); =20 /* seize from 'l' was possible */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | @@ -301,7 +305,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* l - 1 should show that it has BEEN_SEIZED */ - access =3D tpm_tis_i2c_readb(l - 1, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l - 1, TPM_I2C_REG_= ACCESS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_BEEN_SEIZED | @@ -309,10 +313,10 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* clear the BEEN_SEIZED flag and make sure it's gone */ - tpm_tis_i2c_writeb(l - 1, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l - 1, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_BEEN_SEIZED); =20 - access =3D tpm_tis_i2c_readb(l - 1, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l - 1, TPM_I2C_REG_= ACCESS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | pending_request_flag | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); @@ -330,22 +334,22 @@ static void tpm_tis_i2c_test_check_access_reg_seize(c= onst void *data) /* release access from l - 1; this activates locty - 1 */ l--; =20 - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCESS); DPRINTF_ACCESS; =20 DPRINTF("%s: %d: relinquishing control on l =3D %d\n", __func__, __LINE__, l); - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); =20 - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCESS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | pending_request_flag | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 for (l =3D locty - 1; l >=3D 0; l--) { - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | @@ -353,7 +357,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* release this locality */ - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); =20 if (l =3D=3D 1) { @@ -363,7 +367,7 @@ static void tpm_tis_i2c_test_check_access_reg_seize(con= st void *data) =20 /* no locality may be active now */ for (l =3D 0; l < TPM_TIS_NUM_LOCALITIES - 1; l++) { - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); @@ -384,14 +388,14 @@ static void tpm_tis_i2c_test_check_access_reg_release= (const void *data) for (locty =3D TPM_TIS_NUM_LOCALITIES - 2; locty >=3D 0; locty--) { pending_request_flag =3D 0; =20 - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 /* request use of locality */ - tpm_tis_i2c_writeb(locty, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, locty, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); - access =3D tpm_tis_i2c_readb(locty, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, locty, TPM_I2C_REG_ACCE= SS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); @@ -405,9 +409,9 @@ static void tpm_tis_i2c_test_check_access_reg_release(c= onst void *data) * request use of locality 'l' -- we MUST see REQUEST USE and * may see PENDING_REQUEST */ - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_REQUEST_USE | @@ -416,7 +420,7 @@ static void tpm_tis_i2c_test_check_access_reg_release(c= onst void *data) pending_request_flag =3D TPM_TIS_ACCESS_PENDING_REQUEST; } /* release locality 'locty' */ - tpm_tis_i2c_writeb(locty, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, locty, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); /* * highest locality should now be active; release it and make sure= the @@ -427,16 +431,16 @@ static void tpm_tis_i2c_test_check_access_reg_release= (const void *data) continue; } /* 'l' should be active now */ - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_S= TS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | pending_request_flag | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); /* 'l' relinquishes access */ - tpm_tis_i2c_writeb(l, TPM_I2C_REG_ACCESS, + tpm_tis_i2c_writeb(global_qtest, l, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); - access =3D tpm_tis_i2c_readb(l, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, l, TPM_I2C_REG_ACCE= SS); DPRINTF_ACCESS; if (l =3D=3D 1 || (locty <=3D 1 && l =3D=3D 2)) { pending_request_flag =3D 0; @@ -460,22 +464,24 @@ static void tpm_tis_i2c_test_check_transmit(const voi= d *data) size_t i; =20 /* enable csum */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_CSUM_ENABLE, TPM_DATA_CSUM_ENAB= LED); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE, + TPM_DATA_CSUM_ENABLED); /* check csum enable register has bit 0 set */ - v =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + v =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE); g_assert_cmpint(v, =3D=3D, TPM_DATA_CSUM_ENABLED); /* reading it as 32bit register returns same result */ - v =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + v =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_ENABLE); g_assert_cmpint(v, =3D=3D, TPM_DATA_CSUM_ENABLED); =20 /* request use of locality 0 */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_USE); - access =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_ACCESS); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_ACCESS, + TPM_TIS_ACCESS_REQUEST_USE); + access =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_ACCESS); g_assert_cmpint(access, =3D=3D, TPM_TIS_ACCESS_TPM_REG_VALID_STS | TPM_TIS_ACCESS_ACTIVE_LOCALITY | TPM_TIS_ACCESS_TPM_ESTABLISHMENT); =20 - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); DPRINTF_STS; =20 g_assert_cmpint(sts & 0xff, =3D=3D, 0); @@ -484,21 +490,22 @@ static void tpm_tis_i2c_test_check_transmit(const voi= d *data) g_assert_cmpint(bcount, >=3D, 128); =20 /* read bcount from STS + 1 must work also */ - bcount2 =3D tpm_tis_i2c_readw(0, TPM_I2C_REG_STS + 1); + bcount2 =3D tpm_tis_i2c_readw(global_qtest, 0, TPM_I2C_REG_STS + 1); g_assert_cmpint(bcount, =3D=3D, bcount2); =20 /* ic2 must have bits 26-31 zero */ g_assert_cmpint(sts & (0x1f << 26), =3D=3D, 0); =20 - tpm_tis_i2c_writel(0, TPM_I2C_REG_STS, TPM_TIS_STS_COMMAND_READY); - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + tpm_tis_i2c_writel(global_qtest, 0, TPM_I2C_REG_STS, + TPM_TIS_STS_COMMAND_READY); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); DPRINTF_STS; g_assert_cmpint(sts & 0xff, =3D=3D, TPM_TIS_STS_COMMAND_READY); =20 /* transmit command */ for (i =3D 0; i < sizeof(TPM_CMD); i++) { - tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_FIFO, TPM_CMD[i]); - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_DATA_FIFO, TPM_CMD= [i]); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); DPRINTF_STS; if (i < sizeof(TPM_CMD) - 1) { g_assert_cmpint(sts & 0xff, =3D=3D, @@ -509,21 +516,21 @@ static void tpm_tis_i2c_test_check_transmit(const voi= d *data) g_assert_cmpint((sts >> 8) & 0xffff, =3D=3D, --bcount); } /* read the checksum */ - csum =3D tpm_tis_i2c_readw(0, TPM_I2C_REG_DATA_CSUM_GET); + csum =3D tpm_tis_i2c_readw(global_qtest, 0, TPM_I2C_REG_DATA_CSUM_GET); g_assert_cmpint(csum, =3D=3D, 0x6733); =20 /* start processing */ - tpm_tis_i2c_writeb(0, TPM_I2C_REG_STS, TPM_TIS_STS_TPM_GO); + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_STS, TPM_TIS_STS_TPM_G= O); =20 uint64_t end_time =3D g_get_monotonic_time() + 50 * G_TIME_SPAN_SECOND; do { - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); if ((sts & TPM_TIS_STS_DATA_AVAILABLE) !=3D 0) { break; } } while (g_get_monotonic_time() < end_time); =20 - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); DPRINTF_STS; g_assert_cmpint(sts & 0xff, =3D=3D , TPM_TIS_STS_VALID | TPM_TIS_STS_DATA_AVAILABLE); @@ -534,8 +541,8 @@ static void tpm_tis_i2c_test_check_transmit(const void = *data) g_assert_cmpint(sizeof(tpm_msg), =3D=3D, bcount); =20 for (i =3D 0; i < sizeof(tpm_msg); i++) { - tpm_msg[i] =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_FIFO); - sts =3D tpm_tis_i2c_readl(0, TPM_I2C_REG_STS); + tpm_msg[i] =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_DATA= _FIFO); + sts =3D tpm_tis_i2c_readl(global_qtest, 0, TPM_I2C_REG_STS); DPRINTF_STS; if (sts & TPM_TIS_STS_DATA_AVAILABLE) { g_assert_cmpint((sts >> 8) & 0xffff, =3D=3D, --bcount); @@ -544,9 +551,9 @@ static void tpm_tis_i2c_test_check_transmit(const void = *data) g_assert_cmpmem(tpm_msg, sizeof(tpm_msg), s->tpm_msg, sizeof(*s->tpm_m= sg)); =20 /* relinquish use of locality 0 */ - tpm_tis_i2c_writeb(0, + tpm_tis_i2c_writeb(global_qtest, 0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); - access =3D tpm_tis_i2c_readb(0, TPM_I2C_REG_ACCESS); + access =3D tpm_tis_i2c_readb(global_qtest, 0, TPM_I2C_REG_ACCESS); } =20 int main(int argc, char **argv) diff --git a/tests/qtest/tpm-tis-i2c-util.c b/tests/qtest/tpm-tis-i2c-util.c index 07b1eeba69..6e724a4a47 100644 --- a/tests/qtest/tpm-tis-i2c-util.c +++ b/tests/qtest/tpm-tis-i2c-util.c @@ -20,45 +20,45 @@ uint32_t aspeed_bus_addr; =20 static uint8_t cur_locty =3D 0xff; =20 -static void tpm_tis_i2c_set_locty(uint8_t locty) +static void tpm_tis_i2c_set_locty(QTestState *s, uint8_t locty) { if (cur_locty !=3D locty) { cur_locty =3D locty; - aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, + aspeed_i2c_writeb(s, aspeed_bus_addr, I2C_SLAVE_ADDR, TPM_I2C_REG_LOC_SEL, locty); } } =20 -uint8_t tpm_tis_i2c_readb(uint8_t locty, uint8_t reg) +uint8_t tpm_tis_i2c_readb(QTestState *s, uint8_t locty, uint8_t reg) { - tpm_tis_i2c_set_locty(locty); - return aspeed_i2c_readb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); + tpm_tis_i2c_set_locty(s, locty); + return aspeed_i2c_readb(s, aspeed_bus_addr, I2C_SLAVE_ADDR, reg); } =20 -uint16_t tpm_tis_i2c_readw(uint8_t locty, uint8_t reg) +uint16_t tpm_tis_i2c_readw(QTestState *s, uint8_t locty, uint8_t reg) { - tpm_tis_i2c_set_locty(locty); + tpm_tis_i2c_set_locty(s, locty); return aspeed_i2c_readw(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); } =20 -uint32_t tpm_tis_i2c_readl(uint8_t locty, uint8_t reg) +uint32_t tpm_tis_i2c_readl(QTestState *s, uint8_t locty, uint8_t reg) { - tpm_tis_i2c_set_locty(locty); - return aspeed_i2c_readl(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR,= reg); + tpm_tis_i2c_set_locty(s, locty); + return aspeed_i2c_readl(s, aspeed_bus_addr, I2C_SLAVE_ADDR, reg); } =20 -void tpm_tis_i2c_writeb(uint8_t locty, uint8_t reg, uint8_t v) +void tpm_tis_i2c_writeb(QTestState *s, uint8_t locty, uint8_t reg, uint8_t= v) { if (reg !=3D TPM_I2C_REG_LOC_SEL) { - tpm_tis_i2c_set_locty(locty); + tpm_tis_i2c_set_locty(s, locty); } - aspeed_i2c_writeb(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); + aspeed_i2c_writeb(s, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, v); } =20 -void tpm_tis_i2c_writel(uint8_t locty, uint8_t reg, uint32_t v) +void tpm_tis_i2c_writel(QTestState *s, uint8_t locty, uint8_t reg, uint32_= t v) { if (reg !=3D TPM_I2C_REG_LOC_SEL) { - tpm_tis_i2c_set_locty(locty); + tpm_tis_i2c_set_locty(s, locty); } - aspeed_i2c_writel(global_qtest, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, = v); + aspeed_i2c_writel(s, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, v); } diff --git a/tests/qtest/tpm-tis-i2c-util.h b/tests/qtest/tpm-tis-i2c-util.h index dfe626b43d..3289545f61 100644 --- a/tests/qtest/tpm-tis-i2c-util.h +++ b/tests/qtest/tpm-tis-i2c-util.h @@ -20,11 +20,11 @@ extern uint32_t aspeed_bus_addr; #define I2C_SLAVE_ADDR 0x2e #define I2C_DEV_BUS_NUM 10 =20 -uint8_t tpm_tis_i2c_readb(uint8_t locty, uint8_t reg); -uint16_t tpm_tis_i2c_readw(uint8_t locty, uint8_t reg); -uint32_t tpm_tis_i2c_readl(uint8_t locty, uint8_t reg); +uint8_t tpm_tis_i2c_readb(QTestState *s, uint8_t locty, uint8_t reg); +uint16_t tpm_tis_i2c_readw(QTestState *s, uint8_t locty, uint8_t reg); +uint32_t tpm_tis_i2c_readl(QTestState *s, uint8_t locty, uint8_t reg); =20 -void tpm_tis_i2c_writeb(uint8_t locty, uint8_t reg, uint8_t v); -void tpm_tis_i2c_writel(uint8_t locty, uint8_t reg, uint32_t v); +void tpm_tis_i2c_writeb(QTestState *s, uint8_t locty, uint8_t reg, uint8_t= v); +void tpm_tis_i2c_writel(QTestState *s, uint8_t locty, uint8_t reg, uint32_= t v); =20 #endif /* TESTS_TPM_TIS_I2C_UTIL_H */ --=20 2.43.0 From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381699; cv=none; d=zohomail.com; s=zohoarc; b=dSSLlURA46CYw1DTBPAIy3Rj4ZnVkYJt7cMGLHCmAAnqkY+tAgnYgBqtIP3Tq9kDSqHDNx52bSCcC8ffxVaEZJ7upiTD9+hy8Z1jDuVHvGh8hJYJBR3R/t8m3c7ceOAtRjVkZTm1hjVfzWOifqPRxIxmBLsDD9xLxaaIVHx+lEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381699; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=arkGtvuBxPGsuc49PJzg8dPUFOvRGwp5KxPfimG25hQ=; b=HDRqr4ykYSy0LwG8ZEuRF60xNqpE3rWHKg4J2q/FlPeczvG7iLQdzcMnBhg3Yt0OrzFGKSXK4+jouo6y2hTXS5J0mw/l1AdnvLapUxL5ctluPFcX7HiIj3AW2pDqCdWgTOc3/VuG2RlegetPi4I5ji6s5FtBQaGwsRzsO0k4hgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777381699159632.7591055705816; Tue, 28 Apr 2026 06:08:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAG-0006Vb-Kt; Tue, 28 Apr 2026 09:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA3-0006Rx-B3 for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHi9y-0001Jg-Qu for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:33 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63S6rbWJ3705253; Tue, 28 Apr 2026 13:07:30 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drm1dvfty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCwJD5006292; Tue, 28 Apr 2026 13:07:29 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds9eh9pj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7SFJ33620632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:29 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A52EA58056; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60C9658052; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=arkGtvuBxPGsuc49P Jzg8dPUFOvRGwp5KxPfimG25hQ=; b=bmuO26f8HafDZr2vxWfxEntbpTu49HIWi xdvB1StDCh7LP5r1Z7nT9e63Fd4bLIkCp9L7NauV2VeCNAiVIfJszcdfv9wyl3oR /L15wnThgq6ixHcbVxZTWxubTxwcO7ETNGKXm7kgEwAyMRj98XItSAjmkPGJj536 3tFZjm+auAZoob0TGn+o8k/XzlJCZOCDw6wHT3xh7oqxphwsXd58Zsvr5wFK/j8d gYy/95pZjS+aFQYbB+d3FQQfqz1jnsEN0QmClsh4jYLde0gJUUV0QfNbv+iy+aY8 vD/slXeaGTGzfdEazXmZAGZmRhs3d8OpF9i7R+NLU3qdcxLFDFnjg== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 3/6] tests: Set sizes for arrays of expected TPM responses and requests Date: Tue, 28 Apr 2026 13:07:15 +0000 Message-ID: <20260428130718.1325177-4-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: BxsYcDWTSJOeVmG8mebhPuC3eU5Eikv6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfX5Hf644nmEPpF XqxXtKjtlbSk3Xtpq43N9vesmj7AYcAWMDlKqIHLV7AFNuh4Z///LW4ezVxz/ithn5jnTXPTond 2Ri5sjrUiUjnBMUg5qiJmGxLEcRpSJG1B5br7GAZWFuE2IeU0gM47dIhZ3NqH8GJcP2216cImDN AOAgC8qEFGc7H+9vDoRXwX1oAvcEdLMweDVKfoVnv2W+S/7rvr7AtYjJfV/EXMp8zZifWd963C7 lOOpN3o6AhfezeD7Sw1dE/5YsIiEiqNg1ofIAiLNZCFHxlKNwc2JUdW0Eo6UZXgdUoezJGq6wFC EC7hl7mtU8gsZt7UnpubUDyDaH0wvkfOLLZZ2Vu6/wwV95TyurWo6paR/0NgEaOImLy/pAqX0vV ohbadE8aRsDbgNz/gn5qI5+6DpUrp5N1Wrmw7oU+Xhwp9eT/9sn9ujbwie1osw9tp6gDTdHDhR7 kJQqtK+PyFOqtrmlhuQ== X-Authority-Analysis: v=2.4 cv=VZLH+lp9 c=1 sm=1 tr=0 ts=69f0b111 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=E-MnKC11_1REocI9e9kA:9 X-Proofpoint-GUID: BxsYcDWTSJOeVmG8mebhPuC3eU5Eikv6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=stefanb@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381700207158501 Content-Type: text/plain; charset="utf-8" Set the sizes of byte arrays holding TPM requests and responses to avoid a terminating NUL byte to be added and to only compare the expected part of responses. Signed-off-by: Stefan Berger --- tests/qtest/tpm-tests.c | 4 ++-- tests/qtest/tpm-util.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c index 197714f8d9..dcbf5457ed 100644 --- a/tests/qtest/tpm-tests.c +++ b/tests/qtest/tpm-tests.c @@ -59,7 +59,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_fun= c *tx, tpm_util_startup(s, tx); tpm_util_pcrextend(s, tx); =20 - static const unsigned char tpm_pcrread_resp[] =3D + static const unsigned char tpm_pcrread_resp[62] =3D "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00" "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85" "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" @@ -105,7 +105,7 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_= path, tpm_util_startup(src_qemu, tx); tpm_util_pcrextend(src_qemu, tx); =20 - static const unsigned char tpm_pcrread_resp[] =3D + static const unsigned char tpm_pcrread_resp[62] =3D "\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00" "\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85" "\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89" diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index 2cb2dd4796..1a47099807 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -54,9 +54,9 @@ void tpm_util_crb_transfer(QTestState *s, void tpm_util_startup(QTestState *s, tx_func *tx) { unsigned char buffer[1024]; - static const unsigned char tpm_startup[] =3D + static const unsigned char tpm_startup[12] =3D "\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00"; - static const unsigned char tpm_startup_resp[] =3D + static const unsigned char tpm_startup_resp[10] =3D "\x80\x01\x00\x00\x00\x0a\x00\x00\x00\x00"; =20 tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer)); @@ -68,14 +68,14 @@ void tpm_util_startup(QTestState *s, tx_func *tx) void tpm_util_pcrextend(QTestState *s, tx_func *tx) { unsigned char buffer[1024]; - static const unsigned char tpm_pcrextend[] =3D + static const unsigned char tpm_pcrextend[65] =3D "\x80\x02\x00\x00\x00\x41\x00\x00\x01\x82\x00\x00\x00\x0a\x00\x00" "\x00\x09\x40\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" "\x0b\x74\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00"; =20 - static const unsigned char tpm_pcrextend_resp[] =3D + static const unsigned char tpm_pcrextend_resp[19] =3D "\x80\x02\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x01\x00\x00"; =20 @@ -89,7 +89,7 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx, const unsigned char *exp_resp, size_t exp_resp_size) { unsigned char buffer[1024]; - static const unsigned char tpm_pcrread[] =3D + static const unsigned char tpm_pcrread[20] =3D "\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b" "\x03\x00\x04\x00"; =20 --=20 2.43.0 From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381759; cv=none; d=zohomail.com; s=zohoarc; b=FYThmKwrK2OKj6SZ+GeSZTGwubLuLVU/mjj+Ad2pdW7drSDue/LvmBVdcW/UvhYZFcnhEZDISDxu/bziD/JREvwkGBnPsUmx4k/o/nhG2Sd7YEoQQjUDJb5rk3Ud2cQBkdQ1G/cU8I791/IVAO/UVoGvs3AZULDej3scoUd/tjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381759; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u7zRD1jLbjv2J3d38lrtkX+IaipO4wlaxY9OnsHGeLg=; b=g3UJtqFRCBxZF3uNsQiG1UO7Bv1onV5D3dVlbUsosnWcphkrEGzFNOKrnpUuGlSSINTM/cH3/Aq4DwPOtXMdjd46d8tymkNIOrsBQcF/lGnoQ72HlDWdaaWRIpb1wwRLtXOQmJVyYziofV0oa/sxUbGKt9D199ED4AbcSeLcyog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177738175996164.72003037323384; Tue, 28 Apr 2026 06:09:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAI-0006W8-B4; Tue, 28 Apr 2026 09:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA5-0006TB-WB for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA3-0001KD-3L for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:37 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63SBvplL899091; Tue, 28 Apr 2026 13:07:31 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drnb55jpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:30 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCw696020105; Tue, 28 Apr 2026 13:07:29 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8avsvm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7Tqx30147300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:29 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A1495805A; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9E3458052; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:28 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=u7zRD1jLbjv2J3d38 lrtkX+IaipO4wlaxY9OnsHGeLg=; b=FXMeYWPL0QJALKVNYgfEts/FF+BHxVoH4 r7nsw+mKNl7FIANM4S5CjSGjZfDPb6eg8Fcrs7JhF/m/ewigNiHNnmfpiT9zPyiC jtpQWQwH7YSQZumcbbd+chCM0Z+v80INtSQN3nU6nYj4F9c/p+2Pcg+v6RWmOB6u T0807DdhORIEYiLfbL32GrNdjr1QumewZDAyIbSUeO/KciBJbAYIXSkkbOuWiPve v2fdx4U0WPCFNxktFjsjTmdxPPYsIcpKSp9dDeWsSC/QzzFptvRIBTSnTEkwgcv0 7CySuwU7K0TYstZ0x75RHO9CqQ0vgooKy0NfwEIz2JyctyAPUigDA== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 4/6] tests: Rename id of tpmdev to tpm0 Date: Tue, 28 Apr 2026 13:07:16 +0000 Message-ID: <20260428130718.1325177-5-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=AqDeGu9P c=1 sm=1 tr=0 ts=69f0b112 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=3rTIqxLH2NqWiAwI-G8A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfX5sWCObex8pEJ Fkx80H+aKYdA5TseQxFePZnUTdi7RlL9e3+Jqma95cuEokiEauRwnX38Txh3XZbD2oKAVoFTdtB V+LofTgsrZhP8y2ipzYa8OOigPDX+VCLzaHrcstRq3auKJRWLF/skHwWIjPTI8gRFgYEM5dMI/y LOZ89EtBR4TnHK8a03/g4CefjSfEilb25k7ureudD5vVN3gn8DJRWJSbXURQQnt5Z/4rRcdch/n cFuDFfan7Nf0mTdfNivj3ZmWphRzv8FXCf+ljwr0xm8EF98UmkaGHFzXU1UCTIml/MackvYCCkg Zph63peiWohLbJ5qIbq3ueQTz9zA5VRN8wVeFbv2HRZfp6hqNJbXCdnRWMTW4CPoQoyVVJMKTXj KSiozTOPC4jvVZpMXT7ULomxLqf95b6d/qhHDOcG+mupDYsN+qWr3m/K2cNQi5K6j4UIeEZjln+ TKMucVK3CbzFo/xPkTA== X-Proofpoint-GUID: fSOdGOT0PUMONoGeHmWQJCCMejNVm-sQ X-Proofpoint-ORIG-GUID: fSOdGOT0PUMONoGeHmWQJCCMejNVm-sQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 phishscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=stefanb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381760232158500 Content-Type: text/plain; charset="utf-8" Rename the id of the tpmdev from dev to tpm0 because this 'dev' cannot be used when the tpm-tis-i2c device is used. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/tpm-tests.c | 4 ++-- tests/qtest/tpm-util.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c index dcbf5457ed..d1fe4a85d4 100644 --- a/tests/qtest/tpm-tests.c +++ b/tests/qtest/tpm-tests.c @@ -49,8 +49,8 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_fun= c *tx, args =3D g_strdup_printf( "%s " "-chardev socket,id=3Dchr,path=3D%s " - "-tpmdev emulator,id=3Ddev,chardev=3Dchr " - "-device %s,tpmdev=3Ddev", + "-tpmdev emulator,id=3Dtpm0,chardev=3Dchr " + "-device %s,tpmdev=3Dtpm0", machine_options ? : "", addr->u.q_unix.path, ifmodel); =20 s =3D qtest_start(args); diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index 1a47099807..35e9d3f32e 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -227,8 +227,8 @@ void tpm_util_migration_start_qemu(QTestState **src_qem= u, src_qemu_args =3D g_strdup_printf( "%s " "-chardev socket,id=3Dchr,path=3D%s " - "-tpmdev emulator,id=3Ddev,chardev=3Dchr " - "-device %s,tpmdev=3Ddev ", + "-tpmdev emulator,id=3Dtpm0,chardev=3Dchr " + "-device %s,tpmdev=3Dtpm0 ", machine_options ? : "", src_tpm_addr->u.q_unix.path, ifmodel); =20 *src_qemu =3D qtest_init(src_qemu_args); @@ -236,8 +236,8 @@ void tpm_util_migration_start_qemu(QTestState **src_qem= u, dst_qemu_args =3D g_strdup_printf( "%s " "-chardev socket,id=3Dchr,path=3D%s " - "-tpmdev emulator,id=3Ddev,chardev=3Dchr " - "-device %s,tpmdev=3Ddev " + "-tpmdev emulator,id=3Dtpm0,chardev=3Dchr " + "-device %s,tpmdev=3Dtpm0 " "-incoming %s", machine_options ? : "", dst_tpm_addr->u.q_unix.path, --=20 2.43.0 From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381762; cv=none; d=zohomail.com; s=zohoarc; b=Y4Gg9B4GV6yEkse3GRU9YIvE/MtxZ4nVPMCUho918gHY9MkQYSfw2lCeMreZFCIvkGG9+HMIXUstpGFvFQBuycopEV+GmRz2/j07Q4/GWs2oSxXFdiXb3IAvmATXSJXV5Rdr/2xBIqr2kQi8SsH/xIIkgjS6WUrIwBNV0Qgdrm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381762; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SWRNRb01m0v6U5QU+YiQjy4XqmU4JddHXVnkxZ0iXGs=; b=lzV15x8SoxTkALy+b+lIow1IUDaGNAZlJN2JeJrNjHqx30tmWDmGvh4MMNd4asWAcCpyZm9HGa/xw0BvAFof1qWMNt7Ad3PvfFHiHOP4bUyL441dUV4S3ygnP2heTd4nRqZOmhzRtOVh2a61OCH2rK0g1XNe40pYCL96M/eQ33M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777381762542713.7704359548399; Tue, 28 Apr 2026 06:09:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAM-0006Yo-0i; Tue, 28 Apr 2026 09:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA6-0006TC-0A for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA3-0001KK-3Q for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:37 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63RLOqRv1456647; Tue, 28 Apr 2026 13:07:31 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn8vccdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:31 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCw6kq032355; Tue, 28 Apr 2026 13:07:30 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dsamy9hw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:30 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7TR230147302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:29 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6347658062; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EE5A58052; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SWRNRb01m0v6U5QU+ YiQjy4XqmU4JddHXVnkxZ0iXGs=; b=rACPE0SITAuUdA+ejQwXY4cYGNFvJ0QOx Pz624e4ZnFfFokJRylW3IFhms5IDysaIv79T4X6TS4YJqqqtT/x5V3FeABSvH0LH otC/jfDdKWxGwYpZwVIN0407AjeIbR7YJ1aJjzu30SuDOpSg2ySIb9W7dBGPwZ0t ahBPeE8G5yzfG4zneMWBd7pBusf1VT8ErSo/og0i6yMOzvCjaXuLjorDGkn70wgn CRBLmYgW8Qp+HY4bV4SG4IOOPKYuVMKz8rUyW/bQXuwGpUKK2+gsimAatPsF4oOk eZdDW97J5Jw2JoYl/aNlI3rwWZeslCS90ITGHVlHcvSaY06W4ZscQ== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 5/6] tests: Implement aspeed_i2c_restart to reenable selection of master Date: Tue, 28 Apr 2026 13:07:17 +0000 Message-ID: <20260428130718.1325177-6-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=CIIamxrD c=1 sm=1 tr=0 ts=69f0b113 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=h_94E6iZm1Z49o2US0QA:9 X-Proofpoint-ORIG-GUID: AHIMFklNcJ6lXKa3MNwjtiaLsLR8QPYY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfX+C0X+G3bKv/B yCDjifqarmUtwRebZfjy6q6K6mjYh7MVosuTSwlSCXD/v+abCfdmNYISme/M7bYk9IFu0TRORy/ iGQTYbpERO5SnZhKREx+1B1RKHnkwPpF97Jkn2qFjfWoMwJLJCmfaOG4Xk3gPQ4gJz3wtOkJyXL /buUvyF/tVJP3RWOeQ0iCS1IQYBDjVUqOLBsQB1zGHUTUGJC7bJY7CEwygD217rxLRbNObi4Ias Bk/Ml3HfrMhWImcpuMRrbVARsadfft9iCkiHfioCBW3+ZfHdawL47kbg2NnH4NCHrN7kpgebC/S 6sZyGzmbM0moquLYseCg/Dxny5h5pxltmYxk3h5AmM3yA0GvD4+JFR9nWoRwrFtLkNVBa6E39xo YodTk2ha2XT3z3uP3VKy36BClscbi2rp3PjFyAIhc5FXPvBpWoyna/Vq/IFywOCzNyGc8PxaQBE A1WoS6+JNUwb1YdlRYA== X-Proofpoint-GUID: AHIMFklNcJ6lXKa3MNwjtiaLsLR8QPYY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=stefanb@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381765678154100 Content-Type: text/plain; charset="utf-8" For some TPM I2C tests it is important to be able to reenable the selection of the master. Implement aspeed_i2c_restart to enable this. Signed-off-by: Stefan Berger --- tests/qtest/qtest_aspeed.c | 8 +++++++- tests/qtest/qtest_aspeed.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qtest_aspeed.c b/tests/qtest/qtest_aspeed.c index f6da9adea9..13934cc660 100644 --- a/tests/qtest/qtest_aspeed.c +++ b/tests/qtest/qtest_aspeed.c @@ -15,11 +15,17 @@ #include "qtest_aspeed.h" #include "hw/i2c/aspeed_i2c.h" =20 +static int once; + +void aspeed_i2c_restart(void) +{ + once =3D false; +} + static void aspeed_i2c_startup(QTestState *s, uint32_t baseaddr, uint8_t slave_addr, uint8_t reg) { uint32_t v; - static int once; =20 if (!once) { /* one time: enable master */ diff --git a/tests/qtest/qtest_aspeed.h b/tests/qtest/qtest_aspeed.h index d35b0c7cba..c0a095bb46 100644 --- a/tests/qtest/qtest_aspeed.h +++ b/tests/qtest/qtest_aspeed.h @@ -23,6 +23,8 @@ static inline uint32_t ast2600_i2c_calc_bus_addr(uint8_t = bus_num) return AST2600_ASPEED_I2C_BASE_ADDR + 0x80 + bus_num * 0x80; } =20 +void aspeed_i2c_restart(void); + uint8_t aspeed_i2c_readb(QTestState *s, uint32_t baseaddr, uint8_t slave_addr, uint8_t re= g); uint16_t aspeed_i2c_readw(QTestState *s, --=20 2.43.0 From nobody Sat May 30 19:21:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1777381719; cv=none; d=zohomail.com; s=zohoarc; b=HnIdd1d7goPsZ4wLivoXp3X5HP4lNZ7Fbr7Lte5U5Q4mLCl2OR2/D6tVddiNc7VIdktzSywvNZipIntMiGHNpA6wBa/x+908dnEEVpffCNLAOGKQaufW61fbBZFnbk+HMHKXwgG1wXAMleBGCme//bvHytoqt8rmVqMjnEbD2U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777381719; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7NnKmXHbZdy2Zm7kzs4Yg9dgU0n6mNdcDNttJIzCMw0=; b=aFMql4z1OsO+Khio3Ku+wlKhKC/yEe/4xGPS5wQgTmDrx00Syyhr11HQbPNVTwMVMWD4ASxHzp5pq6KdXHkH9y8bsXWzu8XEQl9ITCqivXlAN2Gt85s8eLtRiVJmm5IHVLMvwL2rjTNxzg3XYX1PSHgOX5GcYqJhPjPHNmfivCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777381719986400.4079636689637; Tue, 28 Apr 2026 06:08:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wHiAJ-0006XS-DA; Tue, 28 Apr 2026 09:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA6-0006UE-DS for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wHiA3-0001KT-33 for qemu-devel@nongnu.org; Tue, 28 Apr 2026 09:07:38 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63S6peHh2581734; Tue, 28 Apr 2026 13:07:31 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn8vccdc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:31 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63SCw54N010467; Tue, 28 Apr 2026 13:07:30 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ds7xq9wfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Apr 2026 13:07:30 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63SD7T1n30147304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Apr 2026 13:07:30 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6E105805A; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7870D58052; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Apr 2026 13:07:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=7NnKmXHbZdy2Zm7kz s4Yg9dgU0n6mNdcDNttJIzCMw0=; b=kYdHMdO0gbHNp2u4IPbWojo7r5BHWiarz QufyJ5IXWyWkNQxPAYiSXXQ7jDY7KO2KetKY6nOozeF8+jIKScBCSvhlElO6AL+T 4+LOZSzlp/nBRIEiM1CGMgbw0vuXfnLIgLtxyjMNayd0K10qyR+Dy8YHb76n5rFm C1bVIBmSiodUNHO+cKtqaps5+IDMQuvFsJfpAScRm8Og0OIvW91F/u8Rwltc82X8 BeSg3azEY91tCLJV7FPnG9C7GY82zu0cj7j9TknagXT/WKOJ25RCjRyaJ8E3NOL8 A7eV8VYYvFe29pjJKjNVwn32coS2j01WC7+vMMk0doS0AaBFqFt4Q== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH 6/6] tests: Add a TPM TIS I2C swtpm test Date: Tue, 28 Apr 2026 13:07:18 +0000 Message-ID: <20260428130718.1325177-7-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260428130718.1325177-1-stefanb@linux.ibm.com> References: <20260428130718.1325177-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=CIIamxrD c=1 sm=1 tr=0 ts=69f0b113 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=NJ5oAHpCSCO7Ays0SvMA:9 X-Proofpoint-ORIG-GUID: S-R-HLWpzziaw13GZwZ-oHiYLUblNMNJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI4MDExOCBTYWx0ZWRfX0QeM7ci4Z6CO y4agmFwn3imckuxZL5otY1HkvcV9UEA6ncRGcfm06/E7BdyRdSsSUln4gYPH7AjuqgvyR9PQM05 YulJwdTkAPgoOoHXb4+FMIzgoeJg6DBjj0Tk8joGXIZrk+0gwoAhth4FSZgP/MhluUkWck3AWSr COlvOs9O+TucU5xAFXE5ZIxnaM1aJXNPu2f1DXCH/xDOrQMT+s8Hxw1UWa+nmS180iLvLIJNum3 TgrdsoFufTzXm0CAznlhK7BtScnZPpznEJgRshxOe+/Y2uyMcpAcnl1xy72nmuKfDHNomcGW3Gh JosLoHUN+qiadgP6mQ30gHnaAaxf6pbkcqg4NpchWabS4oZogIlTlvqa+sly2wFWN5xxV8LAya9 J/dsgRtRZOcMqjtKL7jfWaZuULmewCwT0HsHd6M88MaUdppT0Z0Q6i+fcjRk0gCjBnfHimiAneb 2pfPL6Zl/nI7GGb/9yg== X-Proofpoint-GUID: S-R-HLWpzziaw13GZwZ-oHiYLUblNMNJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_04,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604280118 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=stefanb@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1777381722105158500 Content-Type: text/plain; charset="utf-8" Add a test case testing the TPM TIS over I2C with swtpm. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/meson.build | 5 +- tests/qtest/tpm-tis-i2c-swtpm-test.c | 86 ++++++++++++++++++++++++++++ tests/qtest/tpm-tis-i2c-util.c | 38 ++++++++++++ tests/qtest/tpm-tis-i2c-util.h | 4 ++ 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 tests/qtest/tpm-tis-i2c-swtpm-test.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 823be192e7..1a94f20f7f 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -241,7 +241,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) += \ (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'= ] : []) + \ - (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test']= : []) + \ + (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : = []) + \ (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : [])= + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') ? qtests_stm32l4x5 := []) + \ @@ -260,7 +260,7 @@ qtests_aarch64 =3D \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test'] : []) + \ (config_all_accel.has_key('CONFIG_TCG') and = \ - config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test']= : []) + \ + config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : [])= + \ (config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + \ (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and @@ -398,6 +398,7 @@ qtests =3D { 'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-i2c-test': [io, tpmemu_files, 'tpm-tis-i2c-util.c', 'qtest_aspe= ed.c'], + 'tpm-tis-i2c-swtpm-test': [io, tpmemu_files, 'tpm-tis-i2c-util.c', 'qtes= t_aspeed.c'], 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'virtio-net-failover': test_migration_files, diff --git a/tests/qtest/tpm-tis-i2c-swtpm-test.c b/tests/qtest/tpm-tis-i2c= -swtpm-test.c new file mode 100644 index 0000000000..54a84251f8 --- /dev/null +++ b/tests/qtest/tpm-tis-i2c-swtpm-test.c @@ -0,0 +1,86 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest testcase for TPM TIS over I2C talking to external swtpm + * + * Copyright (c) 2018, 2026 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 + * + */ + +#include "qemu/osdep.h" + +#include "libqtest.h" +#include "qemu/module.h" +#include "tpm-tests.h" +#include "tpm-tis-i2c-util.h" +#include "qtest_aspeed.h" + +typedef struct TestState { + char *src_tpm_path; + char *dst_tpm_path; + char *uri; + const char *machine_options; + char *ifmodel; +} TestState; + +static void tpm_tis_i2c_swtpm_test(const void *data) +{ + const TestState *ts =3D data; + + aspeed_i2c_restart(); + + tpm_test_swtpm_test(ts->src_tpm_path, tpm_tis_i2c_transfer, + ts->ifmodel, ts->machine_options); +} + +static void tpm_tis_swtpm_migration_test(const void *data) +{ + const TestState *ts =3D data; + + aspeed_i2c_restart(); + + tpm_test_swtpm_migration_test(ts->src_tpm_path, ts->dst_tpm_path, + ts->uri, tpm_tis_i2c_transfer, + ts->ifmodel, ts->machine_options); +} + + +int main(int argc, char **argv) +{ + int ret; + TestState ts; + + ts.src_tpm_path =3D g_dir_make_tmp("qemu-tpm-tis-i2c-swtpm-test.XXXXXX= ", + NULL); + ts.dst_tpm_path =3D g_dir_make_tmp("qemu-tpm-tis-i2c-swtpm-test.XXXXXX= ", + NULL); + ts.uri =3D g_strdup_printf("unix:%s/migsocket", ts.src_tpm_path); + ts.machine_options =3D "-machine rainier-bmc -accel tcg"; + ts.ifmodel =3D g_strdup_printf( + "tpm-tis-i2c,bus=3Daspeed.i2c.bus.%d,address= =3D0x%x", + I2C_DEV_BUS_NUM, I2C_SLAVE_ADDR); + + module_call_init(MODULE_INIT_QOM); + g_test_init(&argc, &argv, NULL); + + aspeed_bus_addr =3D ast2600_i2c_calc_bus_addr(I2C_DEV_BUS_NUM); + + qtest_add_data_func("/tpm/tis-i2c-swtpm/test", &ts, tpm_tis_i2c_swtpm_= test); + qtest_add_data_func("/tpm/tis-i2c-swtpm-migration/test", &ts, + tpm_tis_swtpm_migration_test); + ret =3D g_test_run(); + + tpm_util_rmdir(ts.dst_tpm_path); + g_free(ts.dst_tpm_path); + tpm_util_rmdir(ts.src_tpm_path); + g_free(ts.src_tpm_path); + g_free(ts.uri); + g_free(ts.ifmodel); + + return ret; +} diff --git a/tests/qtest/tpm-tis-i2c-util.c b/tests/qtest/tpm-tis-i2c-util.c index 6e724a4a47..c73420ec5b 100644 --- a/tests/qtest/tpm-tis-i2c-util.c +++ b/tests/qtest/tpm-tis-i2c-util.c @@ -15,6 +15,7 @@ #include "libqtest-single.h" #include "qtest_aspeed.h" #include "tpm-tis-i2c-util.h" +#include "tpm-emu.h" =20 uint32_t aspeed_bus_addr; =20 @@ -62,3 +63,40 @@ void tpm_tis_i2c_writel(QTestState *s, uint8_t locty, ui= nt8_t reg, uint32_t v) } aspeed_i2c_writel(s, aspeed_bus_addr, I2C_SLAVE_ADDR, reg, v); } + +void tpm_tis_i2c_transfer(QTestState *s, + const unsigned char *req, size_t req_size, + unsigned char *rsp, size_t rsp_size) +{ + uint32_t sts; + size_t i; + + /* request use of locality 0 */ + tpm_tis_i2c_writeb(s, 0, TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_REQUEST_US= E); + + tpm_tis_i2c_writel(s, 0, TPM_I2C_REG_STS, TPM_TIS_STS_COMMAND_READY); + + /* transmit command */ + for (i =3D 0; i < req_size; i++) { + tpm_tis_i2c_writeb(s, 0, TPM_I2C_REG_DATA_FIFO, req[i]); + } + + /* start processing */ + tpm_tis_i2c_writeb(s, 0, TPM_I2C_REG_STS, TPM_TIS_STS_TPM_GO); + + uint64_t end_time =3D g_get_monotonic_time() + 50 * G_TIME_SPAN_SECOND; + do { + sts =3D tpm_tis_i2c_readl(s, 0, TPM_I2C_REG_STS); + if ((sts & TPM_TIS_STS_DATA_AVAILABLE) !=3D 0) { + break; + } + } while (g_get_monotonic_time() < end_time); + + /* read response */ + for (i =3D 0; i < rsp_size; i++) { + rsp[i] =3D tpm_tis_i2c_readb(s, 0, TPM_I2C_REG_DATA_FIFO); + } + /* relinquish use of locality 0 */ + tpm_tis_i2c_writeb(s, 0, + TPM_I2C_REG_ACCESS, TPM_TIS_ACCESS_ACTIVE_LOCALITY); +} diff --git a/tests/qtest/tpm-tis-i2c-util.h b/tests/qtest/tpm-tis-i2c-util.h index 3289545f61..499bf4964a 100644 --- a/tests/qtest/tpm-tis-i2c-util.h +++ b/tests/qtest/tpm-tis-i2c-util.h @@ -27,4 +27,8 @@ uint32_t tpm_tis_i2c_readl(QTestState *s, uint8_t locty, = uint8_t reg); void tpm_tis_i2c_writeb(QTestState *s, uint8_t locty, uint8_t reg, uint8_t= v); void tpm_tis_i2c_writel(QTestState *s, uint8_t locty, uint8_t reg, uint32_= t v); =20 +void tpm_tis_i2c_transfer(QTestState *s, + const unsigned char *req, size_t req_size, + unsigned char *rsp, size_t rsp_size); + #endif /* TESTS_TPM_TIS_I2C_UTIL_H */ --=20 2.43.0