From nobody Sun Nov 16 00:57:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1745571205; cv=none; d=zohomail.com; s=zohoarc; b=gbK41zlZipaDKjq8a7gdw4fjKCjv+wQXFQCL0nf+IWHujaGnOaLwTDVy18igoZxCuH2gjohKZGs5H/DGxYwt+a7IWJU7yVRKQzhnVJdpKRB/FOw+2U/yxIXl8SRJpo9h9Sgt++zJewf68A+Joz5VeAsINj5M2yxPmwfm1SoAZe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745571205; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CPnHVBcgsWTqT+InYSFw9LQgKVoq4/hzYKs3O4CxH8I=; b=MtXqa7suqcXc45nHAKqRQ8im+5g+mgm9cgMmgQNPxLKd+gnL1V10K09ETGn1OFehaC23SHjZyMEWZwOKRKC5WPbtEvTBCb/R0C+6CxdxldwuGibVbN3tE38u2mchDi8OL2GaNm/12Hpr8QpqsBl1P0N3qfnPnm88JeGJeVanqq0= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1745571205682482.31976178617526; Fri, 25 Apr 2025 01:53:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Eiw-0002uT-Oe; Fri, 25 Apr 2025 04:47:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u8Eiv-0002uC-Id for qemu-devel@nongnu.org; Fri, 25 Apr 2025 04:47:53 -0400 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 1u8Eit-0003FH-5Q for qemu-devel@nongnu.org; Fri, 25 Apr 2025 04:47:53 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-Q6kfkM_5P9u4RVOMmh4-vg-1; Fri, 25 Apr 2025 04:47:47 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 08FBF1800264; Fri, 25 Apr 2025 08:47:47 +0000 (UTC) Received: from corto.redhat.com (unknown [10.44.33.65]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4C2A530001A2; Fri, 25 Apr 2025 08:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745570869; 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=CPnHVBcgsWTqT+InYSFw9LQgKVoq4/hzYKs3O4CxH8I=; b=Nf6cJ5F5PMn/hthlEnU2JvFUxlY47k2IgxJ/j2AaUo8OSAFkr8twDN9wwhT+ZhxozhEbt9 tXzrCyIQ3oIjYoTgHnzhu0scLqKUByDCBEsxdeuMBuf4iP322eJNZbL9vgaiFU4m1H1mCZ DHSTTwPw4n/A7QNjB9dfusXb5GshSNY= X-MC-Unique: Q6kfkM_5P9u4RVOMmh4-vg-1 X-Mimecast-MFC-AGG-ID: Q6kfkM_5P9u4RVOMmh4-vg_1745570867 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Zhenzhong Duan , John Levon Subject: [PULL 16/50] vfio: Introduce a new header file for VFIOcontainer declarations Date: Fri, 25 Apr 2025 10:46:09 +0200 Message-ID: <20250425084644.102196-17-clg@redhat.com> In-Reply-To: <20250425084644.102196-1-clg@redhat.com> References: <20250425084644.102196-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.84, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1745571207537019100 Gather all VFIOcontainer related declarations into "hw/vfio/vfio-container.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". These declarations were initially introduced in commit 65501a745dba ("vfio: vfio-pci device assignment driver"). They are made available externally for PPC and s390x. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-12-clg@redha= t.com Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-13-clg@redh= at.com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 19 ----------------- include/hw/vfio/vfio-container.h | 36 ++++++++++++++++++++++++++++++++ hw/ppc/spapr_pci_vfio.c | 1 + hw/s390x/s390-pci-vfio.c | 2 +- hw/vfio/container.c | 1 + hw/vfio/spapr.c | 1 + 6 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 include/hw/vfio/vfio-container.h diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b37203374178045f2b534bf6d8990f9dbea1fca7..bcdbc9de57dd11c2c93252b983e= c4e4190a82fe5 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -39,16 +39,6 @@ enum { VFIO_DEVICE_TYPE_CCW =3D 2, VFIO_DEVICE_TYPE_AP =3D 3, }; -struct VFIOGroup; - -typedef struct VFIOContainer { - VFIOContainerBase bcontainer; - int fd; /* /dev/vfio/vfio, empowered by the attached groups */ - unsigned iommu_type; - QLIST_HEAD(, VFIOGroup) group_list; -} VFIOContainer; - -OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); =20 typedef struct VFIODeviceOps VFIODeviceOps; typedef struct VFIOMigration VFIOMigration; @@ -125,15 +115,6 @@ struct VFIODeviceOps { int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f); }; =20 -typedef struct VFIOGroup { - int fd; - int groupid; - VFIOContainer *container; - QLIST_HEAD(, VFIODevice) device_list; - QLIST_ENTRY(VFIOGroup) next; - QLIST_ENTRY(VFIOGroup) container_next; - bool ram_block_discard_allowed; -} VFIOGroup; =20 #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-contai= ner.h new file mode 100644 index 0000000000000000000000000000000000000000..afc498da49fd4aa7625e47a0749= f2c524049296d --- /dev/null +++ b/include/hw/vfio/vfio-container.h @@ -0,0 +1,36 @@ +/* + * VFIO container + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_CONTAINER_H +#define HW_VFIO_CONTAINER_H + +#include "hw/vfio/vfio-container-base.h" + +typedef struct VFIOContainer VFIOContainer; +typedef struct VFIODevice VFIODevice; + +typedef struct VFIOGroup { + int fd; + int groupid; + VFIOContainer *container; + QLIST_HEAD(, VFIODevice) device_list; + QLIST_ENTRY(VFIOGroup) next; + QLIST_ENTRY(VFIOGroup) container_next; + bool ram_block_discard_allowed; +} VFIOGroup; + +typedef struct VFIOContainer { + VFIOContainerBase bcontainer; + int fd; /* /dev/vfio/vfio, empowered by the attached groups */ + unsigned iommu_type; + QLIST_HEAD(, VFIOGroup) group_list; +} VFIOContainer; + +OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); + +#endif /* HW_VFIO_CONTAINER_H */ diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index 76b2a3487b5d6f21528e9c301341eb27bc8fec1d..1722a5bfa3983d42baac558f224= 10e36eed375f5 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -25,6 +25,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pci_device.h" #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" #include "qemu/error-report.h" #include CONFIG_DEVICES /* CONFIG_VFIO_PCI */ =20 diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index db152a625253a0f4047353000ff3bafca1f09938..748a51fd8cc478604340b7c812e= 0da356836b807 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -20,7 +20,7 @@ #include "hw/s390x/s390-pci-clp.h" #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" =20 /* * Get the current DMA available count from vfio. Returns true if vfio is diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 812d5edbcf911911fa896ba3603b91a817ffec6b..bda1942662d1da24c3a47db0f4a= 389a2a0fbec7e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -32,6 +32,7 @@ #include "trace.h" #include "qapi/error.h" #include "pci.h" +#include "hw/vfio/vfio-container.h" =20 VFIOGroupList vfio_group_list =3D QLIST_HEAD_INITIALIZER(vfio_group_list); diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index f21955a3442b956bdcb2964b0042a12e2ac8a03d..31e4dddc9e2707b18ebaf3e744d= 85009e635f172 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -16,6 +16,7 @@ #include "system/address-spaces.h" =20 #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" #include "hw/hw.h" #include "system/ram_addr.h" #include "qemu/error-report.h" --=20 2.49.0