From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706657; cv=none; d=zohomail.com; s=zohoarc; b=bE9FJvk2oyoC5iiXcxtzahDcAwWSeSz5iO2KteOIkFoBjFeu4dE214pwovWKCCGYHpvkIaY0jDKScYZlD+Yml7dRg4CgL4DCeq+NhWwSR7X/KZy0xqAMVReSKRsgALKQabh8iAEyxpBluieFzcopcQgfDrxeb+UwCMeQ4ksJRok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706657; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZYM0E0G75slhjVgSpznVNuQ0X1v2jo6RpWzfk497PSY=; b=G8jvIWz5GVbPQ/eQmZw0LUnoYMGcgndFtulka5hMbFfg3HJTAELplxQlICb7uJiVHhdnUqnEnIK0TnCKN+YFUx8qSHeE6ZR9GXz6jZYQjP8wLnNTKS+sssIhhRjPsnmVftG8woRjvrDogz00NR7uGB4i9eciAbt13JQP9WJwWEY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706657577948.1680961083915; Tue, 3 Nov 2026 03:50:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2B-0003aV-Ju; Tue, 03 Nov 2026 06:50:35 -0500 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 1xOD27-0003ZX-PN for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD26-0000JV-60 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:31 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-tdoCChSpP2-HlJuJo9qZRw-1; Tue, 03 Nov 2026 06:50:28 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48c7fe9736eso3514325f8f.0 for ; Tue, 03 Nov 2026 03:50:27 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e7a1d9d71sm19181738f8f.48.2026.11.03.03.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZYM0E0G75slhjVgSpznVNuQ0X1v2jo6RpWzfk497PSY=; b=gz05GrbKLAlp6ODCRTF9LHkXH/kJbKoSm5bfEy1GQllsFbPmezQxO8ZaPsYS7BXD7IhNUd KmnFXP1weYwE5dsaEqxVRvWUkNV6MxadjqtCBt4IEjLuHL3EI82ctEMDXE0Oe0JHbUjtOF yxm8ISOYI4BKjENlfX077pCsn1YZ5UQ= X-MC-Unique: tdoCChSpP2-HlJuJo9qZRw-1 X-Mimecast-MFC-AGG-ID: tdoCChSpP2-HlJuJo9qZRw_1793706627 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706627; x=1794311427; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZYM0E0G75slhjVgSpznVNuQ0X1v2jo6RpWzfk497PSY=; b=Jl3VY6dcoKEMJHcmXMqCy00Op/+on8vAsuY9UkjmDbjyvghxIWj17M5kE9AVrgXNrq uqKBC9UCieRTStfLASZ+ORUxiptec6N2PAwhZOrwaPS3OL0NkgEsyWVj97IXE29YhelD tsJD0VCjd3ytnhewhCISmEcOZwe9C3sKVB4m/CNN9eFV8RIFcI9NrcB8l+lazuKkgIgl mQV+U49Cy2QcEKQ4NHBu7EmxdvwJnGgtrnJXyNH7XDkcM6E9hQ5reYcV/c0oPyqkJLwW KzU8T6NpaxLbWZwxn7/Zp/S4VpoLbPC5/3utRV7O1CRBY/+cCpRV9FqTIN/XRYJQndRo L76A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706627; x=1794311427; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ZYM0E0G75slhjVgSpznVNuQ0X1v2jo6RpWzfk497PSY=; b=cQmgx72HPiALyx5O310KVMBrF/F4AH6hynVQtW+tfhOY7vl0FS5kuhWicX8g49GXdy RIqBQCQCpX5+yDSB4KSYgUgE20Eot6McEsQ4PTIq+Q77OJYloARqlbd5yH01kR4lXK6q xx7MHGzE3AlovDai2dFO9I6WexrswOznSL6aozKzA8RXc9lPw9weHyV3AvazPqT50PgQ xKmaOb+k2IbQqDPKxG3Si3cpqeHyVASg/oYHQbK5DNXlGLr4YKpJ1GW1WRwF9eB5KPxc VtJgBePyLpazkqfpS2RGMx1sPCqu5vbMiloinlPTsd0G48AyoH57uxtlk28x5bpSx7d2 Jlfg== X-Gm-Message-State: APuU4Z+O1aIfvoI8nwEsjplQRwQOch5gLQi8MsGptabSGMYf+XoW1XJv uzfrYwKOE7J9o7rBUWhDQAIr/FK0eCJ7leizqH00B3QcdARyhJnzvukpPX9WAO5ukr+zH7r0QZ9 vSLTCUNVVXKESgKLActUHlPEF3hdmyoJNiirgxKfMkAJr7MD1ZkolMrigGAiiD67DAg3UzgXugD cHuaz9ZJHSfO7J3vuO0NXGfu1Pd9jp67tcog== X-Gm-Gg: AYBFou1aFA9ePHdrBLWQoZoRk5l7Sd4YaWNr7IzDmyjzrMTlGxPBObq+R3vQwghBh82 QN0xJjyPcAfRqw7Ot0sB47zS9nE2cfQomNqwXOVrNAsgg0yETe5whnI7R6Cpm21l0owg946qQQ8 XD6gdjMI8tqAMJfSK/ZcifIIO2hrnSqO1ZN+tU+lS8TZJpTMQhc6/WifX92yA1IcPTlnoJhZBLI JmrIcszgqYpZqGYJjSibusNecXOqvM8L64Xw4K9ezJdjW3PbP/xoLi3E4ONdFx6PVLkaNa1+cc2 6l9boBj3FArvDT49f1hYo3VP7zban/Ydxpf1Io/jM/5D4RD3excBvCcphI0oh59ll83sQohcghT RP5J0LVEqOOWwXytRuLGWbDOmiHKF6YeQF3lkIhdcpw== X-Received: by 2002:a05:6000:41d1:b0:48e:6a23:4a09 with SMTP id ffacd0b85a97d-48e6e50d8cdmr30708966f8f.54.1793706626771; Tue, 03 Nov 2026 03:50:26 -0800 (PST) X-Received: by 2002:a05:6000:41d1:b0:48e:6a23:4a09 with SMTP id ffacd0b85a97d-48e6e50d8cdmr30708916f8f.54.1793706626028; Tue, 03 Nov 2026 03:50:26 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF Subject: [PULL 01/17] pcie_sriov: Rework the assert statements checking region numbers Message-ID: <5bc52da8047b2174232a52abd55b73a8ca7620cd.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706659942158500 From: Cl=C3=A9ment MATHIEU--DRIF pcie_sriov_pf_init_vf_bar: PCI_ROM_SLOT is already out of the SR-IOV regions. pcie_sriov_pf_init_from_user_created_vfs: ROM region must never have a non-zero size. Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20261028144539.691098-1-clement.mathieu--drif@bull.com> --- hw/pci/pcie_sriov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 6a748c3626..e6891436d3 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -230,7 +230,6 @@ void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int regi= on_num, assert(sriov_cap > 0); assert(region_num >=3D 0); assert(region_num < PCI_SRIOV_NUM_BARS); - assert(region_num !=3D PCI_ROM_SLOT); =20 wmask =3D ~(size - 1); addr =3D sriov_cap + PCI_SRIOV_BAR + region_num * 4; @@ -344,6 +343,8 @@ int16_t pcie_sriov_pf_init_from_user_created_vfs(PCIDev= ice *dev, dev->exp.sriov_pf.vf =3D vfs; dev->exp.sriov_pf.vf_user_created =3D true; =20 + assert(vfs[0]->io_regions[PCI_ROM_SLOT].size =3D=3D 0); + for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) { PCIIORegion *region =3D &vfs[0]->io_regions[i]; =20 --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706664; cv=none; d=zohomail.com; s=zohoarc; b=ZB2Ww4ThL5PQ8y5hKSXova7bBVjPsjs1cB8AOIUaRAxecFEeJ0x2e+DBklmytoTORJgZYTSwGzKsXaIj7P8M96xhpcAoANgdQF56+gztSxI5DOfk+5ukzwWxuEsdehO6oJz4iK8YILlXN6zCmyWGBkVYdupJQGmREinOFyIV6yA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706664; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZJfs1agcLVWNKY9WfuxjZM5yPYkv4w0s3t6dLQQ+mPM=; b=WXdIn/GO3fTnc/pHYVkg41G552trH7ifBAjfdyjgjC3iPUC+2bo5tMmay8YJn5Z+JD+XTAaKQKRCMmZSjmr1Uz9eeE/sm+TzJobr8arlsX2Q1umOl1S5WAsJM+UmmmtmVJMtgpWn8klfeKvXO+LvmyPtA9P8xfa5lGYoCmLy624= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706664908363.7316948600999; Tue, 3 Nov 2026 03:51:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2F-0003bB-1g; Tue, 03 Nov 2026 06:50:39 -0500 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 1xOD2B-0003aL-B1 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD28-0000Ji-At for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:33 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-AfzpXS8MMG-ig6DpwTsdIQ-1; Tue, 03 Nov 2026 06:50:30 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4ae2756fa7aso21580385e9.0 for ; Tue, 03 Nov 2026 03:50:30 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71baa1b3sm23678876f8f.56.2026.11.03.03.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZJfs1agcLVWNKY9WfuxjZM5yPYkv4w0s3t6dLQQ+mPM=; b=WAoRK5obiEqWxwBMSvUvc/QNrmUJAcvFgzmkGmOwh3G53sZU6ZNbrxv2Drl3ChtUgI+wFG ECYDI9xKzGLr9n3nVy+3CnSQ8VFPaEtoQJWe3SeDD/L3bXyj+OLqEyfxSdEY+/+DQiAUdh PBqA1IDUcwZZUPEjGYQ9qqhGTMo6rIA= X-MC-Unique: AfzpXS8MMG-ig6DpwTsdIQ-1 X-Mimecast-MFC-AGG-ID: AfzpXS8MMG-ig6DpwTsdIQ_1793706629 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706629; x=1794311429; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZJfs1agcLVWNKY9WfuxjZM5yPYkv4w0s3t6dLQQ+mPM=; b=Y+zeoFJPfyJjl5NnA18ylX4gOJyhadh4PLsfd0aY0T9BccmY/OIAIENGpaPX7gvAcM T9+kgGf3QkKxLlPVnuoeda6Ymn/RP7YkzZYPk4i/T4MMOwy+lScUf3nElzZZN2pdP0i4 wcRouOmKZ7lYWnFVpcEkwTf0MVocb6cU8Z2c9L13oHfupTD3nkjKR762HBJCn/PY296c madCK8337MM3vkEA9f5ME0S0LF7Wzjo/0miz5wUcKIv1aAhG1poN2UfV98dlFwuorVDP S+ePdVuIloz2x+1+tnDX8JYw50KN5MrDj+R3CTicOfh+bUMN/IC2PgAbytMmaovAOdqG Wtgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706629; x=1794311429; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ZJfs1agcLVWNKY9WfuxjZM5yPYkv4w0s3t6dLQQ+mPM=; b=EW0gXt0U+/OhOXdQlHU+FEIOzhJl93hyidfIAPNUvZki3QGbxFlVYT7ALE7HQVFqhL rVZMRmEvyMY1B8l0PewPlvkLUM/ge3vuzsVcUcoW39YuE5srupn8F9CiIuamRfga4uxM zKM7jSqUFdsZ40iJc7ehz1HDgnnSahQll91VjlYiYuUFOtaajfeIfMr6fYxD6vu+Rrgu 6N4922t3k4ut+IdCkyMZYgx9rqCvFq+lMoomtIWHM/B9QNkHfjntirrIR8IEd6kBS+O3 sFlerscd7XaH5FYPTXOVrGhC4Ggk/Z1Nxf51RG/mnBFt8CS1Hj3ulY+LG3uDSLPJNQ/r NEuQ== X-Gm-Message-State: APuU4Z/4trqA3pFoQYbOeZEcEb7+rjYmaIMtm9zeZgQfH7eSKKC6ThuK K/35aZnJwB4GRsIRPoypgdsq28FIBOmLlNSGjlv50hQKxd4DuZxgCoptEGpxRKeBhDHxE+nq7h6 +RY1ZMcqIw9BCGeCYmMnFYvA8g2bYUlTxNrLNr/i4su0ygTznkdAHXkVFNcLWJDj8Dvo29euCKr IT15S64e6I0o4foXn5GgpBmXAueupB+zu7ig== X-Gm-Gg: AYBFou2yf4L/YrLljWq59Dj9Zb/FkJLO6Rmg53m/ypeHvCyFZZs6D3tsa6IjAmzdHAa wmearO02LeeWsN7e1QTtlumBO2YJTo1hWNpi45YjsknL5aLJ1KuFvljs62jvI6jHnmfUF9RzhgE N0Kn3lSZx7R1SbnIMLiEJ4vPrVDVL/Ys5yVsiiGthT2nLDWBOpQ4lqE14wrEajJz4rDzuIdHoOu Sm/Nec7X4/h10+q8XmfdD7bAl983hvsTAIyC0nlf+0PLc3uAgzjuLOyCVIckTbs5kuF8ip62yOZ Ewp8d5/S0sE4hZu9ZX6svk/L3rhR7axdp8fH0JmnaiTTh+qsbnQVFy95c779TGZ/CURkvlDIx7c 9ZLdJiuYuEPYG3skCaCwq7N96p6uY8J+m6rzITSi41w== X-Received: by 2002:a05:600c:19d1:b0:4a2:677:ad8e with SMTP id 5b1f17b1804b1-4ac1970b9f7mr285799965e9.34.1793706628947; Tue, 03 Nov 2026 03:50:28 -0800 (PST) X-Received: by 2002:a05:600c:19d1:b0:4a2:677:ad8e with SMTP id 5b1f17b1804b1-4ac1970b9f7mr285799485e9.34.1793706628407; Tue, 03 Nov 2026 03:50:28 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF Subject: [PULL 02/17] pcie_sriov: Adapt bar type array size to the number of regions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.7.7.1.5.4/291.452.71 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706666338158500 From: Cl=C3=A9ment MATHIEU--DRIF Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20261028144539.691098-2-clement.mathieu--drif@bull.com> --- include/hw/pci/pcie_sriov.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index b0ea6a62c7..5f81e3b1bb 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -16,7 +16,7 @@ #include "hw/pci/pci.h" =20 typedef struct PCIESriovPF { - uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ + uint8_t vf_bar_type[PCI_SRIOV_NUM_BARS]; /* Store type for each VF b= ar */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ bool vf_user_created; /* If VFs are created by user */ } PCIESriovPF; --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706660; cv=none; d=zohomail.com; s=zohoarc; b=mD3/1VCdlhnPRWuRcXFB2+bhxPNouTD7RKNTcXIdcZTKHmwsqF4pMC1CXuVKo/kf6RPcoaPihXkkSD6dnCAr13s2e35+9deOmkiVJkVzBhxftCrsU6qLwg4c1PrpI28/AqahFQQBQbOQues2TGCLh+15zfXcjFoP/11yh6v0y2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706660; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tZcQd4j24SOkPd+c0T3lL/TJVy1cifbr427VoGmUk7A=; b=nz5kYPlxHDdjB9VUN/eDhqBj3oJvnw872S/OylHWLFrohONZgX8j14BgufkTQ/1T5WvqHV+xOxoS7TcygB6RApl2PV8m4CkitB2rYY9Nfzvei9ZhSRPinzLoejSAecqTFWno+20BtR76MCgNKPBb9S5e3+w0COg8I93u662mEIA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706660322343.00299000567907; Tue, 3 Nov 2026 03:51:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2H-0003bg-C3; Tue, 03 Nov 2026 06:50:41 -0500 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 1xOD2D-0003aw-7q for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2B-0000Jw-B6 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:37 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-3UHSQGR_PYe4WkmEPTzgqA-1; Tue, 03 Nov 2026 06:50:32 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a1fa972b4fso21196165e9.2 for ; Tue, 03 Nov 2026 03:50:32 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2a879f401sm49067545e9.5.2026.11.03.03.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tZcQd4j24SOkPd+c0T3lL/TJVy1cifbr427VoGmUk7A=; b=BJZ2ZfjK0OEgO9cSMSj3l0O+MsNVBjZXLkyTi4ovS1Ep4uD6IsMvkPNO51ZZYo1JijCHxP ZhHoVMCAl6aa4YNqiJ+zOSVRsdUvUAm0XHQ9f93xQdjeUvFnziPuC0hxcyUIgu5W4Lnd48 AbD09g5H5JrSx1siSj/MKINNnK/vE2A= X-MC-Unique: 3UHSQGR_PYe4WkmEPTzgqA-1 X-Mimecast-MFC-AGG-ID: 3UHSQGR_PYe4WkmEPTzgqA_1793706631 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706631; x=1794311431; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=tZcQd4j24SOkPd+c0T3lL/TJVy1cifbr427VoGmUk7A=; b=qu4fleSjVsyG0qbf7yNox2Q/Fy70PHEknnXeWKno5AKhsXFUStjuMuIP3xHmJgev1h KfWV7nF8G9IfXwoupdFJ8Mdy/5vzigJ6ZgrgPtVAV6p0UGFI5p3pOVz8Kb0AbAEtb1yg sL4NZ0QLZGSNyBElkgsIfmx3UvKhTMu3ObNqU9yikA5FcsXmA0PLtRzP0F5+gHp34rPn 3Xap1eMRLU5Aw8SKH4oneQtzVzAFwZnWLbx7nNp0DCKs+1PCZz5CWd2AAwrj5CIly1EP dbk0YfNVd/dRfUViE8F375hbdre3hcOtCnqOQRPQyc49i/NOYzUmjvYIoS76LLDqR/rB XbXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706631; x=1794311431; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tZcQd4j24SOkPd+c0T3lL/TJVy1cifbr427VoGmUk7A=; b=f03b5BGLWWb7ssIsU3VlbwNSiH2nH8xEKqZw76lfe95MpFETMs4/cnZi/Y3GdfcwCQ vnhG/EIaoQHWza+d1HKzfT7slF27BRYxMkk1lECvSiWntDjEQvOUF4uirevNrm+zeP28 uV818vzc20JZODpLzqvT3OjyCXp+LBp8Wg73pTzZEbPzuJi80Iek00YU/6WKG29QSwu0 D+y1/bUwrumfQkoQtfVoNZ8g1KTBn2uipVVU9VDyfECPNqNcfGG4nUjiV6rkGHGpa2bM 0GlHWeNSJ2m/qANfoixxNpMRrO7ZLqkeNeCe82HnngAkGlOH3SiqwV6OEvG9rqIs8emG Py8w== X-Gm-Message-State: APuU4Z9Q5u22z0OZF9VwaOFL/UKRn8Db0dUthsuTzaptfso2dLI246H3 TMz8INMfRxwLZ0wFHqZa/ek37VWIR8SxMH5ySIEXtlZO7qq3qZfjx7M1RmwH6qg/BNNBzrvq4Dx pwdD829EsUWl0pArTHnQOKqy7gA6oLqusTz3f4GS7qgwmfaUKP4ZREOMA7onYXPTJouffKfkRZw bFhWU2SamHviY/G/zeK9iJRyN2Qk5Fsik45A== X-Gm-Gg: AYBFou3pdDpnnz9sSfE3Gqt3hxjrfm/vxNKFNzk6eCSgYtHZC1DDHVch5nMCenp4QGL hH3vNjiH8Z85qGnwvwFhAsAAfL4tFKXyoL/13Bk3LmPds57yeqG4H9Ucc24Y7yFzFvChlGCCa4o EtZKethhxrsgsiRZ7Tx4kKO1ZUlA5bVd1si2wwPoUwxriimeuPcOJnVl4TQr0TbxmoIpHifWhTW QqbG9eeoWf8n5SGupqQYYu9cL8ilCCDabwJe6g697PdAumgN/POogSLIWTNP2mSomL7RNN4VWW9 GjarhoXuSMlzVZqy9JjIntoISfrbRykTgC+q1DjUHKSodRqAKe9hSFpAt1wD2emHdn9okuJjPw+ pOR/9X+rNkA9kDFuMTPkMzHBFCScI2Pa/RYyCzEwGhw== X-Received: by 2002:a05:600c:4e08:b0:4a1:ce33:1536 with SMTP id 5b1f17b1804b1-4ac1719112emr282931205e9.9.1793706631462; Tue, 03 Nov 2026 03:50:31 -0800 (PST) X-Received: by 2002:a05:600c:4e08:b0:4a1:ce33:1536 with SMTP id 5b1f17b1804b1-4ac1719112emr282930595e9.9.1793706630961; Tue, 03 Nov 2026 03:50:30 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gerd Hoffmann , Pierrick Bouvier Subject: [PULL 03/17] pci id: clarify pci subsystem id usage Message-ID: <16085c7f27f95d6c178d77894d35de46d6b83e86.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706661898158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gerd Hoffmann Qemu uses the pci subsystem id not only for emulated devices, but also for virtio devices and generic pci class devices such as pci bridges, xhci + nvme controllers etc. Update the documentation accordingly. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Message-ID: <20261030115455.1121808-2-kraxel@redhat.com> --- docs/specs/pci-ids.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/specs/pci-ids.rst b/docs/specs/pci-ids.rst index 60cb0f7db6..53dd571de2 100644 --- a/docs/specs/pci-ids.rst +++ b/docs/specs/pci-ids.rst @@ -46,8 +46,9 @@ maintained as part of the virtio specification. upstream merge or shipping a distro/product) to avoid conflicts. =20 1af4:1100 - Used as PCI Subsystem ID for existing hardware devices emulated - by QEMU. + Used as PCI Subsystem ID for existing hardware devices emulated by + QEMU, such as the intel chipset devices. Also used for virtio + devices and generic pci class devices (1b36:00xx, see below). =20 1af4:1110 ivshmem device (:doc:`ivshmem-spec`) --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706670; cv=none; d=zohomail.com; s=zohoarc; b=ZGU8bXmHrYMhFn2HHsyonhxYa0m3jYuEtvp/zoIGNNAX/ebEkSUlaG9ju5byvMDMMQfTXZZpY329UqkereOZlt+8Ghg3u7j5p0R7rAAEYo9NvFHTebX1nU+7DQK1cM3a9OK+4HdW6Wf0hhyGHLedCjS2ly50BK7Yx5kxmkzp4eU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706670; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jhEdBOGUBF5XH484uywNcup3u+CPILKNoSQkyF0EXK0=; b=b6JWE9kEdBlbqw5x+OtLA6puZsv1V8iwD9l5yFnvXjTDaiDbfSuEu9arEqJObHGSEWCacF0YXrcUjJFowYW3iOJAr3py3yldAMTNaDEXDSFO3EbD5yzKR9oqpLdMpkkMuEPSTA021koGnePRvDyaQu3hoshYUJuOtHYg61bdOsE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706670686389.81584090721867; Tue, 3 Nov 2026 03:51:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2M-0003ed-Lj; Tue, 03 Nov 2026 06:50:47 -0500 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 1xOD2G-0003be-QE for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2D-0000K5-8G for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:39 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-voqyWbI5Nj2XGAjyAIbg0A-1; Tue, 03 Nov 2026 06:50:35 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a16dc2323cso35081295e9.3 for ; Tue, 03 Nov 2026 03:50:35 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4abeb77c132sm235400615e9.1.2026.11.03.03.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jhEdBOGUBF5XH484uywNcup3u+CPILKNoSQkyF0EXK0=; b=c4Elh4FIWZ0CrB4vRFG+XCeo6aAJdt4XCYfdNr4n4u0ETTkNypZhqAhFqunjByjiiTbp3/ AhS4+W38BgYsosDcwWdFKJ22FraZ8y9fflKYGJu0POd4ygMUq+eu0gRU9HgIVb/2jTj5VJ jfmKJ+Nmk/6NSiNF6+336wW8K5lC5Bc= X-MC-Unique: voqyWbI5Nj2XGAjyAIbg0A-1 X-Mimecast-MFC-AGG-ID: voqyWbI5Nj2XGAjyAIbg0A_1793706634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706634; x=1794311434; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=jhEdBOGUBF5XH484uywNcup3u+CPILKNoSQkyF0EXK0=; b=k+tQPJRMxl6GIfc7y0+6fzu3Pe3ZsC0AJhkK/jC+9bywtRX8RiHlVNLbEPxKsR/L6h 0N0kEGuHjArVwwyKVKFEP2n9/fYHffQkZ9xLffyikor15Pv0D18zqtyMFVAgT/H/57oZ 6NdX+2vM2fhqSealh1n8IGuSr2Tg2390HfeiZwK0kUbxfX4SzgiccSzjRi/6Yf/UG1Gh gpZtzt00aDZYRJfe4C4V7SvdAhi6bZuRZWRx1lDWVuB9VijuUaGsVqjrHJP/L6d9jv/z g9b9lRHDW3HZUE7a6Cxf1CwWwnOuzWtKw3veam4zxPjrsJss/J+4uYiMMIjWHAvgPbVO XWaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706634; x=1794311434; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=jhEdBOGUBF5XH484uywNcup3u+CPILKNoSQkyF0EXK0=; b=JzKcoYem/eJnM/zwJlkFso9rZKCYZ4h9DnnKnrUA33tHuL7ZV4ZC6penC00PX2nHCI G3E7JHFdyKYB+7ZStLDz2RqLl/Jx1MwoauAqgj54/xJiN9mfPtQezJ1ZCS1+Wfs/T+R6 oqgUDNk/Jk6pP+JvXA43XqAQpcWcT1VpEsu6PcRw2UvljMgeewIE7nCNLz5g3A9FZ4pn jQ70hXMy+Vf/rOgMhvbmX2lv0Zq00UgCCcHdTzUfc17YwKog/08i72kbCHbLVXI4lsVU ZVkPazV0kymaclusPjjMT0SV2y+I3iMJxWUx9KUOMGESDLUyYdTQgFTxq6pZ30NdgxnV Wp2w== X-Gm-Message-State: APuU4Z8Pfnbxz7ZfvJCD590ZpjNOsedb7r9B5Ju4H3Pau1qVTIWJ4FgD xUPf5X/v0JjjvSfRmn0wGT6uXPQ7g/8zRhQbP9eR1HrEWF0xPpMhTgWWFT1UCWmNV46BVZQo30T W52qrmKbJud9eQZVx9xbjOJPvkWPyVaql8X2CPUwu6QrsArQuKko7B0f91NZa4gpYtexSYBXQ5O T0/7snR9fZBUEElb5hr0QAHKsvrg26bCv+pQ== X-Gm-Gg: AYBFou28l9BMKOPSSjPTSPn9aAE727hAQDxMwqRYFpUEWNPcIIxn8N68XFupX/50YIg B0AszOrWcFvKNlPoh6lWnp7ZMGxt4X27CZHMJs7tO5LaAGKqnWliDJNiNyiZ9R8gqPMuwE0L71Y eDcdiS2w4UhfYMGtYUyntKhq8lzv1yNHDmLQm9ewxqY+Zly4Y5R+IXLQIA/edUI4zol1e7xYcYS PIXJpjC5+u7L1oWp+IWYemeUWwDYIvGqhoo/Gclq8FpgF0rPHsGTKpkEMbgUnp67u3EdUeEwc6C AY/VQ98Gpde38jABFgUGVugW/aCIN0lbxbBO9O7NM1o2jRYK6Iqt4eCI1Yg97BEaQUXKsM80COJ xkegMqo5I5E1Wx6iZr1ZEyUgajn3lCfuDvaZDl6Z/Vw== X-Received: by 2002:a05:600c:840e:b0:4a1:813f:2a60 with SMTP id 5b1f17b1804b1-4ac17d168b1mr327245575e9.11.1793706633895; Tue, 03 Nov 2026 03:50:33 -0800 (PST) X-Received: by 2002:a05:600c:840e:b0:4a1:813f:2a60 with SMTP id 5b1f17b1804b1-4ac17d168b1mr327244815e9.11.1793706633242; Tue, 03 Nov 2026 03:50:33 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gerd Hoffmann , =?utf-8?B?xJDhuqF0IE5nw7QgUXXhu5Fj?= , Pierrick Bouvier Subject: [PULL 04/17] pci id: assign pci subsystem id for osmates Message-ID: <66086984bc9a42b6f85dc2e71d56cb5d16d44318.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706671858158500 From: Gerd Hoffmann Allows the guest driver to identify the host implementation, useful to be more specific when applying quirks etc. OSMates is an open source VMM for macOS under MIT license. It will be released in near future and will be available from github.com/osmates. Cc: =C4=90=E1=BA=A1t Ng=C3=B4 Qu=E1=BB=91c Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Message-ID: <20261030115455.1121808-3-kraxel@redhat.com> --- docs/specs/pci-ids.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/specs/pci-ids.rst b/docs/specs/pci-ids.rst index 53dd571de2..74460bb19e 100644 --- a/docs/specs/pci-ids.rst +++ b/docs/specs/pci-ids.rst @@ -50,6 +50,10 @@ maintained as part of the virtio specification. QEMU, such as the intel chipset devices. Also used for virtio devices and generic pci class devices (1b36:00xx, see below). =20 +1af4:1101 + PCI Subsystem ID for OSMates (github.com/osmates), will be used + for virtio devices and pci class devices (xhci, nvme). + 1af4:1110 ivshmem device (:doc:`ivshmem-spec`) =20 --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706744; cv=none; d=zohomail.com; s=zohoarc; b=QehvLWfk2ZLIRkQHP/jWVnNkJNqyUE20LOKpFvpBwv0SoPcN7Mme4D1nfOd3enffPERGwMsJ+eDZPcJ6oeUoJFq/oQygiYNmhNep9jgqd9bKvUVBMJQf588xg5wfhS8As/RcB+OICtFI210m5JiJB9kOG41szv31UG5PaSRThuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706744; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m0qbRXJbDPkLJdjaZclhzEufolZE690wiCirz9W/4hE=; b=cZnnC+JNZErPpMiZiZy338UWy/EnoodtLtjsS0ZfmHSXGtOP/2Xg5UCpLBUQMmYpWGPWBuCoa+Jf9fMMzLnCB+5gxerDJCM4pzsDFfMKRDMMhmfqvV0pTA14nAiaYK95t+nK3kcIfQ/Ek0SEsruSJeDv+p1Jw6s+ZmkmDxjfpTQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706744887273.1227720949071; Tue, 3 Nov 2026 03:52:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2Q-0003gL-DU; Tue, 03 Nov 2026 06:50:50 -0500 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 1xOD2K-0003eP-Ti for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2I-0000KQ-6b for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:43 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-xXh6FCcSM9-j9rpL5IrK9Q-1; Tue, 03 Nov 2026 06:50:37 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a2063be141so37295405e9.1 for ; Tue, 03 Nov 2026 03:50:37 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71bab1a8sm24296457f8f.57.2026.11.03.03.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m0qbRXJbDPkLJdjaZclhzEufolZE690wiCirz9W/4hE=; b=gzGA5yNVaeTC/Z1l7Ax4IoH9GMPLyV89pa+YvNaNDoJN39bH6bxpXFyfOd1fSYIn7OkdVI 2mYyPFZ+oqmQz39dKQ0v1adn3FemFXzQy8D0k88mPj618rTXvvW1p1LFhnxPfNhYj9ujQh qk1lRDZx4kIIeqWp9Y57moVzwNjItV8= X-MC-Unique: xXh6FCcSM9-j9rpL5IrK9Q-1 X-Mimecast-MFC-AGG-ID: xXh6FCcSM9-j9rpL5IrK9Q_1793706637 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706636; x=1794311436; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=m0qbRXJbDPkLJdjaZclhzEufolZE690wiCirz9W/4hE=; b=jLIpiY8FtO0bViiOkAp112b0MddppKH1dkIiTiSB+1rQWy1+ixEEim2L+B7sHCJZ3d IcQnW3NJGkn2d6Ydp3y9f+yEC91fJO8RZ3p2Hq+NXdLSQ9qNDoYJDcwOWBe2eB4jzm6W 5CvI6sboLFuSDxT5eDDCmaeFVon4Lder1O/pjCy0TxJm32UGmturifORLiXWGvPJY4Cn pmUIzBwkhZkrxrvt8Wo3mysdYpcwnt1rBhVfh9CyKowcg7/WHE/qoUVEGxkegFMnauM1 i++NF118Xu2CGKTO8dD59zXxn35E0kLpfzpx/noGbzEP66IED/B9NIv/3480NiJVXCbk AKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706636; x=1794311436; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=m0qbRXJbDPkLJdjaZclhzEufolZE690wiCirz9W/4hE=; b=2ss+zyMkZ1vaGpTeGEvThXI9O3FJ2vk/KbaS3djqlyL/HjhMeXRhtNo/dn5dJ+UPtu 1TlNX4amNNJxISePhGYlhERPRjNe/a4r+MN3Hb9qojfhznTI0x9pAZ6+3Yumo4ERR36N 6VOQ3OG/q8tCFc3nARfNyTiAKCzbW59AUyTtxPLUoEHA9P03OkZAKfw8uNWLIGQixJsL WUc6/ezNFN6h06VmBpHU1XEluo++5RhKf0TzT027tg/tukSVQ56D+RSsltIWUzxsz/T/ 9b2HHPuMqs9XbMCAat1DvhYFH+boTigQkYOo7zJjgO81OTVmL6dmJKnd0JB64a8Uyvr0 YK8A== X-Gm-Message-State: APuU4Z9HJxkFSkRJUeE5srf3NKQ8NTBOR+njERdT4znYi8m5dVr5EbJ9 QxWI78TQeHYy6Wf3QHDbIfkXMJLRa6nOeLoSAHY3efOZItb6c+DRcC7Md+o8s0tueMivKFxEv59 D+jJVeFoBuuqffVa7bE4kqq38R812zoyKP5iCfDCCdfpseRYxhjUtLJ1TblOxrC6NofRCzTERZz tNM2QDcKDSgkUpNaFZMXphV/pnJNfycHZsMg== X-Gm-Gg: AYBFou1h47+5P2R+tCVBApzI0A86rBz1IVxZE37KB+XD1+/jA2vR2xqju9XUWMPGios GNqqRrmB6gGa7Z+4HuYoe3qVAUZslYTZLh44OIATc9OwdBYYF1ZS1I84Jwob8z3Mp6EyBm6csHG OZXbteignHIY9pZVy2EmqHDTGQydORv6npjWjO0IrbXfbv4ylPbtk/9WJD191U/82M0LTpjhEiW VhdOAY1mVnJbXOqUEjgrPPJBXxOvS1cQWk8nAGYXYNgGZcpKpoJOxfWB2lVb/K0XfTbMK2Szd7k bOhV1e4c6XARUOxfgsU1FhD0Z3APyHo8SQnmzULqTZ8HSVTlSRaxlE2ELaMx9PbNQeT06Y+4fhy mkXsJLmQx789tGrIvJsVWgPiOsAfbg5KVat44eBZ/KA== X-Received: by 2002:a05:600c:4e13:b0:49c:d019:70c5 with SMTP id 5b1f17b1804b1-4ac1228978cmr270900365e9.0.1793706636590; Tue, 03 Nov 2026 03:50:36 -0800 (PST) X-Received: by 2002:a05:600c:4e13:b0:49c:d019:70c5 with SMTP id 5b1f17b1804b1-4ac1228978cmr270899815e9.0.1793706636077; Tue, 03 Nov 2026 03:50:36 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniel Paziyski , qemu-stable@nongnu.org Subject: [PULL 05/17] pci: fix null pointer dereference on pci device registration failure Message-ID: <7ecad9ed2e1c7fc7076cb23186c0e3b3317b6c4e.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706746142158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Paziyski When a PCI device fails to be registered using do_pci_register_device, which takes the PCI device as one of its arguments, and returns the PCI device it= self on success or null on failure, the acpi index is forcefully released using pci_unregister_acpi_index. However, this causes a null pointer to be passed always on failure to pci_unregister_acpi_index. Instead, do not reassign pci_dev from the return value of do_pci_register_device, just check it. Cc: qemu-stable@nongnu.org Resolves: Coverity CID 1689947 Fixes: 432ea8cc7d27 ("pcie_sriov: register user created virtual function be= fore realizing it") Signed-off-by: Daniel Paziyski Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261101162132.147838-2-danielpaziyski@gmail.com> --- hw/pci/pci.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2d2fe02c68..1ea388be37 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2327,10 +2327,8 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) pci_dev->cap_present |=3D QEMU_PCIE_CAP_CXL; } =20 - pci_dev =3D do_pci_register_device(pci_dev, - object_get_typename(OBJECT(qdev)), - pci_dev->devfn, errp); - if (pci_dev =3D=3D NULL) { + if (!do_pci_register_device(pci_dev, object_get_typename(OBJECT(qdev)), + pci_dev->devfn, errp)) { pci_unregister_acpi_index(pci_dev); return; } --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706725; cv=none; d=zohomail.com; s=zohoarc; b=cohKuu5hiRLT7vypzGNzE+KQ0r544zRTlwLfArxmG+vTU4P2chuxoV21J/v2ft+ayhBn8Md/wsT50ssXTRsEAVIizEv3AsBWClcmHpHQTKUzXhCnH+7kA55Ql+PYBFihLUQbgpaQJe+k5XJP0elaNAE2qxFrddO4kr68B3H42rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706725; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TktMWa3JuBokAU/8i9lgcgCAS9ZCodBfbqHTmz9KQWs=; b=KUSpa6MXNXPHO+neGbR6jZmhDUUlC138flusOezYm+78E343e2PekGy9fKfbwUFLJ++G9r4QyOuBgOos5KJ3BlaI6VSKmdMNzIYvRDEEybZTO3yMu6BkjGrQ9wY1CFxCToA7geoM2TK7lBk6H5ff9Snq38iPx3yksLZVLboqq3I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706725105680.0678685883391; Tue, 3 Nov 2026 03:52:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2R-0003ix-4n; Tue, 03 Nov 2026 06:50:51 -0500 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 1xOD2K-0003eO-Ti for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2I-0000KV-KH for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:44 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-ene5ltVfNza94IDXVLBa0Q-1; Tue, 03 Nov 2026 06:50:40 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48b01a74792so2756203f8f.0 for ; Tue, 03 Nov 2026 03:50:40 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b78c10sm24274145f8f.25.2026.11.03.03.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TktMWa3JuBokAU/8i9lgcgCAS9ZCodBfbqHTmz9KQWs=; b=V01d16S/TbFSZ74pwjO/Hk5PiVpmgLIdEim9s/kdT1GQslSvsmZtMHGZHlneEOVoZ6wA9f iKk3iazpKlfaGXGhBUaz3ETL9F8SUhngW4EA0WyjBEyd+xZe2HZA42sYvseMcCLfJjuSdS 3fW/dJSmMPctyIRIurtH8qW2RYShFlk= X-MC-Unique: ene5ltVfNza94IDXVLBa0Q-1 X-Mimecast-MFC-AGG-ID: ene5ltVfNza94IDXVLBa0Q_1793706639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706639; x=1794311439; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=TktMWa3JuBokAU/8i9lgcgCAS9ZCodBfbqHTmz9KQWs=; b=A/7cb8FBZhhhTuL6V6LZHrwGmXVTMsdaEvYzHSmZV26CZ7fxt9zXt+Hb6HmKBBaBiw +uNLcaCXkOC4Dl9MCMULg+EZ9pC4O+81QyfBRye5yikatNEZnP9hG2Cn6t7tgBGN1/Ai MZf3o7dNISVwVoo++UuCYK0AZF1KpirU23HjT7kJI7FZnWCpRj0h3mXN6c2K4e5mqKRb xJq0zUWM+NR0/DIhROpzEPzU/ebhQdWSr/zH+aLadVa1OwQWvVcWB4L6ih12Ka49+YWw 5r89qBJw9RpaeK4C+hTA6G8Af0jOMg51HyHhNsyRRlBbl/rDgbCvthKeTPdcUz8+DG9n kDZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706639; x=1794311439; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TktMWa3JuBokAU/8i9lgcgCAS9ZCodBfbqHTmz9KQWs=; b=f4V1K7wi1R+8Kpeh2Z2+HK0AzY7qu/QNOJzvBGA7gl7FWzw0ifwAdWihldNg0FFk9g LfqFQDTsqhf5JsXPlszg5Pp1Z4XeAnUfmZiHrH6ueKo0c/b9MzuzND7oaHhKujoVuDup /4Mz+CgoYewvTE0yuBTM1TY2iBg3bW0MgbTSicr7hrgELmgF1VxCogc/U/yEJjlp4DCZ mqTU2+SCbjvhXKadByP4Ktz5XxYyHHSAlL0sDQyM9GFjLBSkgAFm8w6gnt6zy3hl4AfX B4QmNLi/FbYnDQ12i1OPXKDThNQv7OHU26dMVlYKJdEo5XUI7R3uh+8RR7RR5WqDn2EF kDtg== X-Gm-Message-State: APuU4Z+pFj/4JWCzYj8a2QhOm0+WUUV1Rw4b2428F1XAngas9w9NTmJU VddhuUso1tEMCnAU9IDM8mfqI9WMyuR7hadMxEvwPj5ZFXzpob248R5RAnwzk+EkNeHaA8v9U6K iotxZDpUG60B7YUSfqiYxcux3PLHrw3lnyA2GUMmF4ToJjZJnspQe9m9f3nlJ+Qf9hvDnljZDO2 I/0i07CIiaSRt8awmtVNIoXi4g+fMVYUaK2A== X-Gm-Gg: AYBFou31YcsUQDOQwiC+mEYDtg2dZ65vDNBVX0lyjuNiiF0AxVUPT+3Ezf09ejfv0/6 0DyN0/y7+VePfql9VRQrFLrVmyvuj/eLjNzJZJmkTh7hFXDX35E8q0LBF3zn2hrEoVxQTzBSEPZ CSt69pPbHBOmYk7sD/0QbnPM1teg8TusAE8+Jibk1Unw7IEmEozU//+CmWOPdRSJKKWJSZ5EJdz o8o+uvmaPS27EonsHxH9AEukJWs2Q2oqFW7CXEHjn3pyZziLAwjtkV2jfOYfBF4NocdanynoNcs j8I3F0yqMr5FoNHMFBeDxjmBp1Zhw0rHvdEzBZIHmiJtB2EmD4KqqYaslpS+aHxfjeuseDYW9Yz vt9ijMrhwzJ5I4tw39GgAP6hs6QRahUXrbT+PhnmEEg== X-Received: by 2002:a5d:63ce:0:b0:48e:247f:a106 with SMTP id ffacd0b85a97d-48e6e4fa97bmr22225353f8f.54.1793706639253; Tue, 03 Nov 2026 03:50:39 -0800 (PST) X-Received: by 2002:a5d:63ce:0:b0:48e:247f:a106 with SMTP id ffacd0b85a97d-48e6e4fa97bmr22225299f8f.54.1793706638569; Tue, 03 Nov 2026 03:50:38 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniel Paziyski , qemu-stable@nongnu.org Subject: [PULL 06/17] pcie_sriov: perform additional checks after pci device realization Message-ID: <36bc5a879e0f0993aaf95e0896cb35426a32249c.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706726062158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Paziyski Handle two cases after realization, which were implicitly handled back when= PCI SR-IOV device registration was done after PCI realization before commit 432ea8cc7d27 ("pcie_sriov: register user created virtual function before re= alizing it") - If a device is a PF of user created VFs, make sure that it has initialize= d its list of VFs. This check seems to be superfluous, because the only way it = can fail is: - if PCI device realization forgets to initialize the user created virtual functions via pcie_sriov_pf_init_from_user_created_vfs, despite having = set sriov_vf_user_creatable in the device class; - if the pcie_sriov_pf_init_from_user_created_vfs function fails, but for= gets to set errp (which does not happen), and the device specific realization code forgets to check and/or propagate if an error has happened. However, this check was present, so let's include it again for good measu= re. - If a device is a user created VF, make sure that the device is still a PCI Express device. This edge case occurs on devices that before realizat= ion have the PCIe capability set, but then during realization they clear it f= or some reason. This only seems to happen to modern virtio-net-pci devices, = which have their PCIe capability on, as any other modern virtio device, on obje= ct instantiation, but is then cleared in its realize function when it is loc= ated at the root complex or not in a PCIe bus. Cc: qemu-stable@nongnu.org Fixes: 432ea8cc7d27 ("pcie_sriov: register user created virtual function be= fore realizing it") Signed-off-by: Daniel Paziyski Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261101162132.147838-3-danielpaziyski@gmail.com> --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 5 +++++ hw/pci/pcie_sriov.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 5f81e3b1bb..41ccba8a71 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ int16_t pcie_sriov_pf_init_from_user_created_vfs(PCIDevic= e *dev, bool pcie_sriov_register_device(PCIDevice *dev, Error **errp); void pcie_sriov_unregister_device(PCIDevice *dev); =20 +bool pcie_sriov_check_after_realize(PCIDevice *dev, Error **errp); + /* * Default (minimal) page size support values * as required by the SR/IOV standard: diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1ea388be37..e85b34d06d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2347,6 +2347,11 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) } } =20 + if (!pcie_sriov_check_after_realize(pci_dev, errp)) { + pci_qdev_unrealize(DEVICE(pci_dev)); + return; + } + /* * A PCIe Downstream Port that do not have ARI Forwarding enabled must * associate only Device 0 with the device attached to the bus diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index e6891436d3..63d19ea488 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -393,6 +393,25 @@ bool pcie_sriov_register_device(PCIDevice *dev, Error = **errp) return true; } =20 +bool pcie_sriov_check_after_realize(PCIDevice *dev, Error **errp) +{ + if (!dev->exp.sriov_pf.vf && dev->qdev.id && + pfs && g_hash_table_contains(pfs, dev->qdev.id)) { + error_setg(errp, "attaching user-created SR-IOV VF unsupported"); + return false; + } + + if (dev->sriov_pf) { + /* some devices might clear their PCIe capability during realizati= on */ + if (!pci_is_express(dev)) { + error_setg(errp, "PCI Express is required for SR-IOV VF"); + return false; + } + } + + return true; +} + void pcie_sriov_unregister_device(PCIDevice *dev) { if (dev->sriov_pf && pfs) { --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706683; cv=none; d=zohomail.com; s=zohoarc; b=WHqCr/kSrm5MC36Zj1uSjz9vH6PJOOj42aX+eB/mtV+2GlhlPxYztPIkqsMDJsPkB5jbiAAK9t4o8KBPNzsmODqpDI3Qd/iaAhHLAi77q1mQbOU+z4F7LwM6rKDRcYKbrhPeam86E+Bij/G7jLnejTGoBcACgunEFPVF7YU6giU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706683; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7QHNDyK/phJ9tU0kowrtkVbtSo8Bjfz9PyfAuxDA36k=; b=HbmQnwpt03acuGi8PKhpngc3xPAgBZiuR/DEt/uJCmCNm6+qo+lFsgoV7+HfLant8aFCb5kx0Q44QvYwpYaz9mAKHN/n2Laa6PTTKXCQUC3RXjaUD3b3lDJZieEc/VC1LOng+VXkbVTXNITsOEhRRqy2Do+TJUO3xc/T8b8jtB4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706683538732.7587721266285; Tue, 3 Nov 2026 03:51:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2S-0003l2-L7; Tue, 03 Nov 2026 06:50:52 -0500 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 1xOD2O-0003gR-Op for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2L-0000Ko-D2 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:47 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-lG6V0QNhOpCH_4zBnYcFdQ-1; Tue, 03 Nov 2026 06:50:43 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a1f03f2e8aso36228815e9.1 for ; Tue, 03 Nov 2026 03:50:42 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b8bd8esm24811724f8f.42.2026.11.03.03.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7QHNDyK/phJ9tU0kowrtkVbtSo8Bjfz9PyfAuxDA36k=; b=ClGaJCV3Ua+i26nRBd9oi/8GNh1m+xMu2WZy2/xPLBvv9LhOmMJ+AvPMCZxU7IIzeZaW3n Q7iQSPXORgJ23x6XudmIeYTuBLhyziqSbosKDMy3FphtO5BbweIQpyeV9NtGw+cer7Spbs Upy2imGoDBGXEG7z0hoDx46AOBmF8Fc= X-MC-Unique: lG6V0QNhOpCH_4zBnYcFdQ-1 X-Mimecast-MFC-AGG-ID: lG6V0QNhOpCH_4zBnYcFdQ_1793706642 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706642; x=1794311442; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7QHNDyK/phJ9tU0kowrtkVbtSo8Bjfz9PyfAuxDA36k=; b=hcXKTcBEpJP9KZvZpQd+B6yPT17tmxe+o5usAzBg3U2dyHj2SL8Dnn+JAn1PvGTfOD DpD6QC9haUa2oTKegp22+zkei0RFdpVCxdn79TIpzQao5c1sXiRZCuBiV9Cat4a1zgUm 0WM5O9rXtivpkDm9TQVSEm78BCohjdIxW5qDPXJrmq+eIf9UJ2WSk56XGvLfyfM1a/4B 3Neb2eZegb3SaXQ1gvYlXuL1F2Romp2HVpBsfNqdCByl5DB6pKEmD3yLPcmL0A9FL0tr oLDz5+3cJPOvEJ7Wr8NdCSZ/UuIat/AkTof6ynQekBLO0lfJ4MVz1vZ7v01ZUm64gAEz Mb1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706642; x=1794311442; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7QHNDyK/phJ9tU0kowrtkVbtSo8Bjfz9PyfAuxDA36k=; b=z8NT1shn2hnaW1Cm7e2YbMDr+etuV+KznqQuy86H4Eg2bNeOwOnkqRqkiN1XRtbxyV VugoIi2eBJUV/4QByLw5CNAmuglxwrC8QLV1ppML1EK00MuFCIFaAdCQw1+c0lzXVrpm vFBESBZ8ZSpezh3sCYTGWpxsFfz9eV3ABJSSilOyQk8cGqH2/GeKoXAZBzmP2HRzCyMC q6/rUY3iK2AvdUrZVDn90dk8BF3/065De9HfO065CGdJJZ5ai2snfBLhebq3f930RQB2 9jkU8oIT6hwGAxkYzA6bXJl4RIwUvslTTg3kP6luoQBLQXqjAVHFeQxwAMforAJJ9Z5d BA7A== X-Gm-Message-State: APuU4Z8XdhkTaeWEYSvs69VumjyGjQuc4YBg+nkrFpHzNkyWvZwbuyiy VBMuSh51bxkwkawmuuSq7ew4r/AF40dTPmSOl+Zutse4704BcEMVs2cYu+2e1ueSsdqbZ3Jx9Ty c7VzFOJoXEFkC5rJ/PBZKFd8Z5QitmWxzeJjTvIQ9/yBxkAZrBERIMRxpGfhouoq4DZJUhj2Rlq PWALn2q64U0kLCA3TlWv0dgYnRwovkMwRyvw== X-Gm-Gg: AYBFou2lJliyHeoFe1MEkEPeF0vmLCt+pxKvpxZT7zVt463Bj7pTaY2nnktI4FwRBO2 Ou0OMSNLP8GObhdHDys1Dbz9MxjG3MTdSMWPTWaLsGwBvgv1+akEpMeVSIs5yNHDrYxLunQBphH Gmhsqwrgkdn7eGHniSLlenOXDXrqpmue6eWUXuR0yiJDR0xMdCme3DR3RwTbuTW4n/lGgnFlG9H ywbyJ3ee84ifOgOxMxdcAIm0OXiz2GI+NpTx7j0IlPvV30McBqZo/fFcBRb2h1c+p/0jnjAV/di OrMQJf6MsAycU2FrXIqnA5R7JKalRt6CoNWRxMYcb006u1yMOq4aHl/so8xfcgp8Ii8mhUXIA5L l5zW3G/YNtWYSV2Jp9BLR06j3Ps8nHiDMyN0hG3zZJg== X-Received: by 2002:a05:600c:4454:b0:4a3:5a7b:6002 with SMTP id 5b1f17b1804b1-4ac17d19777mr285784415e9.28.1793706641628; Tue, 03 Nov 2026 03:50:41 -0800 (PST) X-Received: by 2002:a05:600c:4454:b0:4a3:5a7b:6002 with SMTP id 5b1f17b1804b1-4ac17d19777mr285783805e9.28.1793706641020; Tue, 03 Nov 2026 03:50:41 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniel Paziyski , qemu-stable@nongnu.org Subject: [PULL 07/17] pcie_sriov: fix null pointer dereference when initializing PFs in a system with user and device created VFs Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706683825158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Paziyski pcie_sriov_pf_init is only used to initialize PFs for device created VFs, a= nd as such, it is checked that the PF has not been referenced by a user create= d VF by means of the sriov-pf parameter. This check crashes if it is performed for a PF that does not have an ID, and there are already user created VFs in the system. Example: qemu-system-x86_64 -M q35 \ -device pcie-root-port,id=3Drp1,chassis=3D1,slot=3D1 \ -device virtio-net-pci,sriov-pf=3Df,addr=3D0.1,bus=3Drp1 \ -device virtio-net-pci,id=3Df,addr=3D0.0,bus=3Drp1 \ -device pcie-root-port,id=3Drp2,chassis=3D1,slot=3D2 \ -device nvme-subsys,id=3Dsubsys0 \ -device nvme,sriov_max_vfs=3D1,serial=3Ds,sriov_vq_flexible=3D2,sri= ov_vi_flexible=3D1,bus=3Drp2,subsys=3Dsubsys0 ASAN message: The signal is caused by a READ memory access. Hint: address points to the zero page. #0 in g_str_hash (/usr/lib/libglib-2.0.so.0+0x49954) #1 in g_hash_table_contains (/usr/lib/libglib-2.0.so.0+0x4ad3b) #2 in pcie_sriov_pf_init ../hw/pci/pcie_sriov.c:161 #3 in nvme_init_sriov ../hw/nvme/ctrl.c:9088 #4 in nvme_init_pci ../hw/nvme/ctrl.c:9218 #5 in nvme_realize ../hw/nvme/ctrl.c:9696 Cc: qemu-stable@nongnu.org Fixes: 19e55471d4e8 ("pcie_sriov: Allow user to create SR-IOV device") Signed-off-by: Daniel Paziyski Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261101162132.147838-4-danielpaziyski@gmail.com> --- hw/pci/pcie_sriov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 63d19ea488..9ba14d46c4 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -158,7 +158,7 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, BusState *bus =3D qdev_get_parent_bus(&dev->qdev); int32_t devfn =3D dev->devfn + vf_offset; =20 - if (pfs && g_hash_table_contains(pfs, dev->qdev.id)) { + if (pfs && dev->qdev.id && g_hash_table_contains(pfs, dev->qdev.id)) { error_setg(errp, "attaching user-created SR-IOV VF unsupported"); return false; } --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706695; cv=none; d=zohomail.com; s=zohoarc; b=PEjPgXVibXxo91IQAGn7LuHl0VcNVAg2/Qcb6laiGY1U/cHiriUlnz6Uj9XB2FlvQLKB9RicIFkxanw25prHPaCgFC3Meo/VU/oHQnITVQoM30a+SXNJLqpd/3nKrtKWaOOvWt9c5uJr/wMdACxzJPjjyhnbC3s1Iqy54/3dEpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706695; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UHKNN3BJbuzXQxrUE+/Ofxxpwwy9gN/qPKU69iR6cNE=; b=Vlv5VDr5trmWskKPFw+FuTTYiq2MlWBazvlZVICYljN8Gu+MmIgdGyLd++343E/v9ZOzY5tmk2mAXWXor663gKBG+F0ZxV1ClH+OxNVzyXhlj2UdjLb2xWKe38YpKdz2A2pWt0+eKYgCyLQJOen0HhT8XJ3dxkMtn4Zj2sVJ6j4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706695513345.9675566404726; Tue, 3 Nov 2026 03:51:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2S-0003l5-Uz; Tue, 03 Nov 2026 06:50:52 -0500 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 1xOD2R-0003k5-Pm for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2P-0000LR-QY for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:51 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-HOIOmq62NLiOm5JcRNzjvw-1; Tue, 03 Nov 2026 06:50:47 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48b0a199b20so3444975f8f.1 for ; Tue, 03 Nov 2026 03:50:47 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b80eb1sm26123209f8f.34.2026.11.03.03.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHKNN3BJbuzXQxrUE+/Ofxxpwwy9gN/qPKU69iR6cNE=; b=cd+kI/cS5LJwasOx3cCKHqAsRzozcJEO0WaWYpBo/2xonesyEAlaFjgUKa1WNSI9Y5uybe SwvnQPPpxm9Z17jagePaS/yrKhfG9a/TRwzx6JGm28T+CGmhn8MadoyrHa6VcG99Gy0frU 77sZyCEC1MgkYG8whxgsE9WhfOA4j5Q= X-MC-Unique: HOIOmq62NLiOm5JcRNzjvw-1 X-Mimecast-MFC-AGG-ID: HOIOmq62NLiOm5JcRNzjvw_1793706646 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706646; x=1794311446; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=UHKNN3BJbuzXQxrUE+/Ofxxpwwy9gN/qPKU69iR6cNE=; b=qLP5zsErhsBa5SJX1vSGgyBm+blF/wFWVjCPIRbt8XaksxrKWnsz0YxcG3aElkPUFb QCnsQWo7yFYHrruA/6qfcSjwy9bdMwAKWV7InYDycTFt4pttNQ6Og7olbLW5tA3PQZMd d4r/+ZTVWIYmm0WqLWjjkId+3xgIpHKdZ806Cjs9qZMQHsfRwasYk03lOp4+hu0vFrFn 58QwzWY66OVqO5PPhMo0+z0pzuSyVQDAmk9X52143RMYVd1e+OiHLz4q6kH7hik5FeEV VEliLo7PGBEGeLyYIY93BE1Nct95yMDxPgSEU+lvrZqXEWjxo/6xmlqb0o/s5Aa1C/FK sffA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706646; x=1794311446; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=UHKNN3BJbuzXQxrUE+/Ofxxpwwy9gN/qPKU69iR6cNE=; b=wMYSFrdO/hqcIMsNeije+m9VbNiKYN37OyRW9jbBCCq8k4w/2BKDFS+ZUVliXFaZAa JOTW7l+NWrXsJOLBGkNp1aiXsd5B/n7S1tns5BrEQTRWUGWodc+L16uG2m0ySq3CghnU BGoUHmQViQG0BQADh3z7/Zp+yPFH4Dd5Uo+wWccEkic17NOAn7YIS4hfBWEuCG2E70S6 ha2wBmkidV3J0Lu+2EUThbDAlTktHUgD8fityavZuaPAr3HHCGz+GC1CeJ2b9vjSjNNC vlwU6BymsRO/+JqPYTyDVMLiFSwQ9E8DXHpdLygGBv+Oh9qMZ3kJc1EYUjjlZ01JijbV 97rA== X-Gm-Message-State: APuU4Z8++afcvoENB2TgWazVSL6QuuH9/eA3EJHzZU7+jOjYQ5drIu9u IgI54tMlAR2z6vj9eOZINdCKgsdSSx2I5e7vI/OZY+rCwbgiPWdJ9KAGVaKouFGXvwtrHCjqgHf moaEp+i6lvX9jcUKrtF+r9DW5GwGROs0R3bJLgAZh3ir5GOfzKiuHC2ckcQM/74veg87G+XBLwo D2zoCqx18ZXhMWKWJA+5ITE9gACnN0Ba9duA== X-Gm-Gg: AYBFou1EK0MxHfOZ7DeJXVuCFHlpt5sZrgI4SJjMQ4v1qRpsm4OX8cRWgACCJzs9kS1 Vv7IFVZ1p6HvC9SX9/idAi4K7dIHR9TEMuENEmWnn3fqGKHPeBZUWhes78I5luvcf62Can458wd 9V2kHbJ7B+39qs4v4oVAIxzQHWwEDagEnR/NB5Jpjj/R53pM7yoT/WGvat1a2XOofJqtupt1vij jtnPxWUSM2pUS/mHwpxxsgEaZcj8dbBJd+Jq0bPTfZ/mkLiqtuZpXMGG9uTezfESiWOEQH3aICl 2C88ZpwjrvAAZR0lD1RvgkU7Z9C/YIHaP2Me6ObJq4XT9k2U8scc/sW2Vbc8zsX3ZZaGT56fDtL Knh37kahFiUXmjOZy1Pf3rUr4Ru8Umn3gW/Dt8zKdVA== X-Received: by 2002:a5d:588a:0:b0:48e:932:af0b with SMTP id ffacd0b85a97d-48e6e4f6a88mr28298086f8f.32.1793706646363; Tue, 03 Nov 2026 03:50:46 -0800 (PST) X-Received: by 2002:a5d:588a:0:b0:48e:932:af0b with SMTP id ffacd0b85a97d-48e6e4f6a88mr28298017f8f.32.1793706645754; Tue, 03 Nov 2026 03:50:45 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , Laurent Vivier , Paolo Bonzini Subject: [PULL 08/17] tests/qtest: Enforce zero for the "un-fired" msix message value Message-ID: <370993e916a0b5f35c3284355e373db654112310.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706698076158500 From: Nicholas Piggin 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 Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-2-uverma@linux.ibm.com> --- 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 4e67fcbd5d..f31b3be656 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 002bf8b8c2..102e45b524 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 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706708; cv=none; d=zohomail.com; s=zohoarc; b=JuSzsgTQO6V9fH0k5yeLA12tqdinMfXUSkcfQw6j7e8TRGwIYqOrmEHTrBUW/mQDrzNUa+osI/IBa2ERj/ja03D0NKd7uTjF+O+FjrKOqa5hZQSZ7YZ4ISxgxLfMVxC4XDUcPcOqrrqlbmtMtrDx+Cp69r0/2o/bpwNO2J6Kdwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706708; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RLXt3FQxlARNWg3uYE2Yv1IT4qzgDEC1brvODdILLZU=; b=Y2YeMLXw5vRPewiZKOHCLSCCbEEJrDUlNT2tAXWKx70YJzVcdyVw+B6UpTW21VQ1Jh0NsdCZ76fs2lDn7/4X1ZmnzrqnwV2gG4lLqipubdMsGMiaQsvn1Z+82GPZGtd7gtZlPD14HSXjqx8LHfJQMRNIuvPytQ+noTeaXeSEBDg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706708781298.97907865003447; Tue, 3 Nov 2026 03:51:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2V-0003ng-Vc; Tue, 03 Nov 2026 06:50:56 -0500 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 1xOD2T-0003lE-KJ for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2S-0000Lb-2O for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:50:53 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-WWOGsqygNUG0VvqmRqkv2w-1; Tue, 03 Nov 2026 06:50:50 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4a16dc2323cso35083555e9.3 for ; Tue, 03 Nov 2026 03:50:50 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ac09ad5ff8sm233079665e9.4.2026.11.03.03.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RLXt3FQxlARNWg3uYE2Yv1IT4qzgDEC1brvODdILLZU=; b=EgviBV72ozyZdKv/pF4SI60E/XnBIWmiI5uXdtlCEaRjMEPyh4vqZkAue0r7uzrys/znjK mfT0vU+Wb52hYB5UPI/r0srTfxiO4zd/BP0uR5DT9rpCmi9zHcr7a/mgtbz86SxCylo965 dHb4GNywQFaIdP8/aSbph2YuqDNYO9s= X-MC-Unique: WWOGsqygNUG0VvqmRqkv2w-1 X-Mimecast-MFC-AGG-ID: WWOGsqygNUG0VvqmRqkv2w_1793706649 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706649; x=1794311449; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=RLXt3FQxlARNWg3uYE2Yv1IT4qzgDEC1brvODdILLZU=; b=tAQeUHm2aHLfjM6F6kOoRm9FyvXYXShXQp0t+zoippImK1/HfcMjmA9dQdvmj3xEx/ 7lgPGzguqpIquT0ncksrGJ2SVgp3t/O8quvMNVpssUu8QyJXIT6RsVEDWtfJo7Q8UoUg 4UHgo4z2lHeJfu8mrgSEMdnPt4xJWH9WtFstQ/i4Q/hbToTSk0dl0E7aXwjwF9U9FP8E RyqxR0dUGmAwSf8yopx6Bd79ugqwWwz2XAFYm20gwTCyrW2I/vlKtzQtpRCf8IV11q7P 8QfmfzDdBZnCFrhFN65C8yJCxbfKRl7X3hIKfqf8xRbIAwWZdBtKF7DDuxLa+GX8Omyj Mlyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706649; x=1794311449; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RLXt3FQxlARNWg3uYE2Yv1IT4qzgDEC1brvODdILLZU=; b=sq32ViClx2HiV+Si/NW0XG/4mkr5LvGZVdoVnb/tcBtFSJuiLsYl9topgVNDQKa6qt LNjZ3M7GgyHmUFGnEZKjt8eZVfLxd6lLDZvMRIojJ58JZdTHB7tf/Yb2sGa9IgSeiBKr B54JgxJAGK996l2i2AUN2Ux1fSMCvkb0Adsnunj4SQrVg0TUee9sOLNOSKiQdk94aYYl 9xxo9+9vQOrgJMPUo+T/xFZhKaZnw4y+AmQZfmRQ+s8sP5FMqQJ9dYccLiCdx7kltzcK gm7Ed+A6FRH8pK8S6cgZecRGkA8eaCqcqBpJf52mqOYy5qmNVrzXvYi2aLE4p/PAiJ/7 tONg== X-Gm-Message-State: APuU4Z9l3M2kULbMkAcwuWRa33OSa9ZAZVTooAtMq1jKTf0j3c1X9uju uo5l2a9Le6VGhZFaX+tEyjWPRI2OcRkhC50LpK4XQ89S8qXF/OtPy201zwgBvKyRzf902zglXRj DnpiMLnWJHglID+as1qVv5xJh8+hVMu62bhnMGAwt+dccgY12uZpROX+OYucXgpKIFIeP3oGyTL G9KLTYrwfdBi6fX7vgEZgOfm42g7XtCjdAww== X-Gm-Gg: AYBFou1PBE6XAc5CrdYyt5cntZ/Ru8+IwBZhpVdca5prt44RtBinG6jOWCuFNyD6ZE/ Di4vP+Yf+dVJCLiSSzRWSCioopzZO5k6/J7jRVPX7TCqcN8gBUCVfJHsgcahj0zzXXgeYvdSt4s 4O/T5xW216wwt6s5rQ3karzIaHuoXKuJ56mZtKOvDw2XoFDNI8JSByJlOEdn3LF0Fn6BY4ERSjX aH2G64mpNOshJ/7ezlxEyhy8OYdk2LXn7mU5u8JOwmxAjmzr3aMC9HJ1bJs61p9uhZEj1ThaFxh 1GYYM0ApUckEiqfjru9bZ49v3uCGJyPHYQIHOdbfu5I1MvVa7RGKT09Dj4pQmFs7JZuOhzorcl/ +5X2gIrQebSYK25yDbWh93+Syp/3YkB3IX3Pa+BVM6g== X-Received: by 2002:a05:600c:4e44:b0:4a1:7bd4:d07d with SMTP id 5b1f17b1804b1-4ac1932a2d5mr302022505e9.34.1793706648841; Tue, 03 Nov 2026 03:50:48 -0800 (PST) X-Received: by 2002:a05:600c:4e44:b0:4a1:7bd4:d07d with SMTP id 5b1f17b1804b1-4ac1932a2d5mr302021875e9.34.1793706648260; Tue, 03 Nov 2026 03:50:48 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , Laurent Vivier , Paolo Bonzini Subject: [PULL 09/17] tests/qtest: Fix virtio msix message endianness Message-ID: <8d082458a3abf01babe570f19056b896fa7b14e9.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706709971158500 From: Nicholas Piggin 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 Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-3-uverma@linux.ibm.com> --- tests/qtest/libqos/virtio-pci-modern.c | 4 +++- tests/qtest/libqos/virtio-pci.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/vi= rtio-pci-modern.c index f31b3be656..097b548f95 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, sizeof(data)); + 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 102e45b524..d2b978d4b1 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -131,7 +131,9 @@ 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, sizeof(data)); + data =3D le32_to_cpu(data); if (data =3D=3D 0) { return false; } @@ -156,7 +158,9 @@ 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, + &data, sizeof(data)); + data =3D le32_to_cpu(data); if (data =3D=3D 0) { return false; } --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706680; cv=none; d=zohomail.com; s=zohoarc; b=L9y64FqpAS4Dv06047N87guK8R78lEB3llqi5z/5k9fFSca0x5wCuDngBAqVN4dLpiv7eM3qZUvmwzYkuToHvXY5qu/eApC7JxfgbBbuDrjeGuBFArsH5X8uY7lrlPSEnMOFbncba8oSa2jeGJF4iSshxx3zuMBsW4P0X67IA5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706680; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rshh+tIe6aQJAkNotufAQz4PwuypIOwQej5HS2h/j3o=; b=CrONPWacdxlphA/tG9GfqIwBce7tx3/s3qIVvY/dl2cL9tUhLNHdVr1J9SI5JogVmncvBh1XYuG25UQ0XbWP4ZPVSKM0VhDJhfeHIxbXC3Eq1qEmLa2x/LRC3qxCM6fKsCsVhYks0rJvB6rFqK5hCvIu8mrSC/IXviPENv55P8M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706680576438.9728172713276; Tue, 3 Nov 2026 03:51:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2c-0003vI-5c; Tue, 03 Nov 2026 06:51:02 -0500 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 1xOD2a-0003ua-Mj for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2Y-0000M0-1s for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:00 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-d18wjybaMO2USherxxQnKw-1; Tue, 03 Nov 2026 06:50:54 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48c7fe9736eso3514719f8f.0 for ; Tue, 03 Nov 2026 03:50:54 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ac09bcc967sm249754805e9.3.2026.11.03.03.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rshh+tIe6aQJAkNotufAQz4PwuypIOwQej5HS2h/j3o=; b=RSww2HD7n/wei+3Dx7PgHcjxCV4N+1E3BFEXqCclYd/NSGDsN7lj/jWyVbD4x7HKveZVGq eodVx1R20LkvWW0k6xeKPtN2sFbeEaptcrLhA67FE1dFNXCb14aP4wG7xv0FqAp0zab7As 8jWD1OGstjiv1tK5nSMzm1QFGuj/k8E= X-MC-Unique: d18wjybaMO2USherxxQnKw-1 X-Mimecast-MFC-AGG-ID: d18wjybaMO2USherxxQnKw_1793706653 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706653; x=1794311453; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Rshh+tIe6aQJAkNotufAQz4PwuypIOwQej5HS2h/j3o=; b=mHloRmgv1YHYH34Vu9FDujZ2Ow34JXQy6u8nFCb/5MFX66+WoR1WfCnXDM7cCYN3Ip UQCbIW31KKgE6AR1QBlShMrHNlWvn0hLluPym2XtUC/ylW8EUCRucyMkaXcA/Fa7D+r6 GK5vLjCunFxXeEOk6H7IPPFFqa8ZaAdrXgFnOi5sCJFODBY+eLBhDhUhWZH47Z/DfLg9 ORbOwW38VLRMTo0bTAZu3vF3yc06CYYhw3vIoT3jvaQFLLpxDGUPwLhNKEJs9P79H8gp fdqZ1nJ0hpBXB5vZqWnf6AyvOrBXrmrQWP6ZuUOcUOzg6lvwj6BIk/5sZesOo2AHCrxl oDMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706653; x=1794311453; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Rshh+tIe6aQJAkNotufAQz4PwuypIOwQej5HS2h/j3o=; b=KGU3NV4nNR3Swecuyl5cXR4hTx6s9Iaf1CCeFOk3bfDrvNtjbMSnaA1cFfX9hmvp2r G33UPc1hZ21xW9bAsk7CQvmNYz5kt5ZruzbxdO+UFC511TmL4rIvKYTBN0jn23oG5Zmn uwdjic+VNpXIJpjaEWhS/4e7MQB3EbMWP2A1hPeShQG7CaHrQ8loaE9FkCEc+NsrfYNT OA+5zMOBOp9ykF699sHJaEGY7B5Vc9nWF1fbQQM8w+qktBcVRVK2no1sn2KR+rPqpqWd BBvRnMmqDvaRhqaB0mJuSy4okvcyzxpK0SagkfKFuLj0jY1OWw0x+h1Oh2T0oGJDM62v G1jA== X-Gm-Message-State: APuU4Z9E790GSQ4HM09RZJCS1HGo0oJkbzmMDNj8WZe1eiatscpP7oyu c9Na+I2T39M0djRfe6H/dWzYyteNVyPSzTxCoP8EL/BQyn81H/ErJoXuXP/Jf6ru6ruPLYUr0Oi fNts5cYspPOxj2MlmCqwS+1DTxYkxO+Vbnay5+lo84nP29ZOBuA8w7lMPwYzdcAnr74dXbMrdm6 MHrRhOZ+jDe55vD9AupklAnbJkT+mI0akFgA== X-Gm-Gg: AYBFou0T4+W6FAixlMG262vH5dIB3C8Bb6iA3kpwlx4QuZRt/Pe/lj6mO+5T9Lq2/59 ibyka9HTP+ZQuAlo33rSAy6RRHWOBrMa+Vk3+zAQAsNUvNuvxXavyPbBUVQSMMDYk4d1+Gbauo0 y0ikMIj1Jt4O+ryUopuNvVPy56olkWd2YmM+gjF1+gZpDtlVBscdtxyMlDb+os4wnIS0kg6d329 hPgquYrfKYJtLTBTSRjBsaNo9nfxk+8yYKIdccBbokT5/Kc8vCYcmRu3xObl5V1u3NRNfCm4yox BPHdlZ6Qqb+xps7Qz9r/guS1i9q8QY1Ren27WO9f9Ug5uaXwIwEPYjzvA86LqBqwh8U6p613f/O nGsFgeTTk2WGUZNQ1RHIES97Dha8rCzX06YQXkKbmmQ== X-Received: by 2002:a05:600c:1990:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ac1923581cmr280121095e9.32.1793706652739; Tue, 03 Nov 2026 03:50:52 -0800 (PST) X-Received: by 2002:a05:600c:1990:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ac1923581cmr280120485e9.32.1793706652113; Tue, 03 Nov 2026 03:50:52 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Jishnu Warrier , Utkarsh Verma , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 10/17] tests/qtest: Add libqos function for testing MSI-X interrupt status Message-ID: <599bbb67fed50121cfd7598aac4d2356d132bca2.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706681916158500 From: Nicholas Piggin 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. Make msix_entry to uint16_t to match other MSI-X helpers and validate it against qpci_msix_table_size() to correctly catch uninitialized or out of bounds vectors instead of checking !=3D -1. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-4-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 2 + tests/qtest/libqos/pci.c | 53 ++++++++++++++++++++++++++ tests/qtest/libqos/virtio-pci-modern.c | 31 +++------------ tests/qtest/libqos/virtio-pci.c | 42 ++++---------------- 4 files changed, 67 insertions(+), 61 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 8389614523..d51bf240ee 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, uint16_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 a59197b992..f6db133f6a 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -351,6 +351,59 @@ bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry) } } =20 +/** + * qpci_msix_test_interrupt - test whether MSI-X interrupt has been raised + * @dev: PCI device + * @msix_entry: MSI-X entry to test + * @msix_addr: address of MSI-X message + * @msix_data: expected MSI-X message payload + * + * This tests whether the device has raised an MSI-X interrupt. If the MSI= -X + * 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 + * MSI-X message address to 0 if it is found set. This must be called with + * the MSI-X address memory containing either 0 or the value of data, othe= rwise + * it will assert on incorrect message. + */ +bool qpci_msix_test_interrupt(QPCIDevice *dev, uint16_t msix_entry, + uint64_t msix_addr, uint32_t msix_data) +{ + uint32_t data; + + g_assert(dev->msix_enabled); + g_assert_cmpint(msix_entry, <, qpci_msix_table_size(dev)); + + 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); + } + + /* + * 0 is used as the "not fired" sentinel =E2=80=94 callers must progra= m a + * non-zero MSI-X data value so the pre-zeroed target memory can be + * polled reliably. + */ + g_assert_cmpint(msix_addr, !=3D, 0); + g_assert_cmpint(msix_data, !=3D, 0); + + /* MSI-X payload is written in little-endian format */ + qtest_memread(dev->bus->qts, msix_addr, &data, sizeof(data)); + 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, sizeof(data)); + + 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 097b548f95..0d7d89bbcb 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, sizeof(data)); - 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 d2b978d4b1..ea8114e243 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -122,26 +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, sizeof(data)); - 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; } @@ -150,25 +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, - &data, sizeof(data)); - 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 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706708; cv=none; d=zohomail.com; s=zohoarc; b=b32l9Ned5zFTZuty3w16H/CMIOHSHsReeuyNDAFKGqd5KqTANSKRXErMIkYiHQBme9tUPAm/1ZN3Pzu7qsiPQBFAIPXj8yOyQtSVJyRlJjGXvJTWz6RFFIF4bxZw/Wtt5/6sbbA/0e++rjoPoyZsVjr3V99WpAOERtb3fAYYG60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706708; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lHzGHDO8IKROc4ryf1CkQKtK0sSIGe+ITrTR/Gnd9ck=; b=i45G8sh5+er1ovu2Cw/meIzvphW80km8g6RseFlUpSSCPXpAwbMITK+muMMaGiFnsWV/+Jukj04cx1Ecnajuzydoajn+NDC6CoTq9WPx8SZDDTcJwBUTkPzoKco18v22wOwq7eaEK+dzQkHfeLFuJyj418agHUYdClRpLI10vVs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179370670844010.491354892551499; Tue, 3 Nov 2026 03:51:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2f-00048M-Jt; Tue, 03 Nov 2026 06:51:05 -0500 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 1xOD2b-0003vF-He for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2Y-0000M7-L6 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:01 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-9PeoEWqnOf2g-E9HrMBUEg-1; Tue, 03 Nov 2026 06:50:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48b01a74792so2756401f8f.0 for ; Tue, 03 Nov 2026 03:50:56 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2a96fc87fsm48576075e9.12.2026.11.03.03.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lHzGHDO8IKROc4ryf1CkQKtK0sSIGe+ITrTR/Gnd9ck=; b=gOJsT1HRlzH3F/p8PM4V7QNSKyaVu18xmpwO4NVLWIE1CRdCfwE7i+zOn2zHEiHSWRKBxi B0+y1jnryRjNhY9FIJ/yrSucENT0En8xiK5I+Td37rGInTsENkPSSpeDtbyGsHWjAT3hf1 Qqhw31TMUaCivPcUkIHvUX4M+KU9ktA= X-MC-Unique: 9PeoEWqnOf2g-E9HrMBUEg-1 X-Mimecast-MFC-AGG-ID: 9PeoEWqnOf2g-E9HrMBUEg_1793706655 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706655; x=1794311455; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lHzGHDO8IKROc4ryf1CkQKtK0sSIGe+ITrTR/Gnd9ck=; b=T6blcy1tTGzYjerp3wk6FgMvt3WnkgELGYTuq8rNJM7cGpjZ4TsGSj/Ewexr+fjwkz 9at1hxFotyvpQzlFU7XZofhofApzb6vGooQ7E+tpipi7lZktsvI+kXfXKtAXDRSGvpQn ge85GiMy2E28gROjiPM3cE7s5OyzEDwpjfb9x9iXlaPZ78EwLsZj9fnwJDZn+21gMolK t3HN3YqY+t7lRXPOMjg2fHVS/iImmmr5Bb0JyE7JZpp5Rs2DbLxnzSTvwe8qkaahOvfG 4z038KHZrvLNxjvUKLe9TbFn4gBMQNf2M8pAt0hQCI02YLwi+0dNAgvaRHX9Gzpwze3i GOPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706655; x=1794311455; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lHzGHDO8IKROc4ryf1CkQKtK0sSIGe+ITrTR/Gnd9ck=; b=Q4rdatyriDTPXBLoyeTaWKTeJT7iKTCNyH3gKHogvG28mRZO5WSAvdq2r/LY4zhoIB XSH9/y3/EskZuXOEWRR/u23x06mLE8yi0CJyfHYql0Z6jfwSIhZCe9RiYDUXWZXpqlZb qq9wjNzq1+ixhaj02hteOftRLWar/sTPMLNOhiMwsK36UOKZQFio10S61GZM+acN7Lf5 Vw4q4Gk18oZ3RIJl1DtEK91YFgNa1k2vYpllkv0Bf+JlkTy7OJ5W5Ek+B3kuJeHM8aqY CnvwJ7HC89NekEOQmKn9y5CYUBoa62O1X7tBVL9YoBCHJkLkyoXZ1mGa2bGAVeZcHbLE MvwA== X-Gm-Message-State: APuU4Z/JnEniyBgO8iIs0mbatbH6IK/BRZbiRfac0nSm3ZfTV0MOlspI JtviDMHcue1f57ug5SRE7dM2Yo9WQOkftgriKe3SeuiY+QoIInRr0+EJnN1hz8Pk61OC54qOZDl SH3Cahivxf3x+5w7fIUGAqvtSjd5557aFgrsJ9N485L/Xeki63nteZkU6iCnDxj/qCraNzwvf9/ RgDFnvTfWzkB96ajuS/wbmnMQ69jRsqOQp5Q== X-Gm-Gg: AYBFou3NmwgKjUF0gxotmN55DZHVrXfGPynyvcCPTIEw7GhskEvNKR5r5exj84M1MJx aat90CsvV2Je/qg4kA9zU5nBFqeNeU0lQDmc0uNBivdBzRYQ1V2rk3/09mZNnwkjO5rK+lYiT4+ flLvZ+ErkiZtES6y0VLothdRAG/8/66oqlqg4tgHmrNiLZMHieklvXQ7iN7GOEwWzp+DY7JYcj+ Zmz577rJxpLwrXZQPNAMRjAEsY1/nCE4073dyAKhlPIMpbDHrnAL5lAzIQkGLl4FNgATuwTTMYE 7O6j0ipliFI34s+OGYkG7tSmaScaGHPWSwr2YXDEwo+6by8Q4q87Qh1rFqqAGLHSkseahn+qHYU SCd1Ph2NvWr/FBL/WFfFfc0YNq7MqWRTHDzkJbkpzgA== X-Received: by 2002:a05:600c:b8a:b0:4ab:c447:49df with SMTP id 5b1f17b1804b1-4ac182dca8emr282537995e9.23.1793706655379; Tue, 03 Nov 2026 03:50:55 -0800 (PST) X-Received: by 2002:a05:600c:b8a:b0:4ab:c447:49df with SMTP id 5b1f17b1804b1-4ac182dca8emr282537365e9.23.1793706654751; Tue, 03 Nov 2026 03:50:54 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Utkarsh Verma , Keith Busch , Klaus Jensen , Jesper Devantier , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PULL 11/17] tests/qtest/nvme-test: fix NVMe struct field endianness Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706710588158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Utkarsh Verma NVMe queue structures in guest memory are written and read in little endian byte order, so they must not be byte swapped depending on target endianness. Instead, read using qtest_memread/memwrite with explicit le*-to-cpu / cpu-to-le* conversions. Also, fix the qtest_writel call with qtest_writeb for NvmeIdentify.cns (uint8_t) access. Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-5-uverma@linux.ibm.com> --- tests/qtest/nvme-test.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/qtest/nvme-test.c b/tests/qtest/nvme-test.c index f9395cc252..edf982a111 100644 --- a/tests/qtest/nvme-test.c +++ b/tests/qtest/nvme-test.c @@ -223,10 +223,12 @@ static void nvme_init_cq(nvme_ctrl *ctrl, nvme_cq *cq= , uint16_t db_idx, =20 static int nvme_cqe_pending(nvme_cq *cq) { - uint16_t status =3D qtest_readw( - cq->common.ctrl->pdev->bus->qts, - PHYS_ADDR_OF(NvmeCqe, cq->phys_cqe, [cq->head].status)); - return (status & 1) =3D=3D cq->phase; + uint16_t status; + + qtest_memread(cq->common.ctrl->pdev->bus->qts, + PHYS_ADDR_OF(NvmeCqe, cq->phys_cqe, [cq->head].status), + &status, sizeof(status)); + return (le16_to_cpu(status) & 1) =3D=3D cq->phase; } =20 static int nvme_is_cqe_success(NvmeCqe *cqe) @@ -253,8 +255,8 @@ static NvmeCqe nvme_handle_cqe(nvme_sq *sq) } cq->head =3D cq_next_head; =20 - if (cqe.sq_head !=3D sq->head) { - sq->head =3D cqe.sq_head; + if (le16_to_cpu(cqe.sq_head) !=3D sq->head) { + sq->head =3D le16_to_cpu(cqe.sq_head); g_test_message("sq %p head =3D %u", sq, sq->head); } =20 @@ -298,15 +300,14 @@ static uint64_t nvme_get_next_sqe(nvme_sq *sq, uint8_= t opcode, qtest_memset(sq->common.ctrl->pdev->bus->qts, phys_sqe, 0, sizeof(NvmeCmd)); =20 - #define GUEST_MEM_WRITE(fn, phys_addr, val) \ - fn(sq->common.ctrl->pdev->bus->qts, phys_addr, (val)) + #define GUEST_MEM_WRITE(phys_addr, val) \ + qtest_memwrite(sq->common.ctrl->pdev->bus->qts, phys_addr, &val, s= izeof(val)) =20 - GUEST_MEM_WRITE(qtest_writeb, - PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, opcode), opcode); - GUEST_MEM_WRITE(qtest_writew, - PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, cid), cid); - GUEST_MEM_WRITE(qtest_writeq, - PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, dptr.prp1), prp1= ); + GUEST_MEM_WRITE(PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, opcode), opcode); + cid =3D cpu_to_le16(cid); + GUEST_MEM_WRITE(PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, cid), cid); + prp1 =3D cpu_to_le64(prp1); + GUEST_MEM_WRITE(PHYS_ADDR_OF_FIELD(NvmeCmd, phys_sqe, dptr.prp1), prp1= ); =20 #undef GUEST_MEM_WRITE =20 @@ -344,7 +345,7 @@ static uint64_t nvme_admin_identify_ctrl(nvme_ctrl *ctr= l, =20 GUEST_MEM_WRITE(qtest_writel, PHYS_ADDR_OF_FIELD(NvmeCmd, phys_cmd_identify, nsid), = 0); - GUEST_MEM_WRITE(qtest_writel, + GUEST_MEM_WRITE(qtest_writeb, PHYS_ADDR_OF_FIELD(NvmeIdentify, phys_cmd_identify, cn= s), NVME_ID_CNS_CTRL); =20 --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706770; cv=none; d=zohomail.com; s=zohoarc; b=O4h+iL827+lzKPcOeMRlr2EgOuzI2AT/ZKItTQEY2edFTWJyRlqhImNHOUJ4EIMeTSrpcSXXURUDVWwdFpfrX/TOLBDzLtn8HWqQlkFVvJFT5tzM0TjN12NpVaNCOLfy/TK/KTuRrAVuXLXXm8wtJWIwL0p/T/Bqh0SkQBQAXd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706770; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yQCH9SYugeT5hKKSsRS5jJSKFCmvsBmXHBibJ+Nshmg=; b=HuVhXxJ370QBs88mF9RzfyT2km64Fu6pZZ55x6j1oqmNAXB1xjDa2uxIas7mfpfbg8IzFi4rS5MJFl1HW9TeU6trfKocXDr1MnUlkazI0HHPaKhUI2ThErwgjNrejguC9VCRQQzpET8T9umGxwF18V1vPKuB5dN0fdj/s6KJRAI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706770407772.769367035754; Tue, 3 Nov 2026 03:52:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2k-0004Rg-BP; Tue, 03 Nov 2026 06:51:10 -0500 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 1xOD2i-0004L2-My for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2g-0000Mn-GA for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:08 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-OQPAHvq6Ox6i3KeWwQPaYQ-1; Tue, 03 Nov 2026 06:51:04 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48df730c035so2854237f8f.0 for ; Tue, 03 Nov 2026 03:51:04 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b725b8sm24750840f8f.20.2026.11.03.03.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yQCH9SYugeT5hKKSsRS5jJSKFCmvsBmXHBibJ+Nshmg=; b=hXVu+OwWsk7JByBg0kzd6xVQYr/cXyhxqP9CaNLy1/7CSVR7ZSDCRAypF3o2qGY0tOOS6Y 1tl1tJ3Dxds3xI4NWtCsgPrHskep/uOvduDSZ6igmOjmUrF4BqHabtLl/hVdzo7h0oe0/1 mNv0bnoiOlCA4fA8LsFf09QmKjOC+N0= X-MC-Unique: OQPAHvq6Ox6i3KeWwQPaYQ-1 X-Mimecast-MFC-AGG-ID: OQPAHvq6Ox6i3KeWwQPaYQ_1793706663 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706663; x=1794311463; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yQCH9SYugeT5hKKSsRS5jJSKFCmvsBmXHBibJ+Nshmg=; b=Hdv4MtPhJbgp6TYP8rvc6pUBr6YtAJyC4kkU8nF3DUdX3rJ3fWBldxOlG/Os7GFp/B 8WNzP4xX5GR1Oyw6izGyHtUUgme27Xc8JP3P8rfD0QzVT34/h3nEyiRHQfsgqJFdZuop K+EnWTO/0Hz1XSBcm/L40SSZEgaTMMqsLJ3kpkFVeJJJeWlzsQ+Wl0+gBZE8c071V2s/ q/RTlH/3YxCqMhPNfrQpljLmm44r2pZVe3pZ1AZAl27fuCvWC3TMhDJhN6omkBlkyGhT OA2YdjRKD0pPiKMi4NkXbF8if7ARfNKxrooOPR+JSViLVqQH3jXw/NIMGWA9PRRIgxNI evWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706663; x=1794311463; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yQCH9SYugeT5hKKSsRS5jJSKFCmvsBmXHBibJ+Nshmg=; b=amuefeXFXw7GaBdgdfEF2vfwVzsumsC6QdSTC/0bKAB7gmk6Oqj+uLzkVN5WYRZPaQ ls7tGICnLEVAp3cbjMG7EBbIsEIYOkNIkWI/n7nz9DkRbOOdVRE96yDbVO5Cg7Ua1456 PxeFkhwLAVGvUtXGFd1+PYsjrhFEQ0UCnUERJSfqJ+hwn3V3VlemI3pK0pPqbOQegwgg UrISlm4M2WRnDgm7MgmlD1FXGp6ybJAkhMjaCF3ZJUG94xZyCUxRHfPtF7Ak9Qt1E3J4 VdMLRit9LntonHWRwAn68t/77dAOVhzArvOzYhqZTrDNFSGIVJp6MQBX3TCcOOLEKRnp VpQg== X-Gm-Message-State: APuU4Z+60+eY0g4OPku/t/pJVa+DbnwAcgjfpYOjoupOKQx741PFm3Zm 4bD0LL1A04PoTE0hviR6f54cmxpUAx/JFhgzf+L2YZn0zcoSTA/h+t/TuBmv2kl3spCJE34w38b cUUe2CTue/J7XIxfKsAnSYR7qJGQ1/BY2L/JEVJ8yTPZW1QJopE4ucqb8f6oIWvfFKzMBQwKSab kQE+dtAuNXnu4/JiNRiAZFOWHslE9DRA8m8Q== X-Gm-Gg: AYBFou2lk/HFnJgAYI6coXbSH7D5EuAMMFGBUiHw1op/CTAS0f6ToCVevizX0Wkxto6 dArwtjiaAt0soccG3k/QfBGciMYsgDT48aAMvVtlZm+Af3GKcnK8K3ljIXzpz4nFPlqHAGO9XvM 1jX7YFAeQhP9UTxyPL2QX6j75vx2VSuyO5HQbJ9FFOXdUDgg2G2UzRaLgJX9CR/Ir7lcXrKX+XP jhMeGxkj4uuYBWvaswsk5GZK7/5Gr76+I78kPZQWKaB/yUwsAaHK4IGwYo596BssI0hAUoQ8T8J 6XsNIJHW+0Jt1eYnTTeCOmrvoMPcDsUqVAKZ1gZb40Twig9Rk3CBvX9XHtwcNDlDlnO0hMetoyl hqEfLS3DFkgMoM404iSelYuxmXX9O9L0F3dSiBpJA/g== X-Received: by 2002:a05:6000:4313:b0:48e:679a:4af3 with SMTP id ffacd0b85a97d-48e6e4fcfd7mr29527032f8f.49.1793706663213; Tue, 03 Nov 2026 03:51:03 -0800 (PST) X-Received: by 2002:a05:6000:4313:b0:48e:679a:4af3 with SMTP id ffacd0b85a97d-48e6e4fcfd7mr29526944f8f.49.1793706662451; Tue, 03 Nov 2026 03:51:02 -0800 (PST) Date: Tue, 3 Nov 2026 06:50:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , Harsh Prateek Bora , Amit Machhiwal , Dmitry Fleytman , Akihiko Odaki , Laurent Vivier , Paolo Bonzini , Sriram Yagnaraman , Keith Busch , Klaus Jensen , Jesper Devantier , Stefan Hajnoczi , qemu-ppc@nongnu.org, qemu-block@nongnu.org Subject: [PULL 12/17] tests/qtest: Enable spapr dma with linear iommu Message-ID: <97e4f09a1fcbc73e67f1b36ec1f6ebe2ad3cac9f.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706773517158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin 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. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-6-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 4 ---- hw/ppc/spapr_iommu.c | 10 +++++++++- 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/nvme-test.c | 4 ---- tests/qtest/vhost-user-blk-test.c | 6 ------ tests/qtest/virtio-blk-test.c | 12 ------------ 11 files changed, 13 insertions(+), 90 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index d51bf240ee..c3a0f85fef 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 e6264b0785..5470602ef1 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -22,6 +22,8 @@ #include "qemu/log.h" #include "qemu/module.h" #include "system/kvm.h" +#include "system/qtest.h" +#include "exec/target_page.h" #include "kvm_ppc.h" #include "migration/vmstate.h" #include "system/dma.h" @@ -125,7 +127,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 de9738fdb7..8300bf5a5b 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 3d397ea697..1b3b5aa6c7 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 b77617524c..93cc3b8561 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 147009f4f4..8b79d858bd 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 3723cbb38d..b58cc1b59f 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 f6db133f6a..e9233c81e9 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/nvme-test.c b/tests/qtest/nvme-test.c index edf982a111..09972b50ff 100644 --- a/tests/qtest/nvme-test.c +++ b/tests/qtest/nvme-test.c @@ -493,10 +493,6 @@ static void test_migrate(void *obj, void *data, QGuest= Allocator *alloc) { 333, false } }; =20 - if (qpci_check_buggy_msi(pdev)) { - return; - } - /* create temporary dir and prepare unix socket path for migration */ tmpfs =3D g_dir_make_tmp("nvme-test-XXXXXX", &err); if (!tmpfs) { diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index ea90d41232..3e71fdb9d7 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 722bd0711f..a7e864ee81 100644 --- a/tests/qtest/virtio-blk-test.c +++ b/tests/qtest/virtio-blk-test.c @@ -476,14 +476,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 @@ -586,14 +580,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 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706699; cv=none; d=zohomail.com; s=zohoarc; b=dgxDECqV2u6LJ8PGdg58vYfMJILY76IIr2U0FrBelagyOGoE/C3qoMW1qtbhgMwcsy1QISctOE+cq5qnE2m7ffuJoyPz9/T2XLGm3HFNpV3ZkKl87vhLRagQcw0VH1jwaPpQ4ZG4q7A609rEpVFryjBCE+HltyzQ31gFuUq4s1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706699; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VKqxlI/UASRAYwg9QvB0xV8ul06yjEI6yc9Z7vxiWlw=; b=TDj+uXJLVMvfORX+yQgKaaG4lW01QlPMyQYm4HnobSgWXgCBonV1j/VxYKRMoiKo1w1CvHNtkAQlomLJ7Ey6G1HcJL1OvTYGtCzt5Zfejdi2rjh5R/kPT4fuZ2aEnkHhGp3EfD5NW9N+Cj5ncx0vz0a2g31OysbXMYuHmGW4+qE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706699529767.9678091000261; Tue, 3 Nov 2026 03:51:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2o-0004lZ-Mw; Tue, 03 Nov 2026 06:51:14 -0500 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 1xOD2m-0004bI-73 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2j-0000N8-Ac for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:11 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-taNxD8_eOXWJyHTpTgkBlA-1; Tue, 03 Nov 2026 06:51:07 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48e0c896d05so3465242f8f.1 for ; Tue, 03 Nov 2026 03:51:07 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71a4d4f9sm25011883f8f.2.2026.11.03.03.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VKqxlI/UASRAYwg9QvB0xV8ul06yjEI6yc9Z7vxiWlw=; b=I9Xr7Z8RHvUoxG06Xkw8j9x6Z4c5wIJrFxc7F858MHaUSaxI2Hroc16abYujZWK4nWuYws XxEapExqvDDDngDRNJzhFDLRn/Nw/4C3Mrd/0FOL7aAHN+aACjVktKhrphGKcLLpNLqsRg GcnK5q8cAmPxuBqKL/ET55G+QihluFo= X-MC-Unique: taNxD8_eOXWJyHTpTgkBlA-1 X-Mimecast-MFC-AGG-ID: taNxD8_eOXWJyHTpTgkBlA_1793706666 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706666; x=1794311466; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=VKqxlI/UASRAYwg9QvB0xV8ul06yjEI6yc9Z7vxiWlw=; b=FT+i9P29/otoAKQwxpJJwXiPLNa2eoPzTiJZKt84lzULq1xxZeIofTwnwlqLPEMlN4 LhhShO101w8Xrqam15xXLL502lJ/vAynm9v/YKfLoyNJUBPzbjtm2R68j+9GQcckqWHM rSdM4nu7g3OyduYbOYC7t192106/vf34K/rYdaVXQXdSS6KD6ojlOIj/uhJT5Pc/aL39 esIAg2BijPpQkFYY6Hv0BJsz/vdGKDcGUMJf9I3Zl/uy6sYF+oYoUmc2a4jyW4rxj7gh Fk8iMgms/5jxD46RRhUbsAfPbnw71nKDct+UXnU6ubMuhlURb1t/dbbQeVjCY824Z1bG LU3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706666; x=1794311466; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VKqxlI/UASRAYwg9QvB0xV8ul06yjEI6yc9Z7vxiWlw=; b=2GwzcO5b5vLTO5a6vC6+W48zd7V8qZkNwqAi582FKZMLrfHIDYL2AzrgU7vzoY1BMc ol3CVov5jWA9VJae2HwBtZC3Ac6eDFCcayRBvL7vYPCz04YziZWGX7dOCKFHjohm6py1 3JmCpNa0YO7gWmq21DREX2YeHhNUmWXa89HAdomDaCiAB8SgGY0J7jXC+ziVxqGeemRd YvOyTKvFlM/vYdLMc0wFg14eQ06CmsVYnnQhtTaLRkbBfka2tdTZb8TOUPoiHvWHpw+G h3x425TbqfndvSHasskknB8AoaE8tqyMqyVOwLsNOCyRQ1hVGfyDx7PRJUEG7f9rQq9i vReA== X-Gm-Message-State: APuU4Z8QSSg60EN7excjXanfPWXh4Selg/MHvrPxNnDjzqp+NY1EaURH HqyexG0p3Utkdyuo1iQljcup3lFJbiZGAPue6bVGUosgewEM/++piPSLSJL37XMhyNYILx51ePW SsfvsYcFo4HSOynLu2vS6G+p10B7xHsmorit5SXQLKg+BH402EKmHrtBGOtyPcpZ8lRn8oDHJxH rqo73C4UFuDnlm5H/ctVBdnIMFGkGN01IcIQ== X-Gm-Gg: AYBFou1AS3m8QtnzB7vhpUworqLX41mUnu1jgkeThyHtUPuWio8L2pM9eYKfgwIRJqf v8kxJk2uoJY9gtn8R7AndVvPU5sIkWqpAxoqpRhu536Y8f8Uq17DSgS63FHp+lTbcXGBJT4hjtw usnxiaH0AiqrSCb3kK78BcWiJxgrozRprO/X6Mk/R4VF7WMbaIy3o4g7v6r+Yb1Ynn7AxosSM/R M48N7FNjraIYZ/x8tPQanDO3SKIHTKKi0L6qZqFzZlc2S/fObO4XSrGehZ7tZ3cbdd91M0YGUz5 nFelxz3vRMFLLWsd0T9i4WOY0LqnKGN3l7uzQ0x3whq8uWlEJBQwOlSWKSBFJT2FyGP/445TLLC jnaVeSy8f/NNlJ8TOFGTXyanM66hoo4C2QS6eu8Gtvg== X-Received: by 2002:a5d:59c4:0:b0:48e:3085:425f with SMTP id ffacd0b85a97d-48e6e2dbbdamr30505940f8f.2.1793706666161; Tue, 03 Nov 2026 03:51:06 -0800 (PST) X-Received: by 2002:a5d:59c4:0:b0:48e:3085:425f with SMTP id ffacd0b85a97d-48e6e2dbbdamr30505879f8f.2.1793706665604; Tue, 03 Nov 2026 03:51:05 -0800 (PST) Date: Tue, 3 Nov 2026 06:51:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Marcel Apfelbaum , Akihiko Odaki , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , John Snow , "Denis V. Lunev" , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PULL 13/17] tests/qtest/ahci: unmap pci bar before reusing device Message-ID: <0ca8f676d5f334e3c1d2c4b93dd7c8ad695320c5.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706702415158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin ahci-test double-maps the hba bar in the pending_callback test. Unmap it first, to keep iomaps balanced. Cc: Michael S. Tsirkin Cc: Marcel Apfelbaum Cc: Akihiko Odaki Reviewed-by: Akihiko Odaki Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-7-uverma@linux.ibm.com> --- tests/qtest/libqos/ahci.h | 2 ++ tests/qtest/ahci-test.c | 6 ++++++ tests/qtest/libqos/ahci.c | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/tests/qtest/libqos/ahci.h b/tests/qtest/libqos/ahci.h index 6d861c79ee..f098c91b47 100644 --- a/tests/qtest/libqos/ahci.h +++ b/tests/qtest/libqos/ahci.h @@ -580,7 +580,9 @@ void ahci_clean_mem(AHCIQState *ahci); QPCIDevice *get_ahci_device(QTestState *qts, uint32_t *fingerprint); void free_ahci_device(QPCIDevice *dev); void ahci_pci_enable(AHCIQState *ahci); +void ahci_pci_disable(AHCIQState *ahci); void start_ahci_device(AHCIQState *ahci); +void stop_ahci_device(AHCIQState *ahci); void ahci_hba_enable(AHCIQState *ahci); =20 /* Port Management */ diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index c49aa61862..043a916fdd 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -85,6 +85,8 @@ static void verify_state(AHCIQState *ahci, uint64_t hba_o= ld) uint64_t hba_base; AHCICommandHeader cmd; =20 + g_assert_cmphex(ahci->hba_bar.addr, =3D=3D, hba_old); + ahci_fingerprint =3D qpci_config_readl(ahci->dev, PCI_VENDOR_ID); g_assert_cmphex(ahci_fingerprint, =3D=3D, ahci->fingerprint); =20 @@ -198,6 +200,7 @@ static void ahci_shutdown(AHCIQState *ahci) { QOSState *qs =3D ahci->parent; =20 + ahci_pci_disable(ahci); ahci_clean_mem(ahci); free_ahci_device(ahci->dev); g_free(ahci); @@ -1457,7 +1460,9 @@ static void test_reset(void) CMD_READ_DMA_EXT, CMD_WRITE_DMA_EXT); ahci_set(ahci, AHCI_GHC, AHCI_GHC_HR); + stop_ahci_device(ahci); ahci_clean_mem(ahci); + start_ahci_device(ahci); } =20 ahci_shutdown(ahci); @@ -1523,6 +1528,7 @@ static void test_reset_pending_callback(void) sleep(1); =20 /* Start again. */ + stop_ahci_device(ahci); ahci_clean_mem(ahci); ahci_pci_enable(ahci); ahci_hba_enable(ahci); diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c index 50b63239c2..a709558aac 100644 --- a/tests/qtest/libqos/ahci.c +++ b/tests/qtest/libqos/ahci.c @@ -206,6 +206,11 @@ void ahci_pci_enable(AHCIQState *ahci) =20 } =20 +void ahci_pci_disable(AHCIQState *ahci) +{ + stop_ahci_device(ahci); +} + /** * Map BAR5/ABAR, and engage the PCI device. */ @@ -218,6 +223,12 @@ void start_ahci_device(AHCIQState *ahci) qpci_device_enable(ahci->dev); } =20 +void stop_ahci_device(AHCIQState *ahci) +{ + /* Unmap AHCI's ABAR */ + qpci_iounmap(ahci->dev, ahci->hba_bar); +} + /** * Test and initialize the AHCI's HBA memory areas. * Initialize and start any ports with devices attached. --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706707; cv=none; d=zohomail.com; s=zohoarc; b=XcAHqwJXtbGAo4X7ZKNRVEM+ZrVMnlkDR59g4A+oecpYjl9My+DIAb1FtiI2D7dn1v11+wkB2P80QMl2GjUKF8akoH1sECGa5o6eiweLIx51T/aMPaTFJKPVgiNccNfSOVTFcrkwaLd4XI5l33Qb8qVqI5UtyJFpQ81CBXjGnFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706707; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=99ub510hspfjTNbRaNnKOoklgZRp2udwZpVPiomHk3Q=; b=l2Aje47tRNckE7plWT+t6xs+hx/PLHRnxRih0dvEjspEgu64DtGreg5K3QOoM4D0gdqPcthO0h4H3sndq5bPP90WkjP+Bp6NLoRCzqw9KaxkqbwArWeGmKL5lyRsA9s8Q0V/jk3RjFt3XBYX2g/hM8avy2mKIhUqfihbcoSWuRs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706707705627.1375393644905; Tue, 3 Nov 2026 03:51:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2s-0004zh-Ja; Tue, 03 Nov 2026 06:51:18 -0500 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 1xOD2p-0004sw-Gp for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2n-0000Nx-S3 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:15 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-dLeiZGywMTqERpDYHVg_cw-1; Tue, 03 Nov 2026 06:51:11 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48df5b058ddso2686277f8f.0 for ; Tue, 03 Nov 2026 03:51:11 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b80ecbsm25280492f8f.35.2026.11.03.03.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=99ub510hspfjTNbRaNnKOoklgZRp2udwZpVPiomHk3Q=; b=bmfzcp4sQjqw+2Mt26waxHN6MTb+40o5p3uhtBVBfJ7keOMeiYaXsBp+cn/DV16mII3G58 jeLwxyUfG7gfN7E3GrQa2U93Dl39+wFCGxp4Uy+qOmCgOBGAORrtHPCWiJfCOThRrx2nc2 kSCL0LOR4A1rf7GzxK3n4qk7KQ9FW5c= X-MC-Unique: dLeiZGywMTqERpDYHVg_cw-1 X-Mimecast-MFC-AGG-ID: dLeiZGywMTqERpDYHVg_cw_1793706671 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706670; x=1794311470; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=99ub510hspfjTNbRaNnKOoklgZRp2udwZpVPiomHk3Q=; b=ZFC465lB7O8ra04ScduDcDRo9YuGGVViK3B+i7EOkSo7Y6JOMYDgrs4V6Tiw8k6t5E 5YxL7r4IF6UPgDIn7AAhKg+4ZVizMz5/TlOko9dRBJbVTy40J/DiPo1E9Oq9PYQlOqX8 sNbdayPAOIu/YXWNWCgiyFvehHTYjLKM0lbuxdxBe2YmVoYEsutv2XP2V3UC5ZmN7/EX KfFPsxsJkQrv4mCnW1DDHLpNL/M8uzX9NMQNi77ApvyXV9bCj8L2rKUqhwTjel8Ozp/O SUGtaEadqiv8xEamZ1Dgg5WV821TnwTj7i/SD6m/WF0cFtKfUShXitxjUeV7hGq71cPu 4Qnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706670; x=1794311470; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=99ub510hspfjTNbRaNnKOoklgZRp2udwZpVPiomHk3Q=; b=otPnhJBflR+CuwLD6kNCa/wAPYYnB8/Omgi1EW2kkElUeYhW88R3u/C/2wuJ0mZAB/ aGLRuSq4bQ/v7s50NB6AKF7wLoA5o8fbuDwl7smQEV7am3mgFOsaAiU5Ir/FGSXO4Lja 2R2Xu1gpdhjBsebrnbh8vjCyr0zDGCPVyfxEttkE6jEYpxpKn/2iwD5XB57SzFfsdRV8 OW7Y9ZQsrXEG5d+11gsWujFKjENRg/llOuIxG++S635orh657bjjYLR4cU9KTXAF1FId NTu3c6O4fehopcEL9o1iURqMq0Y6Fj7CPdoZosRhQiY2PWCb8JM5bFFfJXFlvReL7s2t aWhQ== X-Gm-Message-State: APuU4Z8UrCKIYjly8xlAewDrOA+h400gqYsFML3uSF+kRhojYarJbNNk GqqiD9ABwIzPnjHdX5d4Bz+krINc2LFH1uoKJnAmzTqsBVdLKY124ZCZJoJ2sQ0tr/xgXRXzRFK phH8jRYb9CNjDbPWSTn33A3726hvroftYzEkN56ImifPaxF34AYVwoaPHqf1aQuNqdQTYrxxUEa 9GcW0D810Hk4bM7BJOgq1bAp+udCfv+tlyaA== X-Gm-Gg: AYBFou0gbBhvJ784ghqd8YbJORGa/n0oOknNJBkh7DswRDyk61xVAJ7WF4ywaW69LPR 3YDnPdemK2Zg9OFey7aa2tYe3cGJbHKEl4DPwEgXbaMt0fX+zqWkEMytU0eyFZGfBc12VFy3nK6 QvFRQPj9AIBIyBmyQBPPXUkQkI3SqpJR5wUzoEM/V1WoM+8UYFJLlXqu58ohNeXoXf5l+aeiCUE n/mo+de7Ito/iMGhYxpZ1rGXYvShNaZOwk5F4ZnTK5T28L3RA38w1FeIs1Yy9y9dN92PoWts4jM BwzdD5KxVKBE/8CBjy1RokY3r0KgdbjAzjyIUcxco47UBfvV3XHthuoBMSgv+Yeas4rq1FOnUpF mWFqslMVlYuDSIqSNa54OKRF8xKZfIS0TmpBKDDSXnA== X-Received: by 2002:a05:6000:46c5:b0:48e:5db7:fd6c with SMTP id ffacd0b85a97d-48e6e2bde59mr17109050f8f.4.1793706670350; Tue, 03 Nov 2026 03:51:10 -0800 (PST) X-Received: by 2002:a05:6000:46c5:b0:48e:5db7:fd6c with SMTP id ffacd0b85a97d-48e6e2bde59mr17109018f8f.4.1793706669743; Tue, 03 Nov 2026 03:51:09 -0800 (PST) Date: Tue, 3 Nov 2026 06:51:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Akihiko Odaki , Jishnu Warrier , Utkarsh Verma , John Snow , "Denis V. Lunev" , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL 14/17] tests/qtest/libquos/pci: Add migration fixup helper for pci devices Message-ID: <4de39eb9370b7518c3c8e6668e73b88e5c7efb20.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706710572158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Migration tests can create new QPCI devices for the destination machine which may need to take on some state of the source machine after destination is complete. Add a migration fixup helper and call it from ahci and nvme migration tests. This is currently a noop and will be used subsequently. Reviewed-by: Akihiko Odaki Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-8-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 1 + tests/qtest/ahci-test.c | 1 + tests/qtest/libqos/pci.c | 4 ++++ tests/qtest/nvme-test.c | 4 +--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index c3a0f85fef..cfb7c17dd3 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -120,6 +120,7 @@ void qpci_memwrite(QPCIDevice *bus, QPCIBar token, uint= 64_t off, const void *buf, size_t len); QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr); void qpci_iounmap(QPCIDevice *dev, QPCIBar addr); +void qpci_migrate_fixup(QPCIDevice *to, QPCIDevice *from); QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr); =20 void qpci_unplug_acpi_device_test(QTestState *qs, const char *id, uint8_t = slot); diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index 043a916fdd..291f29e762 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -137,6 +137,7 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *= to, const char *uri) memcpy(to, from, sizeof(AHCIQState)); to->parent =3D tmp; to->dev =3D dev; + qpci_migrate_fixup(to->dev, from->dev); =20 tmp =3D from->parent; dev =3D from->dev; diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index e9233c81e9..e78dd4d4c7 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -625,6 +625,10 @@ QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t ad= dr) return bar; } =20 +void qpci_migrate_fixup(QPCIDevice *to, QPCIDevice *from) +{ +} + void add_qpci_address(QOSGraphEdgeOptions *opts, QPCIAddress *addr) { g_assert(addr); diff --git a/tests/qtest/nvme-test.c b/tests/qtest/nvme-test.c index 09972b50ff..dfa59cfbce 100644 --- a/tests/qtest/nvme-test.c +++ b/tests/qtest/nvme-test.c @@ -517,8 +517,6 @@ static void test_migrate(void *obj, void *data, QGuestA= llocator *alloc) test_migrate_setup_nvme_ctrl(ctrl); test_migrate_send_nvme_reqs(ctrl, test_reqs, ARRAY_SIZE(test_reqs)); =20 - qpci_iounmap(ctrl->pdev, ctrl->bar); - dest_cmdline =3D g_string_new(qos_get_current_command_line()); g_string_append_printf(dest_cmdline, " -incoming %s", uri); =20 @@ -528,8 +526,8 @@ static void test_migrate(void *obj, void *data, QGuestA= llocator *alloc) /* Get access to PCI device from destination VM */ nvme =3D qos_allocate_objects(to, &ctrl->alloc); pdev =3D &nvme->dev; + qpci_migrate_fixup(pdev, ctrl->pdev); ctrl->pdev =3D pdev; - ctrl->bar =3D qpci_iomap(ctrl->pdev, 0, NULL); g_assert(pdev->bus->qts =3D=3D to); =20 /* Migrate VM */ --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706709; cv=none; d=zohomail.com; s=zohoarc; b=NDiLiq/XvN7DXoXHRECJrRlaICAMLIqoxLi9BO3lo5YA3asYLF4ywmdxZWpR7j/YgaBVXs2hcrz41qqtGfBMpC4HJwpKA0tYIdznjFOgSMgHmXW5K/9aQZo/XICDy9nEyFXEMMtnkoTjb6Df9w+j/2g7yGc0VfBReZxmq/6XTS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706709; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Vh/HExgeMIX4Em0/d9K1PmkLbGHVgRKObwEntphz+ug=; b=Jd1O8KenA218f4r9vbpXhe1TvTsedNuWBhYAEUGTL3Oilz/v+WFHo7jOOFM7OpoXhPrTTb4udBHg/9Rr+SRPXsLxy0Jqio4UF6+Owub5Az8cCX6jhCYsOcapLfQziK3dVfbwivS3LS/op2EjADDtQOSieGCz1q0B5mGyXbVo86s= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706709544380.0600037545719; Tue, 3 Nov 2026 03:51:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD2x-0005M2-PE; Tue, 03 Nov 2026 06:51:23 -0500 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 1xOD2v-0005I3-Tr for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2u-0000Ol-2c for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:21 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-NDPUhed4Pxa3Vt2puJzWvg-1; Tue, 03 Nov 2026 06:51:16 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a009f82bedso31753725e9.0 for ; Tue, 03 Nov 2026 03:51:16 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2a80e0fe6sm59972555e9.1.2026.11.03.03.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vh/HExgeMIX4Em0/d9K1PmkLbGHVgRKObwEntphz+ug=; b=J+Olz1VagGIQApFonXs3L9aSWpXHF1MWH3ZHPsTbgOdSVji7HHZh+fmvyq7lEAMFL9wVRf dXk2qU9YrQhMZJpCW/OSHB7Erg1476J16x8x/2cqDkqB0znOXAw0Xm3NDRorhf4wnlpscs 6qhPEjjpoI8ezwVdq3fqmB8m8hwctNU= X-MC-Unique: NDPUhed4Pxa3Vt2puJzWvg-1 X-Mimecast-MFC-AGG-ID: NDPUhed4Pxa3Vt2puJzWvg_1793706675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706675; x=1794311475; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Vh/HExgeMIX4Em0/d9K1PmkLbGHVgRKObwEntphz+ug=; b=BTX1aOKfMGhkqvVeu0i70Z42QF8TgAMDcpFUI3S+d1EZ2bXcpfoLyWoB2nqsapoR1J ljYk71z+yq2aaDH3+TOsjO1xI+r8A27Z9QgWLq6h0Q5ADIwF6tamnn+xBzpIB5mvCMOE 0Qow3WzX28yzhlcprn5hVEaPlXEyN8Q2FLi+qH6sLFVezLZKZuQs9+bth/kK/CRqQgzG z7BlLzB4pn1w7/AhqQSMrRIIcX7EYO0it8EpaV2JKhQorHioxKHVX48GAH/728rGGvk8 jPoTydeoLt6jcWf1xdOZHZZT2KnrliNFbe/tnCvgkaWuauqmJTTFS8uazS0Zgx4E6mnL 0afg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706675; x=1794311475; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Vh/HExgeMIX4Em0/d9K1PmkLbGHVgRKObwEntphz+ug=; b=jpYxKM2CCKKPmquep4KLJSBkuHB8DqcqwTOcdx2cVBwClket62G8oH7TCPuJEgw3R9 OYcKVghiswgzxpoFnNoRjup1eokuJtuke18R2biIE8NNbU/SuBKdefdub8QNSLemQOsj IecXDpRyRhVBc9AUFehR2l4q7Sygw/Cpn0dMuwmGJ//aHfdEFjLOlOwGQxcAIo1GatSP 3dOVkMtPIdYLG0yd+hcyO4cSkmI1fn1NT+qGdNNfxW5h7/5D+ci7PPBWSd+XD+QlglmA P3e60nxycha/vOkCUtkK8c70628/wHNvq2oxe7Riuch9+94abGz27ByFS+/BXeatO8CD 367A== X-Gm-Message-State: APuU4Z/XTNw0iuYDipLsml2KO7WzbaZj2SAf5lU8HXSzfOkzgfHNsYK6 LM2cIfM56XAafCWlmL99V0gVaqtCenE97KUrRRVRdEa8HCgQ4FYxXpb6mKQ2pKlY6unbZNditsX BQO9OzmGTPc7NsUADlGsAH1SNIdjNTVICK/rP3vPObpq5JcHRMhhBufgTCWQTpcaV3ojVwvDowz RxsN4tAn2Y97fQOzCv8lTAP3jv8n6hHLsSPw== X-Gm-Gg: AYBFou0wJQXa5Np0HUfZtxVIf6RDAW8mRuAXYFOOKF5NBPY4+5+35CyxaFd7KCvhCqJ q+ioxpiFrg2UPUA2szE/2PGTfnZgN0QVUyltFmppZd1bMgOyEEkvEzqrdbkUUJUEWVK/jlH+O7p vpGnb5SNxrzMDCsVSdSq7UtKNS3+8mtv1CiwpkEhNJnx8jXfeo8DLcSZnvlpZvcqDkYMO0w9EBt 2DbI4BTD2doMptKsn1ebknIh/ilqoMx6grGx72V4SVi2/JAORNE5S5w9mrnYFVfudq7mbeDaHVg HtbzJeyADElFOroUfUx8QjTsbUpdjCc4A23o8pS5kN2uxcKkPqLEW4xxqqnwTqL/8FxkrljDksW Ewlh2VNpTpD1PVn5dJbYlAQ9LahPrFoRyApFwQLphGA== X-Received: by 2002:a05:600c:c171:b0:49c:fa20:cbfd with SMTP id 5b1f17b1804b1-4ad739eb30fmr212353555e9.20.1793706675016; Tue, 03 Nov 2026 03:51:15 -0800 (PST) X-Received: by 2002:a05:600c:c171:b0:49c:fa20:cbfd with SMTP id 5b1f17b1804b1-4ad739eb30fmr212352935e9.20.1793706674338; Tue, 03 Nov 2026 03:51:14 -0800 (PST) Date: Tue, 3 Nov 2026 06:51:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Marcel Apfelbaum , Akihiko Odaki , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , John Snow , "Denis V. Lunev" , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PULL 15/17] qtest/libqos/pci: Enforce balanced iomap/unmap Message-ID: <19fd038a6b741fb925ad95bb608923111cb32bfe.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706710175158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Add assertions to ensure a BAR is not mapped twice, and that only previously mapped BARs are unmapped. This can help catch bugs and fragile coding. Cc: Michael S. Tsirkin Cc: Marcel Apfelbaum Reviewed-by: Akihiko Odaki Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-9-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 10 +++++++ tests/qtest/libqos/ahci.c | 3 ++- tests/qtest/libqos/pci.c | 57 +++++++++++++++++++++++++++++++++++---- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index cfb7c17dd3..2f9555ae4e 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -58,12 +58,22 @@ struct QPCIBus { struct QPCIBar { uint64_t addr; bool is_io; + bool mapped; }; =20 +/* + * hw/pci permits 7 (PCI_NUM_REGIONS) regions, the last for PCI_ROM_SLOT. + * libqos does not implement PCI_ROM_SLOT at the moment, and as such it + * permits 6. + */ +#define QPCI_NUM_REGIONS 6 + struct QPCIDevice { QPCIBus *bus; int devfn; + bool bars_mapped[QPCI_NUM_REGIONS]; + QPCIBar bars[QPCI_NUM_REGIONS]; bool msix_enabled; QPCIBar msix_table_bar, msix_pba_bar; uint64_t msix_table_off, msix_pba_off; diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c index a709558aac..53a98bd6cb 100644 --- a/tests/qtest/libqos/ahci.c +++ b/tests/qtest/libqos/ahci.c @@ -225,7 +225,7 @@ void start_ahci_device(AHCIQState *ahci) =20 void stop_ahci_device(AHCIQState *ahci) { - /* Unmap AHCI's ABAR */ + /* Unmap AHCI's ABAR (no-op if not mapped) */ qpci_iounmap(ahci->dev, ahci->hba_bar); } =20 @@ -250,6 +250,7 @@ void ahci_hba_enable(AHCIQState *ahci) uint8_t num_cmd_slots; =20 g_assert(ahci !=3D NULL); + g_assert(ahci->hba_bar.mapped); =20 /* Set GHC.AE to 1 */ ahci_set(ahci, AHCI_GHC, AHCI_GHC_AE); diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index e78dd4d4c7..365fde1fb9 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -79,12 +79,17 @@ QPCIDevice *qpci_device_find(QPCIBus *bus, int devfn) void qpci_device_init(QPCIDevice *dev, QPCIBus *bus, QPCIAddress *addr) { uint16_t vendor_id, device_id; + int i; =20 qpci_device_set(dev, bus, addr->devfn); vendor_id =3D qpci_config_readw(dev, PCI_VENDOR_ID); device_id =3D qpci_config_readw(dev, PCI_DEVICE_ID); g_assert(!addr->vendor_id || vendor_id =3D=3D addr->vendor_id); g_assert(!addr->device_id || device_id =3D=3D addr->device_id); + + for (i =3D 0; i < QPCI_NUM_REGIONS; i++) { + g_assert(!dev->bars_mapped[i]); + } } =20 static uint8_t qpci_find_resource_reserve_capability(QPCIDevice *dev) @@ -554,21 +559,31 @@ void qpci_memwrite(QPCIDevice *dev, QPCIBar token, ui= nt64_t off, dev->bus->memwrite(dev->bus, token.addr + off, buf, len); } =20 -QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr) +static uint8_t qpci_bar_reg(int barno) { - QPCIBus *bus =3D dev->bus; static const int bar_reg_map[] =3D { PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_1, PCI_BASE_ADDRESS_2, PCI_BASE_ADDRESS_3, PCI_BASE_ADDRESS_4, PCI_BASE_ADDRESS_5, }; + + g_assert(barno >=3D 0 && barno < QPCI_NUM_REGIONS); + + return bar_reg_map[barno]; +} + +QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr) +{ + QPCIBus *bus =3D dev->bus; QPCIBar bar; int bar_reg; uint32_t addr, size; uint32_t io_type; uint64_t loc; =20 - g_assert(barno >=3D 0 && barno <=3D 5); - bar_reg =3D bar_reg_map[barno]; + g_assert(barno >=3D 0 && barno < QPCI_NUM_REGIONS); + g_assert(!dev->bars_mapped[barno]); + + bar_reg =3D qpci_bar_reg(barno); =20 qpci_config_writel(dev, bar_reg, 0xFFFFFFFF); addr =3D qpci_config_readl(dev, bar_reg); @@ -611,12 +626,40 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64= _t *sizeptr) } =20 bar.addr =3D loc; + bar.mapped =3D true; + + dev->bars_mapped[barno] =3D true; + dev->bars[barno] =3D bar; + return bar; } =20 void qpci_iounmap(QPCIDevice *dev, QPCIBar bar) { - /* FIXME */ + int bar_reg; + int i; + + if (!bar.mapped) { + return; /* bar was never mapped; no-op */ + } + + for (i =3D 0; i < QPCI_NUM_REGIONS; i++) { + if (!dev->bars_mapped[i]) { + continue; + } + if (dev->bars[i].addr =3D=3D bar.addr) { + dev->bars_mapped[i] =3D false; + dev->bars[i].mapped =3D false; + bar_reg =3D qpci_bar_reg(i); + qpci_config_writel(dev, bar_reg, 0xFFFFFFFF); + /* FIXME: the address space is leaked */ + return; + } + } + /* + * bar was not iomap()ed; treat as no-op for callers that may + * call iounmap unconditionally during cleanup paths. + */ } =20 QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr) @@ -627,6 +670,10 @@ QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t ad= dr) =20 void qpci_migrate_fixup(QPCIDevice *to, QPCIDevice *from) { + memcpy(to->bars_mapped, from->bars_mapped, sizeof(from->bars_mapped)); + memset(from->bars_mapped, 0, sizeof(from->bars_mapped)); + memcpy(to->bars, from->bars, sizeof(from->bars)); + memset(from->bars, 0, sizeof(from->bars)); } =20 void add_qpci_address(QOSGraphEdgeOptions *opts, QPCIAddress *addr) --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706740; cv=none; d=zohomail.com; s=zohoarc; b=OyRQf5gzBATXPqSMOFa3zxux8I7FBiwXCUwVH+lLo2NDJJXUdSmt4ubSC+Xs1IfsyWtByWgduygnBxTQG13Iop7HJGy9Ha+1jmmYCI3fn6DX+O6j+nAS9oAObdRUI2tG3ZBhJZ767xwdxUwPYGSEB7Jrb/EGUXFbiv2TrFWiKtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706740; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=R8RjRqZq+zwdRtCWfwySynm5xd1MEW7N/hnP/GKOxA8=; b=OmbqwuXxEDuzWemHGgynLL6JcJofdic9+fsVBAEJ4QVWxp80CYaFDYG821UB9AW3R8Rt9Ob4alCA3m3gP2diwNlgOVGJQlMVs4iazfpSB7cGxF7AOt3Ydh8ZR9AaCLliGQN/z+AfOj1wDsRtKvpPQ7X1wiYM1ppP9by1+qvndiA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793706740178539.2707895875938; Tue, 3 Nov 2026 03:52:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD30-0005TZ-3l; Tue, 03 Nov 2026 06:51:26 -0500 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 1xOD2x-0005Ld-DQ for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2v-0000Or-6k for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:23 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654--uzPgEnIOoSLDYdNDeMADQ-1; Tue, 03 Nov 2026 06:51:19 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48af4a0bd0fso2274506f8f.2 for ; Tue, 03 Nov 2026 03:51:19 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b7815fsm25315109f8f.22.2026.11.03.03.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R8RjRqZq+zwdRtCWfwySynm5xd1MEW7N/hnP/GKOxA8=; b=f/RfjwpWNf8dRTQQb1pgc8vR//mOnpkj9oxSS34jnDArO5EjwYZfVRacvL+XOW3k5tnauP Xh/SvSApiTbW6pvkxUocgnSJyHWmXmkf21UHDWsfQCZX36/ShqGcFiVeQ+pVHeDMd5pwCY l3TT2UjXOyUwTOrVbWd8aAEkWkYtKr4= X-MC-Unique: -uzPgEnIOoSLDYdNDeMADQ-1 X-Mimecast-MFC-AGG-ID: -uzPgEnIOoSLDYdNDeMADQ_1793706678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706678; x=1794311478; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=R8RjRqZq+zwdRtCWfwySynm5xd1MEW7N/hnP/GKOxA8=; b=gWe5Bq1Zi7Su/qV6M/fVUqpia2yfVaQO7M2N+7dJX1nXkuSlDPpI4O9rYPBk9pGXFd bQ+vPdUlBxfyYY3q9iXdKKBMJQsC40ay7ylLdHdZIYik4qJSRgpppYqEHgm5ggSn8Lnv 5gaxRTq0CfW9pPNh0ZADdOCVKXnZMsZB7lq3dIosFgYoy9/ra0XLE13kCYl8v+v9KDqQ o9nwWeUGnkCdroh3Ff2rovmbFae+eeDn4QypBPv/8v1z0VnY751UYoTVcCDx3UJuKQim VXQZ6QjtTofns3IPkBIZNlUPlE1FnTdOXXMnYV9p9dBZEhaXe+9PV3uW6AeuL9cGXwd5 WYwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706678; x=1794311478; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=R8RjRqZq+zwdRtCWfwySynm5xd1MEW7N/hnP/GKOxA8=; b=HgeyrMHv2Be5wGZnJqNJ3w9ndtoPV6iZXl9Zx24KzQENXApdThacHbSYiyu7A1lv3w 3uur6wrXFBhZDB4DiEisGW6B8S2FTR+aJbf0XHlHW92hQ41esjzKu4d5gXY0OVuuF38h 7NB9oqNjTQbaoZwEtCOQW/5TsM89dZMyZNqSR9U7SV1HdCtznVs2DE2pwYWb54l7abmF TGNVovqoxwPr0eKLCy0xqd3PItBcw8BWX8Tdsvp6mb1cRP3xIufpgEqhEnEeWHFWGfad LnIv6IQsdikd1xKrKAN0neJQn0CBhnL4h/d8dDphTQbumV1YViff1fiuqxKHE5eJaurf HWcg== X-Gm-Message-State: APuU4Z+/N/FfZ5pKx8soJJl+OYWL9YGFrVDz6gJvBRISIDB4oAFyK2jh AWhkWMMZS0dnJ3NeFIsn+KJdjrCBKbMCB3bVJy4nA4Quu7h/E64/OdLpzroMy7WxfNmD1k3kS8D 7Tz3awUOFqN8Il0ipNhWyyst//mMpao3TiB9GyHYTCzSGwSHLbkOUnuoKMapv6k297Orh+HhR+j BZN0V2b5rBTGQtVlMGU5PgDqL9TPLRRAF/lw== X-Gm-Gg: AYBFou1Dv1Kr3w/qRZbtu1L8DB/3659cy54PG3dBHrqWFmhCJKbNr3IDbwQ8EapWjod 77bGOfdsKcpFdFWy2grLQqL2TW0CBEqvr0NUSLTCTRBZcFsf1gTK5ZKUq4z5+Vgt9P5TY8kjGKa uOciScSmepubq80mGJO/CZThc+kDqJ5ft2bZlPkeq4kIp9tCJJlWGK/WrBOf/F+sU8qlt5NpTG4 GY2FqxXz9dsBdR/dG4/QneCG1EP8eJHNVGHZqF3/4gLdM1j7xP/YNR3wjW5nhQl8xp27FCiq8Zy kmnqq19yA7rJiwufe+9hV1DpOsMRs6MzohVt9OAHj8oGYd0sCMHHZ6EbqlknwnFQxf6kleZZ2+R ecXmz4ucJI9QRk4Au2kyhF1Sh4n9zpM2vMhOFu75yXA== X-Received: by 2002:a05:6000:1aca:b0:48c:7037:aee9 with SMTP id ffacd0b85a97d-48e6e4fcfacmr27885105f8f.50.1793706677989; Tue, 03 Nov 2026 03:51:17 -0800 (PST) X-Received: by 2002:a05:6000:1aca:b0:48c:7037:aee9 with SMTP id ffacd0b85a97d-48e6e4fcfacmr27885051f8f.50.1793706677399; Tue, 03 Nov 2026 03:51:17 -0800 (PST) Date: Tue, 3 Nov 2026 06:51:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Marcel Apfelbaum , Akihiko Odaki , Fabiano Rosas , Jishnu Warrier , Utkarsh Verma , Laurent Vivier , Paolo Bonzini Subject: [PULL 16/17] qtest/libqos/pci: Fix qpci_msix_enable sharing bar0 Message-ID: <3c6c791284c12350266ec7ef8ed0079de39e05cf.1793706601.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706742193158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Devices where the MSI-X addresses are shared with other MMIO on BAR0 can not use msi_enable because it unmaps and remaps BAR0, which interferes with device MMIO mappings. xhci-nec is one such device we would like to test with msix. Use the BAR iomap tracking structure introduced in the previous change to have qpci_misx_enable() use existing iomaps if msix bars are already mapped. Cc: Michael S. Tsirkin Cc: Marcel Apfelbaum Reviewed-by: Akihiko Odaki Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-10-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 1 + tests/qtest/libqos/pci.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 2f9555ae4e..2fcddd19a8 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -75,6 +75,7 @@ struct QPCIDevice bool bars_mapped[QPCI_NUM_REGIONS]; QPCIBar bars[QPCI_NUM_REGIONS]; bool msix_enabled; + bool msix_table_bar_iomap, msix_pba_bar_iomap; QPCIBar msix_table_bar, msix_pba_bar; uint64_t msix_table_off, msix_pba_off; }; diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index 365fde1fb9..41f9673022 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -274,15 +274,21 @@ void qpci_msix_enable(QPCIDevice *dev) =20 table =3D qpci_config_readl(dev, addr + PCI_MSIX_TABLE); bir_table =3D table & PCI_MSIX_FLAGS_BIRMASK; - dev->msix_table_bar =3D qpci_iomap(dev, bir_table, NULL); + if (dev->bars_mapped[bir_table]) { + dev->msix_table_bar =3D dev->bars[bir_table]; + } else { + dev->msix_table_bar_iomap =3D true; + dev->msix_table_bar =3D qpci_iomap(dev, bir_table, NULL); + } dev->msix_table_off =3D table & ~PCI_MSIX_FLAGS_BIRMASK; =20 table =3D qpci_config_readl(dev, addr + PCI_MSIX_PBA); bir_pba =3D table & PCI_MSIX_FLAGS_BIRMASK; - if (bir_pba !=3D bir_table) { - dev->msix_pba_bar =3D qpci_iomap(dev, bir_pba, NULL); + if (dev->bars_mapped[bir_pba]) { + dev->msix_pba_bar =3D dev->bars[bir_pba]; } else { - dev->msix_pba_bar =3D dev->msix_table_bar; + dev->msix_pba_bar_iomap =3D true; + dev->msix_pba_bar =3D qpci_iomap(dev, bir_pba, NULL); } dev->msix_pba_off =3D table & ~PCI_MSIX_FLAGS_BIRMASK; =20 @@ -293,6 +299,7 @@ void qpci_msix_disable(QPCIDevice *dev) { uint8_t addr; uint16_t val; + uint32_t table; =20 g_assert(dev->msix_enabled); addr =3D qpci_find_capability(dev, PCI_CAP_ID_MSIX, 0); @@ -301,10 +308,31 @@ void qpci_msix_disable(QPCIDevice *dev) qpci_config_writew(dev, addr + PCI_MSIX_FLAGS, val & ~PCI_MSIX_FLAGS_ENAB= LE); =20 - if (dev->msix_pba_bar.addr !=3D dev->msix_table_bar.addr) { + if (dev->msix_pba_bar_iomap) { + dev->msix_pba_bar_iomap =3D false; qpci_iounmap(dev, dev->msix_pba_bar); + } else { + /* + * If we had reused an existing iomap, ensure it is still mapped + * otherwise it would be a bug if it were unmapped before msix is + * disabled. A refcounting iomap implementation could avoid this + * issue entirely, but let's wait until that's needed. + */ + uint8_t bir_pba; + table =3D qpci_config_readl(dev, addr + PCI_MSIX_PBA); + bir_pba =3D table & PCI_MSIX_FLAGS_BIRMASK; + g_assert(dev->bars_mapped[bir_pba]); + } + + if (dev->msix_table_bar_iomap) { + dev->msix_table_bar_iomap =3D false; + qpci_iounmap(dev, dev->msix_table_bar); + } else { + uint8_t bir_table; + table =3D qpci_config_readl(dev, addr + PCI_MSIX_TABLE); + bir_table =3D table & PCI_MSIX_FLAGS_BIRMASK; + g_assert(dev->bars_mapped[bir_table]); } - qpci_iounmap(dev, dev->msix_table_bar); =20 dev->msix_enabled =3D 0; dev->msix_table_off =3D 0; --=20 MST From nobody Mon Nov 23 04:25:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793706760; cv=none; d=zohomail.com; s=zohoarc; b=N8vA0sEkCpWxKbDrPnHqgq4hVw8NNShoXZ/zrlqAcOfHZ1MFUxiy/7sjzP80YbxS5Yz9KQD96HO7plztXeXfqIz8kD7YArjVOow7TjXl22+B8rj+fUYb0I1SHKUjUz1p0evQw7oB5mt7zqGtM8P76CZluBOLIDfKTOfB79CmsgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793706760; h=Content-Type: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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HffnJCbg1QtlWwhIPhB98LHrLu4vD50Q+fEQLlHW3Vo=; b=AJKMLVk3PzWAC36SiMFVoykwBbvx5GglDd/34UGVBIk1NURHMAIJ2xA1NZGQPdQfgEIzYxtKyhgKzQpURJt7FxSIaxDSEyrMSd+GuSFnWYhYWiREpjvUfp+NyL6jO021H7LPzzEutxsh+e0BOrJ7AoN6Gja2/cB0976DsFljxaQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179370676056753.005822561703894; Tue, 3 Nov 2026 03:52:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xOD32-0005fl-RF; Tue, 03 Nov 2026 06:51:28 -0500 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 1xOD31-0005bh-87 for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xOD2z-0000PS-8i for qemu-devel@nongnu.org; Tue, 03 Nov 2026 06:51:26 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-A8T25PGbOR-56527X1DJ2g-1; Tue, 03 Nov 2026 06:51:22 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4ad3d35e899so23574585e9.1 for ; Tue, 03 Nov 2026 03:51:21 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1506:fd00:9e19:9994:44b1:e6f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2a82cebc1sm76836865e9.1.2026.11.03.03.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 03:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793706684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HffnJCbg1QtlWwhIPhB98LHrLu4vD50Q+fEQLlHW3Vo=; b=FPH+h3r52qjKoGisqtKXx5PZn+ol3+78xmBYgwA0FvmCUKfCByvSvfGcZr63/m/AO/xpvj io3FqMTPQtpF7035/50LE7YoGT0lLWrRN0mXHa/ryjNxSbnI7qYmWpeFLFwTd8wWjImQOb BAaZ/j1XWq69MN2uhgXmKP0xrkYtatY= X-MC-Unique: A8T25PGbOR-56527X1DJ2g-1 X-Mimecast-MFC-AGG-ID: A8T25PGbOR-56527X1DJ2g_1793706681 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1793706681; x=1794311481; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HffnJCbg1QtlWwhIPhB98LHrLu4vD50Q+fEQLlHW3Vo=; b=MJ8CUKXo1zvBIAXNHcBm2aJDL0rBFNRBNoKWxcKEtNb5qmn/oUyT2GEMtJQTlQiYdO CvCWn1s//RI9KVIITGtOum1tT5mipmZX/Md8FlwyrkYo3dGcJWze5knp5k6BOSA4VMNc e2xtRmqSGLG+gpKj1AmWyZCfoiRCrzn5OHXoUsKlohH9Ujk8Xk/3vxzkD4zqLJIBNWAP GQXHzRzAvKe8by3yAymapK+TDoXFbBstQ7+4UVQOrTFaFd1XpNOqIVXghKoyDJ9WUdjg VT61KFTnfH2NXRMSp5lX0r5GOA1SwdiNXdfOHBEVNqsPqNQ9r4RA0qk07OFKSEgWCDvA wJiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793706681; x=1794311481; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HffnJCbg1QtlWwhIPhB98LHrLu4vD50Q+fEQLlHW3Vo=; b=1lDyrd23VzsWkDGz1ZS7jKFrCvu8jZennAzAfwYVGXm/dDgpSr9TaR/l3hsv+2MjXY kNZcQmepUmY1fwtyyg7F1lS5aN1PTfR7zebInC4pVN9Jap116Y57ySaE9JYlRRNxA5IF 4cbjf1gIGuRwh1D9Bu2ShWkrEX7e6Xt8kQAKEVyQjH9sQWDhWifzqftdDwwBh5TpLZcE aCjWU01pXJEeXj2Sa6jDM8wqygmv9cwCZ5K4ufxI63oW9+WC/5fJJMu2mjfjIKh/0UaQ T+AIEIHBTPbR6M8m1VPG7ke+IRSXcM4bxBX2ln+JqpiQ62ues8LwX0aJMCxUxOMLmcqf t1+w== X-Gm-Message-State: APuU4Z+P7cN/NRZDb0ve5e4qB5Zbcdy65hV57CsZOWobJ3lO//25nCLA 9vlyv9j+yzdhzgD9rLOHm85+5BU1od5G0X4v9NoRBnElhG1I22x4rQQmni/nq0xYMqqWux38rbY ibcfD0kJl3VsUU5MvANOhpl4qzOSJGL3I8l7FXvIyO83q+YiAx5CmHe1D+jw/MrLVVryMN5fCzT NjPBrl+VMzHH9BuB/kscPxgdI3vOogCWogVQ== X-Gm-Gg: AYBFou3isjlZ74FFyUumL6vuTnMNmM07tqEuUVMM/RQY85Lla3nYWGfOx257rGJQSat QJyhno4JY6yW1aAjMj0pwa2rX9WZrV67SnfOkiGLX9clF3txQBYWYMVl2r4+SKbehsEaajylU3f aYX2k8MqsnonQBVy9G8CZAwu2+dSDN/RdFfvRZw2batA6VidI4FzZY/ogsTyVrf+m+W5YegaLk8 0k0r1+0ZlmuL1s8uK4eO7s6UDyfW+hsZEYVK1J8UNm853z+Fyk+KoTcskEAV4z8/lMaEXATL/0U t5qiHIJzXSrVNLjPreIIOEdc2NXyUhfKwQoJ3D1Ptf8ZZ7m+zqAElAZ8l4kitU0RCCrcbFDqURh sdrNV0M52gwKFfK5+wr4KjVD/pUSWCjyUqnClzYhUpw== X-Received: by 2002:a05:600c:8116:b0:4a2:150f:160f with SMTP id 5b1f17b1804b1-4ac1913eecdmr289687805e9.25.1793706680709; Tue, 03 Nov 2026 03:51:20 -0800 (PST) X-Received: by 2002:a05:600c:8116:b0:4a2:150f:160f with SMTP id 5b1f17b1804b1-4ac1913eecdmr289687275e9.25.1793706680132; Tue, 03 Nov 2026 03:51:20 -0800 (PST) Date: Tue, 3 Nov 2026 06:51:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicholas Piggin , Akihiko Odaki , Jishnu Warrier , Utkarsh Verma , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 17/17] qtest/libqos/pci: Factor msix entry helpers into pci common code Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/293.698.2 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1793706762295158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nicholas Piggin Setting msix entry address and data and masking is moved into common code helpers from virtio tests. For now that remains the only user, but there are changes under development to enable msix vectors for msix, e1000e, and xhci tests, which can make use of them. Reviewed-by: Akihiko Odaki Signed-off-by: Nicholas Piggin Signed-off-by: Jishnu Warrier Signed-off-by: Utkarsh Verma Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20261102035306.2291147-11-uverma@linux.ibm.com> --- tests/qtest/libqos/pci.h | 3 ++ tests/qtest/libqos/pci.c | 49 +++++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio-pci.c | 48 ++++---------------------------- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 2fcddd19a8..986cc53c3a 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -97,8 +97,11 @@ 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); void qpci_msix_disable(QPCIDevice *dev); +void qpci_msix_set_entry(QPCIDevice *dev, uint16_t entry, + uint64_t guest_addr, uint32_t data); bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry); bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry); +void qpci_msix_set_masked(QPCIDevice *dev, uint16_t entry, bool masked); bool qpci_msix_test_interrupt(QPCIDevice *dev, uint16_t msix_entry, uint64_t msix_addr, uint32_t msix_data); uint16_t qpci_msix_table_size(QPCIDevice *dev); diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index 41f9673022..253c5df3e4 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -339,6 +339,24 @@ void qpci_msix_disable(QPCIDevice *dev) dev->msix_pba_off =3D 0; } =20 +void qpci_msix_set_entry(QPCIDevice *dev, uint16_t entry, + uint64_t guest_addr, uint32_t data) +{ + uint64_t vector_off =3D dev->msix_table_off + entry * PCI_MSIX_ENTRY_S= IZE; + + g_assert(dev->msix_enabled); + g_assert_cmpint(entry, <, qpci_msix_table_size(dev)); + + qpci_io_writel(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_LOWER_ADDR, guest_addr & ~0= UL); + qpci_io_writel(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_UPPER_ADDR, + (guest_addr >> 32) & ~0UL); + + qpci_io_writel(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_DATA, data); +} + bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry) { uint32_t pba_entry; @@ -346,6 +364,8 @@ bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry) uint64_t off =3D (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4; =20 g_assert(dev->msix_enabled); + g_assert_cmpint(entry, <, qpci_msix_table_size(dev)); + pba_entry =3D qpci_io_readl(dev, dev->msix_pba_bar, dev->msix_pba_off = + off); return (pba_entry & (1 << bit_n)) !=3D 0; } @@ -357,6 +377,8 @@ bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry) uint64_t vector_off =3D dev->msix_table_off + entry * PCI_MSIX_ENTRY_S= IZE; =20 g_assert(dev->msix_enabled); + g_assert_cmpint(entry, <, qpci_msix_table_size(dev)); + addr =3D qpci_find_capability(dev, PCI_CAP_ID_MSIX, 0); g_assert_cmphex(addr, !=3D, 0); val =3D qpci_config_readw(dev, addr + PCI_MSIX_FLAGS); @@ -370,6 +392,33 @@ bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry) } } =20 +void qpci_msix_set_masked(QPCIDevice *dev, uint16_t entry, bool masked) +{ + uint8_t addr; + uint16_t val; + uint64_t vector_off =3D dev->msix_table_off + entry * PCI_MSIX_ENTRY_S= IZE; + + g_assert(dev->msix_enabled); + g_assert_cmpint(entry, <, qpci_msix_table_size(dev)); + + addr =3D qpci_find_capability(dev, PCI_CAP_ID_MSIX, 0); + g_assert_cmphex(addr, !=3D, 0); + val =3D qpci_config_readw(dev, addr + PCI_MSIX_FLAGS); + g_assert(!(val & PCI_MSIX_FLAGS_MASKALL)); + + val =3D qpci_io_readl(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_VECTOR_CTRL); + if (masked && !(val & PCI_MSIX_ENTRY_CTRL_MASKBIT)) { + qpci_io_writel(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_VECTOR_CTRL, + val | PCI_MSIX_ENTRY_CTRL_MASKBIT); + } else if (!masked && (val & PCI_MSIX_ENTRY_CTRL_MASKBIT)) { + qpci_io_writel(dev, dev->msix_table_bar, + vector_off + PCI_MSIX_ENTRY_VECTOR_CTRL, + val & ~PCI_MSIX_ENTRY_CTRL_MASKBIT); + } +} + /** * qpci_msix_test_interrupt - test whether MSI-X interrupt has been raised * @dev: PCI device diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pc= i.c index ea8114e243..16e0220920 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -290,66 +290,28 @@ void qvirtio_pci_device_disable(QVirtioPCIDevice *d) void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci, QGuestAllocator *alloc, uint16_t e= ntry) { - uint32_t control; - uint64_t off; - g_assert(d->pdev->msix_enabled); - off =3D d->pdev->msix_table_off + (entry * 16); - - g_assert_cmpint(entry, >=3D, 0); - g_assert_cmpint(entry, <, qpci_msix_table_size(d->pdev)); vqpci->msix_entry =3D entry; - 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, - off + PCI_MSIX_ENTRY_UPPER_ADDR, - (vqpci->msix_addr >> 32) & ~0UL); - qpci_io_writel(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_DATA, vqpci->msix_data); - - control =3D qpci_io_readl(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_VECTOR_CTRL); - qpci_io_writel(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_VECTOR_CTRL, - control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT); =20 + qpci_msix_set_entry(d->pdev, entry, vqpci->msix_addr, vqpci->msix_data= ); + qpci_msix_set_masked(d->pdev, entry, false); d->msix_ops->set_queue_vector(d, vqpci->vq.index, entry); } =20 void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d, QGuestAllocator *alloc, uint16_t e= ntry) { - uint32_t control; - uint64_t off; - g_assert(d->pdev->msix_enabled); - off =3D d->pdev->msix_table_off + (entry * 16); - - g_assert_cmpint(entry, >=3D, 0); - g_assert_cmpint(entry, <, qpci_msix_table_size(d->pdev)); d->config_msix_entry =3D entry; - 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); - qpci_io_writel(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_UPPER_ADDR, - (d->config_msix_addr >> 32) & ~0UL); - qpci_io_writel(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_DATA, d->config_msix_data); - - control =3D qpci_io_readl(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_VECTOR_CTRL); - qpci_io_writel(d->pdev, d->pdev->msix_table_bar, - off + PCI_MSIX_ENTRY_VECTOR_CTRL, - control & ~PCI_MSIX_ENTRY_CTRL_MASKBIT); - + qpci_msix_set_entry(d->pdev, entry, d->config_msix_addr, + d->config_msix_data); + qpci_msix_set_masked(d->pdev, entry, false); d->msix_ops->set_config_vector(d, entry); } =20 --=20 MST