From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197498; cv=none; d=zohomail.com; s=zohoarc; b=BTHicNaX4OV4pvON/IXyPxCZ0g7HUyq8m0HoJ6xfhMVKnQTjWhOpvh+I9le9MNKAjE3Gt1PuzDi07mMo3oMPJhPwPIaNUpV/BMyDucsLjXhl/PfLuZcpaiLxYMgLdnpTRTGUpJk7Z1SCkvOjv9rxWNsBFsewl/7PFgIqvFTQhsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197498; 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=80UiQ6GEHogTpKZyXdTxaFHGnmMR0uKIi2Wc/ALYM8Y=; b=FIpnjoN3z70gmeqqx4UBcLmV9NGBZ2i0IUdgm999eq0kAyDIBDgZBNOXF4T86NuLg0SuuoLWynlcows3xMaB+JUWyVqFOjnteuKEx34Gs1hTEqVqPpvcq5RYYmeJjymuJ90csEwcItP6KVGmfxgjKSwwesN/oxV69xUbM7D9wuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197497656614.7601045980941; Wed, 12 Jun 2024 06:04:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbn-000358-A1; Wed, 12 Jun 2024 09:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNbk-00034B-Qs for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:44 -0400 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 1sHNbh-0007lo-EP for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:44 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-hO4xi5BgOy6Mirris-3uSw-1; Wed, 12 Jun 2024 09:01:30 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40CEB1955D75; Wed, 12 Jun 2024 13:01:29 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C6371956053; Wed, 12 Jun 2024 13:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197297; 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=80UiQ6GEHogTpKZyXdTxaFHGnmMR0uKIi2Wc/ALYM8Y=; b=AfqmX4OHAgAK/vTxPFGV8GQwpRoAHDThzHVPJXozcDZWg4aYmqwm4OYhGcMdpSbm3ws8RW Sdyzi2Q90Qda38za/dthklFxadviWDrLeBlTrZ5gJ8njYwrFZ2XHYBMbkbrWHRRa/zJ3O1 dzMJ/3VVypHPXOaA5wOOx3w73NOn7+Y= X-MC-Unique: hO4xi5BgOy6Mirris-3uSw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 01/16] vfio: Make vfio_devices_dma_logging_start() return bool Date: Wed, 12 Jun 2024 15:01:07 +0200 Message-ID: <20240612130122.813935-2-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197499910100007 Since vfio_devices_dma_logging_start() takes an 'Error **' argument, best practices suggest to return a bool. See the api/error.h Rules section. It will simplify potential changes coming after. vfio_container_set_dirty_page_tracking() could be modified in the same way but the errno value can be saved in the migration stream when called from vfio_listener_log_global_stop(). Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 9e4c0cc95ff90209d3e8184035af0806a2bf890b..d48cd9b9361a92d184e423ffc60= aabaff40fb487 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1020,7 +1020,7 @@ static void vfio_device_feature_dma_logging_start_des= troy( g_free(feature); } =20 -static int vfio_devices_dma_logging_start(VFIOContainerBase *bcontainer, +static bool vfio_devices_dma_logging_start(VFIOContainerBase *bcontainer, Error **errp) { struct vfio_device_feature *feature; @@ -1033,7 +1033,7 @@ static int vfio_devices_dma_logging_start(VFIOContain= erBase *bcontainer, &ranges); if (!feature) { error_setg_errno(errp, errno, "Failed to prepare DMA logging"); - return -errno; + return false; } =20 QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { @@ -1058,7 +1058,7 @@ out: =20 vfio_device_feature_dma_logging_start_destroy(feature); =20 - return ret; + return ret =3D=3D 0; } =20 static bool vfio_listener_log_global_start(MemoryListener *listener, @@ -1067,18 +1067,18 @@ static bool vfio_listener_log_global_start(MemoryLi= stener *listener, ERRP_GUARD(); VFIOContainerBase *bcontainer =3D container_of(listener, VFIOContainer= Base, listener); - int ret; + bool ret; =20 if (vfio_devices_all_device_dirty_tracking(bcontainer)) { ret =3D vfio_devices_dma_logging_start(bcontainer, errp); } else { - ret =3D vfio_container_set_dirty_page_tracking(bcontainer, true, e= rrp); + ret =3D vfio_container_set_dirty_page_tracking(bcontainer, true, e= rrp) =3D=3D 0; } =20 - if (ret) { + if (!ret) { error_prepend(errp, "vfio: Could not start dirty page tracking - "= ); } - return !ret; + return ret; } =20 static void vfio_listener_log_global_stop(MemoryListener *listener) --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197430; cv=none; d=zohomail.com; s=zohoarc; b=lsf1eu64PhPsggJa7BWD5TCF9218A2ZR0AjfLRrtIlANSoaRUtxX5td6Pqr3nfxK5eERFsc8J5d+Sdy5FxT54iMcqjH9F9n1hbH5uu6WrZVstnxKNBhlUWyvlks0qw2cVJFn4BnuFCwLm3IxW9BYSn3+gu/2Tng8Hc8oW3VoIf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197430; 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=qlJFtZJjwq8+p7ez8aklM5DrH5iXcuxwqEn8YjmMP1Y=; b=l+tuSBeb6kgIC1qEwKPFfHuRkhoHpSSBHWaIPJM8KYgJ/u471qFl6vqRyraav+Ts2Gzb2hX5e45Lx46GVhZJNzhnwHbmx74dH+Q9GYcTVQyTT3XvbtQtvU//o3ViHuoX3VKQcOLepvaZNjhU0A97iQw71e7tspwCbs7fOAYrZ7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197430257309.3482679825969; Wed, 12 Jun 2024 06:03:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbm-00034u-KY; Wed, 12 Jun 2024 09:01:46 -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 1sHNbk-000346-Et for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:44 -0400 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 1sHNbh-0007kD-Dz for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:44 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-52M5Ycy2PKiwgNtut0PQJA-1; Wed, 12 Jun 2024 09:01:33 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65A3A1955D6A; Wed, 12 Jun 2024 13:01:31 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8400D1956056; Wed, 12 Jun 2024 13:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197295; 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=qlJFtZJjwq8+p7ez8aklM5DrH5iXcuxwqEn8YjmMP1Y=; b=abOCsPLUQ/eQXjMfWuGhzv0wakkfQ0JCwmaaSRFShD9GTIZdqiezDHjA0TSkwv6frtVQI+ 4nLxz7Dy3YPCvCb81FzOCmsliZVIIyyOhZH35vGiiF2MI53v9mCzSAeBSgcpctKxSxbubW eK+BZ2a/iS7b1neD+y9S/n8x5MJLXmM= X-MC-Unique: 52M5Ycy2PKiwgNtut0PQJA-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 02/16] vfio: Remove unused declarations from vfio-common.h Date: Wed, 12 Jun 2024 15:01:08 +0200 Message-ID: <20240612130122.813935-3-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197431487100002 These were forgotten in the recent cleanups. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 776de8064f740784f95cab0311c5f15f50d60ffe..c19572f90b277193491020af28e= 8b5587f15bfd1 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -207,10 +207,6 @@ typedef struct VFIODisplay { VFIOAddressSpace *vfio_get_address_space(AddressSpace *as); void vfio_put_address_space(VFIOAddressSpace *space); =20 -/* SPAPR specific */ -int vfio_spapr_container_init(VFIOContainer *container, Error **errp); -void vfio_spapr_container_deinit(VFIOContainer *container); - void vfio_disable_irqindex(VFIODevice *vbasedev, int index); void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197403; cv=none; d=zohomail.com; s=zohoarc; b=XeBXNWtfq7+uoOgSk9OAgk1N0ppDPJniscBeU0nyk7tVp5RJTOm3dvphlpDoulx9VtCJeVhCS1ymyjmzlBaoNQzcDehZIAwP11DRI+aywNPmqBMsLhlFmzqI81jq5EZW98zaXfwIyUb4nnjicRCOXcOu1+tsiDIBEb4zxuud2fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197403; 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=22GmMhxSkrGnQpEgBkeVNUCd6j5Y2gc1C0L0csbODhI=; b=C8sozXFE6qKK0znQjWXFh2YwPnqsr/HNlvIpyBC1xtvd+nwayM+lMHfwpQ6ZWkvJnVwJ+nB6CLk7GPZFOzVWvLRofA79ElOPhttpRvjoCkC5MaMboofM3TY/aDKcewxladA8NeCUmexchFIHMEFeerXX9p28E+G/tDN/a6g0dkw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197403159221.88675628555234; Wed, 12 Jun 2024 06:03:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbq-00036w-7R; Wed, 12 Jun 2024 09:01:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNbm-00034k-3G for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:46 -0400 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 1sHNbh-0007kJ-Gr for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:45 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-FFydPRNePSuhbVGOTM65cg-1; Wed, 12 Jun 2024 09:01:34 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C3F491955F12; Wed, 12 Jun 2024 13:01:33 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A89F41956053; Wed, 12 Jun 2024 13:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197296; 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=22GmMhxSkrGnQpEgBkeVNUCd6j5Y2gc1C0L0csbODhI=; b=f6IDGy8xMDpbb0cnWv6Q9MMoj0+qCl4vPkrvEl+FQqg4Wn2ILnhuQsVJKcVJNTulbPWYO/ bY6+w6M05hLfV29wZUMSk5QN6oF5t7tHdX8L/hoYT27tLdWfNkTjbvJd8KWbniVZLl90VM 9GPyoz77DkFRysRe/RHbLRwUvCC72Nk= X-MC-Unique: FFydPRNePSuhbVGOTM65cg-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 03/16] vfio/common: Move dirty tracking ranges update to helper Date: Wed, 12 Jun 2024 15:01:09 +0200 Message-ID: <20240612130122.813935-4-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197405328100003 From: Joao Martins Separate the changes that updates the ranges from the listener, to make it reusable in preparation to expand its use to vIOMMU support. Signed-off-by: Joao Martins [ clg: - Rebased on upstream - Introduced vfio_dirty_tracking_update_range() ] Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index d48cd9b9361a92d184e423ffc60aabaff40fb487..fe215918bdf66ddbe3c5db803e1= 0ce1aa9756b90 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -839,20 +839,11 @@ static bool vfio_section_is_vfio_pci(MemoryRegionSect= ion *section, return false; } =20 -static void vfio_dirty_tracking_update(MemoryListener *listener, - MemoryRegionSection *section) +static void vfio_dirty_tracking_update_range(VFIODirtyRanges *range, + hwaddr iova, hwaddr end, + bool update_pci) { - VFIODirtyRangesListener *dirty =3D container_of(listener, - VFIODirtyRangesListener, - listener); - VFIODirtyRanges *range =3D &dirty->ranges; - hwaddr iova, end, *min, *max; - - if (!vfio_listener_valid_section(section, "tracking_update") || - !vfio_get_section_iova_range(dirty->bcontainer, section, - &iova, &end, NULL)) { - return; - } + hwaddr *min, *max; =20 /* * The address space passed to the dirty tracker is reduced to three r= anges: @@ -873,8 +864,7 @@ static void vfio_dirty_tracking_update(MemoryListener *= listener, * The alternative would be an IOVATree but that has a much bigger run= time * overhead and unnecessary complexity. */ - if (vfio_section_is_vfio_pci(section, dirty->bcontainer) && - iova >=3D UINT32_MAX) { + if (update_pci && iova >=3D UINT32_MAX) { min =3D &range->minpci64; max =3D &range->maxpci64; } else { @@ -889,7 +879,23 @@ static void vfio_dirty_tracking_update(MemoryListener = *listener, } =20 trace_vfio_device_dirty_tracking_update(iova, end, *min, *max); - return; +} + +static void vfio_dirty_tracking_update(MemoryListener *listener, + MemoryRegionSection *section) +{ + VFIODirtyRangesListener *dirty =3D + container_of(listener, VFIODirtyRangesListener, listener); + hwaddr iova, end; + + if (!vfio_listener_valid_section(section, "tracking_update") || + !vfio_get_section_iova_range(dirty->bcontainer, section, + &iova, &end, NULL)) { + return; + } + + vfio_dirty_tracking_update_range(&dirty->ranges, iova, end, + vfio_section_is_vfio_pci(section, dirty->bcontainer)= ); } =20 static const MemoryListener vfio_dirty_tracking_listener =3D { --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197375; cv=none; d=zohomail.com; s=zohoarc; b=jgVZQsiZ7bt5WcvIc7h7YVtSGS+EPrtUmZssJVGfuCiOMnZ4+nsaG1+JxdQAvzS0K8nYHU1XUwyWTKnue2z8lVZoHOAq8655+P+1ku9tqWV0l9U7XswhWpjD2V+sqpePi0PSKfFV2TGiwPAUt20vJPuS84d51iAAhtzV4ha+//g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197375; 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=h4tug8Qf6vvztvO7K6lVXWn6yVxd15mqm4F8ME6ZIp0=; b=JuFY0E7Oi5hb5leMdyPptGbTmEhvwy4daljy2L8ieZ2RTHPyzQlNsR6e2Euqco6K8eOOkzD40CwjcJm7Gj2EnHL3ATYEyFMEMuAJ8sVSK8wDZBKnzU0cd0FfFuCAJehUOETgAvn0R78wQxxFzAthAsVNYV0Hh4cYvWo3M9PBUc4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197375973640.9998261160724; Wed, 12 Jun 2024 06:02:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbn-00035I-FK; Wed, 12 Jun 2024 09:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNbl-00034c-Ol for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:45 -0400 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 1sHNbh-0007ly-Go for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:45 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-fVpOaHsmNni_cdppElErkQ-1; Wed, 12 Jun 2024 09:01:37 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E1F51955E7A; Wed, 12 Jun 2024 13:01:36 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1236C1956053; Wed, 12 Jun 2024 13:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197298; 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=h4tug8Qf6vvztvO7K6lVXWn6yVxd15mqm4F8ME6ZIp0=; b=DiHbqKzsLy/P8kHO9fM4zsEwu3LfNXREGBt2odOab0Rn+ufjNfmv27/qGSslSri43Nu1Ox nJmFarvlMSP1LJUb6BvhOZ7PivJ6Ih6zep53ngPvPXC9TgACumMrziIp2mfeSotoOtfe+l mnOZcDj9zl1dYYFWO6+9W4Xy3nJQryA= X-MC-Unique: fVpOaHsmNni_cdppElErkQ-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , Avihai Horon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 04/16] vfio/common: Extract vIOMMU code from vfio_sync_dirty_bitmap() Date: Wed, 12 Jun 2024 15:01:10 +0200 Message-ID: <20240612130122.813935-5-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197377485100003 From: Avihai Horon Extract vIOMMU code from vfio_sync_dirty_bitmap() to a new function and restructure the code. This is done in preparation for optimizing vIOMMU deviice dirty page tracking. No functional changes intended. Signed-off-by: Avihai Horon Signed-off-by: Joao Martins [ clg: - Rebased on upstream ] Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 63 +++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index fe215918bdf66ddbe3c5db803e10ce1aa9756b90..f28641bad5cf4b71fcdc0a6c9d4= 2b24c8d786248 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1302,37 +1302,50 @@ vfio_sync_ram_discard_listener_dirty_bitmap(VFIOCon= tainerBase *bcontainer, &vrdl); } =20 +static int vfio_sync_iommu_dirty_bitmap(VFIOContainerBase *bcontainer, + MemoryRegionSection *section) +{ + VFIOGuestIOMMU *giommu; + bool found =3D false; + Int128 llend; + vfio_giommu_dirty_notifier gdn; + int idx; + + QLIST_FOREACH(giommu, &bcontainer->giommu_list, giommu_next) { + if (MEMORY_REGION(giommu->iommu_mr) =3D=3D section->mr && + giommu->n.start =3D=3D section->offset_within_region) { + found =3D true; + break; + } + } + + if (!found) { + return 0; + } + + gdn.giommu =3D giommu; + idx =3D memory_region_iommu_attrs_to_index(giommu->iommu_mr, + MEMTXATTRS_UNSPECIFIED); + + llend =3D int128_add(int128_make64(section->offset_within_region), + section->size); + llend =3D int128_sub(llend, int128_one()); + + iommu_notifier_init(&gdn.n, vfio_iommu_map_dirty_notify, IOMMU_NOTIFIE= R_MAP, + section->offset_within_region, int128_get64(llend), + idx); + memory_region_iommu_replay(giommu->iommu_mr, &gdn.n); + + return 0; +} + static int vfio_sync_dirty_bitmap(VFIOContainerBase *bcontainer, MemoryRegionSection *section, Error **er= rp) { ram_addr_t ram_addr; =20 if (memory_region_is_iommu(section->mr)) { - VFIOGuestIOMMU *giommu; - - QLIST_FOREACH(giommu, &bcontainer->giommu_list, giommu_next) { - if (MEMORY_REGION(giommu->iommu_mr) =3D=3D section->mr && - giommu->n.start =3D=3D section->offset_within_region) { - Int128 llend; - vfio_giommu_dirty_notifier gdn =3D { .giommu =3D giommu }; - int idx =3D memory_region_iommu_attrs_to_index(giommu->iom= mu_mr, - MEMTXATTRS_UNSPECIF= IED); - - llend =3D int128_add(int128_make64(section->offset_within_= region), - section->size); - llend =3D int128_sub(llend, int128_one()); - - iommu_notifier_init(&gdn.n, - vfio_iommu_map_dirty_notify, - IOMMU_NOTIFIER_MAP, - section->offset_within_region, - int128_get64(llend), - idx); - memory_region_iommu_replay(giommu->iommu_mr, &gdn.n); - break; - } - } - return 0; + return vfio_sync_iommu_dirty_bitmap(bcontainer, section); } else if (memory_region_has_ram_discard_manager(section->mr)) { int ret; =20 --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197329; cv=none; d=zohomail.com; s=zohoarc; b=XzmouaxS9G8ygYqeFUckpT8akUNVh6JzcozokHWHccam3o3zm7l6tef8GszcEr51NBbq9Ba3VkqHBs1xnlvuTW7zLhp/vfWABng8bfS08BcSn1W4gMi66InlRH31xTf0H4QKjMeAfMl0zVf6xbMQIyb7DTHPnJ8bsZqLiKjpd+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197329; 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=W5yPa/CrSkiXKfoEvEjbGkVBxkpCeg24L8RyMBsrzzY=; b=JQ5H/GBiLtk+xBpvkCo0aV/VzLDxfSlLhWo2KtoJRlvxKv8GrcHVd8iyxghYGtUTILve8FznP9JeU31V73ef3PdYiPzx9BIlws00KdDixuaNouty5s8kE8c/TlbezMh3jA9J0VAqqG31PW/uq7Jb/EM5DRIOMwHGWWrSivF48BM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197329228353.0897739254708; Wed, 12 Jun 2024 06:02:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbo-00035y-5d; Wed, 12 Jun 2024 09:01:48 -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 1sHNbl-00034j-W8 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:46 -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 1sHNbh-0007pi-H9 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:45 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-gmDMMCbMNbSTVrRy6AGOcw-1; Wed, 12 Jun 2024 09:01:39 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 688331955E9F; Wed, 12 Jun 2024 13:01:38 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 96D361956053; Wed, 12 Jun 2024 13:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197300; 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=W5yPa/CrSkiXKfoEvEjbGkVBxkpCeg24L8RyMBsrzzY=; b=FYn2qC9a6zGyGiEizBYK/jxQYUraJYo3ckqq/XUb11ZXHwg3BX+9b8r0S1cRhdooy5gMHr NjRP1d5dDIju34uUxuaADSDMg5eDveKYT6Ez+YUS1OYfP/3+GTvlatrByXYTNh2w6XEBhk u3r7fNW0U5GsgCBxChWJDyvdXO/tbHA= X-MC-Unique: gmDMMCbMNbSTVrRy6AGOcw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 05/16] vfio/container: Introduce vfio_address_space_insert() Date: Wed, 12 Jun 2024 15:01:11 +0200 Message-ID: <20240612130122.813935-6-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197330954100007 It will ease future changes. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 ++ hw/vfio/common.c | 6 ++++++ hw/vfio/container.c | 2 +- hw/vfio/iommufd.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index c19572f90b277193491020af28e8b5587f15bfd1..825d80130bd435fe50830c8ae5b= 7905d18104dd6 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -206,6 +206,8 @@ typedef struct VFIODisplay { =20 VFIOAddressSpace *vfio_get_address_space(AddressSpace *as); void vfio_put_address_space(VFIOAddressSpace *space); +void vfio_address_space_insert(VFIOAddressSpace *space, + VFIOContainerBase *bcontainer); =20 void vfio_disable_irqindex(VFIODevice *vbasedev, int index); void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index f28641bad5cf4b71fcdc0a6c9d42b24c8d786248..8cdf26c6f5a490cfa02bdf1087a= 91948709aaa33 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1508,6 +1508,12 @@ void vfio_put_address_space(VFIOAddressSpace *space) } } =20 +void vfio_address_space_insert(VFIOAddressSpace *space, + VFIOContainerBase *bcontainer) +{ + QLIST_INSERT_HEAD(&space->containers, bcontainer, next); +} + struct vfio_device_info *vfio_get_device_info(int fd) { struct vfio_device_info *info; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index edd0df6262a0fb48bc60476c0187b957b8544cf7..15ca3643bc1b4e1a50a5a3de435= 9d61ec1bda9de 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -637,7 +637,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, vfio_kvm_device_add_group(group); =20 QLIST_INIT(&container->group_list); - QLIST_INSERT_HEAD(&space->containers, bcontainer, next); + vfio_address_space_insert(space, bcontainer); =20 group->container =3D container; QLIST_INSERT_HEAD(&container->group_list, group, container_next); diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 1706784063120dbb7f694addfbfadc3f9af4e813..19bb6419bdffd1c69cc14c7cd56= 84eb6d0231338 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -358,7 +358,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, =20 bcontainer =3D &container->bcontainer; vfio_container_init(bcontainer, space, iommufd_vioc); - QLIST_INSERT_HEAD(&space->containers, bcontainer, next); + vfio_address_space_insert(space, bcontainer); =20 if (!iommufd_cdev_attach_container(vbasedev, container, errp)) { goto err_attach_container; --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197814; cv=none; d=zohomail.com; s=zohoarc; b=LGmwk09yXjSFeXoTTWLNctaYkpOfoEOadaHgtY0lZbUereL9OJ5HI/TSs4sPvWYoHzmQSFMrv4yMjjArN7gvG3Q0NQplTeOfz8DtLInd8Gu+QgJsOc/6jUfhONYzleCaM4FoGtYO0g0LE8nNgDXkROXk8sSXMpzOkN1+YxIKiBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197814; 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=qUKDYanprLniMeqwrHAv6cargk98Oow3Mh4VWG0FwdI=; b=ShoWQYrqRhdJjQ703uHgWG7IpRGa72RQDHdv0ws8HNMSHXkXzcMHLD8PcOHkITjrgbQ4IZrrm74MEQ4xof0s3KB45ERnev0VmHNmVXRy2fT6HrHEiMOGZHvrkv7+JUK2O8ZL84Q5exWSWMC0/JsV1JOrrLKCH2YBehRLR1esDpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197814105740.9985563332245; Wed, 12 Jun 2024 06:10:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbp-00036X-HL; Wed, 12 Jun 2024 09:01:49 -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 1sHNbn-000353-5G for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:47 -0400 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 1sHNbj-0007wt-SV for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:46 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-vDR9FGgjMC27DWI23NLhGA-1; Wed, 12 Jun 2024 09:01:41 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 94B09195608B; Wed, 12 Jun 2024 13:01:40 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C8D801956053; Wed, 12 Jun 2024 13:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197303; 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=qUKDYanprLniMeqwrHAv6cargk98Oow3Mh4VWG0FwdI=; b=PxbTsrhsvApxwBEc0TqgFmr91YBpDGJ05+6WBqfP8gB6DBNZzAWfAmKPYJQmzDOMaBvN0c SRWJwubx8aqpljM5EiFqKs9NxFLbKbs+o576igxdxnHfmGF/SiXkGYv6GNL0sTHGV3Nign mI3urmHYBu0AB1wzsOc42SiRszz89Yk= X-MC-Unique: vDR9FGgjMC27DWI23NLhGA-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 06/16] vfio/container: Simplify vfio_container_init() Date: Wed, 12 Jun 2024 15:01:12 +0200 Message-ID: <20240612130122.813935-7-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197815758100003 Assign the base container VFIOAddressSpace 'space' pointer in vfio_address_space_insert(). To be noted that vfio_connect_container() will assign the 'space' pointer later in the execution flow. This should not have any consequence. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-base.h | 1 - hw/vfio/common.c | 1 + hw/vfio/container-base.c | 3 +-- hw/vfio/container.c | 6 +++--- hw/vfio/iommufd.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 442c0dfc4c1774753c239c2c8360dcd1540d44fa..d505f63607ec40e6aa44aeb3e20= 848ac780562a1 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -87,7 +87,6 @@ int vfio_container_query_dirty_bitmap(const VFIOContainer= Base *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp); =20 void vfio_container_init(VFIOContainerBase *bcontainer, - VFIOAddressSpace *space, const VFIOIOMMUClass *ops); void vfio_container_destroy(VFIOContainerBase *bcontainer); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 8cdf26c6f5a490cfa02bdf1087a91948709aaa33..1686a0bed23bd95467bfb00a0c3= 9a4d966e49cae 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1512,6 +1512,7 @@ void vfio_address_space_insert(VFIOAddressSpace *spac= e, VFIOContainerBase *bcontainer) { QLIST_INSERT_HEAD(&space->containers, bcontainer, next); + bcontainer->space =3D space; } =20 struct vfio_device_info *vfio_get_device_info(int fd) diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 760d9d0622b2e847ecb3368c88df772efb06043f..280f0dd2db1fc3939fe9925ce00= a2c50d0e14196 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -71,11 +71,10 @@ int vfio_container_query_dirty_bitmap(const VFIOContain= erBase *bcontainer, errp); } =20 -void vfio_container_init(VFIOContainerBase *bcontainer, VFIOAddressSpace *= space, +void vfio_container_init(VFIOContainerBase *bcontainer, const VFIOIOMMUClass *ops) { bcontainer->ops =3D ops; - bcontainer->space =3D space; bcontainer->error =3D NULL; bcontainer->dirty_pages_supported =3D false; bcontainer->dma_max_mappings =3D 0; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 15ca3643bc1b4e1a50a5a3de4359d61ec1bda9de..70fd6334e9c959f4301b46ed1ae= 9b77fcb4d7d1c 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -394,7 +394,7 @@ static const VFIOIOMMUClass *vfio_get_iommu_class(int i= ommu_type, Error **errp) } =20 static bool vfio_set_iommu(VFIOContainer *container, int group_fd, - VFIOAddressSpace *space, Error **errp) + Error **errp) { int iommu_type; const VFIOIOMMUClass *vioc; @@ -432,7 +432,7 @@ static bool vfio_set_iommu(VFIOContainer *container, in= t group_fd, return false; } =20 - vfio_container_init(&container->bcontainer, space, vioc); + vfio_container_init(&container->bcontainer, vioc); return true; } =20 @@ -614,7 +614,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, container->fd =3D fd; bcontainer =3D &container->bcontainer; =20 - if (!vfio_set_iommu(container, group->fd, space, errp)) { + if (!vfio_set_iommu(container, group->fd, errp)) { goto free_container_exit; } =20 diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 19bb6419bdffd1c69cc14c7cd5684eb6d0231338..d97a4f7393791660b90e340436c= 6e084c0781444 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -357,7 +357,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, container->ioas_id =3D ioas_id; =20 bcontainer =3D &container->bcontainer; - vfio_container_init(bcontainer, space, iommufd_vioc); + vfio_container_init(bcontainer, iommufd_vioc); vfio_address_space_insert(space, bcontainer); =20 if (!iommufd_cdev_attach_container(vbasedev, container, errp)) { --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197453; cv=none; d=zohomail.com; s=zohoarc; b=oIjnPGWsqejd4PC7rP3NJDS8VPMu3c1nXDq79ZmkXEBBY91M46YIqGBKgDBOY4gWDrPqsHSqZQjVo9AG3QeAKc5M6UeZkTZipSPesM4yIzmB2KxVy2aeXO+2koKyovDBdiod+DZV6/OafknPGCBWhYFD50Ajusu1YnwPc5pryIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197453; 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=QWySTbTuviL2MDR9XALnanz0FRZNH9KAmxqIVmaxBo4=; b=VG0uAwd6cI4hwZ7zOvu50RRiwBLRQh4vCBxrWxbo8+T7IDqVQ4qtINl9eKBAQ5g9E6VHvVNbrgOGedY1loiKZ9mfspuYxvjGHWV/KZkwq7/T1baXjiVsviqKDW0BpIFQwNxpWcz0vBBa59fH4Buq2lVb0oP2Mtk0oWGynSFlJ6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197453426545.7260490686803; Wed, 12 Jun 2024 06:04:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbq-00036x-CG; Wed, 12 Jun 2024 09:01:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNbp-00036T-Co for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:49 -0400 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 1sHNbn-0007xe-DK for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:48 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-qUy7ApuZM4O1OA70C4A6hg-1; Wed, 12 Jun 2024 09:01:44 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E57181955F4A; Wed, 12 Jun 2024 13:01:43 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DA31B1956053; Wed, 12 Jun 2024 13:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197306; 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=QWySTbTuviL2MDR9XALnanz0FRZNH9KAmxqIVmaxBo4=; b=GWViFH/zg2JH7B7mX2uh7JaI/BOQPWyTUbgDiz3Iuum+BlMt7JqZ2Qi7YbGD1A47h9WoWZ nN+nEcPlDfGDURZvts/89nfAzuAoj6A4KKo/6C/A3hi1/SGtI6KZrmWmNOseWxHbGgN5a2 FWSf0k2PAy8PLO1XMygHCLLGT4s9yz0= X-MC-Unique: qUy7ApuZM4O1OA70C4A6hg-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 07/16] vfio/container: Modify vfio_get_iommu_type() to use a container fd Date: Wed, 12 Jun 2024 15:01:13 +0200 Message-ID: <20240612130122.813935-8-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197453673100002 The 'container' pointer has no other use than its 'fd' attribute. Simplify the prototype to ease future changes. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 70fd6334e9c959f4301b46ed1ae9b77fcb4d7d1c..4b68fca13ec0d77022988e975ac= 742382453db47 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -354,7 +354,7 @@ static void vfio_kvm_device_del_group(VFIOGroup *group) /* * vfio_get_iommu_type - selects the richest iommu_type (v2 first) */ -static int vfio_get_iommu_type(VFIOContainer *container, +static int vfio_get_iommu_type(int container_fd, Error **errp) { int iommu_types[] =3D { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU, @@ -362,7 +362,7 @@ static int vfio_get_iommu_type(VFIOContainer *container, int i; =20 for (i =3D 0; i < ARRAY_SIZE(iommu_types); i++) { - if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) { + if (ioctl(container_fd, VFIO_CHECK_EXTENSION, iommu_types[i])) { return iommu_types[i]; } } @@ -399,7 +399,7 @@ static bool vfio_set_iommu(VFIOContainer *container, in= t group_fd, int iommu_type; const VFIOIOMMUClass *vioc; =20 - iommu_type =3D vfio_get_iommu_type(container, errp); + iommu_type =3D vfio_get_iommu_type(container->fd, errp); if (iommu_type < 0) { return false; } --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197522; cv=none; d=zohomail.com; s=zohoarc; b=cb+mFzdLWxmuEIdEXMKSPORbmzHx9V/z/4mrxUA9d2bOqxuiVawg7haGvk96t6FzO2/ZM9Qzv6fHjG4/RKJ8PN+vTsgqtQEa9MZIXdSge5weS+t5ZuDg33yVgnq0DwtVBrQcLlW+2ZmnQr+ylNKe0qcrpe8Q3V+KvLj+/FrDoV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197522; 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=EH8UUSIvDtKEBWOUPp4igw+WtShVTbQ3mCG64g0G7lw=; b=e6I1/VZX/zYM6G6FxfUKq0BwbOb89duUkzlXyldReBg32p/cLDrnHTU6F+YTIQ682QCtPXzkueXggOEQIJwPhIk8V1cpZ0xlC9bZaeILGcTz+5Mkq6yM+MeAv/f6w0TJxoUummX5Uu4b9ENkfJOERNwx6bVvzjCI8m591RlI2rc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197522914436.23303461635385; Wed, 12 Jun 2024 06:05:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbv-00037s-Ph; Wed, 12 Jun 2024 09:01:55 -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 1sHNbu-00037d-Fu for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:54 -0400 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 1sHNbs-0007yu-Rh for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:54 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660--mg6F2PtMMazVcK7ItVdvg-1; Wed, 12 Jun 2024 09:01:46 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E99DE19560B8; Wed, 12 Jun 2024 13:01:45 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4180D1956053; Wed, 12 Jun 2024 13:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197312; 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=EH8UUSIvDtKEBWOUPp4igw+WtShVTbQ3mCG64g0G7lw=; b=BLgc0ZGJx2OK4tRVZxQ8GEvbpHSxoQ+CMgBJIPMvKGiBebWMGE6uOdjueLNA+TE0cJowQc KHIe/j35+ey8f+nUnMtwv1slbmI8itrcRpqaf6D/xnBHszPiFml0qepg6lVs7HHWJhjPQz nWNx9E3vD/0hvMeWWjONkMUgUyEeoAY= X-MC-Unique: -mg6F2PtMMazVcK7ItVdvg-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 08/16] vfio/container: Introduce vfio_get_iommu_class_name() Date: Wed, 12 Jun 2024 15:01:14 +0200 Message-ID: <20240612130122.813935-9-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197524031100003 Rework vfio_get_iommu_class() to return a literal class name instead of a class object. We will need this name to instantiate the object later on. Since the default case asserts, remove the error report as QEMU will simply abort before. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 4b68fca13ec0d77022988e975ac742382453db47..c5ddfdda3426fce0e449e606304= 12875d070b011 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -373,24 +373,20 @@ static int vfio_get_iommu_type(int container_fd, /* * vfio_get_iommu_ops - get a VFIOIOMMUClass associated with a type */ -static const VFIOIOMMUClass *vfio_get_iommu_class(int iommu_type, Error **= errp) +static const char *vfio_get_iommu_class_name(int iommu_type) { - ObjectClass *klass =3D NULL; - switch (iommu_type) { case VFIO_TYPE1v2_IOMMU: case VFIO_TYPE1_IOMMU: - klass =3D object_class_by_name(TYPE_VFIO_IOMMU_LEGACY); + return TYPE_VFIO_IOMMU_LEGACY; break; case VFIO_SPAPR_TCE_v2_IOMMU: case VFIO_SPAPR_TCE_IOMMU: - klass =3D object_class_by_name(TYPE_VFIO_IOMMU_SPAPR); + return TYPE_VFIO_IOMMU_SPAPR; break; default: g_assert_not_reached(); }; - - return VFIO_IOMMU_CLASS(klass); } =20 static bool vfio_set_iommu(VFIOContainer *container, int group_fd, @@ -398,6 +394,7 @@ static bool vfio_set_iommu(VFIOContainer *container, in= t group_fd, { int iommu_type; const VFIOIOMMUClass *vioc; + const char *vioc_name; =20 iommu_type =3D vfio_get_iommu_type(container->fd, errp); if (iommu_type < 0) { @@ -426,11 +423,8 @@ static bool vfio_set_iommu(VFIOContainer *container, i= nt group_fd, =20 container->iommu_type =3D iommu_type; =20 - vioc =3D vfio_get_iommu_class(iommu_type, errp); - if (!vioc) { - error_setg(errp, "No available IOMMU models"); - return false; - } + vioc_name =3D vfio_get_iommu_class_name(iommu_type); + vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(vioc_name)); =20 vfio_container_init(&container->bcontainer, vioc); return true; --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197510; cv=none; d=zohomail.com; s=zohoarc; b=PT0kSHQ75QFdDa0ri9ZToyB0BWSzJvMSjyIxhXfJIrPAwjOPEGesbBhimTzgphrdwO7Wb5Rnx6rugLY5sCT5GVwctg64lJQJ0GbWuBYRbYweNPX8obdL2e0BiR1UdW08/aGM7Iu4M23ZJLKKzWWwbrhFc9ie7gA/4llmSS9DGfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197510; 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=0ruBv5M0blGO19jCA10TbUnAMzMHW8clbxP1/8/PlqA=; b=eIj+V4q+48DDiCPtyHYLUICaQ8ZN0RXw2dZvWRd+jbNAZG1g8qW1QJ+Svx47KhxtV0Y+n98uc5UpC/iVyFk6T7hRL7lTtF1U1GMtE6fqiddmTgKaOX/qQC/GqhE0GgceDXuCAtSyYpC6iDVPo5+nw51X0yDSe2AMIBMcZDlD2Vc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17181975104718.707878679894293; Wed, 12 Jun 2024 06:05:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNbv-00037v-Ui; Wed, 12 Jun 2024 09:01:55 -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 1sHNbs-00037T-FU for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:53 -0400 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 1sHNbr-0007yL-30 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:01:52 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-jjrhaGzKPPqlNsblYkyk0Q-1; Wed, 12 Jun 2024 09:01:48 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0200E1954AC8; Wed, 12 Jun 2024 13:01:48 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5254D1956059; Wed, 12 Jun 2024 13:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197310; 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=0ruBv5M0blGO19jCA10TbUnAMzMHW8clbxP1/8/PlqA=; b=K9aBWjyuNyL+8t91BjE+xPau/zDVvZE9IDLz+SqC9Q5uMcYBcjKi7aik4PGr8vr5MmxzKt ajROwZEhOxPx90plqDcekqD8g7jCTgLOgI0ULNMjrVBDRC+p4HGuezbDPW8RCw08ZyT6Ag XuPjw8uaWTU8NHJxPwrILu1JisR1XJc= X-MC-Unique: jjrhaGzKPPqlNsblYkyk0Q-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 09/16] vfio/container: Introduce vfio_create_container() Date: Wed, 12 Jun 2024 15:01:15 +0200 Message-ID: <20240612130122.813935-10-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197511938100003 This routine allocates the QEMU struct type representing the VFIO container. It is minimal currently and future changes will do more initialization. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index c5ddfdda3426fce0e449e60630412875d070b011..8b47d1a13dca793dee1e1b7e06f= 36e8ea58a81e9 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -430,6 +430,16 @@ static bool vfio_set_iommu(VFIOContainer *container, i= nt group_fd, return true; } =20 +static VFIOContainer *vfio_create_container(int fd, VFIOGroup *group, + Error **errp) +{ + VFIOContainer *container; + + container =3D g_malloc0(sizeof(*container)); + container->fd =3D fd; + return container; +} + static int vfio_get_iommu_info(VFIOContainer *container, struct vfio_iommu_type1_info **info) { @@ -604,13 +614,14 @@ static bool vfio_connect_container(VFIOGroup *group, = AddressSpace *as, goto close_fd_exit; } =20 - container =3D g_malloc0(sizeof(*container)); - container->fd =3D fd; - bcontainer =3D &container->bcontainer; - + container =3D vfio_create_container(fd, group, errp); + if (!container) { + goto close_fd_exit; + } if (!vfio_set_iommu(container, group->fd, errp)) { goto free_container_exit; } + bcontainer =3D &container->bcontainer; =20 if (!vfio_cpr_register_container(bcontainer, errp)) { goto free_container_exit; --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197685; cv=none; d=zohomail.com; s=zohoarc; b=KS4YQFS2xXry59+9lvsWjoiTiPiuzBRbPqd4QEeeugF+cptStz/GNtOx9JGGUEJtp1MOd7x0mh2eC8EOhvI/p3pF/rY4pJtOQX05+p2vcWxGML0YQCrEgafh3yp0jPV1DJiCNZukzcbdGzi59EFrSEE6ilyK6w698F+zGbj6VKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197685; 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=zlQIixF+5BWQgaBiWgi4DZhNkx7aTai0kzaTXlzG5rc=; b=Dg5joBrm/VPaewAM2pIozembixQeDhCr01xlHDrfCvs0pA+fhXEsjfCW97USUpOuChIjAPeHuRI7rpJMPpHNT3HJw/y8hfTJOUM+8e+FTMc+5fBIGb4tPjVN7+dx3JcY1NmjlsTYhX4Uk+quU+mjAFi/wCPWazkM+9LMgsbKC5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197685531908.9236274545528; Wed, 12 Jun 2024 06:08:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNcZ-00045l-G5; Wed, 12 Jun 2024 09:02:35 -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 1sHNcV-0003rX-N3 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:31 -0400 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 1sHNcT-000836-Ic for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:31 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-_CFrJJWoP323RyPcB-IBzw-1; Wed, 12 Jun 2024 09:02:02 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD9881954201; Wed, 12 Jun 2024 13:01:50 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6340F1956053; Wed, 12 Jun 2024 13:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197344; 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=zlQIixF+5BWQgaBiWgi4DZhNkx7aTai0kzaTXlzG5rc=; b=ANRhNVywO1T3CbbH5qQjb+lpzFL7lL6qNOXAJzFkcyLJS+A/Gs8vui+RUejWGL/+5kMXD3 xyzdmReOdThgCXH4dZ2YJn6El1z0vrdHV8Ze2WL+5QWMA4wCRf0CyEJDhFTWHt6pC4iWpO 7oL4PmkX2W0JZ0xXbggfJN2/Qpeqaqs= X-MC-Unique: _CFrJJWoP323RyPcB-IBzw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 10/16] vfio/container: Discover IOMMU type before creating the container Date: Wed, 12 Jun 2024 15:01:16 +0200 Message-ID: <20240612130122.813935-11-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197686931100003 Since the QEMU struct type representing the VFIO container is deduced from the IOMMU type exposed by the host, this type should be well defined *before* creating the container struct. This will be necessary to instantiate a QOM object of the correct type in future changes. Rework vfio_set_iommu() to extract the part doing the container initialization and move it under vfio_create_container(). Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 47 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 8b47d1a13dca793dee1e1b7e06f36e8ea58a81e9..983726f9514ec1106d521c9711a= 46a4780688ee1 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -389,54 +389,56 @@ static const char *vfio_get_iommu_class_name(int iomm= u_type) }; } =20 -static bool vfio_set_iommu(VFIOContainer *container, int group_fd, - Error **errp) +static bool vfio_set_iommu(int container_fd, int group_fd, + int *iommu_type, Error **errp) { - int iommu_type; - const VFIOIOMMUClass *vioc; - const char *vioc_name; - - iommu_type =3D vfio_get_iommu_type(container->fd, errp); - if (iommu_type < 0) { - return false; - } - - if (ioctl(group_fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { + if (ioctl(group_fd, VFIO_GROUP_SET_CONTAINER, &container_fd)) { error_setg_errno(errp, errno, "Failed to set group container"); return false; } =20 - while (ioctl(container->fd, VFIO_SET_IOMMU, iommu_type)) { - if (iommu_type =3D=3D VFIO_SPAPR_TCE_v2_IOMMU) { + while (ioctl(container_fd, VFIO_SET_IOMMU, *iommu_type)) { + if (*iommu_type =3D=3D VFIO_SPAPR_TCE_v2_IOMMU) { /* * On sPAPR, despite the IOMMU subdriver always advertises v1 = and * v2, the running platform may not support v2 and there is no * way to guess it until an IOMMU group gets added to the cont= ainer. * So in case it fails with v2, try v1 as a fallback. */ - iommu_type =3D VFIO_SPAPR_TCE_IOMMU; + *iommu_type =3D VFIO_SPAPR_TCE_IOMMU; continue; } error_setg_errno(errp, errno, "Failed to set iommu for container"); return false; } =20 - container->iommu_type =3D iommu_type; - - vioc_name =3D vfio_get_iommu_class_name(iommu_type); - vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(vioc_name)); - - vfio_container_init(&container->bcontainer, vioc); return true; } =20 static VFIOContainer *vfio_create_container(int fd, VFIOGroup *group, Error **errp) { + int iommu_type; + const VFIOIOMMUClass *vioc; + const char *vioc_name; VFIOContainer *container; =20 + iommu_type =3D vfio_get_iommu_type(fd, errp); + if (iommu_type < 0) { + return NULL; + } + + if (!vfio_set_iommu(fd, group->fd, &iommu_type, errp)) { + return NULL; + } + + vioc_name =3D vfio_get_iommu_class_name(iommu_type); + vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(vioc_name)); + container =3D g_malloc0(sizeof(*container)); container->fd =3D fd; + container->iommu_type =3D iommu_type; + vfio_container_init(&container->bcontainer, vioc); return container; } =20 @@ -618,9 +620,6 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, if (!container) { goto close_fd_exit; } - if (!vfio_set_iommu(container, group->fd, errp)) { - goto free_container_exit; - } bcontainer =3D &container->bcontainer; =20 if (!vfio_cpr_register_container(bcontainer, errp)) { --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197530; cv=none; d=zohomail.com; s=zohoarc; b=LJXp0bSvcN/tzpBLFNLtDpNCH54W6OIuJx986vduv3h+WRGZYgGSft3xTII1JozkJfSQlQwjD6K+vuQxxtDrW//X3Y1FQQ7k0gGRzZQ0qU0sJP4qjv5SAKeJRJIOHlfdJJbS/vMJquRnTqXSH65oN5MvHUYC82ENBuT6aPanN84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197530; 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=5nBen5IgEEM+2o2uUCFlCqfCdfjnfcktdBhaZYPZvfA=; b=jbSd3Lbt6J4Sqo7gatdkOzCNMhhB9jFfbee7EwY3dFi0kmvN+ILqsNZ9p5VjkYO0k5IxIMZqu32anCFCGRql2ZWWsZT7n8pWAxInUu/kkA68nQdIB7ZzDDli120JOKQ9Y3IGvMDSanXJMas2zwKAg1BhR0pMeUUNELUj32arek0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197530274199.93635700835273; Wed, 12 Jun 2024 06:05:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNc3-00039O-KO; Wed, 12 Jun 2024 09:02:03 -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 1sHNc1-00038n-HM for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:01 -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 1sHNby-0007zl-92 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:01 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-HoFZ_CMyNpSnMwzN-H3Xbw-1; Wed, 12 Jun 2024 09:01:53 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B1591955E93; Wed, 12 Jun 2024 13:01:52 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E5AE61956053; Wed, 12 Jun 2024 13:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197317; 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=5nBen5IgEEM+2o2uUCFlCqfCdfjnfcktdBhaZYPZvfA=; b=Y5v0pdsK2Z2GqjgNparFpOwFCOqQm7ebX1WzJK9lQKY7u3fFUV9fHArjAuLWlIO9yqwHtx eI/1z1UgBC8BwtZ79uZ/p5lsPKA5Fj2voZ00HjLN8ztkT9VVqUZELyGHnMnMLJoSVg0Iij fh/Qvne9ezZ9ZukR0pSTekWx++MBz2k= X-MC-Unique: HoFZ_CMyNpSnMwzN-H3Xbw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 11/16] vfio/container: Change VFIOContainerBase to use QOM Date: Wed, 12 Jun 2024 15:01:17 +0200 Message-ID: <20240612130122.813935-12-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197532039100010 VFIOContainerBase was made a QOM interface because we believed that a QOM object would expose all the IOMMU backends to the QEMU machine and human interface. This only applies to user creatable devices or objects. Change the VFIOContainerBase nature from interface to object and make the necessary adjustments in the VFIO_IOMMU hierarchy. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 4 ++++ include/hw/vfio/vfio-container-base.h | 12 +++--------- hw/vfio/container-base.c | 4 +++- hw/vfio/container.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/spapr.c | 3 +++ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 825d80130bd435fe50830c8ae5b7905d18104dd6..5d0b8496cf85bac8d4ea770fae0= 4acc02d84df82 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -84,6 +84,8 @@ typedef struct VFIOContainer { QLIST_HEAD(, VFIOGroup) group_list; } VFIOContainer; =20 +OBJECT_DECLARE_TYPE(VFIOContainer, VFIOIOMMUClass, VFIO_IOMMU_LEGACY); + typedef struct VFIOHostDMAWindow { hwaddr min_iova; hwaddr max_iova; @@ -99,6 +101,8 @@ typedef struct VFIOIOMMUFDContainer { uint32_t ioas_id; } VFIOIOMMUFDContainer; =20 +OBJECT_DECLARE_TYPE(VFIOIOMMUFDContainer, VFIOIOMMUClass, VFIO_IOMMU_IOMMU= FD); + typedef struct VFIODeviceOps VFIODeviceOps; =20 typedef struct VFIODevice { diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index d505f63607ec40e6aa44aeb3e20848ac780562a1..b079b76f68975c5701a289ce901= 2e912a8e44fc6 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -34,6 +34,7 @@ typedef struct VFIOAddressSpace { * This is the base object for vfio container backends */ typedef struct VFIOContainerBase { + Object parent; const VFIOIOMMUClass *ops; VFIOAddressSpace *space; MemoryListener listener; @@ -96,17 +97,10 @@ void vfio_container_destroy(VFIOContainerBase *bcontain= er); #define TYPE_VFIO_IOMMU_SPAPR TYPE_VFIO_IOMMU "-spapr" #define TYPE_VFIO_IOMMU_IOMMUFD TYPE_VFIO_IOMMU "-iommufd" =20 -/* - * VFIOContainerBase is not an abstract QOM object because it felt - * unnecessary to expose all the IOMMU backends to the QEMU machine - * and human interface. However, we can still abstract the IOMMU - * backend handlers using a QOM interface class. This provides more - * flexibility when referencing the various implementations. - */ -DECLARE_CLASS_CHECKERS(VFIOIOMMUClass, VFIO_IOMMU, TYPE_VFIO_IOMMU) +OBJECT_DECLARE_TYPE(VFIOContainerBase, VFIOIOMMUClass, VFIO_IOMMU) =20 struct VFIOIOMMUClass { - InterfaceClass parent_class; + ObjectClass parent_class; =20 /* Properties */ const char *hiod_typename; diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 280f0dd2db1fc3939fe9925ce00a2c50d0e14196..98c15e174dd78df5146ee83c05c= 98f3ea9c1e52c 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -102,8 +102,10 @@ void vfio_container_destroy(VFIOContainerBase *bcontai= ner) static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU, - .parent =3D TYPE_INTERFACE, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(VFIOContainerBase), .class_size =3D sizeof(VFIOIOMMUClass), + .abstract =3D true, }, }; =20 diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 983726f9514ec1106d521c9711a46a4780688ee1..f1519518d0b7efd2a6086f07bc4= 97596a5236abf 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -1194,6 +1194,7 @@ static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU_LEGACY, .parent =3D TYPE_VFIO_IOMMU, + .instance_size =3D sizeof(VFIOContainer), .class_init =3D vfio_iommu_legacy_class_init, }, { .name =3D TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO, diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index d97a4f7393791660b90e340436c6e084c0781444..80ba09b859a02bb89823460064a= 9f099fd98cff0 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -670,6 +670,7 @@ static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU_IOMMUFD, .parent =3D TYPE_VFIO_IOMMU, + .instance_size =3D sizeof(VFIOIOMMUFDContainer), .class_init =3D vfio_iommu_iommufd_class_init, }, { .name =3D TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 47b040f1bcca7dd0b5cf052d941b43541e98a3c5..05a3cedc4b1703a61573730bc77= fc15d44f7a9eb 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -30,6 +30,8 @@ typedef struct VFIOSpaprContainer { QLIST_HEAD(, VFIOHostDMAWindow) hostwin_list; } VFIOSpaprContainer; =20 +OBJECT_DECLARE_TYPE(VFIOSpaprContainer, VFIOIOMMUClass, VFIO_IOMMU_SPAPR); + static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *sect= ion) { if (memory_region_is_iommu(section->mr)) { @@ -548,6 +550,7 @@ static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU_SPAPR, .parent =3D TYPE_VFIO_IOMMU_LEGACY, + .instance_size =3D sizeof(VFIOSpaprContainer), .class_init =3D vfio_iommu_spapr_class_init, }, }; --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197577; cv=none; d=zohomail.com; s=zohoarc; b=FUgzg4uzHUVNpRjsJLa7H/Tg1idhR3PhP1K/hx3NYWeGZG64m+ZmbCTnfQz9QmpXS7RjFD6Af7ga3yzF+oQqPaaYYp94iadzs5wD3N35PLyhfbqbg7pgdAMJGRnZcLcWka7RNBOrtPY+HLTYIh5zVCjegvSHdm9cLOjDxJpf2mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197577; 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=aAFSvPlmfqnTJEUUtuHv/7KBJ58vK70XthaPf9rN1VY=; b=JBAFZmvs0Nk8JB9v1nZnaNREhnAfpal5J3Yp8nktS/P5t+8a15ZMEjmz88TkVYsB9q00itoF0VUgpKdGUvR0KTrH4QGPdZN0UOekscxggk2B74aQ4oGAInp7l3ja2wKyI98j5f5SpaLaRZCKjmCpKbIZV4mMMLj99YfEwfO77O8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197577279740.3336926141527; Wed, 12 Jun 2024 06:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNc5-00039Y-6h; Wed, 12 Jun 2024 09:02:05 -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 1sHNc1-00038i-5o for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:01 -0400 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 1sHNby-0007zm-7i for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:00 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-AYLpDI9ZMmCbP8zEj6Us-A-1; Wed, 12 Jun 2024 09:01:55 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CB1F9195607B; Wed, 12 Jun 2024 13:01:54 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04EC51956053; Wed, 12 Jun 2024 13:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197317; 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=aAFSvPlmfqnTJEUUtuHv/7KBJ58vK70XthaPf9rN1VY=; b=Dz9grMY6mbiF6WpWEPSAm6hIYXaENIAT7yxXDcxs8wAYrUuZuohs7tuiNMOwXNYY6OLMV8 OYerJQmnGB/CZUkrppuYC9pIxQtxgXT94qKvBEupRLCHlCcJnCygcfjFkqEwN3rrh56WSS lOLzSCjU++QkDki63X5m16U7uj6aEdA= X-MC-Unique: AYLpDI9ZMmCbP8zEj6Us-A-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 12/16] vfio/container: Switch to QOM Date: Wed, 12 Jun 2024 15:01:18 +0200 Message-ID: <20240612130122.813935-13-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197578257100003 Instead of allocating the container struct, create a QOM object of the appropriate type. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 6 +++--- hw/vfio/iommufd.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index f1519518d0b7efd2a6086f07bc497596a5236abf..f8bde76cfdba41f3d6da8a7c852= 624485bd933a0 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -435,7 +435,7 @@ static VFIOContainer *vfio_create_container(int fd, VFI= OGroup *group, vioc_name =3D vfio_get_iommu_class_name(iommu_type); vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(vioc_name)); =20 - container =3D g_malloc0(sizeof(*container)); + container =3D VFIO_IOMMU_LEGACY(object_new(vioc_name)); container->fd =3D fd; container->iommu_type =3D iommu_type; vfio_container_init(&container->bcontainer, vioc); @@ -674,7 +674,7 @@ unregister_container_exit: vfio_cpr_unregister_container(bcontainer); =20 free_container_exit: - g_free(container); + object_unref(container); =20 close_fd_exit: close(fd); @@ -718,7 +718,7 @@ static void vfio_disconnect_container(VFIOGroup *group) trace_vfio_disconnect_container(container->fd); vfio_cpr_unregister_container(bcontainer); close(container->fd); - g_free(container); + object_unref(container); =20 vfio_put_address_space(space); } diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 80ba09b859a02bb89823460064a9f099fd98cff0..5daf9c1ea268e7b4ab0dbfe9e55= a176b23aaa62b 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -239,7 +239,7 @@ static void iommufd_cdev_container_destroy(VFIOIOMMUFDC= ontainer *container) memory_listener_unregister(&bcontainer->listener); vfio_container_destroy(bcontainer); iommufd_backend_free_id(container->be, container->ioas_id); - g_free(container); + object_unref(container); } =20 static int iommufd_cdev_ram_block_discard_disable(bool state) @@ -352,7 +352,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, =20 trace_iommufd_cdev_alloc_ioas(vbasedev->iommufd->fd, ioas_id); =20 - container =3D g_malloc0(sizeof(*container)); + container =3D VFIO_IOMMU_IOMMUFD(object_new(TYPE_VFIO_IOMMU_IOMMUFD)); container->be =3D vbasedev->iommufd; container->ioas_id =3D ioas_id; =20 --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197939; cv=none; d=zohomail.com; s=zohoarc; b=GnXIDRIuugRMCBL7flnwaeq6naMDtTVZ8KBPSXMUDJSw5iF9qSb2MdTmZCTY77BRB+wYvpwfiw54qpv9f3oKNUTSFJNr0GizIh+20xqEueRyEXZ1okV5c4Ysqk3nuyvh78bYIURDePQBy0EDhJ5cvXMwwP+czgSO3I3XBYTtQwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197939; 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=wZmcgFMvgRdwuVB8jTrsKpoEok8IGGidAmfsen4KOfg=; b=mSs7+hIAG7MXfpZmce4fZJmi+EyfX4e2fOuXlVPKcY9cVTDRkTWzWehF+QmO+jJH3UkMoU9oE7UeYQY7po9H8NsFhZ0mYhs81qa6L0zHICYwr+hxT5xXi6wCN5aU9CtAn8rVwZb38gOiTNT1LFiaERIYAwsnwZE5RFGlomVQums= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197938910914.9316132731344; Wed, 12 Jun 2024 06:12:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNcN-0003RP-KD; Wed, 12 Jun 2024 09:02:23 -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 1sHNcD-0003Dk-1L for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:18 -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 1sHNc3-00080r-3h for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:04 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-aWog0iRPPZab3__3kgdIBw-1; Wed, 12 Jun 2024 09:01:57 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E867C1955DC5; Wed, 12 Jun 2024 13:01:56 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1A3FE1956053; Wed, 12 Jun 2024 13:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197321; 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=wZmcgFMvgRdwuVB8jTrsKpoEok8IGGidAmfsen4KOfg=; b=GEBI/oYYpo4n9sYicrR6ZDdcmhxXCYE3jd6RAFVVPPWdh4AfETeHFnzloEdxK/KwtUJrU7 Y3DNepqXElOljfWaDy3BHy4vVndBaX/zSJ7WsuYBzBw92VQ2ew4LxSPaE9U1MHEKb+w+0z AYARAGlzNm/eO0rKtMNkuEVLq+A4YQM= X-MC-Unique: aWog0iRPPZab3__3kgdIBw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 13/16] vfio/container: Introduce an instance_init() handler Date: Wed, 12 Jun 2024 15:01:19 +0200 Message-ID: <20240612130122.813935-14-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197940205100003 This allows us to move the initialization code from vfio_container_init(), which we will soon remove. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container-base.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 98c15e174dd78df5146ee83c05c98f3ea9c1e52c..3858f5ab1d68e897f9013161d7c= 5c20c0553029d 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -75,12 +75,6 @@ void vfio_container_init(VFIOContainerBase *bcontainer, const VFIOIOMMUClass *ops) { bcontainer->ops =3D ops; - bcontainer->error =3D NULL; - bcontainer->dirty_pages_supported =3D false; - bcontainer->dma_max_mappings =3D 0; - bcontainer->iova_ranges =3D NULL; - QLIST_INIT(&bcontainer->giommu_list); - QLIST_INIT(&bcontainer->vrdl_list); } =20 void vfio_container_destroy(VFIOContainerBase *bcontainer) @@ -99,10 +93,23 @@ void vfio_container_destroy(VFIOContainerBase *bcontain= er) g_list_free_full(bcontainer->iova_ranges, g_free); } =20 +static void vfio_container_instance_init(Object *obj) +{ + VFIOContainerBase *bcontainer =3D VFIO_IOMMU(obj); + + bcontainer->error =3D NULL; + bcontainer->dirty_pages_supported =3D false; + bcontainer->dma_max_mappings =3D 0; + bcontainer->iova_ranges =3D NULL; + QLIST_INIT(&bcontainer->giommu_list); + QLIST_INIT(&bcontainer->vrdl_list); +} + static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU, .parent =3D TYPE_OBJECT, + .instance_init =3D vfio_container_instance_init, .instance_size =3D sizeof(VFIOContainerBase), .class_size =3D sizeof(VFIOIOMMUClass), .abstract =3D true, --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197780; cv=none; d=zohomail.com; s=zohoarc; b=H2KrHvaY/EZYbBDUKP7RIjaV55mrshwkTIEQy0HPvPbLlRRB2jq00tv8zQqgXen12ghoieWC9n3w2UNXnwj6iC2881pVi/BH5L8QVFnJVpK94Oy3abUuih8Z4m7y/AcVs8MEcwGqqPrqViqA+7UeKSonWAXo00lPJrjBjJPqAyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197780; 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=BtR9KWjkVOl5a+QyMVcTFX2Y2Sd5zloxUYPRhRaXBqo=; b=KSVUT2eNetWit76nk8m7WJXoaWeq9oZ+IrEKB/IR0d7QNnyn5iGOPxUJtKTXE3K/F4ehWhhwRzK7P975NR+79Il8hvemO53Rstv4BeJznDdErxrQ+lmHjKE2b8mtYiYYDOScLuY75m6B073zTow4M6B5rQzMnfdfydFY0+VEOCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197780947694.3894381827392; Wed, 12 Jun 2024 06:09:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNcM-0003P3-TO; Wed, 12 Jun 2024 09:02:23 -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 1sHNcH-0003EA-0d for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:19 -0400 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 1sHNcA-000817-I1 for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:14 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-jA4zdDZgNg6hAJ0cAY7ZNA-1; Wed, 12 Jun 2024 09:02:00 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AD4701955DC7; Wed, 12 Jun 2024 13:01:59 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 53E6F1956053; Wed, 12 Jun 2024 13:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197324; 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=BtR9KWjkVOl5a+QyMVcTFX2Y2Sd5zloxUYPRhRaXBqo=; b=CnQ2tVhc4YW/zLZDCGT/hy/QhUHUmxUokQgLP/gGv5Aj6cV693SC+oPtjPMuDt2M/PdYZ1 2pJ7tfxv+rIqIyUbNAlysOe4VOQKaivsN9oBlaNTeMivHNVWrNCUx9aimWH5pYiRgyGjkr uw73Gl0EiXQ9O1PQrvyx9YUr09d1pLM= X-MC-Unique: jA4zdDZgNg6hAJ0cAY7ZNA-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 14/16] vfio/container: Remove VFIOContainerBase::ops Date: Wed, 12 Jun 2024 15:01:20 +0200 Message-ID: <20240612130122.813935-15-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197781471100001 Instead, use VFIO_IOMMU_GET_CLASS() to get the class pointer. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-base.h | 1 - hw/vfio/common.c | 2 +- hw/vfio/container-base.c | 37 +++++++++++++++++---------- hw/vfio/container.c | 15 ++++++----- hw/vfio/iommufd.c | 4 +-- hw/vfio/pci.c | 4 +-- 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index b079b76f68975c5701a289ce9012e912a8e44fc6..6b57cd8e7f5d7d2817f6e3b96ce= 4566d2630bb12 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -35,7 +35,6 @@ typedef struct VFIOAddressSpace { */ typedef struct VFIOContainerBase { Object parent; - const VFIOIOMMUClass *ops; VFIOAddressSpace *space; MemoryListener listener; Error *error; diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 1686a0bed23bd95467bfb00a0c39a4d966e49cae..7cdb969fd396ae3815cb175ad63= 1d93d7cca7006 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1573,5 +1573,5 @@ void vfio_detach_device(VFIODevice *vbasedev) return; } object_unref(vbasedev->hiod); - vbasedev->bcontainer->ops->detach_device(vbasedev); + VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); } diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 3858f5ab1d68e897f9013161d7c5c20c0553029d..24669d4d7472f49ac3adf2618a3= 2bf7d82c5c344 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -19,62 +19,73 @@ int vfio_container_dma_map(VFIOContainerBase *bcontaine= r, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly) { - g_assert(bcontainer->ops->dma_map); - return bcontainer->ops->dma_map(bcontainer, iova, size, vaddr, readonl= y); + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + g_assert(vioc->dma_map); + return vioc->dma_map(bcontainer, iova, size, vaddr, readonly); } =20 int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, IOMMUTLBEntry *iotlb) { - g_assert(bcontainer->ops->dma_unmap); - return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb); + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + g_assert(vioc->dma_unmap); + return vioc->dma_unmap(bcontainer, iova, size, iotlb); } =20 bool vfio_container_add_section_window(VFIOContainerBase *bcontainer, MemoryRegionSection *section, Error **errp) { - if (!bcontainer->ops->add_window) { + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + if (!vioc->add_window) { return true; } =20 - return bcontainer->ops->add_window(bcontainer, section, errp); + return vioc->add_window(bcontainer, section, errp); } =20 void vfio_container_del_section_window(VFIOContainerBase *bcontainer, MemoryRegionSection *section) { - if (!bcontainer->ops->del_window) { + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + if (!vioc->del_window) { return; } =20 - return bcontainer->ops->del_window(bcontainer, section); + return vioc->del_window(bcontainer, section); } =20 int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, bool start, Error **errp) { + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + if (!bcontainer->dirty_pages_supported) { return 0; } =20 - g_assert(bcontainer->ops->set_dirty_page_tracking); - return bcontainer->ops->set_dirty_page_tracking(bcontainer, start, err= p); + g_assert(vioc->set_dirty_page_tracking); + return vioc->set_dirty_page_tracking(bcontainer, start, errp); } =20 int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp) { - g_assert(bcontainer->ops->query_dirty_bitmap); - return bcontainer->ops->query_dirty_bitmap(bcontainer, vbmap, iova, si= ze, + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + g_assert(vioc->query_dirty_bitmap); + return vioc->query_dirty_bitmap(bcontainer, vbmap, iova, size, errp); } =20 void vfio_container_init(VFIOContainerBase *bcontainer, const VFIOIOMMUClass *ops) { - bcontainer->ops =3D ops; } =20 void vfio_container_destroy(VFIOContainerBase *bcontainer) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index f8bde76cfdba41f3d6da8a7c852624485bd933a0..9e9e1ab229c0804f073cd65d927= 35d4bbf63d1d7 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -548,6 +548,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, VFIOContainerBase *bcontainer; int ret, fd; VFIOAddressSpace *space; + VFIOIOMMUClass *vioc; =20 space =3D vfio_get_address_space(as); =20 @@ -632,9 +633,10 @@ static bool vfio_connect_container(VFIOGroup *group, A= ddressSpace *as, goto unregister_container_exit; } =20 - assert(bcontainer->ops->setup); + vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + assert(vioc->setup); =20 - if (!bcontainer->ops->setup(bcontainer, errp)) { + if (!vioc->setup(bcontainer, errp)) { goto enable_discards_exit; } =20 @@ -663,8 +665,8 @@ listener_release_exit: QLIST_REMOVE(bcontainer, next); vfio_kvm_device_del_group(group); memory_listener_unregister(&bcontainer->listener); - if (bcontainer->ops->release) { - bcontainer->ops->release(bcontainer); + if (vioc->release) { + vioc->release(bcontainer); } =20 enable_discards_exit: @@ -689,6 +691,7 @@ static void vfio_disconnect_container(VFIOGroup *group) { VFIOContainer *container =3D group->container; VFIOContainerBase *bcontainer =3D &container->bcontainer; + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); =20 QLIST_REMOVE(group, container_next); group->container =3D NULL; @@ -700,8 +703,8 @@ static void vfio_disconnect_container(VFIOGroup *group) */ if (QLIST_EMPTY(&container->group_list)) { memory_listener_unregister(&bcontainer->listener); - if (bcontainer->ops->release) { - bcontainer->ops->release(bcontainer); + if (vioc->release) { + vioc->release(bcontainer); } } =20 diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 5daf9c1ea268e7b4ab0dbfe9e55a176b23aaa62b..e1932135df410c53d4062616ee2= 664b27d30b92c 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -324,7 +324,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, /* try to attach to an existing container in this space */ QLIST_FOREACH(bcontainer, &space->containers, next) { container =3D container_of(bcontainer, VFIOIOMMUFDContainer, bcont= ainer); - if (bcontainer->ops !=3D iommufd_vioc || + if (VFIO_IOMMU_GET_CLASS(bcontainer) !=3D iommufd_vioc || vbasedev->iommufd !=3D container->be) { continue; } @@ -465,7 +465,7 @@ static VFIODevice *iommufd_cdev_pci_find_by_devid(__u32= devid) VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD)); =20 QLIST_FOREACH(vbasedev_iter, &vfio_device_list, global_next) { - if (vbasedev_iter->bcontainer->ops !=3D iommufd_vioc) { + if (VFIO_IOMMU_GET_CLASS(vbasedev_iter->bcontainer) !=3D iommufd_v= ioc) { continue; } if (devid =3D=3D vbasedev_iter->devid) { diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d8a76c1ee003e6f5669e8390271836fd9d839a8a..e03d9f3ba5461f55f6351d937ab= a5d522a9128ec 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2511,9 +2511,9 @@ int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vd= ev, static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) { VFIODevice *vbasedev =3D &vdev->vbasedev; - const VFIOIOMMUClass *ops =3D vbasedev->bcontainer->ops; + const VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(vbasedev->bcontain= er); =20 - return ops->pci_hot_reset(vbasedev, single); + return vioc->pci_hot_reset(vbasedev, single); } =20 /* --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197741; cv=none; d=zohomail.com; s=zohoarc; b=lUZwfoDXCOz20QUMn7slV1VCpZtAMecA4i0/1YBF17Pen+4SqgFJy0hzN6A1bJLoiKDzkwcLJMvI7qk0YWeeqsg7Zv6mg4y8zABjNCpuH2zZK+1FQ58Si1lVuZrQMomJ80uyFDsy9G+CfjDBtmjGSdQo5CjH/jVn3sK8vZ+DYCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197741; 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=G4pjGaGoyjtNHc+eRM2tVmkqWWianbUh/EWWOB064lE=; b=jpceb+iLQPFYsKSCAtCZw99RVqYujkh10bWLo2guocLTWQRk+J0nPf6qZ+bhOBkjulVruobFKKlpG0KLrdDDX/FAlpsdL3TKpDNThrBARdteqBMTzm2W5hjVTub3qkpVsPp67XEZTPwQ7MxyOKo0TIpqjAEekEFx86qdQ8BxYlU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197741239235.64191097850517; Wed, 12 Jun 2024 06:09:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNcO-0003SG-H4; Wed, 12 Jun 2024 09:02:24 -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 1sHNcK-0003KT-TN for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:20 -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 1sHNcC-00081Q-Oj for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:19 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-jqQTprIaPOudRrniSpSlbw-1; Wed, 12 Jun 2024 09:02:02 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B32E1954214; Wed, 12 Jun 2024 13:02:02 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B2B31956053; Wed, 12 Jun 2024 13:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197328; 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=G4pjGaGoyjtNHc+eRM2tVmkqWWianbUh/EWWOB064lE=; b=W1YFj6Yr+WbuC/C/HX0ILkxMMvqT/xBSKQQ/tFTkyeLM4Z5OmR1phExu5HrZ017/NMNxB9 /WkWRYIyceNy9nayE+hgtYOBQd8vdxm8+1vifYpqaYVudVGP3e17UESE3YJlnotCoVKlF6 5GH7e+vnRWRHJiJqRlFOG/PxRQyjorA= X-MC-Unique: jqQTprIaPOudRrniSpSlbw-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 15/16] vfio/container: Remove vfio_container_init() Date: Wed, 12 Jun 2024 15:01:21 +0200 Message-ID: <20240612130122.813935-16-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197743252100003 It's now empty. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-base.h | 2 -- hw/vfio/container-base.c | 5 ----- hw/vfio/container.c | 3 --- hw/vfio/iommufd.c | 1 - 4 files changed, 11 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 6b57cd8e7f5d7d2817f6e3b96ce4566d2630bb12..6242a62771caa8cf19440a53ad6= f4db862ca12d7 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -86,8 +86,6 @@ int vfio_container_set_dirty_page_tracking(VFIOContainerB= ase *bcontainer, int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp); =20 -void vfio_container_init(VFIOContainerBase *bcontainer, - const VFIOIOMMUClass *ops); void vfio_container_destroy(VFIOContainerBase *bcontainer); =20 =20 diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 24669d4d7472f49ac3adf2618a32bf7d82c5c344..970ae2356a92f87df44e1dd58ff= 8c67045a24ef1 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -83,11 +83,6 @@ int vfio_container_query_dirty_bitmap(const VFIOContaine= rBase *bcontainer, errp); } =20 -void vfio_container_init(VFIOContainerBase *bcontainer, - const VFIOIOMMUClass *ops) -{ -} - void vfio_container_destroy(VFIOContainerBase *bcontainer) { VFIOGuestIOMMU *giommu, *tmp; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 9e9e1ab229c0804f073cd65d92735d4bbf63d1d7..60a0838a9ca83a010d73396dbcd= 2d24fcdc802ae 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -419,7 +419,6 @@ static VFIOContainer *vfio_create_container(int fd, VFI= OGroup *group, Error **errp) { int iommu_type; - const VFIOIOMMUClass *vioc; const char *vioc_name; VFIOContainer *container; =20 @@ -433,12 +432,10 @@ static VFIOContainer *vfio_create_container(int fd, V= FIOGroup *group, } =20 vioc_name =3D vfio_get_iommu_class_name(iommu_type); - vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(vioc_name)); =20 container =3D VFIO_IOMMU_LEGACY(object_new(vioc_name)); container->fd =3D fd; container->iommu_type =3D iommu_type; - vfio_container_init(&container->bcontainer, vioc); return container; } =20 diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index e1932135df410c53d4062616ee2664b27d30b92c..811e12b7da91357fa5b85ebb9dc= c3adeabfa41fd 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -357,7 +357,6 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, container->ioas_id =3D ioas_id; =20 bcontainer =3D &container->bcontainer; - vfio_container_init(bcontainer, iommufd_vioc); vfio_address_space_insert(space, bcontainer); =20 if (!iommufd_cdev_attach_container(vbasedev, container, errp)) { --=20 2.45.2 From nobody Tue Oct 22 20:47:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1718197404; cv=none; d=zohomail.com; s=zohoarc; b=LjMoE7Hd33k/oVoivLjqkIYDWNqOG5Z0Wgqu+dXHO9CuPpaGB/Z9cLbJ/X1axwvWkrkRiG/Eg3U44FC3idT/aAdC2KfvOO+q4NGYN6QgQUaUMMx9JMzmtW0H2AYDlKYtAMKbJ8voNmqSQmfHuFVw/IfW9y5XDicMsVwIeIbZTN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718197404; 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=Ws/ojGwG8BdlKWnideBj9jHmFCpvjonk90U9l4xkS/o=; b=aAl2T24BGfPpXjp9Qj9qpUGuKQ4d0b3cHjmwQsA1N6zRmUE+qJ2KBFCZX5ER0mp7SrYGUe9zGFohp/Jf+lpTYnCk/QjP5xIN97J7vJHm7F7r01WX5zaRxwtzeZIEaE6PwgRPqVlO1UXnhWVvYUu4hw7kBf9kL8NUpki5zw7NS5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718197404952414.96580439961895; Wed, 12 Jun 2024 06:03:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNcL-0003MJ-Vz; Wed, 12 Jun 2024 09:02:22 -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 1sHNcI-0003GC-Ug for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:19 -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 1sHNcD-00081C-Hm for qemu-devel@nongnu.org; Wed, 12 Jun 2024 09:02:17 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-BpMRUI1hPimHpkpHb-JbHA-1; Wed, 12 Jun 2024 09:02:04 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0FCE51955D65; Wed, 12 Jun 2024 13:02:04 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F5911956056; Wed, 12 Jun 2024 13:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718197326; 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=Ws/ojGwG8BdlKWnideBj9jHmFCpvjonk90U9l4xkS/o=; b=Opdc+Qe0Is1BI7N29tVyzqggtHleG6JnjbjK+zPzvYGubOXlfSnUoLoPyk1jk7cnjKZ/ZT 9baxEAFKdniGBkjKGHQhN1Dcs47MaBtgpibnnKKKl9hl0r8w3KR9uAfoQZ2nllq/Yefuyl jWaKlQ93e77CqHUeNYGltEAG8tx32DM= X-MC-Unique: BpMRUI1hPimHpkpHb-JbHA-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Eric Auger , Zhenzhong Duan , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v1 16/16] vfio/container: Introduce vfio_iommu_legacy_instance_init() Date: Wed, 12 Jun 2024 15:01:22 +0200 Message-ID: <20240612130122.813935-17-clg@redhat.com> In-Reply-To: <20240612130122.813935-1-clg@redhat.com> References: <20240612130122.813935-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.0 on 10.30.177.17 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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: 1718197405318100002 Just as we did for the VFIOContainerBase object, introduce an instance_init() handler for the legacy VFIOContainer object and do the specific initialization there. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 60a0838a9ca83a010d73396dbcd2d24fcdc802ae..b76cdf7e06e5675a8734b1fba57= 37eae3d5ad955 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -639,7 +639,6 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, =20 vfio_kvm_device_add_group(group); =20 - QLIST_INIT(&container->group_list); vfio_address_space_insert(space, bcontainer); =20 group->container =3D container; @@ -1181,6 +1180,13 @@ hiod_legacy_vfio_get_iova_ranges(HostIOMMUDevice *hi= od, Error **errp) return l; } =20 +static void vfio_iommu_legacy_instance_init(Object *obj) +{ + VFIOContainer *container =3D VFIO_IOMMU_LEGACY(obj); + + QLIST_INIT(&container->group_list); +} + static void hiod_legacy_vfio_class_init(ObjectClass *oc, void *data) { HostIOMMUDeviceClass *hioc =3D HOST_IOMMU_DEVICE_CLASS(oc); @@ -1194,6 +1200,7 @@ static const TypeInfo types[] =3D { { .name =3D TYPE_VFIO_IOMMU_LEGACY, .parent =3D TYPE_VFIO_IOMMU, + .instance_init =3D vfio_iommu_legacy_instance_init, .instance_size =3D sizeof(VFIOContainer), .class_init =3D vfio_iommu_legacy_class_init, }, { --=20 2.45.2