From nobody Thu Dec 18 19:29:42 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744815662; cv=none; d=zohomail.com; s=zohoarc; b=Das1q0nE7wgh4NpO1L6yvkL5cChgZZ7SujDzfM1K56FPWLaD2eRyzTl/n9pAZwgAGXUxqAHpkJYYo7ocesEvnsronHM9zU5xM8zokifVTg3JH0lShbqCpehjOepoBP+audOV11rvEIi7eVd8ByEf4FVZgyYsP4lnmrx8TVn4OQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744815662; h=Content-Type: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=3JXU/iDoCeiLKmXbMmkzTXvAvxJfUqOqd0YNU9sN6g0=; b=Gi1PFtHWSU8E7wXLodPIs5Xb39/IdLJHo9mbhBXlAmhzOic1b4x1oCmGzpC2k0nwp2rISicujUQ1HBjXYrj+bG5fuMu4iDdQITxl3Wlx1+E1Gg54vVQFwt2oj/DvdjL+rPZ45nYxB7y6hVTNlnFRWDBwFlIWZ8LaWZ0GY+isYjw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744815662820614.2234700060161; Wed, 16 Apr 2025 08:01:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u54Fe-0006xF-GA; Wed, 16 Apr 2025 11:00:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u54Et-0006cT-E3; Wed, 16 Apr 2025 10:59:48 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u54En-000362-T4; Wed, 16 Apr 2025 10:59:46 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7396f13b750so7242151b3a.1; Wed, 16 Apr 2025 07:59:34 -0700 (PDT) Received: from wheely.local0.net ([1.145.55.85]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bd230e355sm10814506b3a.139.2025.04.16.07.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Apr 2025 07:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744815573; x=1745420373; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3JXU/iDoCeiLKmXbMmkzTXvAvxJfUqOqd0YNU9sN6g0=; b=jOg6i0YEbUkwubKDT53qJX4b1Fl3/TDhkyh8WZi9tn0Oj5fMxQYqPCGqWG9TZ4ENPy i2uSrWijG/icOYU0xC0ImOM4GMOd78gzuMfT2azeFRxTqRAHv8bxWHSDSiKtmfaBnzrW VAABXZz7mxpAwevrtpp+xbDHfGMKsb3x7olX1O/5LvcH7oVeiqxj8hrO0c+FTNp5Br/g PK6LstXhnF65Dt0tWTHKGvOB6ddUnR7kYvkmzmvQoBWTVsnowAGEc2phPTlCgT3/a51z 4V8U7oIPJAUUvUqfAbxh7ZRIQydHeQl4/U1PICGR3uLFqx5Ey4bxo9vsoRIZE/5gYDQi yJ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744815573; x=1745420373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3JXU/iDoCeiLKmXbMmkzTXvAvxJfUqOqd0YNU9sN6g0=; b=aHHGeCi28+5cBRwNEjpQpGIUqf8z5duL9mb0VkHmo7R4kLOwtqcReb3BXHpzk4yIV9 LE87/rB8N/MHppogmSN7gj2mdAt3OFGSriZKLyXtRS7dNznstI9P6PGtbjc7UQVjIgFy /MJK73q2VLYGkq3szZMckl8WZGchpUk1xop1K+NmA3sGTQNtooq1rsC3QR8N61GPEnQu Z4A/bRKYmBDeSmHzGHldp3mkI5aiJSmd8JvtZAJVR0YgM8J7SYrSjatkhF5ILRYLPBh3 gsNO83r5/NMyvjiOleASJwkGwRI2tm4hM9loueW5KWsOhVV36UcUpya9y55ybc6h/4lv h0Ew== X-Forwarded-Encrypted: i=1; AJvYcCWC1t/6bTgLmxM80Ttmk7dk5jA/DQosvhQ8ICxZCl6Cbx2grG0RSdtV9dLKhuiZXp7yAwzKY165+/E4Hg==@nongnu.org, AJvYcCWOt1EAS4oRDmKYFUUr06VZgbFL4H6PeCw+r8bnzzChC+EVlshqpXaqWkQ1p/bSIhzZxHxG23mNXQt/@nongnu.org X-Gm-Message-State: AOJu0YzaIysDdNb2R/mYyG1qfehSIbOuo6P0j9ikoavlNAbZ6Xg2+oj/ u/bbMlhRgUTHaOATSFX/xE1Jpu5E4gQT/HnZXkpl6ojotoOgBnuibojRLg== X-Gm-Gg: ASbGncsIPDJ3antiW8piAXA7zk1vLPOH4PtyuiHMOcA0iKRWjzQvWDL2YUO1TvCv+bi k7jIfnkDcopNsVWR+g+0TJZ641qoOyhfXGRUpTxWKiHCusH6D6cOvIvB/iVhuufQWe9nEo23902 N/0aKx/gi9JsKW9NssZhCdZ0AkCwSRCjOXzlG2dFA01vAIZyepfLkBhnDDxLpM1ZhskquK4ZjS5 8ZvGqShxdKync7/q2z4/EufWHgFggrzCXUATZKNqJLpSR6NaJN/w7r3gkLulaBS7YyOyvm+Guds bnzg+U9QP8dsxnm5BRPeSHewc3QC0VNqeNG5Rcz7XLFi30LpC1Dt X-Google-Smtp-Source: AGHT+IF+u0cVhMbMIfaTbtSM87tUe5zK1Q4kvmCdKt0MtnllTzQ0HUNCyrXZI7lNvG+2r33VEP7Imw== X-Received: by 2002:a05:6a00:390f:b0:730:8a5b:6e61 with SMTP id d2e1a72fcca58-73c266b4473mr2695040b3a.2.1744815573179; Wed, 16 Apr 2025 07:59:33 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Coiby Xu , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 1/4] tests/qtest: Enforce zero for the "un-fired" msix message value Date: Thu, 17 Apr 2025 00:59:15 +1000 Message-ID: <20250416145918.415674-2-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250416145918.415674-1-npiggin@gmail.com> References: <20250416145918.415674-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=npiggin@gmail.com; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744815663850019100 virtio-pci detects an unmasked msix interrupt has fired by looking for the data payload value at the target address. If a value of zero is enforced for the memory value when an interrupt has not fired, then an assertion can be added to catch the case where something changed the memory to an unexpected value. This catches an endian conversion bug in the message value when running these tests on a big endian target. Previously the test just times out waiting for interrupt, after this it fails nicely. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- tests/qtest/libqos/virtio-pci-modern.c | 9 +++++---- tests/qtest/libqos/virtio-pci.c | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/vi= rtio-pci-modern.c index 4e67fcbd5d3..f31b3be656d 100644 --- a/tests/qtest/libqos/virtio-pci-modern.c +++ b/tests/qtest/libqos/virtio-pci-modern.c @@ -137,12 +137,13 @@ static bool get_msix_status(QVirtioPCIDevice *dev, ui= nt32_t msix_entry, } =20 data =3D qtest_readl(dev->pdev->bus->qts, msix_addr); - if (data =3D=3D msix_data) { - qtest_writel(dev->pdev->bus->qts, msix_addr, 0); - return true; - } else { + if (data =3D=3D 0) { return false; } + /* got a message, ensure it matches expected value then clear it. */ + g_assert_cmphex(data, =3D=3D, msix_data); + qtest_writel(dev->pdev->bus->qts, msix_addr, 0); + return true; } =20 static bool get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq) diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pc= i.c index 002bf8b8c2d..102e45b5248 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -132,12 +132,13 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioD= evice *d, QVirtQueue *vq) return qpci_msix_pending(dev->pdev, vqpci->msix_entry); } else { data =3D qtest_readl(dev->pdev->bus->qts, vqpci->msix_addr); - if (data =3D=3D vqpci->msix_data) { - qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0); - return true; - } else { + if (data =3D=3D 0) { return false; } + /* got a message, ensure it matches expected value then clear = it. */ + g_assert_cmphex(data, =3D=3D, vqpci->msix_data); + qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0); + return true; } } else { return qpci_io_readb(dev->pdev, dev->bar, VIRTIO_PCI_ISR) & 1; @@ -156,12 +157,13 @@ static bool qvirtio_pci_get_config_isr_status(QVirtio= Device *d) return qpci_msix_pending(dev->pdev, dev->config_msix_entry); } else { data =3D qtest_readl(dev->pdev->bus->qts, dev->config_msix_add= r); - if (data =3D=3D dev->config_msix_data) { - qtest_writel(dev->pdev->bus->qts, dev->config_msix_addr, 0= ); - return true; - } else { + if (data =3D=3D 0) { return false; } + /* got a message, ensure it matches expected value then clear = it. */ + g_assert_cmphex(data, =3D=3D, dev->config_msix_data); + qtest_writel(dev->pdev->bus->qts, dev->config_msix_addr, 0); + return true; } } else { return qpci_io_readb(dev->pdev, dev->bar, VIRTIO_PCI_ISR) & 2; @@ -323,6 +325,7 @@ void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVi= rtQueuePCI *vqpci, vqpci->msix_entry =3D entry; =20 vqpci->msix_addr =3D guest_alloc(alloc, 4); + qtest_memset(d->pdev->bus->qts, vqpci->msix_addr, 0, 4); qpci_io_writel(d->pdev, d->pdev->msix_table_bar, off + PCI_MSIX_ENTRY_LOWER_ADDR, vqpci->msix_addr & ~0U= L); qpci_io_writel(d->pdev, d->pdev->msix_table_bar, @@ -355,6 +358,7 @@ void qvirtio_pci_set_msix_configuration_vector(QVirtioP= CIDevice *d, =20 d->config_msix_data =3D 0x12345678; d->config_msix_addr =3D guest_alloc(alloc, 4); + qtest_memset(d->pdev->bus->qts, d->config_msix_addr, 0, 4); =20 qpci_io_writel(d->pdev, d->pdev->msix_table_bar, off + PCI_MSIX_ENTRY_LOWER_ADDR, d->config_msix_addr & = ~0UL); --=20 2.47.1 From nobody Thu Dec 18 19:29:42 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744815644; cv=none; d=zohomail.com; s=zohoarc; b=iDpl/WWMIYWwBAnV/pvgqbRboBURP6HSDeuAt8FY12/iijwd1yL0jE9CtYh4VouorWfQBaZVtVekmd/rlTDQ+8LAtsi1hYHMECUm5VZ8snfy4n3Iu0hU9JX43RSnCZC8hhzGTS+ZeOfDLvm0ARf9n0GkV1VKwAaY1wUsya+yLHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744815644; h=Content-Type: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=oyvoNMD/MGbgPmwNNQJl9p2mFi5GZdgxMiyr2KvPotM=; b=FG8ajkVsYe6eHVnCZVP0jRRNOoaIvJol6t0QHejjvYB1OJ4EtsimKUhE6VM2ao+4PNP8wrspb/HHkDOm5rhR7Sbg9UOc7FkpTa5VXdiPhIRl4JLXAeNxNmsH3Vs4V48rqDk7y/KT+ifblqA89NnkL7UmUwmDGMo4OUUDyqWExWo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174481564467722.809415591124093; Wed, 16 Apr 2025 08:00:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u54FJ-0006mY-Pw; Wed, 16 Apr 2025 11:00:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u54Et-0006cS-DS; Wed, 16 Apr 2025 10:59:48 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u54En-00036r-TH; Wed, 16 Apr 2025 10:59:46 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-227c7e57da2so62897135ad.0; Wed, 16 Apr 2025 07:59:39 -0700 (PDT) Received: from wheely.local0.net ([1.145.55.85]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bd230e355sm10814506b3a.139.2025.04.16.07.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Apr 2025 07:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744815578; x=1745420378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oyvoNMD/MGbgPmwNNQJl9p2mFi5GZdgxMiyr2KvPotM=; b=Ba5sh9tOpgF1aqEDcjI5bl9pugkKB5NoXCPoL7JU3yjVhdq16cnoSpSvjGpVRl2iHE xIBxeGIfbRaYaK9mkwsIXR+jzmVnKjW5CN8NH0Cce4kbezjjaC3mf6GLNP/9v4xKaHD5 AGVadjzqTX6wpXkuUO6z/xWYsLPwXWIzSEQFBxi2cmFufc9B1EmKu5aKN2GcReOY6T0L JIS/2W/cEJqtFHiOJJQJysM9fLdHWI46TW8cm+K3gkdfbAUkxSe+4xY/Ty6fbSv1OoWm 0LOaBlREQgxnVFG7Vjd5aXAs8ac2F/jHRQ3lewfB+pnbpAV5MRBvd1YBsbWer4eQldc+ fSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744815578; x=1745420378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oyvoNMD/MGbgPmwNNQJl9p2mFi5GZdgxMiyr2KvPotM=; b=P96QrDTHcqZYgYSmeXRu5HijIXgeca4MMD3NxG8Pqvovb/Bg0iEBFsOEIVGo3rcJbQ UR6XSglAyD2v1VzTl5jXQljrcmuz4yoBfkBYre6hlttQUZ1svYiT4RJ/76mnkaqtW8BZ pde9OKLbjFP3McoX0wF1qfKioymouZjkUHNy/ShicJrfF/ey8qW6usfkGcrSYMAq54+B A2amU0C70ur1Eh4W2rbfEoIK8dds3Q46piHwIHkT753yH3zGOCcIktrN4Sc6G2q36baf 1JhbkcXsYcslatGkkuGhHZsUEJ/SQri7RARxOE0D3vj5PFFwDE7c8zN2zVvjFMIpV0Ad OzQQ== X-Forwarded-Encrypted: i=1; AJvYcCVd9V2UlUH+KIN8cblQOx/RWXKdO18JZk5ruSn7mmcU998RFFB463B8i4uLXXCGxagqLPojT3KhBV/GAg==@nongnu.org, AJvYcCXt4I8YjNPctRc/vD9MRx9w9/8yQTzg+wiqIftP8GJb0edzhRUND51HP6YybyNZxnfzOwTLHJTag2fg@nongnu.org X-Gm-Message-State: AOJu0Yw7M7337BxMtcfciLvobPD0YpGCEDOsJeqw+BAKjhE4fm23eO3Z VP9WK805fczmKQLzDaxHkUJH++t0793sj9z2JkeBWIrgyalVmi5HaEBQDA== X-Gm-Gg: ASbGncs8JlCa1zgdCfm+fEKOYfoUH9V5KAWTNDl++epsFbrf+NxLQl7bZ++DmXvTTQ6 vYRG2Iwn5hAO+HCuS2OvO8iNa9VR4Ct+FTWpAuNX6JlOOLbhvuafmS6DSiuMj71viHefjFfgc9f XSsM5/XwGE3NsiKdyoB4Rkven24WgMn7fBBAeG/TKpAmCEu7F4BY4+vB2j0yqFvAQqZzy87qd1s 1ciwER6gFZLqttumF7rfcMt4LMwhcAhdwsQOItdCC6yXwA2BbjqWsEWv0uTkVuZ8vNml/oxR4/u SALi4gdxDkst9kleN8kz+F88NQftxEyI4yPvdQ9Auw== X-Google-Smtp-Source: AGHT+IHyUsvFSEPPqJyGG0q7Ktigwy3M9LlmGN6QgT66bjF0HOOKhwvrvBYNeZAeB5cIlPq+LLQBdw== X-Received: by 2002:a17:903:3c4f:b0:21f:45d:21fb with SMTP id d9443c01a7336-22c358c61a6mr33034405ad.3.1744815578317; Wed, 16 Apr 2025 07:59:38 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Coiby Xu , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 2/4] tests/qtest: Fix virtio msix message endianness Date: Thu, 17 Apr 2025 00:59:16 +1000 Message-ID: <20250416145918.415674-3-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250416145918.415674-1-npiggin@gmail.com> References: <20250416145918.415674-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=npiggin@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744815645916019100 msix messages are written to memory in little-endian order, so they should not be byteswapped depending on target endianness, but read as le and converted to host endian by the qtest. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- tests/qtest/libqos/virtio-pci-modern.c | 4 +++- tests/qtest/libqos/virtio-pci.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/vi= rtio-pci-modern.c index f31b3be656d..5dae41e6d74 100644 --- a/tests/qtest/libqos/virtio-pci-modern.c +++ b/tests/qtest/libqos/virtio-pci-modern.c @@ -8,6 +8,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/bswap.h" #include "standard-headers/linux/pci_regs.h" #include "standard-headers/linux/virtio_pci.h" #include "standard-headers/linux/virtio_config.h" @@ -136,7 +137,8 @@ static bool get_msix_status(QVirtioPCIDevice *dev, uint= 32_t msix_entry, return qpci_msix_pending(dev->pdev, msix_entry); } =20 - data =3D qtest_readl(dev->pdev->bus->qts, msix_addr); + qtest_memread(dev->pdev->bus->qts, msix_addr, &data, 4); + data =3D le32_to_cpu(data); if (data =3D=3D 0) { return false; } diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pc= i.c index 102e45b5248..76ea1f45ba9 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -131,7 +131,8 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDev= ice *d, QVirtQueue *vq) /* No ISR checking should be done if masked, but read anyway */ return qpci_msix_pending(dev->pdev, vqpci->msix_entry); } else { - data =3D qtest_readl(dev->pdev->bus->qts, vqpci->msix_addr); + qtest_memread(dev->pdev->bus->qts, vqpci->msix_addr, &data, 4); + data =3D le32_to_cpu(data); if (data =3D=3D 0) { return false; } @@ -156,7 +157,8 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDe= vice *d) /* No ISR checking should be done if masked, but read anyway */ return qpci_msix_pending(dev->pdev, dev->config_msix_entry); } else { - data =3D qtest_readl(dev->pdev->bus->qts, dev->config_msix_add= r); + qtest_memread(dev->pdev->bus->qts, dev->config_msix_addr, &dat= a, 4); + data =3D le32_to_cpu(data); if (data =3D=3D 0) { return false; } --=20 2.47.1 From nobody Thu Dec 18 19:29:42 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744815689; cv=none; d=zohomail.com; s=zohoarc; b=chp55UzJUXXrL59dqGOd6L0fExVDSksCOdGrubuhSyygdsyB5oLU+xjAnJ8CCB1vTMSCXIcEX6inulRSmOCHnR5L3UfB1KHK5b+pN8gA7iN3WAsEmjDTwfrgr915rmvOm6KmOPcC/yrd1g6e8Bla/Oy2uZk49eoM2Osnkdemm8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744815689; 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=CLsKC1VDfykrLR/xlFXBSJARqTmqeD4ZLZllGCOlULE=; b=i/WaAmqXPbHiGaHmKKmI7FJvfcC6l8AUut5mAeqG6kPkFavDaaMQN43T4xjYtbuynr2NltG0iyL9yuapG7DSI7wXo+CTgVGNGTXPdSa3A0iBIxeSVGNB5d3+R667jCevWmCctKdCvX22CNRCE9I1vu+cD0y8fqQlsU28edCGFOQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744815688932356.8236859065122; Wed, 16 Apr 2025 08:01:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u54Fr-00073u-Lr; Wed, 16 Apr 2025 11:00:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u54F0-0006fZ-9X; Wed, 16 Apr 2025 10:59:56 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u54Eu-00037v-1s; Wed, 16 Apr 2025 10:59:53 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-227c7e57da2so62898795ad.0; Wed, 16 Apr 2025 07:59:45 -0700 (PDT) Received: from wheely.local0.net ([1.145.55.85]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bd230e355sm10814506b3a.139.2025.04.16.07.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Apr 2025 07:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744815584; x=1745420384; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CLsKC1VDfykrLR/xlFXBSJARqTmqeD4ZLZllGCOlULE=; b=Yt3br3lgOKkWbbJVY/fkIxop+3leGiPue1UFm66V+2bPsxJ9J8CEb0YyVlqy1Du3Qt Q9Jw/sCx4U+JstWJmngUVeGqYuUlp7pIlnQ2tpb28b/F7F6gtMaf8iiK+hr2V7ZHbK8Q 0iayiYnR/toIBhaodZH+Vy2o9s7WbBMPy4EDB+2AFyYrEONIRTDvCnEp8+dG0DXfVCY0 a5U5spHHMzfjaPNACP1rVJ12USZwNZUGy5ZjVQ8K9UbQUX260U1RJQOY63TjhkDjSZTU BNqYeImiiZMfF7Z7X1oTn9SJWsXNkhhb4Q2VHODbZwR4YOlOk+toTkqzmXvqv/ZT7T1L Ctxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744815584; x=1745420384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CLsKC1VDfykrLR/xlFXBSJARqTmqeD4ZLZllGCOlULE=; b=HRuCqm3lYWmDKdhwcVBoBKkkLB1c1TogcthrDWieE/HJRU2DMF0hLPwligC/YIqRsD vy2l1/EJhCs1vpt3naSg84IzHyiXX6AB1Z0NfO2Vv8tVmNBYlYNzWJVu7slSf5CKSVtz ZIADbmI+q/tiAc/cdwkG+OnjU2Ghm2J7JGk1WhLsNVgnS1KzWBO5uFWW4VV7FifqQ4Bw hY6oFVC4vb3i5/eqP4UewuB4gHerqb/CsG0kQDy8rh6Av1xMMy8Y0+ByNvBN0puQUcQO creyshdSWX/1RSzyUrgHCJFf2tUkO4YDtpM4SRFI2e86EfqvQjGQuIu60ZCs9frTO3rF BjzQ== X-Forwarded-Encrypted: i=1; AJvYcCU//nexpJin/N63XFvGTHY5yHcWZ74G5gufers4hhsff8x4F5NBKvCYrgBBjbhjm8uB11I7lB7kNZw6dQ==@nongnu.org, AJvYcCUZ7O+nGlr/h/PHnuWyQFQfZWoci/Wa4VXNe3+T3BSSnOY9qQaVGMNOkzFWBX+BOTQCWtx/HkDJ8cOk@nongnu.org X-Gm-Message-State: AOJu0Yz9yI2TFy9dvFaTDpPBqjlr5lSz6murUvgfh0fKvAuNCvjDrp91 W7b37bJC2cfZFifWSkE8WkaW0kxcBs7r4Oy41c3TnpYvpfL7xik85NnmOQ== X-Gm-Gg: ASbGnctdTk+4JOJCKkkk7dcap925Ri2xJJyqxxyjla2DnzzZtZGJDG7elAK4xQ6/LnE 99EtXOvZDFqppBWfRWIdlR6mEDwKZY4aYznt+tqzikWxNQMPPJPfQ4yQArlk+RQYQUvygyhaX06 vvUqkmuSkt0JVRxOrfnHHH41U9CpnOAn7AOleePY2l0V5LNAiBS+NM3fi4MfWpeNiQGX3jFwBM/ WQHR0ciMGkEuMAvELtat9UyN7OfAS0+6oJkr9ErfOhKvBCE5hEHnD51YaWWU3PYFu+DsUF5IrG+ JqYqrri+VB7oJ669KiWlKXYdZJr5XZGOACmybkZMfg== X-Google-Smtp-Source: AGHT+IGFCNlbnGG1JRN13oUQ2YYJ6G92Z3kiQN//FM0ebPbhMkx/ebLRu4tgJy0LQJ0X77eufL/ytQ== X-Received: by 2002:a17:902:d508:b0:225:ac99:ae0d with SMTP id d9443c01a7336-22c358c6242mr41921485ad.10.1744815583493; Wed, 16 Apr 2025 07:59:43 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Coiby Xu , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 3/4] tests/qtest: Add libqos function for testing msix interrupt status Date: Thu, 17 Apr 2025 00:59:17 +1000 Message-ID: <20250416145918.415674-4-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250416145918.415674-1-npiggin@gmail.com> References: <20250416145918.415674-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=npiggin@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744815691910019100 Content-Type: text/plain; charset="utf-8" This function is duplicated 3 times, with more potential future users. Factor it into libqos, using qtest_memset instead of qtest_writel to clear the message just because that looks nicer with the qtest_memread used to read it. Signed-off-by: Nicholas Piggin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qtest/libqos/pci.h | 2 ++ tests/qtest/libqos/pci.c | 48 ++++++++++++++++++++++++++ tests/qtest/libqos/virtio-pci-modern.c | 31 +++-------------- tests/qtest/libqos/virtio-pci.c | 40 ++++----------------- 4 files changed, 62 insertions(+), 59 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 83896145235..9f8f154c301 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -92,6 +92,8 @@ void qpci_msix_enable(QPCIDevice *dev); void qpci_msix_disable(QPCIDevice *dev); bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry); bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry); +bool qpci_msix_test_interrupt(QPCIDevice *dev, uint32_t msix_entry, + uint64_t msix_addr, uint32_t msix_data); uint16_t qpci_msix_table_size(QPCIDevice *dev); =20 uint8_t qpci_config_readb(QPCIDevice *dev, uint8_t offset); diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index a59197b9922..773fd1fb6cf 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -351,6 +351,54 @@ bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry) } } =20 +/** + * qpci_msix_test_interrupt - test whether msix interrupt has been raised + * @dev: PCI device + * @msix_entry: msix entry to test + * @msix_addr: address of msix message + * @msix_data: expected msix message payload + * + * This tests whether the msix source has raised an interrupt. If the msix + * entry is masked, it tests the pending bit array for a pending message + * and @msix_addr and @msix_data need not be supplied. If the entry is not + * masked, it tests the address for corresponding data to see if the inter= rupt + * fired. + * + * Note that this does not lower the interrupt, however it does clear the + * msix message address to 0 if it is found set. This must be called with + * the msix address memory containing either 0 or the value of data, other= wise + * it will assert on incorrect message. + */ +bool qpci_msix_test_interrupt(QPCIDevice *dev, uint32_t msix_entry, + uint64_t msix_addr, uint32_t msix_data) +{ + uint32_t data; + + g_assert(dev->msix_enabled); + g_assert_cmpint(msix_entry, !=3D, -1); + + if (qpci_msix_masked(dev, msix_entry)) { + /* No ISR checking should be done if masked, but read anyway */ + return qpci_msix_pending(dev, msix_entry); + } + + g_assert_cmpint(msix_addr, !=3D, 0); + g_assert_cmpint(msix_data, !=3D, 0); + + /* msix payload is written in little-endian format */ + qtest_memread(dev->bus->qts, msix_addr, &data, 4); + data =3D le32_to_cpu(data); + if (data =3D=3D 0) { + return false; + } + + /* got a message, ensure it matches expected value then clear it. */ + g_assert_cmphex(data, =3D=3D, msix_data); + qtest_memset(dev->bus->qts, msix_addr, 0, 4); + + return true; +} + uint16_t qpci_msix_table_size(QPCIDevice *dev) { uint8_t addr; diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/vi= rtio-pci-modern.c index 5dae41e6d74..0d7d89bbcb1 100644 --- a/tests/qtest/libqos/virtio-pci-modern.c +++ b/tests/qtest/libqos/virtio-pci-modern.c @@ -126,28 +126,6 @@ static void set_status(QVirtioDevice *d, uint8_t statu= s) status); } =20 -static bool get_msix_status(QVirtioPCIDevice *dev, uint32_t msix_entry, - uint32_t msix_addr, uint32_t msix_data) -{ - uint32_t data; - - g_assert_cmpint(msix_entry, !=3D, -1); - if (qpci_msix_masked(dev->pdev, msix_entry)) { - /* No ISR checking should be done if masked, but read anyway */ - return qpci_msix_pending(dev->pdev, msix_entry); - } - - qtest_memread(dev->pdev->bus->qts, msix_addr, &data, 4); - data =3D le32_to_cpu(data); - if (data =3D=3D 0) { - return false; - } - /* got a message, ensure it matches expected value then clear it. */ - g_assert_cmphex(data, =3D=3D, msix_data); - qtest_writel(dev->pdev->bus->qts, msix_addr, 0); - return true; -} - static bool get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq) { QVirtioPCIDevice *dev =3D container_of(d, QVirtioPCIDevice, vdev); @@ -155,8 +133,8 @@ static bool get_queue_isr_status(QVirtioDevice *d, QVir= tQueue *vq) if (dev->pdev->msix_enabled) { QVirtQueuePCI *vqpci =3D container_of(vq, QVirtQueuePCI, vq); =20 - return get_msix_status(dev, vqpci->msix_entry, vqpci->msix_addr, - vqpci->msix_data); + return qpci_msix_test_interrupt(dev->pdev, vqpci->msix_entry, + vqpci->msix_addr, vqpci->msix_data= ); } =20 return qpci_io_readb(dev->pdev, dev->bar, dev->isr_cfg_offset) & 1; @@ -167,8 +145,9 @@ static bool get_config_isr_status(QVirtioDevice *d) QVirtioPCIDevice *dev =3D container_of(d, QVirtioPCIDevice, vdev); =20 if (dev->pdev->msix_enabled) { - return get_msix_status(dev, dev->config_msix_entry, - dev->config_msix_addr, dev->config_msix_dat= a); + return qpci_msix_test_interrupt(dev->pdev, dev->config_msix_entry, + dev->config_msix_addr, + dev->config_msix_data); } =20 return qpci_io_readb(dev->pdev, dev->bar, dev->isr_cfg_offset) & 2; diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pc= i.c index 76ea1f45ba9..ea8114e2438 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -122,25 +122,12 @@ static void qvirtio_pci_set_status(QVirtioDevice *d, = uint8_t status) static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue = *vq) { QVirtioPCIDevice *dev =3D container_of(d, QVirtioPCIDevice, vdev); - QVirtQueuePCI *vqpci =3D (QVirtQueuePCI *)vq; - uint32_t data; =20 if (dev->pdev->msix_enabled) { - g_assert_cmpint(vqpci->msix_entry, !=3D, -1); - if (qpci_msix_masked(dev->pdev, vqpci->msix_entry)) { - /* No ISR checking should be done if masked, but read anyway */ - return qpci_msix_pending(dev->pdev, vqpci->msix_entry); - } else { - qtest_memread(dev->pdev->bus->qts, vqpci->msix_addr, &data, 4); - data =3D le32_to_cpu(data); - if (data =3D=3D 0) { - return false; - } - /* got a message, ensure it matches expected value then clear = it. */ - g_assert_cmphex(data, =3D=3D, vqpci->msix_data); - qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0); - return true; - } + QVirtQueuePCI *vqpci =3D (QVirtQueuePCI *)vq; + + return qpci_msix_test_interrupt(dev->pdev, vqpci->msix_entry, + vqpci->msix_addr, vqpci->msix_data= ); } else { return qpci_io_readb(dev->pdev, dev->bar, VIRTIO_PCI_ISR) & 1; } @@ -149,24 +136,11 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioD= evice *d, QVirtQueue *vq) static bool qvirtio_pci_get_config_isr_status(QVirtioDevice *d) { QVirtioPCIDevice *dev =3D container_of(d, QVirtioPCIDevice, vdev); - uint32_t data; =20 if (dev->pdev->msix_enabled) { - g_assert_cmpint(dev->config_msix_entry, !=3D, -1); - if (qpci_msix_masked(dev->pdev, dev->config_msix_entry)) { - /* No ISR checking should be done if masked, but read anyway */ - return qpci_msix_pending(dev->pdev, dev->config_msix_entry); - } else { - qtest_memread(dev->pdev->bus->qts, dev->config_msix_addr, &dat= a, 4); - data =3D le32_to_cpu(data); - if (data =3D=3D 0) { - return false; - } - /* got a message, ensure it matches expected value then clear = it. */ - g_assert_cmphex(data, =3D=3D, dev->config_msix_data); - qtest_writel(dev->pdev->bus->qts, dev->config_msix_addr, 0); - return true; - } + return qpci_msix_test_interrupt(dev->pdev, dev->config_msix_entry, + dev->config_msix_addr, + dev->config_msix_data); } else { return qpci_io_readb(dev->pdev, dev->bar, VIRTIO_PCI_ISR) & 2; } --=20 2.47.1 From nobody Thu Dec 18 19:29:42 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744815716; cv=none; d=zohomail.com; s=zohoarc; b=OqopdarKBPeAQsGQxQ+It+ctH2mKFwLDddixIebNgVrtSJLt6puuvsSrfW/m6yyYXrwAOv/hxacyF33Xgh2URiD0ikpO9F7SWzG9rzqbv8FBM8VR2jwhoX83j2Fl3NgR9/DC+Uf1lKVuFZ5Xx4KQgOltFJAZO9CQqOcOtvXlFQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744815716; 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=JL3huZLXxTALjzanwjU/xxJHfPMSswJPDxEWj9Jb8pw=; b=k6kwMTe2ruxO7Cfk7JA4w3kqmha+BE/9EveyIvh2aKCuaABG0ewXdcm7+MsocqzZI+dki4CnZ5miExIqCNQ0oVYYKxI+tATzfdlzQxySciLGw5srEwWVMgw/Q7H8c6n9Y6LVoLhQAuO1Fy4cbLojmStCHg/boA5JSwuhevFBGf0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1744815716093172.6874188768951; Wed, 16 Apr 2025 08:01:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u54Fu-0007Fn-Ex; Wed, 16 Apr 2025 11:00:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u54F2-0006gE-AZ; Wed, 16 Apr 2025 10:59:59 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u54Ey-00039o-02; Wed, 16 Apr 2025 10:59:54 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-736c277331eso897775b3a.1; Wed, 16 Apr 2025 07:59:50 -0700 (PDT) Received: from wheely.local0.net ([1.145.55.85]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73bd230e355sm10814506b3a.139.2025.04.16.07.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Apr 2025 07:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744815589; x=1745420389; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JL3huZLXxTALjzanwjU/xxJHfPMSswJPDxEWj9Jb8pw=; b=EklONd6xgWVqbYM7y/D+w+i9B4O7/ZNPxiE29YyctHEJcYj92QrN5ZQHEtC9HuOdN2 Qs2I4zGz3saOrQ17IK07ztMHxvF0A1RX6rQNM5VO4K34se4sZZ7S6voyiCcSG1VQcYWz +0DIGeHRzwzhiEtapwF9lPlxi3MePj/2bmGsJ20v9dzjY2gzrHudL0RTjxvJwGmV9VUD u/p9DIVqfNj+8oZZAHdLnJOUPGmQkojZBjICwynUXYaiM9A8IOikQ2iJSR4x5mrZnJJ2 V5wq1PXkM4xsS4aIVr48i/4TTPG2GZlvTZfYcUlip6WBxIsHsLxsgMImyKBxkAki7XM3 tThg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744815589; x=1745420389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JL3huZLXxTALjzanwjU/xxJHfPMSswJPDxEWj9Jb8pw=; b=QGEvZa2s88QEV5HhxN/gfT57SiTFbq3p06h6fQ01nnMW1+i7ZlqpHcxHhwsLHPlsNg ktIXRGgCYEFXs2dh1f/mV/hboz84l/Hfj/QbQOWHLI96jbp2k5QQpcehry2GP/h9LITP dNXP4A3vxlfjCa+c5TeEWl8An4pQWrLgT8whncxD/JiLvGAFXyDYah9ACQyj3TewXq8M hGT+j9W1Y2j5haVt2u8CHbMI/ilC0Lzm/794r1+SqCQosNpsTJvGyC8ppk5JFq0E0HoQ xYZpPRxPdYQ6LO2BBYd0s2upX80/cAhCP67dKxDX+r6GKMGimeyJgoi6RfZ+D+m13ZD5 2Jfg== X-Forwarded-Encrypted: i=1; AJvYcCVfDDD/3J52V+BT2PgTX4r35FfKT1+N+E7xXbNqHZKjXlyCsMkuA0TCDHwvg+Hrg7PxpuT0BnKFcdNx@nongnu.org, AJvYcCXRBtOTHmahBZAlyoNrw/ad5LvLliZY64Jj0TC7ttRqRA9trQVFyKA9ThVBp0x00SJqicL5EAu6XMAjzQ==@nongnu.org X-Gm-Message-State: AOJu0YydS77Wak3e+ATaSoS5aMZmuH1XGwxRsJcjUVOXdgWkeXYCu5AX 8BayM7dxl78hZE7/Q29eeDHWWD8LQNgTb6A+xRffNxxNL0nBJUkNSgOOrQ== X-Gm-Gg: ASbGnctzH6xV8eZ4VsunVCJA9PNMy00euHI90SSuL3jdwVI+P2pzEr5tO4H+Izz15fX V3syVghzEMKXcrrfT+C+koSNMXoQmHql31W3WyoKMJ74xhG7PlTfG+ohDKgLuZ9r0UBvcW+KSQj x1/exm1qgBfPqAvKiAno/uf7HWURmXt2k+pVWHD7+nUywF+9acPGeIFZaFLgeIocftRsmBzD7pc iWWZHCgYFGzKF63lbEZ6uOOntQVbz/iZbE90M7zPEa3d/vk8lF6111k7k3QLrUxc9ijiLTXn6DH dVUp5qjeq1qwarg3MQOPzHDPIFxNPaZU1mQr94Hn9Otc3Jjf6VnG X-Google-Smtp-Source: AGHT+IGEE++RC7qEhGL8O0gwOdXz4/rfg5nmivuNx12pjqJsUKEVGB9bqG8aXgX/FoBWgbTDD6/fNw== X-Received: by 2002:a05:6a00:3a96:b0:736:aea8:c9b7 with SMTP id d2e1a72fcca58-73c26d17aa0mr3101368b3a.2.1744815589266; Wed, 16 Apr 2025 07:59:49 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Coiby Xu , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 4/4] tests/qtest: Enable spapr dma with linear iommu map Date: Thu, 17 Apr 2025 00:59:18 +1000 Message-ID: <20250416145918.415674-5-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250416145918.415674-1-npiggin@gmail.com> References: <20250416145918.415674-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=npiggin@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744815717969019100 Content-Type: text/plain; charset="utf-8" qtests spapr dma was broken because the iommu was not set up. spapr requires hypercalls to set up the iommu (TCE tables), but there is no support for that or a side-channel to the iommu in qtests at the moment, so add a quick workaround in QEMU to have the spapr iommu provide a linear map to memory when running qtests. The buggy msix checks can all be removed since the tests all work now. Signed-off-by: Nicholas Piggin --- tests/qtest/libqos/pci.h | 4 ---- hw/ppc/spapr_iommu.c | 9 ++++++++- tests/qtest/e1000e-test.c | 21 --------------------- tests/qtest/igb-test.c | 21 --------------------- tests/qtest/libqos/generic-pcihost.c | 1 - tests/qtest/libqos/pci-pc.c | 3 --- tests/qtest/libqos/pci-spapr.c | 7 ++++--- tests/qtest/libqos/pci.c | 14 -------------- tests/qtest/vhost-user-blk-test.c | 6 ------ tests/qtest/virtio-blk-test.c | 12 ------------ 10 files changed, 12 insertions(+), 86 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 9f8f154c301..ef40a6917d3 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -51,7 +51,6 @@ struct QPCIBus { QTestState *qts; uint64_t pio_alloc_ptr, pio_limit; uint64_t mmio_alloc_ptr, mmio_limit; - bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */ bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */ =20 }; @@ -83,9 +82,6 @@ QPCIDevice *qpci_device_find(QPCIBus *bus, int devfn); void qpci_device_init(QPCIDevice *dev, QPCIBus *bus, QPCIAddress *addr); int qpci_secondary_buses_init(QPCIBus *bus); =20 -bool qpci_has_buggy_msi(QPCIDevice *dev); -bool qpci_check_buggy_msi(QPCIDevice *dev); - void qpci_device_enable(QPCIDevice *dev); uint8_t qpci_find_capability(QPCIDevice *dev, uint8_t id, uint8_t start_ad= dr); void qpci_msix_enable(QPCIDevice *dev); diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index db3a14c1dfd..77895c597df 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -22,6 +22,7 @@ #include "qemu/log.h" #include "qemu/module.h" #include "system/kvm.h" +#include "system/qtest.h" #include "kvm_ppc.h" #include "migration/vmstate.h" #include "system/dma.h" @@ -125,7 +126,13 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(IOMMUMe= moryRegion *iommu, .perm =3D IOMMU_NONE, }; =20 - if ((addr >> tcet->page_shift) < tcet->nb_table) { + if (qtest_enabled()) { + /* spapr qtests does not set up the IOMMU, shortcut a linear map */ + ret.iova =3D addr & TARGET_PAGE_MASK; + ret.translated_addr =3D addr & TARGET_PAGE_MASK; + ret.addr_mask =3D ~TARGET_PAGE_MASK; + ret.perm =3D IOMMU_RW; + } else if ((addr >> tcet->page_shift) < tcet->nb_table) { /* Check if we are in bound */ hwaddr page_mask =3D IOMMU_PAGE_MASK(tcet->page_shift); =20 diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c index de9738fdb74..8300bf5a5b3 100644 --- a/tests/qtest/e1000e-test.c +++ b/tests/qtest/e1000e-test.c @@ -139,13 +139,6 @@ static void test_e1000e_tx(void *obj, void *data, QGue= stAllocator * alloc) { QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 e1000e_send_verify(d, data, alloc); } @@ -154,13 +147,6 @@ static void test_e1000e_rx(void *obj, void *data, QGue= stAllocator * alloc) { QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 e1000e_receive_verify(d, data, alloc); } @@ -173,13 +159,6 @@ static void test_e1000e_multiple_transfers(void *obj, = void *data, =20 QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 for (i =3D 0; i < iterations; i++) { e1000e_send_verify(d, data, alloc); diff --git a/tests/qtest/igb-test.c b/tests/qtest/igb-test.c index 3d397ea6973..1b3b5aa6c76 100644 --- a/tests/qtest/igb-test.c +++ b/tests/qtest/igb-test.c @@ -142,13 +142,6 @@ static void test_igb_tx(void *obj, void *data, QGuestA= llocator * alloc) { QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 igb_send_verify(d, data, alloc); } @@ -157,13 +150,6 @@ static void test_igb_rx(void *obj, void *data, QGuestA= llocator * alloc) { QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 igb_receive_verify(d, data, alloc); } @@ -176,13 +162,6 @@ static void test_igb_multiple_transfers(void *obj, voi= d *data, =20 QE1000E_PCI *e1000e =3D obj; QE1000E *d =3D &e1000e->e1000e; - QOSGraphObject *e_object =3D obj; - QPCIDevice *dev =3D e_object->get_driver(e_object, "pci-device"); - - /* FIXME: add spapr support */ - if (qpci_check_buggy_msi(dev)) { - return; - } =20 for (i =3D 0; i < iterations; i++) { igb_send_verify(d, data, alloc); diff --git a/tests/qtest/libqos/generic-pcihost.c b/tests/qtest/libqos/gene= ric-pcihost.c index 4bbeb5ff508..568897e0ecc 100644 --- a/tests/qtest/libqos/generic-pcihost.c +++ b/tests/qtest/libqos/generic-pcihost.c @@ -182,7 +182,6 @@ void qpci_init_generic(QGenericPCIBus *qpci, QTestState= *qts, =20 qpci->gpex_pio_base =3D 0x3eff0000; qpci->bus.not_hotpluggable =3D !hotpluggable; - qpci->bus.has_buggy_msi =3D false; =20 qpci->bus.pio_readb =3D qpci_generic_pio_readb; qpci->bus.pio_readw =3D qpci_generic_pio_readw; diff --git a/tests/qtest/libqos/pci-pc.c b/tests/qtest/libqos/pci-pc.c index 147009f4f44..8b79d858bd5 100644 --- a/tests/qtest/libqos/pci-pc.c +++ b/tests/qtest/libqos/pci-pc.c @@ -124,9 +124,6 @@ void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGu= estAllocator *alloc) { assert(qts); =20 - /* tests can use pci-bus */ - qpci->bus.has_buggy_msi =3D false; - qpci->bus.pio_readb =3D qpci_pc_pio_readb; qpci->bus.pio_readw =3D qpci_pc_pio_readw; qpci->bus.pio_readl =3D qpci_pc_pio_readl; diff --git a/tests/qtest/libqos/pci-spapr.c b/tests/qtest/libqos/pci-spapr.c index 0f1023e4a73..dfa2087a599 100644 --- a/tests/qtest/libqos/pci-spapr.c +++ b/tests/qtest/libqos/pci-spapr.c @@ -20,6 +20,10 @@ * PCI devices are always little-endian * SPAPR by default is big-endian * so PCI accessors need to swap data endianness + * + * The spapr iommu model has a qtest_enabled() check that short-cuts + * the TCE table and provides a linear map for DMA, since qtests does + * not have a way to make hcalls to set up the TCE table. */ =20 static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr) @@ -155,9 +159,6 @@ void qpci_init_spapr(QPCIBusSPAPR *qpci, QTestState *qt= s, { assert(qts); =20 - /* tests cannot use spapr, needs to be fixed first */ - qpci->bus.has_buggy_msi =3D true; - qpci->alloc =3D alloc; =20 qpci->bus.pio_readb =3D qpci_spapr_pio_readb; diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index 773fd1fb6cf..2bae119bfca 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -53,20 +53,6 @@ void qpci_device_foreach(QPCIBus *bus, int vendor_id, in= t device_id, } } =20 -bool qpci_has_buggy_msi(QPCIDevice *dev) -{ - return dev->bus->has_buggy_msi; -} - -bool qpci_check_buggy_msi(QPCIDevice *dev) -{ - if (qpci_has_buggy_msi(dev)) { - g_test_skip("Skipping due to incomplete support for MSI"); - return true; - } - return false; -} - static void qpci_device_set(QPCIDevice *dev, QPCIBus *bus, int devfn) { g_assert(dev); diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index ea90d41232e..3e71fdb9d78 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -554,14 +554,8 @@ static void idx(void *obj, void *u_data, QGuestAllocat= or *t_alloc) uint32_t desc_idx; uint8_t status; char *data; - QOSGraphObject *blk_object =3D obj; - QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); QTestState *qts =3D global_qtest; =20 - if (qpci_check_buggy_msi(pci_dev)) { - return; - } - qpci_msix_enable(pdev->pdev); qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); =20 diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c index 98c906ebb4a..3a005d600c1 100644 --- a/tests/qtest/virtio-blk-test.c +++ b/tests/qtest/virtio-blk-test.c @@ -474,14 +474,8 @@ static void msix(void *obj, void *u_data, QGuestAlloca= tor *t_alloc) uint32_t free_head; uint8_t status; char *data; - QOSGraphObject *blk_object =3D obj; - QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); QTestState *qts =3D global_qtest; =20 - if (qpci_check_buggy_msi(pci_dev)) { - return; - } - qpci_msix_enable(pdev->pdev); qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); =20 @@ -584,14 +578,8 @@ static void idx(void *obj, void *u_data, QGuestAllocat= or *t_alloc) uint32_t desc_idx; uint8_t status; char *data; - QOSGraphObject *blk_object =3D obj; - QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); QTestState *qts =3D global_qtest; =20 - if (qpci_check_buggy_msi(pci_dev)) { - return; - } - qpci_msix_enable(pdev->pdev); qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); =20 --=20 2.47.1