From nobody Sat May 30 19:21:11 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=1777465113; cv=none; d=zohomail.com; s=zohoarc; b=nOSv9Fm2slUTVHmkwu2WoIK9rFz6di2E3Q2T/afal8oTvVcD4NxLkO7dLpP9HXOID5uZK40prDO7iL5PcZ0tkDq0B+3jynd0kccq1T3xcUTGyrEqlUq3q8M6TwUl5dd8frNp+cHHZnVE8jbvFq0ui++bOVzfn71tMfTgIgSmxSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465113; 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=KhmwtuPz647wE9lQYCX8IQtwAdej61plNxZ9W+w08AU=; b=Q6RcwKeXGvYL9cG3Kz3Eod4xiG/gnO4inu0TuqSSwd1Khe6IINMNT/WPT0vtd+uJq2bUuz8Bzmw4Fyopr5JltBUtl620x5SQs4AoTH690Lda25ltycQm9ks62RIXy/gLSB4ItWNoExoi29/gdsXKYhFrvYHuuGt9DUY+idGjB/U= 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 177746511300813.952384443712845; Wed, 29 Apr 2026 05:18:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rZ-0004Fq-W8; Wed, 29 Apr 2026 08:17:58 -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 1wI3rX-0004Ew-B4 for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:55 -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 1wI3rV-0000os-4Z for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:54 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63SN5qv41046341; Wed, 29 Apr 2026 12:17:51 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 4drn44tg55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:51 +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 63TC975S002450; Wed, 29 Apr 2026 12:17:50 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8avx969-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:50 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHnai32899708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:49 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6354D58045; Wed, 29 Apr 2026 12:17:49 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD72A58052; Wed, 29 Apr 2026 12:17:48 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:48 +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=KhmwtuPz647wE9lQY CX8IQtwAdej61plNxZ9W+w08AU=; b=EfMtYvj9/IZxPx/fJj/nwwelW+faMYbfl 7UpccGEmJnXYSnFCbYWk189rRWcAIaEeY7Pzxr8sQZOqHd//VddaXyZxvvSDwZ9h PWqcrFZnggQxxRedxtK7IeQ+n1/KExgSIttiim2nqewT9+wgai6ZwG4Qj2xXK9tF pdswIQ0j5+aqM5k5KaYEYyFiYIrknAf+SOFgAGh9PSzd7ru0YXOt6kkwA2az/8P2 ClQ5YPC9nZqmHI6h4HXj6fmdVNUMW+QKMZ3e+mBMYSuONqbsOgIxxkpc5ESN6bZ0 iu153yie13IiCQjDvkwp99O+kQxdHLKf80Ar6qV3tbOsgAEhxL6zQ== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 1/6] tests: Move TPM I2C bus read/write functions to common files Date: Wed, 29 Apr 2026 12:17:38 +0000 Message-ID: <20260429121743.1346635-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jLOVYG8OPfiB47XMOjJVZUaX0aqbm5NX X-Authority-Analysis: v=2.4 cv=Ft81OWrq c=1 sm=1 tr=0 ts=69f1f6ef cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=8hQrII4DcMiSDO2ebf0A:9 X-Proofpoint-GUID: jLOVYG8OPfiB47XMOjJVZUaX0aqbm5NX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfX70jYyFf+h0QD lOjWH2GMfyvnFPCwSx6f901JIURCr4vJ381iYXEqSOEfkqc4rVtH9hDi6H8FnGk4FBwvgWITd6J 4HLvf2Ck0vaGTNjmKhb+IgBKHLwZpk88TPIUfhmcQpbnFK4/M6ZV5xuotzb9Myl78ctDu0ovcN5 RWAFWZ0mQfD3BHhYOCGbn8uFurbj8VpQKtPji+P5r1SUlHONZDkLgLE7LUMS0JEWY+OfTa6d5fN uTnlaK1FXFs21FVDlb24GOxVrIPohAgYs6RB10DR4l2ycD+jQLK+B93VgJsyaWMlMVYQaFpvoxL qMDSA1XJXa6aB2Mo9CTn54IJ14wZUmoq9yCK83o3wqcMF+hsMxS00TBzxtWFhkpL1v+hwJPyQ/L 1IMkQ1y4j/XYQjzL87OecZcMvfmg2tjwLuIcgYY0Vp+mqUyOwAvwuE3TGIlwmb0XPQg25EqOpfy 1OqJff0bzboO6r87lLA== 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_05,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604290125 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: 1777465115165154100 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:12 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=1777465165; cv=none; d=zohomail.com; s=zohoarc; b=DJYpsBJ6gLL8GcUzt5F+amjywN7pPXSMlGUI59QBHtXxJQ/fDOvF+JryJi3vQjH+7m2fLByS2fIkyJMCvwvvgvPn/LSP0eqNIpfBIFTSOXeTgQfOfP1XxCBNOwrA0yhgfRXN8VvW3TLUQmZeCkrOI04l12CDQMNA/j2faAFdtdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465165; 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=TMACQ2wuCxGdCWYVE6bc69xLlQ6Vo/Xg3Dq9YW4Inp4=; b=fS8GhQ1MUn2Sf42zyvxK71BwdImU5s91poVV9L33NjIUkpqKRXk+JpxpHCJ3yOkFg2nvB3EYx2UsmgcTc0HykX6/SrsLJx3FBOPI0P7Gr6gmq2Z/nkZtXj7nP+MdJlnEB5lNPheG0/7bsxZ1OVdiBgqiSiPRggEX6ncsKdF58cI= 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 1777465165330266.05894837823075; Wed, 29 Apr 2026 05:19:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rk-0004Hq-1k; Wed, 29 Apr 2026 08:18:08 -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 1wI3ra-0004Fx-2w for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:58 -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 1wI3rV-0000qQ-TZ for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:57 -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 63T9Hg1x2930935; Wed, 29 Apr 2026 12:17:52 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 4drn9rabuu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +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 63TBrpWf008018; Wed, 29 Apr 2026 12:17:51 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds9ehe47t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:51 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHoY54653612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:50 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18D3A58045; Wed, 29 Apr 2026 12:17:50 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8980D58050; Wed, 29 Apr 2026 12:17:49 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:49 +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=TMACQ2wuCxGdCWYVE 6bc69xLlQ6Vo/Xg3Dq9YW4Inp4=; b=hcxQWr/XEX+/G+mc0Jq85qg2syn7bDGJQ /vmWmBNUpL0SMpcyR9s8Rx/lQKElewIH3PrigWtKAf7/1XdeOtqVg6BdV/yGizXF tfJ4dD8G8m7sSSalfbiLzOwWXwY2vKvgwX6rgcnmF7Ag6iGf3HYlApZ9OyaSGzBI 9GFHQg+Hz/nuiIlelU4xeiuy5uC7Cinf/whCtZhCldSq6GOS9tfGyQFx0N5k+7EZ 8XmwVDdwrlFNYo6JqSBeFeaJxp/rlqepJtzDoADId7L1MPkg1hZ75ryV5ZO2/q5P h++khXrWJ2E554ZAo0hGEu74PFggjhzSvoAFeh63cf7xlQQ4AZ9gw== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 2/6] tests: Have TPM I2C read/write functions take QTestState as first parameter Date: Wed, 29 Apr 2026 12:17:39 +0000 Message-ID: <20260429121743.1346635-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hVqizKvslkGfehkej5ixB34V7T3jTNKc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfX68YulezzR91m nb0+Za/d3qscsuRe1YAlsP1sNr2SYxSuganpBgGZlR8b/d3Z3MEbsvmT/fJc0IaYD24YAzfkaeO /68cH0ecQqmeLltYu49nUKyZ2sTi9rbpnFLapcT54W+teYWdlf6Lemr7rnU5fXSQpA+3cJ2zL/9 H5pQK5MO+LSh18ywx2ASpnueyYvwthtMki+HW0iqBvgKZyiqGbJTY58aD2LmBhXQd8QMgF1iAOR GIdHFsHoMCKN3esrBT1mIuKCd+e12zaKBCA3IhGIwE0ubGGZspWJuPB8/dBygOTwdn4r4OUYt1E 5RgQqG9h1xlO0OboDSrEkvxkuo6JHvIk4UXn490/jANfKV0zLfNDrUv8FHVrGfvJRgRiOFDDXMf GIuBKX5Q7a1ynS5CZNJ64KS9Hs+0g9Drrt974J1f1M0nzOQtHvIWknm3Xw/MpSYEkhagAZZJ0Bg mURuE57gvdvgGXCuYmA== X-Authority-Analysis: v=2.4 cv=Kc7idwYD c=1 sm=1 tr=0 ts=69f1f6f0 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=cp_pve3XC55RmFQTQzQA:9 X-Proofpoint-ORIG-GUID: hVqizKvslkGfehkej5ixB34V7T3jTNKc 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_05,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-2604290125 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: 1777465166212158500 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:12 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=1777465159; cv=none; d=zohomail.com; s=zohoarc; b=lFAU5oVN/tQZ+7pFGUwPBhEILuPG5OSdXE9cKCu0OND9JmgAVSc6AWLnSXPCktCrx3hpnZA+g1fgJXIZe3Ctcze0am5Vn/vdyinwgtnF+1/bbgzlt/ldhGsMD+RtbytRaoGWxfcKd7URvpVJwzBUBbRdanL2k37I23g3IpfNU3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465159; 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=JsTIvCSFlcUXPSgx2xxGQMJKzlpH+LPV/wPmsQGXzT0=; b=OKK63c39cFMiofbJ/P0i2pHtzs93A8RMsDYk0b3g/rhyQWUCsdAFm6iPnfN2YVR30t9IXcHVbL0W6jB/4DRiFKuEDcYJSHiNQ2geFYQfXRRYXY4McOi7M5UXgkxybiUzlntzK7epiEhTqe6ICyJ7WdOsMtDq8anmRdWtVZ5ClOA= 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 1777465159397450.5133264013359; Wed, 29 Apr 2026 05:19:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rb-0004GH-1H; Wed, 29 Apr 2026 08:17:59 -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 1wI3rX-0004Ex-Bh for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:55 -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 1wI3rV-0000pu-FR for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:55 -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 63T9Jn4E3538290; Wed, 29 Apr 2026 12:17:52 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drm1e0ydv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63TC8iNh027713; Wed, 29 Apr 2026 12:17:51 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8xk66hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:51 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHo8m4653620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:51 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC77B58045; Wed, 29 Apr 2026 12:17:50 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C32E58050; Wed, 29 Apr 2026 12:17:50 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:50 +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=JsTIvCSFlcUXPSgx2 xxGQMJKzlpH+LPV/wPmsQGXzT0=; b=NCgkeoS3WQNRAzzAqQii+5Y+kfM3G0ewq EkJYxujdm2LUNergpNqdAr6vz1TaelXUrgiu8ge6+pMWKJ3yWLfY3GD9/P8e9wI9 PFakxjBR+v5wjR2VFCs7ZkVmWPq6WPBrN9lF7/yCPyy5tmsbIre8g89ChVULylkT T6mAJIbxFuy/yPmNauEPf688JXT+8XtIHdZ2tBjmP9RgMZd7SolpuluHz3CHcn// oWmUnvJDOiEmuOtMwf2md5m1SPugzbFmsF2n4Mkl8Z3+WRgRgKawWDht+JRbSy2v PNZtKZZ5XWNAiTsZ/wSloe5z+flyT1nkOx5zPeuN9Za7sTR52NCZA== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 3/6] tests: Convert string arrays to byte arrays Date: Wed, 29 Apr 2026 12:17:40 +0000 Message-ID: <20260429121743.1346635-4-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: oPIYXqv3RPRYT5v7oTPsvwqo9IBt4LFU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfX29aHwTo30VVN NPlrOD4htaMYsoybYFPT1OQixSFoOibuO3OAaVj/VTFo2sominV6Zy1OsQE02KUAbTmx0q/V1Ch k94C9WJOJGAuvMC0Jdjl17pOJUraX4gAv8945NSPHoRWwY7+g5gmjGuc+tU04peiuihHfeSjCRf Th7QhwW5o1QkCVsJQ5rA2jzEzREx1dCOboZe83r+1X4O9KOiX/9p7TjxOPYCwmJsPCkWlPsPjf6 bWYOftSLW53hbzAFqEJ6ko1UTT3+lDRp169my4e4+0do7BwRkC8GrrBo7FdIZOrqeIIHUr1AZxX /zJrn0hDlWoSwzRdCBLPf2nfUVYuGlJytxEEqK8TubT+nkKO51TiL3ramdF6jAp2KMDgTzea3hj 7Si7aLJG2GkIADLywoBO0hzCN/YoU1pk44gwpjxn/EZvaPZxkYCzChfUi7xUEraAsDiLbMRGJvP HWojhciNy436zVdUzVA== X-Authority-Analysis: v=2.4 cv=VZLH+lp9 c=1 sm=1 tr=0 ts=69f1f6f0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=LORrTqdot4XOhRVC2oUA:9 X-Proofpoint-GUID: oPIYXqv3RPRYT5v7oTPsvwqo9IBt4LFU 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_05,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-2604290125 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: 1777465161243154100 Content-Type: text/plain; charset="utf-8" Convert the TPM command and response string arrays to byte arrays. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/tpm-tests.c | 30 ++++++++++++++++++--------- tests/qtest/tpm-util.c | 45 ++++++++++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c index 197714f8d9..8bd3288f80 100644 --- a/tests/qtest/tpm-tests.c +++ b/tests/qtest/tpm-tests.c @@ -59,11 +59,16 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_f= unc *tx, tpm_util_startup(s, tx); tpm_util_pcrextend(s, tx); =20 - static const unsigned char tpm_pcrread_resp[] =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" - "\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde"; + static const unsigned char tpm_pcrread_resp[] =3D { + 0x80, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x0b, 0x03, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0xf6, 0x85, + 0x98, 0xe5, 0x86, 0x8d, 0xe6, 0x8b, 0x97, 0x29, + 0x99, 0x60, 0xf2, 0x71, 0x7d, 0x17, 0x67, 0x89, + 0xa4, 0x2f, 0x9a, 0xae, 0xa8, 0xc7, 0xb7, 0xaa, + 0x79, 0xa8, 0x62, 0x56, 0xc1, 0xde + }; tpm_util_pcrread(s, tx, tpm_pcrread_resp, sizeof(tpm_pcrread_resp)); =20 @@ -105,11 +110,16 @@ void tpm_test_swtpm_migration_test(const char *src_tp= m_path, tpm_util_startup(src_qemu, tx); tpm_util_pcrextend(src_qemu, tx); =20 - static const unsigned char tpm_pcrread_resp[] =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" - "\xa4\x2f\x9a\xae\xa8\xc7\xb7\xaa\x79\xa8\x62\x56\xc1\xde"; + static const unsigned char tpm_pcrread_resp[] =3D { + 0x80, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x0b, 0x03, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0xf6, 0x85, + 0x98, 0xe5, 0x86, 0x8d, 0xe6, 0x8b, 0x97, 0x29, + 0x99, 0x60, 0xf2, 0x71, 0x7d, 0x17, 0x67, 0x89, + 0xa4, 0x2f, 0x9a, 0xae, 0xa8, 0xc7, 0xb7, 0xaa, + 0x79, 0xa8, 0x62, 0x56, 0xc1, 0xde, + }; tpm_util_pcrread(src_qemu, tx, tpm_pcrread_resp, sizeof(tpm_pcrread_resp)); =20 diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index 2cb2dd4796..63cd5b69db 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -54,10 +54,14 @@ 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 - "\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00"; - static const unsigned char tpm_startup_resp[] =3D - "\x80\x01\x00\x00\x00\x0a\x00\x00\x00\x00"; + static const unsigned char tpm_startup[] =3D { + 0x80, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, + 0x01, 0x44, 0x00, 0x00 + }; + static const unsigned char tpm_startup_resp[] =3D { + 0x80, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x00 + }; =20 tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer)); =20 @@ -68,16 +72,23 @@ 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 - "\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"; + static const unsigned char tpm_pcrextend[] =3D { + 0x80, 0x02, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, + 0x01, 0x82, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x09, 0x40, 0x00, 0x00, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x0b, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00 + }; =20 - static const unsigned char tpm_pcrextend_resp[] =3D - "\x80\x02\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - "\x01\x00\x00"; + static const unsigned char tpm_pcrextend_resp[] =3D { + 0x80, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00 + }; =20 tx(s, tpm_pcrextend, sizeof(tpm_pcrextend), buffer, sizeof(buffer)); =20 @@ -89,9 +100,11 @@ 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 - "\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b" - "\x03\x00\x04\x00"; + static const unsigned char tpm_pcrread[] =3D { + 0x80, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, + 0x01, 0x7e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0b, + 0x03, 0x00, 0x04, 0x00 + }; =20 tx(s, tpm_pcrread, sizeof(tpm_pcrread), buffer, sizeof(buffer)); =20 --=20 2.43.0 From nobody Sat May 30 19:21:12 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=1777465159; cv=none; d=zohomail.com; s=zohoarc; b=C4B0XuRMx5mZYIKVJDKqbIfdBY5YKbi5OSlz3IPXStAeq/4aX4CJiVWJ3YxXlXxz8YDPn6QxK7jCdSqEAola4xGJOB0BvkRleaYVHYkdCVWTXV+tf4KYyA/fzAncM5eaLnum/ewKRNRCFq9f8LFw+wMVZLzhL9Y6DtC+Iomk85U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465159; 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=1vtQEoUCOZUMsu673Dw5Piw3N67i5x8+gnNGnf6Gmfw=; b=A4eJaeC6ZP9EuYeFcgD4gHLLTQEAPRiiJ4o6Yeg/jOwmna+MFv92Bhf0Lt7hqJMGisyNjYbVnz8g6QEaO4vvoKzs5VOH3Y0EtLDhkozLekT+9orU5Gsv5HqKvfVrKVJEqxJTlPfxw7pMkhxS8bCW6EMvbQu93GEcOzBavR5X1eA= 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 1777465159986854.1394073809328; Wed, 29 Apr 2026 05:19:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rg-0004Gv-4j; Wed, 29 Apr 2026 08:18:04 -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 1wI3rY-0004FR-JW for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:56 -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 1wI3rV-0000r8-SE for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:56 -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 63TBe7vO3687580; Wed, 29 Apr 2026 12:17:53 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 4drm1e0ydw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +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 63TBrqRE008028; Wed, 29 Apr 2026 12:17:52 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds9ehe47w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHpHr31195862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:51 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BED858045; Wed, 29 Apr 2026 12:17:51 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFDD858050; Wed, 29 Apr 2026 12:17:50 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:50 +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=1vtQEoUCOZUMsu673 Dw5Piw3N67i5x8+gnNGnf6Gmfw=; b=AkB7h6FHlTfyE+sqjELqQR1ooxVfY3FKC D+EC79PM1AJcOiBB7DLb3x9LxQr5Td12u7NOENExOZjh4mgs5CrM2yfeVbB8GdoM cUkZmMeZnqDaiJZ/scHCiEPG/dCHEfWFCQAsFI67wf71R1hGTEWfyz9fsGRAJzAC jYp2yWl5TPi5L332wBJQcRx2As3JKqxL+w2CMUPdkpbsJDiv3KicjppgLg5N282C GsSRp4doMFJDUehnEPbImnBHVWAx19/5DhdAmW/cqaO4JdUw6BId86DjaJvOqYRR lXHm/9ynn4/0qSDRZnhrxj5vuj2kE7U+YvshRMuEBf4htIAKvD1sA== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 4/6] tests: Rename id of tpmdev to tpm0 Date: Wed, 29 Apr 2026 12:17:41 +0000 Message-ID: <20260429121743.1346635-5-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FGZjgh4EfKnQfsqKaKmilYIL2V42TJar X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfXxt3WxJ/o3NBn A//F5W7EQx6LC9A/wLQ5Rd/v9HhXCABZCCFE9vpHc6VdXPHtXa9Cjz5E/IawbtaVI3fgPAyxEDE wmaLzAldvFWfACBxG4o1ibMWxsSBO007+H2ErqtT8trQILZYBMMhh9SjzX1IELmJ5nQb5eGZ1P9 gjj7YyhTZIeoomL10dlXdcAg9+GBwkoYu5OLdkbR2dWK4LS3CjhZZDzy2VfXF6e6brrAOlcPMUZ AeMOT+Yk4A96OPUhgh9t5U+dBDbyq04uX7PyRc9QeF+M4ucLRH3/bh2MxzD0DPnq7o8zp4Pofo8 hJ00xcVDaH4CETZFkognpzXrXpA7F36KuJC790JyhVL1/N+LT/Sw7FnFXa+yb8li1J5DEbvAaxl Zob+c19lx05dE9QoNefycDPNSnt0GaVnSuX49/B9iP5ppjxzuF7hp6Q7pO7rZ/t5wyRIfwSepcH D256qS83BB3KQ1Not+A== X-Authority-Analysis: v=2.4 cv=VZLH+lp9 c=1 sm=1 tr=0 ts=69f1f6f0 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=20KFwNOVAAAA:8 a=Tt6dWLOZzW0yVT5AIBMA:9 X-Proofpoint-GUID: FGZjgh4EfKnQfsqKaKmilYIL2V42TJar 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_05,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-2604290125 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: 1777465160240158500 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 8bd3288f80..1b4f932b0c 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 63cd5b69db..0f9bef8971 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -240,8 +240,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); @@ -249,8 +249,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:12 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=1777465160; cv=none; d=zohomail.com; s=zohoarc; b=chbDBy2xg0d3Qh8iiTXOQNpdDSLXhY+GqQS6LYpBRpGxo9TO1QWe7TocufFRscVKxx+UG+KQ4m0sm4QDpO32dQEjBkc/UiGGa3NyptPWTb7JskC1BBmGXgg3416xyNaMt3cWLxCiBUf+TU2qJNStQw7Vtf+hI6gSBgJptvJ05PI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465160; 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=RPYk52kl6otr6XnssNb00wwkaB+5NLppj3t3DP2ngOo=; b=g6hIT2KEJDcmhl6htDrfPhFbxksHEBNp6SLwS7UITgEwoHiWLhzYENFoGPQ8UTIOlbVIRZxcU9FHXADTJh1NElmkKsxWEnOMDoI8+fJdH1co/n0/yqJkyUi8K7c1+VvdGzUMxI4MrWT5q0l7rNzyhhfayxAX49/SAM9PaOJsSbg= 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 1777465160952106.38029644501967; Wed, 29 Apr 2026 05:19:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rh-0004HP-IC; Wed, 29 Apr 2026 08:18:05 -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 1wI3rY-0004FS-JY for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:56 -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 1wI3rW-0000rU-0H for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:56 -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 63T9o1Fs031301; Wed, 29 Apr 2026 12:17:53 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drm1e0ydx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63TC8iNi027713; Wed, 29 Apr 2026 12:17:52 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8xk66he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHqp15768038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:52 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9EF158045; Wed, 29 Apr 2026 12:17:51 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F9DB58050; Wed, 29 Apr 2026 12:17:51 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:51 +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=RPYk52kl6otr6Xnss Nb00wwkaB+5NLppj3t3DP2ngOo=; b=AgPSqV2tF7D09hK5H19QInVq4QBwVknkB SloOzCF0/z/rIi5TkvaFQg/yMqu4zKFIqDmbhbpKUyTgIlZIFdpWV8/kwoDgbGUA GXprdZeASWY4o9y1JWgpfIBEWIQns+TAkZhJweR5WHGKlTwg4pJ1IwRJc6pTN/YR JeU6sdJkJ36fYZYEZG3nO7wDYnDW3LNIMBrDIsgzjbY7nW63jn2SjgqsM78NLkNz SP3dmn0iCpLYvX7EgDAR791wHp0cnNk/bEKiFfPXE7gKuoQiEfVpvrwoeZPt985T erE+BBznTZkVSjI8nqcyTDvMI8tzCX8Htk56qkwYlJqDj2jGC2yeA== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 5/6] tests: Check whether the I2C master flag is set Date: Wed, 29 Apr 2026 12:17:42 +0000 Message-ID: <20260429121743.1346635-6-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: waqY89nkt9ueGhY4DyNyMoKw0tPY2zFF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfX9nAG1FW1C6ma 3uo8LkNxY8PmPSurDy+Qsb2STtkfQ77yqetqHTyAv2Fx+uynLb0we8+g42ZrqcX7iR2me/sGzTm VANXYJw085aQyMRCQL4Jv8V6Y43paqOy2rv+Mtj9AKXh5osij3Wj3PVr8+jEFi/vL3TTlsODwJc D61rH7H8T+ft58sr8NjG7wsn7ZJftyGboTauKeE8XfkxnOqSUa+tIRpFlZJUuk0HE8ltHhmsYo/ Fq5zQrZRa8nyaYmYb8efjIEvP91Uu0/6ZPrG60d+koUacHL8Gq6fA0x5c6L0u5A8DHlnRTm3KnV lVhJp5E+AMfD1sUa9eCW8zdOwmRXwaHrK6cwynQ88VV4qtscRLH1lOUHI5iQuSDsQykJtEoNiin yVUmmdbTx9tiyE8deOgRw+Cm0Gd21VGE4M7pVJMvBiTLyvmOvW8gvOG7XhaCUm8XedByCiunWrC +lPMpAXLzlB0Die5OEw== X-Authority-Analysis: v=2.4 cv=VZLH+lp9 c=1 sm=1 tr=0 ts=69f1f6f0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=hDG30pTYrb-JhymLzFwA:9 X-Proofpoint-GUID: waqY89nkt9ueGhY4DyNyMoKw0tPY2zFF 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_05,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-2604290125 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: 1777465162333158500 Content-Type: text/plain; charset="utf-8" Replace the 'once' variable with a check for whether the master flag is set so that the flag can be set when needed. Signed-off-by: Stefan Berger Reviewed-by: Arun Menon --- tests/qtest/qtest_aspeed.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/qtest/qtest_aspeed.c b/tests/qtest/qtest_aspeed.c index f6da9adea9..7bf5abb9be 100644 --- a/tests/qtest/qtest_aspeed.c +++ b/tests/qtest/qtest_aspeed.c @@ -15,18 +15,21 @@ #include "qtest_aspeed.h" #include "hw/i2c/aspeed_i2c.h" =20 +static bool aspeed_i2c_is_master_enabled(QTestState *s, uint32_t baseaddr) +{ + return qtest_readl(s, baseaddr + A_I2CC_FUN_CTRL) & A_I2CD_MASTER_EN; +} + 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) { + if (!aspeed_i2c_is_master_enabled(s, baseaddr)) { /* one time: enable master */ qtest_writel(s, baseaddr + A_I2CC_FUN_CTRL, 0); v =3D qtest_readl(s, baseaddr + A_I2CC_FUN_CTRL) | A_I2CD_MASTER_EN; qtest_writel(s, baseaddr + A_I2CC_FUN_CTRL, v); - once =3D 1; } =20 /* select device */ --=20 2.43.0 From nobody Sat May 30 19:21:12 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=1777465170; cv=none; d=zohomail.com; s=zohoarc; b=eybEuviSbhH2GQbGj/cFnoE1D/WE/CCM8Uk/En3fDLURFzfG983mvK0941HlGyaJI/lEMLtO36+666+7iGvSj54SKfVgkdqlz4na3H7RVAqe74kJGrdnD30XNPqt1Ih5PVv10uf1uELR6eg4ELS9RB5dWngZct12+dcQxmOtzUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777465170; 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=+SBRLx3hztB6HqxJ90C7GOa0WF9j8r7wQYbco1ebfes=; b=GHiyuPp5/nOyFtRkydOlb1T29J6PHly70IW/T0HLX1du33puqUVHaIyzQUmwT8ezH67gXmFZHgPAj41244npOC4VUZ8mgNVbsGbKu/cgZE6K7z8pdFpJEmC3I83UZBU+jVCmUvqHUYlnoD161VDiH+tPCiJVFpNxe452TYZ5ha0= 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 1777465170518131.32672301625178; Wed, 29 Apr 2026 05:19:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wI3rm-0004IN-IK; Wed, 29 Apr 2026 08:18:11 -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 1wI3rZ-0004Fo-TY for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:57 -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 1wI3rX-0000t8-Ss for qemu-devel@nongnu.org; Wed, 29 Apr 2026 08:17:57 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63SJXuJr3499801; Wed, 29 Apr 2026 12:17:54 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 4drn44tg5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:54 +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 63TC8jvM002178; Wed, 29 Apr 2026 12:17:53 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8avx96a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:17:53 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63TCHqCA5768042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Apr 2026 12:17:52 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9365658056; Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19A9F58045; Wed, 29 Apr 2026 12:17:52 +0000 (GMT) Received: from mycroft-2.pok.ibm.com (unknown [9.47.158.222]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Apr 2026 12:17:51 +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=+SBRLx3hztB6HqxJ9 0C7GOa0WF9j8r7wQYbco1ebfes=; b=BwZjYVIwvuTcbQ0pom8XBBHwiuSBcFyBY xK5dhu4cVi2uIr09f20adaCHexPA/u9QuZGhuGzFVYb2hPFkar1HiVrLmwZ64fLV Mm4OWt6MS2HSeMQBJ9nIQ0AdihRz5syX6VI3+fuaGAafCMgLqBe0kJVptSc4ddoj DG75kDAGMRWL52fwf6VL34+Dq0JqHefnStSHRTGs5n2WvaJi9pdAuIzhXtcpnsZm GtFlHC3tLPr302AduVlNtFdRfmHermUfOX0D/U28nojhP/xKwAw7G44PicrHfynL 1fOtl6bL5rtCv94Njom3+FRJTOukPNvB5DcLuUNs1DNfb5AHCpZYg== From: Stefan Berger To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, armenon@redhat.com, Stefan Berger Subject: [PATCH v2 6/6] tests: Add a TPM TIS I2C swtpm test Date: Wed, 29 Apr 2026 12:17:43 +0000 Message-ID: <20260429121743.1346635-7-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429121743.1346635-1-stefanb@linux.ibm.com> References: <20260429121743.1346635-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CIj4vYb_saFGwYN_-Rqvp1epvr6W6ruB X-Authority-Analysis: v=2.4 cv=Ft81OWrq c=1 sm=1 tr=0 ts=69f1f6f2 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=nr6cYVCJ1kreKA-1BtQA:9 X-Proofpoint-GUID: CIj4vYb_saFGwYN_-Rqvp1epvr6W6ruB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEyNSBTYWx0ZWRfXziOLCI/amuWv Pm+s4pAJGUB16z7ZZntwuiP/pbit9zCU3/Vco3EUtLvn4VJiA+xlLKNcqlKAesr+KEDCxrkQt7w Zm5zrhsEzbBX8iTJbSA59K3xIw8oT+9to2+uNdjOIx4XqRQ5UZYtmfdevhcL5fjHhCPAQry5TpK 2OzIRRwIP5q/4Cm+DbRv82JqgN+zF6i+uKVyQWrmc/cKEcG5n//YeuDWu7NvRqWI3/ARijRcyvr a/LqA71TrmDgoEfmLIcdck4RiJ5VQBnSNVQ4hs+3FSiYC5NJqi5y07QdkKi5LUUpdKIwf0fKVLW /yEpLULeggnrckL0mWXTdjsBBorZv05ci29jkXNODj5sKsHKYBMw7JYnevCceVBt8RjW/G/2Wqg M9tRqSYtuBwGXOaNQrNv20kFSAiUW6hT17MWV/5UY3vOiouXagweSk8QGXEghBnkkgg38uoOEPr jFlnr3VKM35RyNllSOg== 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_05,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604290125 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: 1777465172260158500 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 | 82 ++++++++++++++++++++++++++++ tests/qtest/tpm-tis-i2c-util.c | 38 +++++++++++++ tests/qtest/tpm-tis-i2c-util.h | 4 ++ 4 files changed, 127 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..50d32a960b --- /dev/null +++ b/tests/qtest/tpm-tis-i2c-swtpm-test.c @@ -0,0 +1,82 @@ +/* + * 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; + + 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; + + 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