From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975551; cv=none; d=zohomail.com; s=zohoarc; b=FiRXTSBN8Aw6pVLUnjTP4s4lsbfR1bmsFHoOjiE22bvIl1kVLo0cmXrZ2HlVInFTARIR7dUkuS1yxzCuJTiiyHAr3NCm85dOGkGTIMw9H+gwEzUGeUexNLAMgjWdaHnxkZsAz5oTCZvxNScuVrFPKUglbZO+8rRsOM0tBDVUQic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975551; 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=Q8qaMaAg5bgIFqf9CpnygZ8vwUqHTxPl5W7aLzDeKso=; b=JaUQP7f3VhTt80HjQ6TUoolsUeoLyu9ha21AD3yFUuJDJpzdchXSXCut1g61mnqBDmSSxji0uxq8x1lGIVUhtVl8J4AomNaqIgpzh+AE9qDFa5IRvdcuRoKMKMsENrie+18MVr3OT2xChizvidxNxYqM0FuhzKrtYhRyW7KXcM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975551857814.2174710431468; Wed, 26 Mar 2025 00:52:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYF-0007oF-MY; Wed, 26 Mar 2025 03:51:51 -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 1txLYD-0007no-H8 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51: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 1txLYB-0006E3-Se for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51:49 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-TVuyAERFOra_ulXFSZP2Pg-1; Wed, 26 Mar 2025 03:51:42 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72F8B1800361; Wed, 26 Mar 2025 07:51:40 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AE9B019560AB; Wed, 26 Mar 2025 07:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975506; 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=Q8qaMaAg5bgIFqf9CpnygZ8vwUqHTxPl5W7aLzDeKso=; b=dYOsr1/a5VLXBLped7ESidS/uA9xgHFTjShOBbGuRKFdqOFAdrJIukVDelLqkIhzha/ojH goqVUE0cQRAc1GApbkwFWQIyG1Vf9MIj0Pv9X4tsF+/lQq8k10TFWPd4dMM8lVARBC4t7+ HvuPYHlrYuI8uC40Rr75nD9ysyMl6J4= X-MC-Unique: TVuyAERFOra_ulXFSZP2Pg-1 X-Mimecast-MFC-AGG-ID: TVuyAERFOra_ulXFSZP2Pg_1742975501 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 01/37] vfio: Move vfio_mig_active() into migration.c Date: Wed, 26 Mar 2025 08:50:46 +0100 Message-ID: <20250326075122.1299361-2-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975554344019100 vfio_mig_active() is part of the VFIO migration API. Move the definitions where VFIO migration is implemented. Reviewed-by: Avihai Horon Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-2-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 16 ---------------- hw/vfio/migration.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a591ce5b97ff41cdc8249e9eeafc8dc347d45fac..e0482a796ff89afae2f017ae4e8= 7f6f4056328fe 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -66,22 +66,6 @@ int vfio_kvm_device_fd =3D -1; * Device state interfaces */ =20 -bool vfio_mig_active(void) -{ - VFIODevice *vbasedev; - - if (QLIST_EMPTY(&vfio_device_list)) { - return false; - } - - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { - if (vbasedev->migration_blocker) { - return false; - } - } - return true; -} - static Error *multiple_devices_migration_blocker; =20 /* diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index fbff46cfc35e0ee69e9599c9f8efc7437bbe3370..b5fb0d218808d010d8210612d31= 82dde8f33514b 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1062,6 +1062,22 @@ void vfio_mig_add_bytes_transferred(unsigned long va= l) qatomic_add(&bytes_transferred, val); } =20 +bool vfio_mig_active(void) +{ + VFIODevice *vbasedev; + + if (QLIST_EMPTY(&vfio_device_list)) { + return false; + } + + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { + if (vbasedev->migration_blocker) { + return false; + } + } + return true; +} + /* * Return true when either migration initialized or blocker registered. * Currently only return false when adding blocker fails which will --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975905; cv=none; d=zohomail.com; s=zohoarc; b=Qp9M4/jqvUhO4LEJaD9zNSNml4pCEaAuen1f+rQy9+SMef+FK1XXz+xxknErck9XrffekABreuURipkZV9vxphZ5/FGpAvNlvyJ2cst4zQb43QkkhvtlxD7f7lv8la6qlbAQjDjbn55jtWh0rtu6siz6xKQ8FJ28lCSuSBibODc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975905; 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=c0KGPIyi2VZ3P11RSRtQPdTPRM3uau7bmwklgXVhA48=; b=VYL1P7NtDiSkkoS15yqzyB92sXiSfdQWOXx1kPKUsGcnQ3c0Msi4SDq/zXRqeMzqMVljdOoGgkXDWf8FWj0LLp0hRQFfsUH/p5FMYCPQQNgFkiMX0z7z5KcLashE7yzMfWixiqwJOl6c5tA3N7Wo4+VjerSFLY+vAFLcCh40raM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975905622806.7528963230266; Wed, 26 Mar 2025 00:58:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYI-0007om-KR; Wed, 26 Mar 2025 03:51:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txLYH-0007oQ-5w for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51: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 1txLYF-0006EF-7O for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51:52 -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-168-xn-WHGZdOjGAdOqypwf0uw-1; Wed, 26 Mar 2025 03:51:46 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 EDB32196D2D2; Wed, 26 Mar 2025 07:51:44 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4DF319560AB; Wed, 26 Mar 2025 07:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975509; 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=c0KGPIyi2VZ3P11RSRtQPdTPRM3uau7bmwklgXVhA48=; b=A1Yrye2ZQkoas0Fk+YspAnLnKXc0HsUARNcs/gPBkh8CQhiiCWL5oJN8Mj+DJLCsqWdZp3 9wdYiF7s4ZbTJIHAougvJIQft77AI45LZwr0LSQAYLMS+ZBkMyqom6qZCvLrkEukkdu0kF QLCE5rZ0wNFqIsEw4dPso4NqpgcviVk= X-MC-Unique: xn-WHGZdOjGAdOqypwf0uw-1 X-Mimecast-MFC-AGG-ID: xn-WHGZdOjGAdOqypwf0uw_1742975505 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH for-10.1 v2 02/37] vfio: Rename vfio_reset_bytes_transferred() Date: Wed, 26 Mar 2025 08:50:47 +0100 Message-ID: <20250326075122.1299361-3-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975907660019000 Enforce a 'vfio_mig_' prefix for the VFIO migration API to better reflect the namespace these routines belong to. Reviewed-by: Avihai Horon Reviewed-by: John Levon Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-3-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/migration.c | 2 +- migration/target.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 04b123a6c929a8f47d740fc5433b54dadd32f731..9cfb3fb6931e71395ef1d67b0a7= 43d8bc1433fdc 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -295,7 +295,7 @@ int vfio_block_multiple_devices_migration(VFIODevice *v= basedev, Error **errp); void vfio_unblock_multiple_devices_migration(void); bool vfio_viommu_preset(VFIODevice *vbasedev); int64_t vfio_mig_bytes_transferred(void); -void vfio_reset_bytes_transferred(void); +void vfio_mig_reset_bytes_transferred(void); void vfio_mig_add_bytes_transferred(unsigned long val); bool vfio_device_state_is_running(VFIODevice *vbasedev); bool vfio_device_state_is_precopy(VFIODevice *vbasedev); diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index b5fb0d218808d010d8210612d3182dde8f33514b..8bf65b8e11094b8363692dba308= 4b762362c7dd6 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1052,7 +1052,7 @@ int64_t vfio_mig_bytes_transferred(void) return MIN(qatomic_read(&bytes_transferred), INT64_MAX); } =20 -void vfio_reset_bytes_transferred(void) +void vfio_mig_reset_bytes_transferred(void) { qatomic_set(&bytes_transferred, 0); } diff --git a/migration/target.c b/migration/target.c index a6ffa9a5ce312d1e64157b650827aa726eb4d364..f5d8cfe7c2a3473f4bd3f506814= 5598c60973c58 100644 --- a/migration/target.c +++ b/migration/target.c @@ -25,7 +25,7 @@ void migration_populate_vfio_info(MigrationInfo *info) =20 void migration_reset_vfio_bytes_transferred(void) { - vfio_reset_bytes_transferred(); + vfio_mig_reset_bytes_transferred(); } #else void migration_populate_vfio_info(MigrationInfo *info) --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975634; cv=none; d=zohomail.com; s=zohoarc; b=JkrraGQ2LuaI74siZ0bsQu4X0uoaVaRnjRlbekizugdANx+w57sVctd2R4d3EV+VLrE1UA0IYumTK5pvVQpp4RlZ7H52+IfyFLAud0hw9DxWo1HdLM7hekrIy4OIRuZzcEy2DiZmgj2zdFN8kFsXMeK7JIM5/whvaytT1gA2uHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975634; 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=nD8OZ87KaQf7VzIto3SOG/w63i0K/C4eC05SnEdCVs0=; b=UKgaXdtLW2Twm9tItUFIX71G/CNeQ0I3cfxGGzYLmElVjL5HUmSAg1LfUpjiqBnfeadUTH3K6VHsW0N/fW7XeieHHBBM6ua37+ZE+vfpomy9r9zhyDm4v0+slal+Fix/UUEjwzhF0+u+sijKILbUUQJnDWjOFoXFL+pc3MbKoAk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975634454336.2741860117577; Wed, 26 Mar 2025 00:53:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYK-0007p7-O8; Wed, 26 Mar 2025 03:51:56 -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 1txLYI-0007oa-34 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51:54 -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 1txLYG-0006EV-8I for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:51:53 -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-161-WfqZxuKWMb2B-CgVQGHMPQ-1; Wed, 26 Mar 2025 03:51:49 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 7E969196D2CD; Wed, 26 Mar 2025 07:51:48 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 771A619560AB; Wed, 26 Mar 2025 07:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975511; 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=nD8OZ87KaQf7VzIto3SOG/w63i0K/C4eC05SnEdCVs0=; b=JDR/wUpoN0DcnqVNrXur2ufpR5eLqhyWjpZ0SCXf+iXhsW401J8IR60vCSi0F5ZkkDzg1d GA//pH4kqptXCcYR22iXinSkXM10nYcOEFHMjt3vy8Jvfq/1maV1wlhFAekvmdwKF8UrU/ cKGQNTsStnIarvnfbyEfvRCfd859l2Y= X-MC-Unique: WfqZxuKWMb2B-CgVQGHMPQ-1 X-Mimecast-MFC-AGG-ID: WfqZxuKWMb2B-CgVQGHMPQ_1742975508 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Kirti Wankhede Subject: [PATCH for-10.1 v2 03/37] vfio: Introduce a new header file for external migration services Date: Wed, 26 Mar 2025 08:50:48 +0100 Message-ID: <20250326075122.1299361-4-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975637149019000 The migration core subsystem makes use of the VFIO migration API to collect statistics on the number of bytes transferred. These services are declared in "hw/vfio/vfio-common.h" which also contains VFIO internal declarations. Move the migration declarations into a new header file "hw/vfio/vfio-migration.h" to reduce the exposure of VFIO internals. While at it, use a 'vfio_migration_' prefix for these services. To be noted, vfio_migration_add_bytes_transferred() is a VFIO migration internal service which we will moved in the subsequent patches. Cc: Kirti Wankhede Cc: Avihai Horon Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Prasad Pandit Reviewed-by: John Levon --- include/hw/vfio/vfio-common.h | 5 +---- include/hw/vfio/vfio-migration.h | 16 ++++++++++++++++ hw/vfio/migration-multifd.c | 5 +++-- hw/vfio/migration.c | 11 ++++++----- migration/target.c | 8 ++++---- 5 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 include/hw/vfio/vfio-migration.h diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 9cfb3fb6931e71395ef1d67b0a743d8bc1433fdc..fd424a4a3d40132e940f457f925= 0458e50ea0b71 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -290,13 +290,10 @@ extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; =20 -bool vfio_mig_active(void); int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **er= rp); void vfio_unblock_multiple_devices_migration(void); bool vfio_viommu_preset(VFIODevice *vbasedev); -int64_t vfio_mig_bytes_transferred(void); -void vfio_mig_reset_bytes_transferred(void); -void vfio_mig_add_bytes_transferred(unsigned long val); +void vfio_migration_add_bytes_transferred(unsigned long val); bool vfio_device_state_is_running(VFIODevice *vbasedev); bool vfio_device_state_is_precopy(VFIODevice *vbasedev); =20 diff --git a/include/hw/vfio/vfio-migration.h b/include/hw/vfio/vfio-migrat= ion.h new file mode 100644 index 0000000000000000000000000000000000000000..0d4ecd33d5d8c214bb77e0652b4= 405b6e43bcafa --- /dev/null +++ b/include/hw/vfio/vfio-migration.h @@ -0,0 +1,16 @@ +/* + * VFIO migration interface + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_MIGRATION_H +#define HW_VFIO_VFIO_MIGRATION_H + +bool vfio_migration_active(void); +int64_t vfio_migration_bytes_transferred(void); +void vfio_migration_reset_bytes_transferred(void); + +#endif /* HW_VFIO_VFIO_MIGRATION_H */ diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c index 378f6f3bf01f6a4155fb424f8028cb5380f27f02..09aa57f5f890f37f7e36c857fd8= 13f55b1da2fce 100644 --- a/hw/vfio/migration-multifd.c +++ b/hw/vfio/migration-multifd.c @@ -11,6 +11,7 @@ =20 #include "qemu/osdep.h" #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-migration.h" #include "migration/misc.h" #include "qapi/error.h" #include "qemu/bswap.h" @@ -575,7 +576,7 @@ vfio_save_complete_precopy_thread_config_state(VFIODevi= ce *vbasedev, return false; } =20 - vfio_mig_add_bytes_transferred(packet_len); + vfio_migration_add_bytes_transferred(packet_len); =20 return true; } @@ -645,7 +646,7 @@ vfio_multifd_save_complete_precopy_thread(SaveLiveCompl= etePrecopyThreadData *d, goto thread_exit; } =20 - vfio_mig_add_bytes_transferred(packet_size); + vfio_migration_add_bytes_transferred(packet_size); } =20 if (!vfio_save_complete_precopy_thread_config_state(vbasedev, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 8bf65b8e11094b8363692dba3084b762362c7dd6..582d65932a6c590eaecd8bf0b76= 5f27d93896c72 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -17,6 +17,7 @@ =20 #include "system/runstate.h" #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-migration.h" #include "migration/misc.h" #include "migration/savevm.h" #include "migration/vmstate.h" @@ -373,7 +374,7 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigrati= on *migration) qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); qemu_put_be64(f, data_size); qemu_put_buffer(f, migration->data_buffer, data_size); - vfio_mig_add_bytes_transferred(data_size); + vfio_migration_add_bytes_transferred(data_size); =20 trace_vfio_save_block(migration->vbasedev->name, data_size); =20 @@ -1047,22 +1048,22 @@ static int vfio_block_migration(VFIODevice *vbasede= v, Error *err, Error **errp) =20 /* ---------------------------------------------------------------------- = */ =20 -int64_t vfio_mig_bytes_transferred(void) +int64_t vfio_migration_bytes_transferred(void) { return MIN(qatomic_read(&bytes_transferred), INT64_MAX); } =20 -void vfio_mig_reset_bytes_transferred(void) +void vfio_migration_reset_bytes_transferred(void) { qatomic_set(&bytes_transferred, 0); } =20 -void vfio_mig_add_bytes_transferred(unsigned long val) +void vfio_migration_add_bytes_transferred(unsigned long val) { qatomic_add(&bytes_transferred, val); } =20 -bool vfio_mig_active(void) +bool vfio_migration_active(void) { VFIODevice *vbasedev; =20 diff --git a/migration/target.c b/migration/target.c index f5d8cfe7c2a3473f4bd3f5068145598c60973c58..12fd399f0c521c5c28535b58f24= feab6845947fd 100644 --- a/migration/target.c +++ b/migration/target.c @@ -11,21 +11,21 @@ #include CONFIG_DEVICES =20 #ifdef CONFIG_VFIO -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-migration.h" #endif =20 #ifdef CONFIG_VFIO void migration_populate_vfio_info(MigrationInfo *info) { - if (vfio_mig_active()) { + if (vfio_migration_active()) { info->vfio =3D g_malloc0(sizeof(*info->vfio)); - info->vfio->transferred =3D vfio_mig_bytes_transferred(); + info->vfio->transferred =3D vfio_migration_bytes_transferred(); } } =20 void migration_reset_vfio_bytes_transferred(void) { - vfio_mig_reset_bytes_transferred(); + vfio_migration_reset_bytes_transferred(); } #else void migration_populate_vfio_info(MigrationInfo *info) --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975613; cv=none; d=zohomail.com; s=zohoarc; b=ONHz0So5WotNpJAoQmzLyiNIdAPBLYoGaZDqFz3Q+o0dRnVDRjiBG4mu6Kz0VlQ6tRMTypn08yUyqQjABys0JUtW/ykHX0jyejsU1CG7W+KV+49JWvrdacLtLPNaAXEa0G7pZodMOl1TIoudUGg9s42CV65UsayaFxs/TDGVFIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975613; 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=aq0CEiR/VL35m3TcTSiCcaeCmol7GTsOXVpsRzJxn/c=; b=Fn7IMan2moas1U3qslBdkw7iMJX3LPuKHsH6z6HdMkg3/GmiJbVO//YNeQeX56ZkMUSf57zxx1iQ2IVe33PujkF0Bx+U88brG5rahx0mYmiv1DHhI6GjfDoSn6zpWrgRNe8g6p9d8QiS9MsPB4XIQrQ2jh4uHF9gVQGCaIQJJ+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975613513369.5525398722598; Wed, 26 Mar 2025 00:53:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYR-0007ps-BV; Wed, 26 Mar 2025 03:52: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 1txLYQ-0007ph-HM for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:02 -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 1txLYO-0006FD-CL for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:02 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-WSdxF8I5PkC7XUCTFNg2DA-1; Wed, 26 Mar 2025 03:51:53 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9108918007E1; Wed, 26 Mar 2025 07:51:52 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0921819560AB; Wed, 26 Mar 2025 07:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975519; 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=aq0CEiR/VL35m3TcTSiCcaeCmol7GTsOXVpsRzJxn/c=; b=ShxheN56WjXcpC1XWBH6hIdhiyjPDa3ZayjZfGY6eUnqDQtJ0k8WhRSVdZwALSwDxezPEf JWMM64ywN/yvKsLMdgCzmUMcgq0G36R4nH/BfdqFSGVX+eusaNyg+f9zKc07o4trU9IiQ0 B/fFbLy4bVzvWirES08D2gSs6RadnzU= X-MC-Unique: WSdxF8I5PkC7XUCTFNg2DA-1 X-Mimecast-MFC-AGG-ID: WSdxF8I5PkC7XUCTFNg2DA_1742975512 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 04/37] vfio: Make vfio_un/block_multiple_devices_migration() static Date: Wed, 26 Mar 2025 08:50:49 +0100 Message-ID: <20250326075122.1299361-5-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975616367019100 Both of these routines are only used in file "migration.c". Move them there. Reviewed-by: Joao Martins Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-5-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-common.h | 2 -- hw/vfio/common.c | 62 ----------------------------------- hw/vfio/migration.c | 62 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 64 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index fd424a4a3d40132e940f457f9250458e50ea0b71..32b816fa122aee00840c70d2e20= 8310a845ad831 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -290,8 +290,6 @@ extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; =20 -int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **er= rp); -void vfio_unblock_multiple_devices_migration(void); bool vfio_viommu_preset(VFIODevice *vbasedev); void vfio_migration_add_bytes_transferred(unsigned long val); bool vfio_device_state_is_running(VFIODevice *vbasedev); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index e0482a796ff89afae2f017ae4e87f6f4056328fe..f78fff41639b83b82eeadf4e40b= 7ca2cf6bd64dd 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -41,7 +41,6 @@ #include "trace.h" #include "qapi/error.h" #include "migration/misc.h" -#include "migration/blocker.h" #include "migration/qemu-file.h" #include "system/tcg.h" #include "system/tpm.h" @@ -66,67 +65,6 @@ int vfio_kvm_device_fd =3D -1; * Device state interfaces */ =20 -static Error *multiple_devices_migration_blocker; - -/* - * Multiple devices migration is allowed only if all devices support P2P - * migration. Single device migration is allowed regardless of P2P migrati= on - * support. - */ -static bool vfio_multiple_devices_migration_is_supported(void) -{ - VFIODevice *vbasedev; - unsigned int device_num =3D 0; - bool all_support_p2p =3D true; - - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { - if (vbasedev->migration) { - device_num++; - - if (!(vbasedev->migration->mig_flags & VFIO_MIGRATION_P2P)) { - all_support_p2p =3D false; - } - } - } - - return all_support_p2p || device_num <=3D 1; -} - -int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **er= rp) -{ - int ret; - - if (vfio_multiple_devices_migration_is_supported()) { - return 0; - } - - if (vbasedev->enable_migration =3D=3D ON_OFF_AUTO_ON) { - error_setg(errp, "Multiple VFIO devices migration is supported onl= y if " - "all of them support P2P migration"); - return -EINVAL; - } - - if (multiple_devices_migration_blocker) { - return 0; - } - - error_setg(&multiple_devices_migration_blocker, - "Multiple VFIO devices migration is supported only if all o= f " - "them support P2P migration"); - ret =3D migrate_add_blocker_normal(&multiple_devices_migration_blocker= , errp); - - return ret; -} - -void vfio_unblock_multiple_devices_migration(void) -{ - if (!multiple_devices_migration_blocker || - !vfio_multiple_devices_migration_is_supported()) { - return; - } - - migrate_del_blocker(&multiple_devices_migration_blocker); -} =20 bool vfio_viommu_preset(VFIODevice *vbasedev) { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 582d65932a6c590eaecd8bf0b765f27d93896c72..db2525fcb926bd228ae2d4dca5e= eb2de28041660 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1022,6 +1022,68 @@ static int vfio_migration_init(VFIODevice *vbasedev) return 0; } =20 +static Error *multiple_devices_migration_blocker; + +/* + * Multiple devices migration is allowed only if all devices support P2P + * migration. Single device migration is allowed regardless of P2P migrati= on + * support. + */ +static bool vfio_multiple_devices_migration_is_supported(void) +{ + VFIODevice *vbasedev; + unsigned int device_num =3D 0; + bool all_support_p2p =3D true; + + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { + if (vbasedev->migration) { + device_num++; + + if (!(vbasedev->migration->mig_flags & VFIO_MIGRATION_P2P)) { + all_support_p2p =3D false; + } + } + } + + return all_support_p2p || device_num <=3D 1; +} + +static int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Err= or **errp) +{ + int ret; + + if (vfio_multiple_devices_migration_is_supported()) { + return 0; + } + + if (vbasedev->enable_migration =3D=3D ON_OFF_AUTO_ON) { + error_setg(errp, "Multiple VFIO devices migration is supported onl= y if " + "all of them support P2P migration"); + return -EINVAL; + } + + if (multiple_devices_migration_blocker) { + return 0; + } + + error_setg(&multiple_devices_migration_blocker, + "Multiple VFIO devices migration is supported only if all o= f " + "them support P2P migration"); + ret =3D migrate_add_blocker_normal(&multiple_devices_migration_blocker= , errp); + + return ret; +} + +static void vfio_unblock_multiple_devices_migration(void) +{ + if (!multiple_devices_migration_blocker || + !vfio_multiple_devices_migration_is_supported()) { + return; + } + + migrate_del_blocker(&multiple_devices_migration_blocker); +} + static void vfio_migration_deinit(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975755; cv=none; d=zohomail.com; s=zohoarc; b=HGZFj269GW3GRC3p+ve6W7f6sGIZPHh61MMs0DMCO8tS0us5F+W1BbzJx5Pu3xcGwQWtp9gPcm6hZ0Cs9d8P6Koef1/FubO5L7l1ufLlYNZp+k34hTuW5r8zEl7QZxJQ7+8frkEIA/YLYYUqfVQc514AzxtCSEbk5a+Bs0UOqNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975755; 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=5voEmL3VrID2AfGqms7hdXfoSDUgkeW7F9KP0Cn3exo=; b=F9Uag1079cBRXNJlZf9L1vlMvTV9D06iVhxh1PjuFowMe+rhAx7NwEzUqP018dylEcm1hn5aoGFHYQMF9KV66zz8eclo5AxcKjBesSoIK5E7LrmWcUI43V47H0QuZJHIOO+qw73WbDCiQ9DNDhLvlrK6xr7pVrYtGH9Dg5Dl15E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975755596215.37415263335913; Wed, 26 Mar 2025 00:55:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYT-0007qO-9w; Wed, 26 Mar 2025 03:52: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 1txLYR-0007px-Q9 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:03 -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 1txLYQ-0006FJ-4o for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:03 -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-8-Jo30luZdP0Cyq7p6pK-Pjw-1; Wed, 26 Mar 2025 03:51:58 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 0088D19560BC; Wed, 26 Mar 2025 07:51:56 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1C71619560AB; Wed, 26 Mar 2025 07:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975521; 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=5voEmL3VrID2AfGqms7hdXfoSDUgkeW7F9KP0Cn3exo=; b=FwRjuCNZOlKkh3KlBNG9YJEC7aXh4y9eC7YUqOLuJ6EYM0T8IvSTRYqrusO1oVgMB2A4OC epja+TubZ8rvzqo5LbN0j1RVM0NqOcM9/iw5HtMcp3TVonXSlugSpirPCs4PszSgkJZ6Lx dyCMEfiXG1QklAeHAwKVhe3ZBkprKlM= X-MC-Unique: Jo30luZdP0Cyq7p6pK-Pjw-1 X-Mimecast-MFC-AGG-ID: Jo30luZdP0Cyq7p6pK-Pjw_1742975517 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 05/37] vfio: Make vfio_viommu_preset() static Date: Wed, 26 Mar 2025 08:50:50 +0100 Message-ID: <20250326075122.1299361-6-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975758592019100 This routine is only used in file "migration.c". Move it there. Reviewed-by: John Levon Reviewed-by: Joao Martins Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-6-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 1 - hw/vfio/common.c | 5 ----- hw/vfio/migration.c | 5 +++++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 32b816fa122aee00840c70d2e208310a845ad831..8bb206d755adab4efee32a173c9= 20d9aa4833685 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -290,7 +290,6 @@ extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; =20 -bool vfio_viommu_preset(VFIODevice *vbasedev); void vfio_migration_add_bytes_transferred(unsigned long val); bool vfio_device_state_is_running(VFIODevice *vbasedev); bool vfio_device_state_is_precopy(VFIODevice *vbasedev); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index f78fff41639b83b82eeadf4e40b7ca2cf6bd64dd..a4ec60e018df7dc9bbbeac27120= 907b0f7bf2f83 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -66,11 +66,6 @@ int vfio_kvm_device_fd =3D -1; */ =20 =20 -bool vfio_viommu_preset(VFIODevice *vbasedev) -{ - return vbasedev->bcontainer->space->as !=3D &address_space_memory; -} - bool vfio_device_state_is_running(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index db2525fcb926bd228ae2d4dca5eeb2de28041660..96d294794bc3056baa3b0b4e234= 88402db5de797 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1141,6 +1141,11 @@ bool vfio_migration_active(void) return true; } =20 +static bool vfio_viommu_preset(VFIODevice *vbasedev) +{ + return vbasedev->bcontainer->space->as !=3D &address_space_memory; +} + /* * Return true when either migration initialized or blocker registered. * Currently only return false when adding blocker fails which will --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976118; cv=none; d=zohomail.com; s=zohoarc; b=VJ2EiHym/y5FaYov5LClCrxMLUdZXkk7rCz256gbFh6mUsfIifj+DbXmCeit2Fwu+FwQymOq/qJ0IvT0XuNhbYHTRw4ek1SsE/vrNvnZYFXv8TDL83BwkX8cUfarB3FAYIqmu7FpT0C9DjhDUECQRWEOA6Eodn0sXJNzvqu7dWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976118; 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=VCB+BDSo2XaU6TJRsFXZkh52bSQojAysgtuVHJHhrng=; b=dovO8ZFi6YlNx/vY/f2X0PpVqgV4VDxNGyiEoNzceX0ZogL03GK3x4Ca6u+6PbAdEHtT8eqIsUkkzSnQsj5EV7094OMiC8iGlVR3z1N5RgICwebdVvLB1EhuJQhCdCgFJnyPCM+td79X5Kt4l9iNSskZKhZIh6WmZ1KNIgQKprc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976118953533.3186134342131; Wed, 26 Mar 2025 01:01:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYW-0007qv-10; Wed, 26 Mar 2025 03:52:08 -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 1txLYT-0007qZ-TH for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:06 -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 1txLYS-0006FU-0u for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:05 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-4rlLz1r8NGGOuTG-ulsoUA-1; Wed, 26 Mar 2025 03:52:00 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9DFAB180899B; Wed, 26 Mar 2025 07:51:59 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7E66319560AD; Wed, 26 Mar 2025 07:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975523; 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=VCB+BDSo2XaU6TJRsFXZkh52bSQojAysgtuVHJHhrng=; b=QuwMdz9wjNlmcPBL0Kik85S+P4d/9LAq4fCaobgbEPmTGzxWfcTwC3sMQdoiPGPukfEnT7 +gK+zxDc3KDyOpUd6FV0b/0Zz+wEBFu9TdFKmBj0y+K/Ms2iB5tHcYjEVYwMx6UPxp5xtc 9zolSxbly3W8PDX5n9OLLouZU0Wmw6Q= X-MC-Unique: 4rlLz1r8NGGOuTG-ulsoUA-1 X-Mimecast-MFC-AGG-ID: 4rlLz1r8NGGOuTG-ulsoUA_1742975519 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Kirti Wankhede Subject: [PATCH for-10.1 v2 06/37] vfio: Introduce a new header file for internal migration services Date: Wed, 26 Mar 2025 08:50:51 +0100 Message-ID: <20250326075122.1299361-7-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976121482019100 Gather all VFIO migration related declarations into "vfio-migration-internal.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Cc: Kirti Wankhede Cc: Avihai Horon Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon Reviewed-by: Prasad Pandit --- hw/vfio/vfio-migration-internal.h | 72 +++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 52 +--------------------- hw/vfio/common.c | 1 + hw/vfio/migration-multifd.c | 1 + hw/vfio/migration.c | 1 + hw/vfio/pci.c | 1 + 6 files changed, 77 insertions(+), 51 deletions(-) create mode 100644 hw/vfio/vfio-migration-internal.h diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-int= ernal.h new file mode 100644 index 0000000000000000000000000000000000000000..ab6a1bad9b513aa61557905e72e= 5c6b264372276 --- /dev/null +++ b/hw/vfio/vfio-migration-internal.h @@ -0,0 +1,72 @@ +/* + * VFIO migration + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_MIGRATION_INTERNAL_H +#define HW_VFIO_VFIO_MIGRATION_INTERNAL_H + +#ifdef CONFIG_LINUX +#include +#endif + +#include "qemu/typedefs.h" +#include "qemu/notify.h" + +/* + * Flags to be used as unique delimiters for VFIO devices in the migration + * stream. These flags are composed as: + * 0xffffffff =3D> MSB 32-bit all 1s + * 0xef10 =3D> Magic ID, represents emulated (virtual) function IO + * 0x0000 =3D> 16-bits reserved for flags + * + * The beginning of state information is marked by _DEV_CONFIG_STATE, + * _DEV_SETUP_STATE, or _DEV_DATA_STATE, respectively. The end of a + * certain state information is marked by _END_OF_STATE. + */ +#define VFIO_MIG_FLAG_END_OF_STATE (0xffffffffef100001ULL) +#define VFIO_MIG_FLAG_DEV_CONFIG_STATE (0xffffffffef100002ULL) +#define VFIO_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL) +#define VFIO_MIG_FLAG_DEV_DATA_STATE (0xffffffffef100004ULL) +#define VFIO_MIG_FLAG_DEV_INIT_DATA_SENT (0xffffffffef100005ULL) + +typedef struct VFIODevice VFIODevice; +typedef struct VFIOMultifd VFIOMultifd; + +typedef struct VFIOMigration { + struct VFIODevice *vbasedev; + VMChangeStateEntry *vm_state; + NotifierWithReturn migration_state; + uint32_t device_state; + int data_fd; + void *data_buffer; + size_t data_buffer_size; + uint64_t mig_flags; + uint64_t precopy_init_size; + uint64_t precopy_dirty_size; + bool multifd_transfer; + VFIOMultifd *multifd; + bool initial_data_sent; + + bool event_save_iterate_started; + bool event_precopy_empty_hit; +} VFIOMigration; + +bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); +void vfio_migration_exit(VFIODevice *vbasedev); +int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); +int vfio_load_device_config_state(QEMUFile *f, void *opaque); + +#ifdef CONFIG_LINUX +int vfio_migration_set_state(VFIODevice *vbasedev, + enum vfio_device_mig_state new_state, + enum vfio_device_mig_state recover_state, + Error **errp); +#endif + +void vfio_migration_add_bytes_transferred(unsigned long val); + +#endif /* HW_VFIO_VFIO_MIGRATION_INTERNAL_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8bb206d755adab4efee32a173c920d9aa4833685..920ad154b4f82b9c244b5b9e8da= 44f7583e5ead0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -23,7 +23,6 @@ =20 #include "exec/memory.h" #include "qemu/queue.h" -#include "qemu/notify.h" #include "ui/console.h" #include "hw/display/ramfb.h" #ifdef CONFIG_LINUX @@ -36,23 +35,6 @@ =20 #define VFIO_MSG_PREFIX "vfio %s: " =20 -/* - * Flags to be used as unique delimiters for VFIO devices in the migration - * stream. These flags are composed as: - * 0xffffffff =3D> MSB 32-bit all 1s - * 0xef10 =3D> Magic ID, represents emulated (virtual) function IO - * 0x0000 =3D> 16-bits reserved for flags - * - * The beginning of state information is marked by _DEV_CONFIG_STATE, - * _DEV_SETUP_STATE, or _DEV_DATA_STATE, respectively. The end of a - * certain state information is marked by _END_OF_STATE. - */ -#define VFIO_MIG_FLAG_END_OF_STATE (0xffffffffef100001ULL) -#define VFIO_MIG_FLAG_DEV_CONFIG_STATE (0xffffffffef100002ULL) -#define VFIO_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL) -#define VFIO_MIG_FLAG_DEV_DATA_STATE (0xffffffffef100004ULL) -#define VFIO_MIG_FLAG_DEV_INIT_DATA_SENT (0xffffffffef100005ULL) - enum { VFIO_DEVICE_TYPE_PCI =3D 0, VFIO_DEVICE_TYPE_PLATFORM =3D 1, @@ -78,27 +60,6 @@ typedef struct VFIORegion { uint8_t nr; /* cache the region number for debug */ } VFIORegion; =20 -typedef struct VFIOMultifd VFIOMultifd; - -typedef struct VFIOMigration { - struct VFIODevice *vbasedev; - VMChangeStateEntry *vm_state; - NotifierWithReturn migration_state; - uint32_t device_state; - int data_fd; - void *data_buffer; - size_t data_buffer_size; - uint64_t mig_flags; - uint64_t precopy_init_size; - uint64_t precopy_dirty_size; - bool multifd_transfer; - VFIOMultifd *multifd; - bool initial_data_sent; - - bool event_save_iterate_started; - bool event_precopy_empty_hit; -} VFIOMigration; - struct VFIOGroup; =20 typedef struct VFIOContainer { @@ -136,6 +97,7 @@ typedef struct VFIOIOMMUFDContainer { OBJECT_DECLARE_SIMPLE_TYPE(VFIOIOMMUFDContainer, VFIO_IOMMU_IOMMUFD); =20 typedef struct VFIODeviceOps VFIODeviceOps; +typedef struct VFIOMigration VFIOMigration; =20 typedef struct VFIODevice { QLIST_ENTRY(VFIODevice) next; @@ -290,13 +252,9 @@ extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; =20 -void vfio_migration_add_bytes_transferred(unsigned long val); bool vfio_device_state_is_running(VFIODevice *vbasedev); bool vfio_device_state_is_precopy(VFIODevice *vbasedev); =20 -int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); -int vfio_load_device_config_state(QEMUFile *f, void *opaque); - #ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info); @@ -311,16 +269,8 @@ struct vfio_info_cap_header * vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); struct vfio_info_cap_header * vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); - -int vfio_migration_set_state(VFIODevice *vbasedev, - enum vfio_device_mig_state new_state, - enum vfio_device_mig_state recover_state, - Error **errp); #endif =20 -bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); -void vfio_migration_exit(VFIODevice *vbasedev); - int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); bool vfio_devices_all_dirty_tracking_started( const VFIOContainerBase *bcontainer); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a4ec60e018df7dc9bbbeac27120907b0f7bf2f83..9bbd798e3e9e0b7a7620d4b1f34= f1ef5e8ac42c1 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -44,6 +44,7 @@ #include "migration/qemu-file.h" #include "system/tcg.h" #include "system/tpm.h" +#include "vfio-migration-internal.h" =20 VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c index 09aa57f5f890f37f7e36c857fd813f55b1da2fce..1eba74beb0f207804e9c80935ea= cb0de19589b85 100644 --- a/hw/vfio/migration-multifd.c +++ b/hw/vfio/migration-multifd.c @@ -22,6 +22,7 @@ #include "io/channel-buffer.h" #include "migration/qemu-file.h" #include "migration-multifd.h" +#include "vfio-migration-internal.h" #include "trace.h" =20 #define VFIO_DEVICE_STATE_CONFIG_STATE (1) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 96d294794bc3056baa3b0b4e23488402db5de797..2a72a8e07542096276cc7c38635= 9ad375e7d24c8 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -31,6 +31,7 @@ #include "pci.h" #include "trace.h" #include "hw/hw.h" +#include "vfio-migration-internal.h" =20 /* * This is an arbitrary size based on migration of mlx5 devices, where typ= ically diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 7f1532fbed9aed2eae2c98f6fd79a9056ff1e84f..158deca06cb240622a254f5059c= 47873e5fcc7de 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -44,6 +44,7 @@ #include "migration/blocker.h" #include "migration/qemu-file.h" #include "system/iommufd.h" +#include "vfio-migration-internal.h" =20 #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" =20 --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975908; cv=none; d=zohomail.com; s=zohoarc; b=XMU+JXURjC327fm4rD0eGfKoKEXTXg3Dy6mc6/a0AR4fiRHz2s8uXNEMAKumue9vEumy9Jdyv2vWoZUWh/HpAsAcceyQB9qxArMJYLHBCWSvXq7noevAl1CFZp2eqo3x4mzKhPDnO1oDtJ8UFPs11ix+XhgpyugIon6AKvM31Qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975908; 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=QiiWpfEa6jKCIajgZpnL7AMQmUw9hRHEuwCDKaVyEO4=; b=MemM7f/tENzU0P5LOpTno3otg77wmGg4j8IP/26mWB120qL+yxhgARYFz9euNPYFYQJNJCut/iOndDzHWBkPFnrGZndQP6CGOb6DfDMoo03BQGAVqEssJSriTsVQwnDSwAaw23w1UILBAGVwQrxme9csIZgv2pxmtFVCd+becUs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975908768388.0027727198433; Wed, 26 Mar 2025 00:58:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYb-0007rd-JZ; Wed, 26 Mar 2025 03:52:13 -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 1txLYa-0007rH-7E for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:12 -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 1txLYY-0006Fr-MI for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:11 -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-222-UWSXANvCMGmjUiuQQQYoxA-1; Wed, 26 Mar 2025 03:52:04 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 E30C618EBE93; Wed, 26 Mar 2025 07:52:02 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 29E1519560AD; Wed, 26 Mar 2025 07:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975529; 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=QiiWpfEa6jKCIajgZpnL7AMQmUw9hRHEuwCDKaVyEO4=; b=Tctw4y1MS9O2igYDYVSBt00A9QOkxASvMn8xfQMw6mpLkMPdALKgwfTd1i6Y08I4YVpRvD RWYlRKsdnJV63+ZdXd4hNG1yaYKLBzaDmdBXvYN7NJtzubbnK4JSYJIJED+jm2Kw6P6n+E QU5RLUFGkBeCw5aVOAlFX7LawhQRejw= X-MC-Unique: UWSXANvCMGmjUiuQQQYoxA-1 X-Mimecast-MFC-AGG-ID: UWSXANvCMGmjUiuQQQYoxA_1742975523 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 07/37] vfio: Move vfio_device_state_is_running/precopy() into migration.c Date: Wed, 26 Mar 2025 08:50:52 +0100 Message-ID: <20250326075122.1299361-8-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975911011019101 These routines are migration related. Move their declaration and implementation under the migration files. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Prasad Pandit Reviewed-by: John Levon --- hw/vfio/vfio-migration-internal.h | 2 ++ include/hw/vfio/vfio-common.h | 3 --- hw/vfio/common.c | 16 ---------------- hw/vfio/migration.c | 16 ++++++++++++++++ 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-int= ernal.h index ab6a1bad9b513aa61557905e72e5c6b264372276..a8b456b239df8a54ab96daf56b5= f778b3ffbfa5e 100644 --- a/hw/vfio/vfio-migration-internal.h +++ b/hw/vfio/vfio-migration-internal.h @@ -57,6 +57,8 @@ typedef struct VFIOMigration { =20 bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); void vfio_migration_exit(VFIODevice *vbasedev); +bool vfio_device_state_is_running(VFIODevice *vbasedev); +bool vfio_device_state_is_precopy(VFIODevice *vbasedev); int vfio_save_device_config_state(QEMUFile *f, void *opaque, Error **errp); int vfio_load_device_config_state(QEMUFile *f, void *opaque); =20 diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 920ad154b4f82b9c244b5b9e8da44f7583e5ead0..799e12d43747addbf444c15052f= 629b65978322f 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -252,9 +252,6 @@ extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; =20 -bool vfio_device_state_is_running(VFIODevice *vbasedev); -bool vfio_device_state_is_precopy(VFIODevice *vbasedev); - #ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 9bbd798e3e9e0b7a7620d4b1f34f1ef5e8ac42c1..33f7191c7fec76bb3f46b96e25d= c1872808ccc8c 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -67,22 +67,6 @@ int vfio_kvm_device_fd =3D -1; */ =20 =20 -bool vfio_device_state_is_running(VFIODevice *vbasedev) -{ - VFIOMigration *migration =3D vbasedev->migration; - - return migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING || - migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_P2P; -} - -bool vfio_device_state_is_precopy(VFIODevice *vbasedev) -{ - VFIOMigration *migration =3D vbasedev->migration; - - return migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY || - migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY_P2P; -} - static bool vfio_devices_all_device_dirty_tracking_started( const VFIOContainerBase *bcontainer) { diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 2a72a8e07542096276cc7c386359ad375e7d24c8..8d69de3c80eaedf9bf4b8bc9b25= f6d722ae619b2 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1223,3 +1223,19 @@ void vfio_migration_exit(VFIODevice *vbasedev) =20 migrate_del_blocker(&vbasedev->migration_blocker); } + +bool vfio_device_state_is_running(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + + return migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING || + migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_P2P; +} + +bool vfio_device_state_is_precopy(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + + return migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY || + migration->device_state =3D=3D VFIO_DEVICE_STATE_PRE_COPY_P2P; +} --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975613; cv=none; d=zohomail.com; s=zohoarc; b=WIgB3f07JniYZRfHk7ZPwaiIzk9ArXeUfM7/qWTNBd6T0sFf67kCqvr+ooHMgONp0zT8gENLDKaUDwe/d8gQWe7rNhVYDDLoCgA/6lOD6yCDO7a6cJxoAusJAKWrFTVAhmd1sUqmmXSG9nnWahERh0RA7Sa/XLBis/DEeC6KdVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975613; 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=vs0j0yrmFEQSQ6fqP7RcnnHyB3sjM+oqxjAG6fntE1c=; b=JonjBwXKgvnaIa6wUnr5j7zCN6kW0gfUWcQ7cg/WciLl5Uk4WyfkCgIVW9LbnWD5Apt6NQ+H0ftBHTK6AG8igwD3FY40GFZUKWpdulPlZq/Xd5kDlo+WSy7yZ+IAggpnpC7P9+XXeAc5dbOhmMc4zyMfd5sadZJQhpEICo8faEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975613840221.48240773789382; Wed, 26 Mar 2025 00:53:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYc-0007ry-RW; Wed, 26 Mar 2025 03:52:14 -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 1txLYb-0007rV-7K for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:13 -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 1txLYZ-0006Fx-HN for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:12 -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-661-iySEzFB0MveAT3l1O9E6Rg-1; Wed, 26 Mar 2025 03:52:08 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 31BB9190308B; Wed, 26 Mar 2025 07:52:07 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D01D19560AB; Wed, 26 Mar 2025 07:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975530; 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=vs0j0yrmFEQSQ6fqP7RcnnHyB3sjM+oqxjAG6fntE1c=; b=K1oiUSlT1N2hEIVLaJaK4nT4VnYqTji1wznTGMqSldd03VuxzkTrUpgYnhHGAQ7NJ5OdAp C9CQnc+8ZZ9Pthcwk3Rz9wPS9zKICoX58yjbJBL8ymudLEcrbunxCaYLS03ygCbea4PMqz Eb75VW+CPebc2k0yI4oyCkFGF5YlygE= X-MC-Unique: iySEzFB0MveAT3l1O9E6Rg-1 X-Mimecast-MFC-AGG-ID: iySEzFB0MveAT3l1O9E6Rg_1742975527 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 08/37] vfio: Introduce a new header file for VFIOdisplay declarations Date: Wed, 26 Mar 2025 08:50:53 +0100 Message-ID: <20250326075122.1299361-9-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975616454019100 Gather all VFIOdisplay related declarations into "vfio-display.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-8-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/pci.h | 1 + hw/vfio/vfio-display.h | 41 +++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 28 ------------------------ hw/vfio/display.c | 2 +- 4 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 hw/vfio/vfio-display.h diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index d94ecaba689c4681687c0a6796ffbcda522ae179..2071b725ea5236a971964750fde= 81485eb8b10a9 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -20,6 +20,7 @@ #include "qemu/timer.h" #include "qom/object.h" #include "system/kvm.h" +#include "vfio-display.h" =20 #define PCI_ANY_ID (~0) =20 diff --git a/hw/vfio/vfio-display.h b/hw/vfio/vfio-display.h new file mode 100644 index 0000000000000000000000000000000000000000..99b8cb67ef7558d3eefe3105a83= 1e3fcb30afc4d --- /dev/null +++ b/hw/vfio/vfio-display.h @@ -0,0 +1,41 @@ +/* + * VFIO display + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_DISPLAY_H +#define HW_VFIO_VFIO_DISPLAY_H + +#include "ui/console.h" +#include "hw/display/ramfb.h" + +typedef struct VFIODMABuf { + QemuDmaBuf *buf; + uint32_t pos_x, pos_y, pos_updates; + uint32_t hot_x, hot_y, hot_updates; + int dmabuf_id; + QTAILQ_ENTRY(VFIODMABuf) next; +} VFIODMABuf; + +typedef struct VFIODisplay { + QemuConsole *con; + RAMFBState *ramfb; + struct vfio_region_info *edid_info; + struct vfio_region_gfx_edid *edid_regs; + uint8_t *edid_blob; + QEMUTimer *edid_link_timer; + struct { + VFIORegion buffer; + DisplaySurface *surface; + } region; + struct { + QTAILQ_HEAD(, VFIODMABuf) bufs; + VFIODMABuf *primary; + VFIODMABuf *cursor; + } dmabuf; +} VFIODisplay; + +#endif /* HW_VFIO_VFIO_DISPLAY_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 799e12d43747addbf444c15052f629b65978322f..288c2fb3d0e792427c0e7655002= 248829b4d189a 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -23,8 +23,6 @@ =20 #include "exec/memory.h" #include "qemu/queue.h" -#include "ui/console.h" -#include "hw/display/ramfb.h" #ifdef CONFIG_LINUX #include #endif @@ -182,32 +180,6 @@ typedef struct VFIOGroup { #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" =20 -typedef struct VFIODMABuf { - QemuDmaBuf *buf; - uint32_t pos_x, pos_y, pos_updates; - uint32_t hot_x, hot_y, hot_updates; - int dmabuf_id; - QTAILQ_ENTRY(VFIODMABuf) next; -} VFIODMABuf; - -typedef struct VFIODisplay { - QemuConsole *con; - RAMFBState *ramfb; - struct vfio_region_info *edid_info; - struct vfio_region_gfx_edid *edid_regs; - uint8_t *edid_blob; - QEMUTimer *edid_link_timer; - struct { - VFIORegion buffer; - DisplaySurface *surface; - } region; - struct { - QTAILQ_HEAD(, VFIODMABuf) bufs; - VFIODMABuf *primary; - VFIODMABuf *cursor; - } dmabuf; -} VFIODisplay; - VFIOAddressSpace *vfio_get_address_space(AddressSpace *as); void vfio_put_address_space(VFIOAddressSpace *space); void vfio_address_space_insert(VFIOAddressSpace *space, diff --git a/hw/vfio/display.c b/hw/vfio/display.c index ea87830fe0d5fc66f3f27a16bde5d75b7b6280c0..8317917203d5e2713fff551ff4a= 122befba55cc2 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -16,9 +16,9 @@ =20 #include "qemu/error-report.h" #include "hw/display/edid.h" -#include "ui/console.h" #include "qapi/error.h" #include "pci.h" +#include "vfio-display.h" #include "trace.h" =20 #ifndef DRM_PLANE_TYPE_PRIMARY --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975802; cv=none; d=zohomail.com; s=zohoarc; b=Wra9KuYiGtCxnaHuv8qdp8/n6uQyeCsADYMPBtB6YYiNehs8qCGyyeZblh6WgnqRZc2L0GjG0XAldv1wHQR33E4Mu+2zh3H+F2s6QSUS0LDrW1ayvBeSCVn/ylapuLfSLUXoHjr7vAIkQxpY3NQsSJpI2iytkaAcQRRKg4lsSc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975802; 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=jnmPj/AkU9O4wMOxyvPYhw0W6nSpfeL6Hb0rOHIReoQ=; b=X+SskNl5Dubhk3ZVXCdg5m4IAK167VjOQpOo7FO+nUMm2p+E5d6elrkz8c5ZcDEyDUtS4oAvSh8JmrHR2hstnPEt5hmFOA9xBum1DKBL80CWM52/s500pAJDCi+h/R/yTjXkFzc7+IdKWID97BVccv4J4yPG0JtR3j8/13h/TTI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975802142361.6021544724232; Wed, 26 Mar 2025 00:56:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYg-0007ss-53; Wed, 26 Mar 2025 03:52:18 -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 1txLYe-0007sE-7v for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:16 -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 1txLYc-0006GD-Hg for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:15 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-7ZLyhGptPV-Vj1d7HTwMXA-1; Wed, 26 Mar 2025 03:52:12 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 180A41800260; Wed, 26 Mar 2025 07:52:11 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A06A319560AB; Wed, 26 Mar 2025 07:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975533; 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=jnmPj/AkU9O4wMOxyvPYhw0W6nSpfeL6Hb0rOHIReoQ=; b=YpIpn011XALpYJk0otVsFTRI+IXsfRZhm70BhoQOppn2uvZZuFTCxFUhM1NDHzdw372ws+ l0vJp+ooFPyKKHACux0CmcHobFQEyXXTzmfAQnJz+MbEyc1B6mW2yiLJJm9k2DxCDUM5u6 +uiB1P7Zs3ncQTceGoH8vG/KDzxxUuw= X-MC-Unique: 7ZLyhGptPV-Vj1d7HTwMXA-1 X-Mimecast-MFC-AGG-ID: 7ZLyhGptPV-Vj1d7HTwMXA_1742975531 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 09/37] vfio: Move VFIOHostDMAWindow definition into spapr.c Date: Wed, 26 Mar 2025 08:50:54 +0100 Message-ID: <20250326075122.1299361-10-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975804664019100 VFIOHostDMAWindow is only used in file "spapr.c". Move it there. Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-9-clg@redhat= .com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 7 ------- hw/vfio/spapr.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 288c2fb3d0e792427c0e7655002248829b4d189a..3355c2d4e57569d7bb01b4d9378= fb49a807335e8 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -69,13 +69,6 @@ typedef struct VFIOContainer { =20 OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); =20 -typedef struct VFIOHostDMAWindow { - hwaddr min_iova; - hwaddr max_iova; - uint64_t iova_pgsizes; - QLIST_ENTRY(VFIOHostDMAWindow) hostwin_next; -} VFIOHostDMAWindow; - typedef struct IOMMUFDBackend IOMMUFDBackend; =20 typedef struct VFIOIOASHwpt { diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 1a5d1611f2cdc8fa6254a77b8ec3d1f56d28e3a6..021cdedbfa483f0599ad3c858a7= 7fc6570f1ace8 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -22,6 +22,13 @@ #include "qapi/error.h" #include "trace.h" =20 +typedef struct VFIOHostDMAWindow { + hwaddr min_iova; + hwaddr max_iova; + uint64_t iova_pgsizes; + QLIST_ENTRY(VFIOHostDMAWindow) hostwin_next; +} VFIOHostDMAWindow; + typedef struct VFIOSpaprContainer { VFIOContainer container; MemoryListener prereg_listener; --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975621; cv=none; d=zohomail.com; s=zohoarc; b=PkaACWkwYlJ0gWwDd2Qu5hVDtKBnZIenpgSCN1Pn7uOeN/tizqkWenV0UobMFHYw62XPqvmnz+nLZ57Ba4kytWoMw5DaDmpZ61eKJRlOAsu58Dx4o18xej8+uK0MkMoQKvXrhrqAL/YRvmMN3EzBntXf0BksLiHepQQMSCzZ2o0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975621; 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=wbSnFxJ5W8RIIcWney/zlJ/GiWz3ThHiX+K+pR/J5go=; b=NZ7qxQ30gM5jBx7XRB8GUrKZtHb+YhRvcgClaViHKT4CpaCyJIK9mmVZ8Ki8xL997Hxxv5DHBGROtxECVsh106D3cjqsJsImDT3xqkbtpFw6gA9tPizIsTmFE7AJjip9WwRBO8tefhPt4JEO40r30c9nkesURzl55Mt/FLvHjhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975621844278.50136026702955; Wed, 26 Mar 2025 00:53:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYn-0007tz-Un; Wed, 26 Mar 2025 03:52:25 -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 1txLYm-0007th-6m for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:24 -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 1txLYk-0006GZ-Es for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:23 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-ameCLK-lPduRN02ecf2bWw-1; Wed, 26 Mar 2025 03:52:15 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9A9E4180AB16; Wed, 26 Mar 2025 07:52:14 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9642C19560AD; Wed, 26 Mar 2025 07:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975541; 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=wbSnFxJ5W8RIIcWney/zlJ/GiWz3ThHiX+K+pR/J5go=; b=HIGNqSAx67LV4D70M2dp6B4G0USdHZBkDQa2KsVEb8eQQ0uhLXNuyJtbyCUiXvbHe8V32m eKTu60kvcf6GLp448RIthrQ5t1Y8NiN+QFq0BxcpyDcVp16o0EO3au9tUfIjTWAVy37kNL Od/FrvdpXZmJQ6xEwtEkk1T//Pj1D7M= X-MC-Unique: ameCLK-lPduRN02ecf2bWw-1 X-Mimecast-MFC-AGG-ID: ameCLK-lPduRN02ecf2bWw_1742975534 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Yi Liu Subject: [PATCH for-10.1 v2 10/37] vfio: Introduce a new header file for VFIOIOMMUFD declarations Date: Wed, 26 Mar 2025 08:50:55 +0100 Message-ID: <20250326075122.1299361-11-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975624366019100 Gather all VFIOIOMMUFD related declarations introduced by commits 5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend") and 5b1e96e65403 ("vfio/iommufd: Introduce auto domain creation") into "vfio-iommufd.h". This to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Cc: Joao Martins Cc: Yi Liu Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-10-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/vfio-iommufd.h | 34 ++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 21 +++------------------ hw/vfio/iommufd.c | 1 + 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 hw/vfio/vfio-iommufd.h diff --git a/hw/vfio/vfio-iommufd.h b/hw/vfio/vfio-iommufd.h new file mode 100644 index 0000000000000000000000000000000000000000..07ea0f43049645a5f3782048117= fd9bf22083053 --- /dev/null +++ b/hw/vfio/vfio-iommufd.h @@ -0,0 +1,34 @@ +/* + * VFIO iommufd + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_IOMMUFD_H +#define HW_VFIO_VFIO_IOMMUFD_H + +#include "hw/vfio/vfio-container-base.h" + +typedef struct VFIODevice VFIODevice; + +typedef struct VFIOIOASHwpt { + uint32_t hwpt_id; + uint32_t hwpt_flags; + QLIST_HEAD(, VFIODevice) device_list; + QLIST_ENTRY(VFIOIOASHwpt) next; +} VFIOIOASHwpt; + +typedef struct IOMMUFDBackend IOMMUFDBackend; + +typedef struct VFIOIOMMUFDContainer { + VFIOContainerBase bcontainer; + IOMMUFDBackend *be; + uint32_t ioas_id; + QLIST_HEAD(, VFIOIOASHwpt) hwpt_list; +} VFIOIOMMUFDContainer; + +OBJECT_DECLARE_SIMPLE_TYPE(VFIOIOMMUFDContainer, VFIO_IOMMU_IOMMUFD); + +#endif /* HW_VFIO_VFIO_IOMMUFD_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 3355c2d4e57569d7bb01b4d9378fb49a807335e8..8d48f5300a791d8858fe29d1bb9= 05f814ef11990 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -69,27 +69,12 @@ typedef struct VFIOContainer { =20 OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); =20 -typedef struct IOMMUFDBackend IOMMUFDBackend; - -typedef struct VFIOIOASHwpt { - uint32_t hwpt_id; - uint32_t hwpt_flags; - QLIST_HEAD(, VFIODevice) device_list; - QLIST_ENTRY(VFIOIOASHwpt) next; -} VFIOIOASHwpt; - -typedef struct VFIOIOMMUFDContainer { - VFIOContainerBase bcontainer; - IOMMUFDBackend *be; - uint32_t ioas_id; - QLIST_HEAD(, VFIOIOASHwpt) hwpt_list; -} VFIOIOMMUFDContainer; - -OBJECT_DECLARE_SIMPLE_TYPE(VFIOIOMMUFDContainer, VFIO_IOMMU_IOMMUFD); - typedef struct VFIODeviceOps VFIODeviceOps; typedef struct VFIOMigration VFIOMigration; =20 +typedef struct IOMMUFDBackend IOMMUFDBackend; +typedef struct VFIOIOASHwpt VFIOIOASHwpt; + typedef struct VFIODevice { QLIST_ENTRY(VFIODevice) next; QLIST_ENTRY(VFIODevice) container_next; diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 42c8412bbf50724dddb43f9b19a3aa40c8bc311d..7196c4080125674ec58b1ebf02d= ad84b4387c355 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -25,6 +25,7 @@ #include "qemu/cutils.h" #include "qemu/chardev_open.h" #include "pci.h" +#include "vfio-iommufd.h" =20 static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr io= va, ram_addr_t size, void *vaddr, bool readonly) --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976008; cv=none; d=zohomail.com; s=zohoarc; b=hJ19Hib32wRpKiz6qIbbKL0m3yHTx01oB1u6LuKu+4wNAgGGc2f5KTJ0qXqwpx3+05xFhdnbsUE67rw1I7VZOcZ0wRswqGVumgS9AmiD+aJltxiyHpd/QsXuofTxo7H5CGsgy8y/3pQ79fUzFJtRKR4zgHjk6pQrjdn+5TbLfZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976008; 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=wG9Mun3oY4gaGFNfnE9ot9Qv8xlpIs9QoxvXpz4Hiis=; b=mu0hYXKJV/5uRSUs09QLelv6ou7VokwIY50lDfB4IhMhlv/krtRSSPiff60OIf5QG3EE6v3aHUfS2dhXJJUSwN5KsEartawU/EiQh6SD9gxLHxiEvbE+SJwOFTXyrV2tEBRD2UWClthmAT3Tx1P43C7gKSmHWiYMs/yCAJ+aUXo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976008527269.78105765044893; Wed, 26 Mar 2025 01:00:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYr-00082U-9j; Wed, 26 Mar 2025 03:52:29 -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 1txLYp-0007yT-EO for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:27 -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 1txLYl-0006Gh-Rb for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:27 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-Hrz4KOINORWvlBZqVLHLZg-1; Wed, 26 Mar 2025 03:52:19 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 795E3180034D; Wed, 26 Mar 2025 07:52:18 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2541E19560AB; Wed, 26 Mar 2025 07:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975543; 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=wG9Mun3oY4gaGFNfnE9ot9Qv8xlpIs9QoxvXpz4Hiis=; b=LTxHt9QQFhHSZElWsqjgbgYfBwIW97x2bLx2z3Z5lP1ihn5R2Pzvh4dW4JZ3ykEO2flmI6 uimKaHFYqyPZRn9zj9QohjufPxuAjtEVyi+g+HtlF+X/UC9si2CAs234MY8CDb5fMZIQGE zG0z50U7TX0XOGKfwpI9dgURbE0i2mk= X-MC-Unique: Hrz4KOINORWvlBZqVLHLZg-1 X-Mimecast-MFC-AGG-ID: Hrz4KOINORWvlBZqVLHLZg_1742975538 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 11/37] vfio: Introduce new files for VFIORegion definitions and declarations Date: Wed, 26 Mar 2025 08:50:56 +0100 Message-ID: <20250326075122.1299361-12-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976010304019000 Gather all VFIORegion related declarations and definitions into their own files to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". They were introduced for 'vfio-platform' support in commits db0da029a185 ("vfio: Generalize region support") and a664477db8da ("hw/vfio/pci: Introduce VFIORegion"). To be noted that the 'vfio-platform' devices have been deprecated and will be removed in QEMU 10.2. Until then, make the declarations available externally for 'sysbus-fdt.c'. Cc: Eric Auger Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/vfio-display.h | 1 + include/hw/vfio/vfio-common.h | 32 +-- include/hw/vfio/vfio-platform.h | 2 + include/hw/vfio/vfio-region.h | 47 ++++ hw/core/sysbus-fdt.c | 1 + hw/vfio/helpers.c | 363 ----------------------------- hw/vfio/pci-quirks.c | 1 + hw/vfio/pci.c | 1 + hw/vfio/platform.c | 1 + hw/vfio/region.c | 394 ++++++++++++++++++++++++++++++++ hw/vfio/meson.build | 1 + hw/vfio/trace-events | 16 +- 12 files changed, 459 insertions(+), 401 deletions(-) create mode 100644 include/hw/vfio/vfio-region.h create mode 100644 hw/vfio/region.c diff --git a/hw/vfio/vfio-display.h b/hw/vfio/vfio-display.h index 99b8cb67ef7558d3eefe3105a831e3fcb30afc4d..2606c34b396a88cec3e8f884adb= 158e48e8105f1 100644 --- a/hw/vfio/vfio-display.h +++ b/hw/vfio/vfio-display.h @@ -11,6 +11,7 @@ =20 #include "ui/console.h" #include "hw/display/ramfb.h" +#include "hw/vfio/vfio-region.h" =20 typedef struct VFIODMABuf { QemuDmaBuf *buf; diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8d48f5300a791d8858fe29d1bb905f814ef11990..3d470d79325526e0508683c445a= 7635c78a57e34 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -39,25 +39,6 @@ enum { VFIO_DEVICE_TYPE_CCW =3D 2, VFIO_DEVICE_TYPE_AP =3D 3, }; - -typedef struct VFIOMmap { - MemoryRegion mem; - void *mmap; - off_t offset; - size_t size; -} VFIOMmap; - -typedef struct VFIORegion { - struct VFIODevice *vbasedev; - off_t fd_offset; /* offset of region within device fd */ - MemoryRegion *mem; /* slow, read/write access */ - size_t size; - uint32_t flags; /* VFIO region flags (rd/wr/mmap) */ - uint32_t nr_mmaps; - VFIOMmap *mmaps; - uint8_t nr; /* cache the region number for debug */ -} VFIORegion; - struct VFIOGroup; =20 typedef struct VFIOContainer { @@ -168,17 +149,7 @@ void vfio_unmask_single_irqindex(VFIODevice *vbasedev,= int index); void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index); bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, int action, int fd, Error **errp); -void vfio_region_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size); -uint64_t vfio_region_read(void *opaque, - hwaddr addr, unsigned size); -int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, - int index, const char *name); -int vfio_region_mmap(VFIORegion *region); -void vfio_region_mmaps_set_enabled(VFIORegion *region, bool enabled); -void vfio_region_unmap(VFIORegion *region); -void vfio_region_exit(VFIORegion *region); -void vfio_region_finalize(VFIORegion *region); + void vfio_reset_handler(void *opaque); struct vfio_device_info *vfio_get_device_info(int fd); bool vfio_device_is_mdev(VFIODevice *vbasedev); @@ -194,7 +165,6 @@ int vfio_kvm_device_del_fd(int fd, Error **errp); bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **er= rp); void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); =20 -extern const MemoryRegionOps vfio_region_ops; typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; extern VFIOGroupList vfio_group_list; diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platfor= m.h index c414c3dffcc840a2f40a1b252d0f7b4e309c78d4..3191545717da51abc41d10cd364= 6cd047b4a676c 100644 --- a/include/hw/vfio/vfio-platform.h +++ b/include/hw/vfio/vfio-platform.h @@ -47,6 +47,8 @@ typedef struct VFIOINTp { /* function type for user side eventfd handler */ typedef void (*eventfd_user_side_handler_t)(VFIOINTp *intp); =20 +typedef struct VFIORegion VFIORegion; + struct VFIOPlatformDevice { SysBusDevice sbdev; VFIODevice vbasedev; /* not a QOM object */ diff --git a/include/hw/vfio/vfio-region.h b/include/hw/vfio/vfio-region.h new file mode 100644 index 0000000000000000000000000000000000000000..9dc0535e7ce46fbb671e70918b9= 3cb115857efe6 --- /dev/null +++ b/include/hw/vfio/vfio-region.h @@ -0,0 +1,47 @@ +/* + * VFIO region + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_REGION_H +#define HW_VFIO_REGION_H + +#include "exec/memory.h" + +typedef struct VFIOMmap { + MemoryRegion mem; + void *mmap; + off_t offset; + size_t size; +} VFIOMmap; + +typedef struct VFIODevice VFIODevice; + +typedef struct VFIORegion { + struct VFIODevice *vbasedev; + off_t fd_offset; /* offset of region within device fd */ + MemoryRegion *mem; /* slow, read/write access */ + size_t size; + uint32_t flags; /* VFIO region flags (rd/wr/mmap) */ + uint32_t nr_mmaps; + VFIOMmap *mmaps; + uint8_t nr; /* cache the region number for debug */ +} VFIORegion; + + +void vfio_region_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size); +uint64_t vfio_region_read(void *opaque, + hwaddr addr, unsigned size); +int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, + int index, const char *name); +int vfio_region_mmap(VFIORegion *region); +void vfio_region_mmaps_set_enabled(VFIORegion *region, bool enabled); +void vfio_region_unmap(VFIORegion *region); +void vfio_region_exit(VFIORegion *region); +void vfio_region_finalize(VFIORegion *region); + +#endif /* HW_VFIO_REGION_H */ diff --git a/hw/core/sysbus-fdt.c b/hw/core/sysbus-fdt.c index e85066b905637b1ca34b5965f383df341f3a4eb7..c339a27875cbee8131b064674aa= 09adf4b9efa25 100644 --- a/hw/core/sysbus-fdt.c +++ b/hw/core/sysbus-fdt.c @@ -35,6 +35,7 @@ #include "hw/vfio/vfio-platform.h" #include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-amd-xgbe.h" +#include "hw/vfio/vfio-region.h" #include "hw/display/ramfb.h" #include "hw/uefi/var-service-api.h" #include "hw/arm/fdt.h" diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 4b255d4f3a9e81f55df00c68fc71da769fd5bd04..89403943a7a219e491b6812d50b= 27b7f1fd7b4a4 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -147,118 +147,6 @@ bool vfio_set_irq_signaling(VFIODevice *vbasedev, int= index, int subindex, return false; } =20 -/* - * IO Port/MMIO - Beware of the endians, VFIO is always little endian - */ -void vfio_region_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size) -{ - VFIORegion *region =3D opaque; - VFIODevice *vbasedev =3D region->vbasedev; - union { - uint8_t byte; - uint16_t word; - uint32_t dword; - uint64_t qword; - } buf; - - switch (size) { - case 1: - buf.byte =3D data; - break; - case 2: - buf.word =3D cpu_to_le16(data); - break; - case 4: - buf.dword =3D cpu_to_le32(data); - break; - case 8: - buf.qword =3D cpu_to_le64(data); - break; - default: - hw_error("vfio: unsupported write size, %u bytes", size); - break; - } - - if (pwrite(vbasedev->fd, &buf, size, region->fd_offset + addr) !=3D si= ze) { - error_report("%s(%s:region%d+0x%"HWADDR_PRIx", 0x%"PRIx64 - ",%d) failed: %m", - __func__, vbasedev->name, region->nr, - addr, data, size); - } - - trace_vfio_region_write(vbasedev->name, region->nr, addr, data, size); - - /* - * A read or write to a BAR always signals an INTx EOI. This will - * do nothing if not pending (including not in INTx mode). We assume - * that a BAR access is in response to an interrupt and that BAR - * accesses will service the interrupt. Unfortunately, we don't know - * which access will service the interrupt, so we're potentially - * getting quite a few host interrupts per guest interrupt. - */ - vbasedev->ops->vfio_eoi(vbasedev); -} - -uint64_t vfio_region_read(void *opaque, - hwaddr addr, unsigned size) -{ - VFIORegion *region =3D opaque; - VFIODevice *vbasedev =3D region->vbasedev; - union { - uint8_t byte; - uint16_t word; - uint32_t dword; - uint64_t qword; - } buf; - uint64_t data =3D 0; - - if (pread(vbasedev->fd, &buf, size, region->fd_offset + addr) !=3D siz= e) { - error_report("%s(%s:region%d+0x%"HWADDR_PRIx", %d) failed: %m", - __func__, vbasedev->name, region->nr, - addr, size); - return (uint64_t)-1; - } - switch (size) { - case 1: - data =3D buf.byte; - break; - case 2: - data =3D le16_to_cpu(buf.word); - break; - case 4: - data =3D le32_to_cpu(buf.dword); - break; - case 8: - data =3D le64_to_cpu(buf.qword); - break; - default: - hw_error("vfio: unsupported read size, %u bytes", size); - break; - } - - trace_vfio_region_read(vbasedev->name, region->nr, addr, size, data); - - /* Same as write above */ - vbasedev->ops->vfio_eoi(vbasedev); - - return data; -} - -const MemoryRegionOps vfio_region_ops =3D { - .read =3D vfio_region_read, - .write =3D vfio_region_write, - .endianness =3D DEVICE_LITTLE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - }, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 8, - }, -}; - int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size) { vbmap->pages =3D REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size= (); @@ -306,257 +194,6 @@ vfio_get_device_info_cap(struct vfio_device_info *inf= o, uint16_t id) return vfio_get_cap((void *)info, info->cap_offset, id); } =20 -static int vfio_setup_region_sparse_mmaps(VFIORegion *region, - struct vfio_region_info *info) -{ - struct vfio_info_cap_header *hdr; - struct vfio_region_info_cap_sparse_mmap *sparse; - int i, j; - - hdr =3D vfio_get_region_info_cap(info, VFIO_REGION_INFO_CAP_SPARSE_MMA= P); - if (!hdr) { - return -ENODEV; - } - - sparse =3D container_of(hdr, struct vfio_region_info_cap_sparse_mmap, = header); - - trace_vfio_region_sparse_mmap_header(region->vbasedev->name, - region->nr, sparse->nr_areas); - - region->mmaps =3D g_new0(VFIOMmap, sparse->nr_areas); - - for (i =3D 0, j =3D 0; i < sparse->nr_areas; i++) { - if (sparse->areas[i].size) { - trace_vfio_region_sparse_mmap_entry(i, sparse->areas[i].offset, - sparse->areas[i].offset + - sparse->areas[i].size - 1); - region->mmaps[j].offset =3D sparse->areas[i].offset; - region->mmaps[j].size =3D sparse->areas[i].size; - j++; - } - } - - region->nr_mmaps =3D j; - region->mmaps =3D g_realloc(region->mmaps, j * sizeof(VFIOMmap)); - - return 0; -} - -int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, - int index, const char *name) -{ - g_autofree struct vfio_region_info *info =3D NULL; - int ret; - - ret =3D vfio_get_region_info(vbasedev, index, &info); - if (ret) { - return ret; - } - - region->vbasedev =3D vbasedev; - region->flags =3D info->flags; - region->size =3D info->size; - region->fd_offset =3D info->offset; - region->nr =3D index; - - if (region->size) { - region->mem =3D g_new0(MemoryRegion, 1); - memory_region_init_io(region->mem, obj, &vfio_region_ops, - region, name, region->size); - - if (!vbasedev->no_mmap && - region->flags & VFIO_REGION_INFO_FLAG_MMAP) { - - ret =3D vfio_setup_region_sparse_mmaps(region, info); - - if (ret) { - region->nr_mmaps =3D 1; - region->mmaps =3D g_new0(VFIOMmap, region->nr_mmaps); - region->mmaps[0].offset =3D 0; - region->mmaps[0].size =3D region->size; - } - } - } - - trace_vfio_region_setup(vbasedev->name, index, name, - region->flags, region->fd_offset, region->size= ); - return 0; -} - -static void vfio_subregion_unmap(VFIORegion *region, int index) -{ - trace_vfio_region_unmap(memory_region_name(®ion->mmaps[index].mem), - region->mmaps[index].offset, - region->mmaps[index].offset + - region->mmaps[index].size - 1); - memory_region_del_subregion(region->mem, ®ion->mmaps[index].mem); - munmap(region->mmaps[index].mmap, region->mmaps[index].size); - object_unparent(OBJECT(®ion->mmaps[index].mem)); - region->mmaps[index].mmap =3D NULL; -} - -int vfio_region_mmap(VFIORegion *region) -{ - int i, ret, prot =3D 0; - char *name; - - if (!region->mem) { - return 0; - } - - prot |=3D region->flags & VFIO_REGION_INFO_FLAG_READ ? PROT_READ : 0; - prot |=3D region->flags & VFIO_REGION_INFO_FLAG_WRITE ? PROT_WRITE : 0; - - for (i =3D 0; i < region->nr_mmaps; i++) { - size_t align =3D MIN(1ULL << ctz64(region->mmaps[i].size), 1 * GiB= ); - void *map_base, *map_align; - - /* - * Align the mmap for more efficient mapping in the kernel. Ideal= ly - * we'd know the PMD and PUD mapping sizes to use as discrete alig= nment - * intervals, but we don't. As of Linux v6.12, the largest PUD si= ze - * supporting huge pfnmap is 1GiB (ARCH_SUPPORTS_PUD_PFNMAP is onl= y set - * on x86_64). Align by power-of-two size, capped at 1GiB. - * - * NB. qemu_memalign() and friends actually allocate memory, where= as - * the region size here can exceed host memory, therefore we manua= lly - * create an oversized anonymous mapping and clean it up for align= ment. - */ - map_base =3D mmap(0, region->mmaps[i].size + align, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (map_base =3D=3D MAP_FAILED) { - ret =3D -errno; - goto no_mmap; - } - - map_align =3D (void *)ROUND_UP((uintptr_t)map_base, (uintptr_t)ali= gn); - munmap(map_base, map_align - map_base); - munmap(map_align + region->mmaps[i].size, - align - (map_align - map_base)); - - region->mmaps[i].mmap =3D mmap(map_align, region->mmaps[i].size, p= rot, - MAP_SHARED | MAP_FIXED, - region->vbasedev->fd, - region->fd_offset + - region->mmaps[i].offset); - if (region->mmaps[i].mmap =3D=3D MAP_FAILED) { - ret =3D -errno; - goto no_mmap; - } - - name =3D g_strdup_printf("%s mmaps[%d]", - memory_region_name(region->mem), i); - memory_region_init_ram_device_ptr(®ion->mmaps[i].mem, - memory_region_owner(region->mem), - name, region->mmaps[i].size, - region->mmaps[i].mmap); - g_free(name); - memory_region_add_subregion(region->mem, region->mmaps[i].offset, - ®ion->mmaps[i].mem); - - trace_vfio_region_mmap(memory_region_name(®ion->mmaps[i].mem), - region->mmaps[i].offset, - region->mmaps[i].offset + - region->mmaps[i].size - 1); - } - - return 0; - -no_mmap: - trace_vfio_region_mmap_fault(memory_region_name(region->mem), i, - region->fd_offset + region->mmaps[i].offs= et, - region->fd_offset + region->mmaps[i].offs= et + - region->mmaps[i].size - 1, ret); - - region->mmaps[i].mmap =3D NULL; - - for (i--; i >=3D 0; i--) { - vfio_subregion_unmap(region, i); - } - - return ret; -} - -void vfio_region_unmap(VFIORegion *region) -{ - int i; - - if (!region->mem) { - return; - } - - for (i =3D 0; i < region->nr_mmaps; i++) { - if (region->mmaps[i].mmap) { - vfio_subregion_unmap(region, i); - } - } -} - -void vfio_region_exit(VFIORegion *region) -{ - int i; - - if (!region->mem) { - return; - } - - for (i =3D 0; i < region->nr_mmaps; i++) { - if (region->mmaps[i].mmap) { - memory_region_del_subregion(region->mem, ®ion->mmaps[i].mem= ); - } - } - - trace_vfio_region_exit(region->vbasedev->name, region->nr); -} - -void vfio_region_finalize(VFIORegion *region) -{ - int i; - - if (!region->mem) { - return; - } - - for (i =3D 0; i < region->nr_mmaps; i++) { - if (region->mmaps[i].mmap) { - munmap(region->mmaps[i].mmap, region->mmaps[i].size); - object_unparent(OBJECT(®ion->mmaps[i].mem)); - } - } - - object_unparent(OBJECT(region->mem)); - - g_free(region->mem); - g_free(region->mmaps); - - trace_vfio_region_finalize(region->vbasedev->name, region->nr); - - region->mem =3D NULL; - region->mmaps =3D NULL; - region->nr_mmaps =3D 0; - region->size =3D 0; - region->flags =3D 0; - region->nr =3D 0; -} - -void vfio_region_mmaps_set_enabled(VFIORegion *region, bool enabled) -{ - int i; - - if (!region->mem) { - return; - } - - for (i =3D 0; i < region->nr_mmaps; i++) { - if (region->mmaps[i].mmap) { - memory_region_set_enabled(®ion->mmaps[i].mem, enabled); - } - } - - trace_vfio_region_mmaps_set_enabled(memory_region_name(region->mem), - enabled); -} - int vfio_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info) { diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 3f002252acfb7ac809107c99bdbdbaf66d56a50d..4591ec68da877b307f43ea1a830= c315721b57e9e 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -26,6 +26,7 @@ #include "hw/qdev-properties.h" #include "pci.h" #include "pci-quirks.h" +#include "hw/vfio/vfio-region.h" #include "trace.h" =20 /* diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 158deca06cb240622a254f5059c47873e5fcc7de..7457e81cdb07bc6657bb1514349= c172a152cb540 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -45,6 +45,7 @@ #include "migration/qemu-file.h" #include "system/iommufd.h" #include "vfio-migration-internal.h" +#include "hw/vfio/vfio-region.h" =20 #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" =20 diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 67bc57409c1f5a6978690c3dc07d249ea0248aa0..83b53d57149a343a00eb6d6f78c= 1cbea004dbaa2 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -37,6 +37,7 @@ #include "hw/platform-bus.h" #include "hw/qdev-properties.h" #include "system/kvm.h" +#include "hw/vfio/vfio-region.h" =20 /* * Functions used whatever the injection method diff --git a/hw/vfio/region.c b/hw/vfio/region.c new file mode 100644 index 0000000000000000000000000000000000000000..08cd69e7047ab950151832864a1= 4af7af774ff3b --- /dev/null +++ b/hw/vfio/region.c @@ -0,0 +1,394 @@ +/* + * VFIO regions + * + * Copyright Red Hat, Inc. 2012 + * + * Authors: + * Alex Williamson + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Based on qemu-kvm device-assignment: + * Adapted for KVM by Qumranet. + * Copyright (c) 2007, Neocleus, Alex Novik (alex@neocleus.com) + * Copyright (c) 2007, Neocleus, Guy Zana (guy@neocleus.com) + * Copyright (C) 2008, Qumranet, Amit Shah (amit.shah@qumranet.com) + * Copyright (C) 2008, Red Hat, Amit Shah (amit.shah@redhat.com) + * Copyright (C) 2008, IBM, Muli Ben-Yehuda (muli@il.ibm.com) + */ + +#include "qemu/osdep.h" +#include + +#include "hw/vfio/vfio-common.h" +#include "hw/vfio/pci.h" +#include "hw/hw.h" +#include "trace.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/units.h" +#include "monitor/monitor.h" + +/* + * IO Port/MMIO - Beware of the endians, VFIO is always little endian + */ +void vfio_region_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + VFIORegion *region =3D opaque; + VFIODevice *vbasedev =3D region->vbasedev; + union { + uint8_t byte; + uint16_t word; + uint32_t dword; + uint64_t qword; + } buf; + + switch (size) { + case 1: + buf.byte =3D data; + break; + case 2: + buf.word =3D cpu_to_le16(data); + break; + case 4: + buf.dword =3D cpu_to_le32(data); + break; + case 8: + buf.qword =3D cpu_to_le64(data); + break; + default: + hw_error("vfio: unsupported write size, %u bytes", size); + break; + } + + if (pwrite(vbasedev->fd, &buf, size, region->fd_offset + addr) !=3D si= ze) { + error_report("%s(%s:region%d+0x%"HWADDR_PRIx", 0x%"PRIx64 + ",%d) failed: %m", + __func__, vbasedev->name, region->nr, + addr, data, size); + } + + trace_vfio_region_write(vbasedev->name, region->nr, addr, data, size); + + /* + * A read or write to a BAR always signals an INTx EOI. This will + * do nothing if not pending (including not in INTx mode). We assume + * that a BAR access is in response to an interrupt and that BAR + * accesses will service the interrupt. Unfortunately, we don't know + * which access will service the interrupt, so we're potentially + * getting quite a few host interrupts per guest interrupt. + */ + vbasedev->ops->vfio_eoi(vbasedev); +} + +uint64_t vfio_region_read(void *opaque, + hwaddr addr, unsigned size) +{ + VFIORegion *region =3D opaque; + VFIODevice *vbasedev =3D region->vbasedev; + union { + uint8_t byte; + uint16_t word; + uint32_t dword; + uint64_t qword; + } buf; + uint64_t data =3D 0; + + if (pread(vbasedev->fd, &buf, size, region->fd_offset + addr) !=3D siz= e) { + error_report("%s(%s:region%d+0x%"HWADDR_PRIx", %d) failed: %m", + __func__, vbasedev->name, region->nr, + addr, size); + return (uint64_t)-1; + } + switch (size) { + case 1: + data =3D buf.byte; + break; + case 2: + data =3D le16_to_cpu(buf.word); + break; + case 4: + data =3D le32_to_cpu(buf.dword); + break; + case 8: + data =3D le64_to_cpu(buf.qword); + break; + default: + hw_error("vfio: unsupported read size, %u bytes", size); + break; + } + + trace_vfio_region_read(vbasedev->name, region->nr, addr, size, data); + + /* Same as write above */ + vbasedev->ops->vfio_eoi(vbasedev); + + return data; +} + +static const MemoryRegionOps vfio_region_ops =3D { + .read =3D vfio_region_read, + .write =3D vfio_region_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 8, + }, +}; + +static int vfio_setup_region_sparse_mmaps(VFIORegion *region, + struct vfio_region_info *info) +{ + struct vfio_info_cap_header *hdr; + struct vfio_region_info_cap_sparse_mmap *sparse; + int i, j; + + hdr =3D vfio_get_region_info_cap(info, VFIO_REGION_INFO_CAP_SPARSE_MMA= P); + if (!hdr) { + return -ENODEV; + } + + sparse =3D container_of(hdr, struct vfio_region_info_cap_sparse_mmap, = header); + + trace_vfio_region_sparse_mmap_header(region->vbasedev->name, + region->nr, sparse->nr_areas); + + region->mmaps =3D g_new0(VFIOMmap, sparse->nr_areas); + + for (i =3D 0, j =3D 0; i < sparse->nr_areas; i++) { + if (sparse->areas[i].size) { + trace_vfio_region_sparse_mmap_entry(i, sparse->areas[i].offset, + sparse->areas[i].offset + + sparse->areas[i].size - 1); + region->mmaps[j].offset =3D sparse->areas[i].offset; + region->mmaps[j].size =3D sparse->areas[i].size; + j++; + } + } + + region->nr_mmaps =3D j; + region->mmaps =3D g_realloc(region->mmaps, j * sizeof(VFIOMmap)); + + return 0; +} + +int vfio_region_setup(Object *obj, VFIODevice *vbasedev, VFIORegion *regio= n, + int index, const char *name) +{ + g_autofree struct vfio_region_info *info =3D NULL; + int ret; + + ret =3D vfio_get_region_info(vbasedev, index, &info); + if (ret) { + return ret; + } + + region->vbasedev =3D vbasedev; + region->flags =3D info->flags; + region->size =3D info->size; + region->fd_offset =3D info->offset; + region->nr =3D index; + + if (region->size) { + region->mem =3D g_new0(MemoryRegion, 1); + memory_region_init_io(region->mem, obj, &vfio_region_ops, + region, name, region->size); + + if (!vbasedev->no_mmap && + region->flags & VFIO_REGION_INFO_FLAG_MMAP) { + + ret =3D vfio_setup_region_sparse_mmaps(region, info); + + if (ret) { + region->nr_mmaps =3D 1; + region->mmaps =3D g_new0(VFIOMmap, region->nr_mmaps); + region->mmaps[0].offset =3D 0; + region->mmaps[0].size =3D region->size; + } + } + } + + trace_vfio_region_setup(vbasedev->name, index, name, + region->flags, region->fd_offset, region->size= ); + return 0; +} + +static void vfio_subregion_unmap(VFIORegion *region, int index) +{ + trace_vfio_region_unmap(memory_region_name(®ion->mmaps[index].mem), + region->mmaps[index].offset, + region->mmaps[index].offset + + region->mmaps[index].size - 1); + memory_region_del_subregion(region->mem, ®ion->mmaps[index].mem); + munmap(region->mmaps[index].mmap, region->mmaps[index].size); + object_unparent(OBJECT(®ion->mmaps[index].mem)); + region->mmaps[index].mmap =3D NULL; +} + +int vfio_region_mmap(VFIORegion *region) +{ + int i, ret, prot =3D 0; + char *name; + + if (!region->mem) { + return 0; + } + + prot |=3D region->flags & VFIO_REGION_INFO_FLAG_READ ? PROT_READ : 0; + prot |=3D region->flags & VFIO_REGION_INFO_FLAG_WRITE ? PROT_WRITE : 0; + + for (i =3D 0; i < region->nr_mmaps; i++) { + size_t align =3D MIN(1ULL << ctz64(region->mmaps[i].size), 1 * GiB= ); + void *map_base, *map_align; + + /* + * Align the mmap for more efficient mapping in the kernel. Ideal= ly + * we'd know the PMD and PUD mapping sizes to use as discrete alig= nment + * intervals, but we don't. As of Linux v6.12, the largest PUD si= ze + * supporting huge pfnmap is 1GiB (ARCH_SUPPORTS_PUD_PFNMAP is onl= y set + * on x86_64). Align by power-of-two size, capped at 1GiB. + * + * NB. qemu_memalign() and friends actually allocate memory, where= as + * the region size here can exceed host memory, therefore we manua= lly + * create an oversized anonymous mapping and clean it up for align= ment. + */ + map_base =3D mmap(0, region->mmaps[i].size + align, PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map_base =3D=3D MAP_FAILED) { + ret =3D -errno; + goto no_mmap; + } + + map_align =3D (void *)ROUND_UP((uintptr_t)map_base, (uintptr_t)ali= gn); + munmap(map_base, map_align - map_base); + munmap(map_align + region->mmaps[i].size, + align - (map_align - map_base)); + + region->mmaps[i].mmap =3D mmap(map_align, region->mmaps[i].size, p= rot, + MAP_SHARED | MAP_FIXED, + region->vbasedev->fd, + region->fd_offset + + region->mmaps[i].offset); + if (region->mmaps[i].mmap =3D=3D MAP_FAILED) { + ret =3D -errno; + goto no_mmap; + } + + name =3D g_strdup_printf("%s mmaps[%d]", + memory_region_name(region->mem), i); + memory_region_init_ram_device_ptr(®ion->mmaps[i].mem, + memory_region_owner(region->mem), + name, region->mmaps[i].size, + region->mmaps[i].mmap); + g_free(name); + memory_region_add_subregion(region->mem, region->mmaps[i].offset, + ®ion->mmaps[i].mem); + + trace_vfio_region_mmap(memory_region_name(®ion->mmaps[i].mem), + region->mmaps[i].offset, + region->mmaps[i].offset + + region->mmaps[i].size - 1); + } + + return 0; + +no_mmap: + trace_vfio_region_mmap_fault(memory_region_name(region->mem), i, + region->fd_offset + region->mmaps[i].offs= et, + region->fd_offset + region->mmaps[i].offs= et + + region->mmaps[i].size - 1, ret); + + region->mmaps[i].mmap =3D NULL; + + for (i--; i >=3D 0; i--) { + vfio_subregion_unmap(region, i); + } + + return ret; +} + +void vfio_region_unmap(VFIORegion *region) +{ + int i; + + if (!region->mem) { + return; + } + + for (i =3D 0; i < region->nr_mmaps; i++) { + if (region->mmaps[i].mmap) { + vfio_subregion_unmap(region, i); + } + } +} + +void vfio_region_exit(VFIORegion *region) +{ + int i; + + if (!region->mem) { + return; + } + + for (i =3D 0; i < region->nr_mmaps; i++) { + if (region->mmaps[i].mmap) { + memory_region_del_subregion(region->mem, ®ion->mmaps[i].mem= ); + } + } + + trace_vfio_region_exit(region->vbasedev->name, region->nr); +} + +void vfio_region_finalize(VFIORegion *region) +{ + int i; + + if (!region->mem) { + return; + } + + for (i =3D 0; i < region->nr_mmaps; i++) { + if (region->mmaps[i].mmap) { + munmap(region->mmaps[i].mmap, region->mmaps[i].size); + object_unparent(OBJECT(®ion->mmaps[i].mem)); + } + } + + object_unparent(OBJECT(region->mem)); + + g_free(region->mem); + g_free(region->mmaps); + + trace_vfio_region_finalize(region->vbasedev->name, region->nr); + + region->mem =3D NULL; + region->mmaps =3D NULL; + region->nr_mmaps =3D 0; + region->size =3D 0; + region->flags =3D 0; + region->nr =3D 0; +} + +void vfio_region_mmaps_set_enabled(VFIORegion *region, bool enabled) +{ + int i; + + if (!region->mem) { + return; + } + + for (i =3D 0; i < region->nr_mmaps; i++) { + if (region->mmaps[i].mmap) { + memory_region_set_enabled(®ion->mmaps[i].mem, enabled); + } + } + + trace_vfio_region_mmaps_set_enabled(memory_region_name(region->mem), + enabled); +} diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index a8939c838657b09c38f93ad69d541df5aea30a6f..07010c7c9e01a39ae3449c54d20= 27a2cdd0a7a4d 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -23,6 +23,7 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'migration.c', 'migration-multifd.c', 'cpr.c', + 'region.c', )) system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( 'iommufd.c', diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 9347e3a5f6607ec6907f9b426da9ab90553292cf..81f4130100c48012c15b5b48584= 46149a7eaf5b6 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -90,8 +90,6 @@ vfio_pci_igd_host_bridge_enabled(const char *name) "%s" vfio_pci_igd_lpc_bridge_enabled(const char *name) "%s" =20 # common.c -vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" -vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint= 64_t data) " (%s:region%d+0x%"PRIx64", %d) =3D 0x%"PRIx64 vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_e= nd) "iommu %s @ 0x%"PRIx64" - 0x%"PRIx64 vfio_listener_region_skip(const char *name, uint64_t start, uint64_t end) = "SKIPPING %s 0x%"PRIx64" - 0x%"PRIx64 vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to = liobn fd %d" @@ -107,6 +105,15 @@ vfio_disconnect_container(int fd) "close container->fd= =3D%d" vfio_put_group(int fd) "close group->fd=3D%d" vfio_get_device(const char * name, unsigned int flags, unsigned int num_re= gions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" vfio_put_base_device(int fd) "close vdev->fd=3D%d" +vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" +vfio_legacy_dma_unmap_overflow_workaround(void) "" +vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 +vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 +vfio_reset_handler(void) "" + +# region.c +vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" +vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint= 64_t data) " (%s:region%d+0x%"PRIx64", %d) =3D 0x%"PRIx64 vfio_region_setup(const char *dev, int index, const char *name, unsigned l= ong flags, unsigned long offset, unsigned long size) "Device %s, region %d = \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" vfio_region_mmap_fault(const char *name, int index, unsigned long offset, = unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault= : %d" vfio_region_mmap(const char *name, unsigned long offset, unsigned long end= ) "Region %s [0x%lx - 0x%lx]" @@ -116,11 +123,6 @@ vfio_region_mmaps_set_enabled(const char *name, bool e= nabled) "Region %s mmaps e vfio_region_unmap(const char *name, unsigned long offset, unsigned long en= d) "Region %s unmap [0x%lx - 0x%lx]" vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) = "Device %s region %d: %d sparse mmap entries" vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long en= d) "sparse entry %d [0x%lx - 0x%lx]" -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" -vfio_legacy_dma_unmap_overflow_workaround(void) "" -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 -vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 -vfio_reset_handler(void) "" =20 # platform.c vfio_platform_realize(char *name, char *compat) "vfio device %s, compat = =3D %s" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975615; cv=none; d=zohomail.com; s=zohoarc; b=ndqJqlPlRwvgwIScGT1PQ+ae0Va0sMFiNvQ+nbood30wTadTRDa1eEONzRcfyQ/LHqBrc9m+8l1WoOKdwi/1Xoh6SEX0QYtZ6NoASiYwVK7vGx8sYN11lSfzAWAFTIX0Vz7f909Z2u/BuP0zB1bUuOPW2fxE9KyeAd/CO9eBu9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975615; 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=Krb75TsMnwRAiI2Hx9sPpV3hjqk6Gh4IPAQF3HKAFB0=; b=WEP9ZZo5BPa5/hVCdmsw53SYKCB/O4urfJbKRBS2s2m76997hmYUcwORmgDzCqWtHIrnCt4OCT11BCjNjweaz3y6MD2ySULy5UhSxHcL25GAjuOv+vPGO0GDt6mgckdkQFf8JIW9p75LENoK1pYwmbMRQK+pITEqmXO1zxqC6iU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975615133617.4419903669475; Wed, 26 Mar 2025 00:53:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYx-00087g-2w; Wed, 26 Mar 2025 03:52: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 1txLYv-000873-02 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:33 -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 1txLYt-0006Ho-10 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:32 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-WdMAL48iN6WJbbRKsYLyXA-1; Wed, 26 Mar 2025 03:52:23 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBAA518007E1; Wed, 26 Mar 2025 07:52:21 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 05CE619560AB; Wed, 26 Mar 2025 07:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975549; 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=Krb75TsMnwRAiI2Hx9sPpV3hjqk6Gh4IPAQF3HKAFB0=; b=RTb7Gd7iN9ywntPZsLcJl343YDjbsFkLZGnq/O8gL44pbx4a0/cC8WRcEjWHvwAYt2LFJb LVSJuZOe586sdU5w15G+AclWNrIH2rg/Xgr0vFEm6KYgE+7tPg7Z4dYP0d2s1J3Dj7VPZE SJqHnTKMicaGsjYXsG+MxaG0+l7LWYU= X-MC-Unique: WdMAL48iN6WJbbRKsYLyXA-1 X-Mimecast-MFC-AGG-ID: WdMAL48iN6WJbbRKsYLyXA_1742975541 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 12/37] vfio: Introduce a new header file for VFIOcontainer declarations Date: Wed, 26 Mar 2025 08:50:57 +0100 Message-ID: <20250326075122.1299361-13-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975616489019100 Gather all VFIOcontainer related declarations into "hw/vfio/vfio-container.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". These declarations were initially introduced in commit 65501a745dba ("vfio: vfio-pci device assignment driver"). They are made available externally for PPC and s390x. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-12-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 19 ----------------- include/hw/vfio/vfio-container.h | 36 ++++++++++++++++++++++++++++++++ hw/ppc/spapr_pci_vfio.c | 1 + hw/s390x/s390-pci-vfio.c | 2 +- hw/vfio/container.c | 1 + hw/vfio/spapr.c | 1 + 6 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 include/hw/vfio/vfio-container.h diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 3d470d79325526e0508683c445a7635c78a57e34..aebce091088f5027c31c7782a16= 83e763bd766ec 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -39,16 +39,6 @@ enum { VFIO_DEVICE_TYPE_CCW =3D 2, VFIO_DEVICE_TYPE_AP =3D 3, }; -struct VFIOGroup; - -typedef struct VFIOContainer { - VFIOContainerBase bcontainer; - int fd; /* /dev/vfio/vfio, empowered by the attached groups */ - unsigned iommu_type; - QLIST_HEAD(, VFIOGroup) group_list; -} VFIOContainer; - -OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); =20 typedef struct VFIODeviceOps VFIODeviceOps; typedef struct VFIOMigration VFIOMigration; @@ -125,15 +115,6 @@ struct VFIODeviceOps { int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f); }; =20 -typedef struct VFIOGroup { - int fd; - int groupid; - VFIOContainer *container; - QLIST_HEAD(, VFIODevice) device_list; - QLIST_ENTRY(VFIOGroup) next; - QLIST_ENTRY(VFIOGroup) container_next; - bool ram_block_discard_allowed; -} VFIOGroup; =20 #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-contai= ner.h new file mode 100644 index 0000000000000000000000000000000000000000..afc498da49fd4aa7625e47a0749= f2c524049296d --- /dev/null +++ b/include/hw/vfio/vfio-container.h @@ -0,0 +1,36 @@ +/* + * VFIO container + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_CONTAINER_H +#define HW_VFIO_CONTAINER_H + +#include "hw/vfio/vfio-container-base.h" + +typedef struct VFIOContainer VFIOContainer; +typedef struct VFIODevice VFIODevice; + +typedef struct VFIOGroup { + int fd; + int groupid; + VFIOContainer *container; + QLIST_HEAD(, VFIODevice) device_list; + QLIST_ENTRY(VFIOGroup) next; + QLIST_ENTRY(VFIOGroup) container_next; + bool ram_block_discard_allowed; +} VFIOGroup; + +typedef struct VFIOContainer { + VFIOContainerBase bcontainer; + int fd; /* /dev/vfio/vfio, empowered by the attached groups */ + unsigned iommu_type; + QLIST_HEAD(, VFIOGroup) group_list; +} VFIOContainer; + +OBJECT_DECLARE_SIMPLE_TYPE(VFIOContainer, VFIO_IOMMU_LEGACY); + +#endif /* HW_VFIO_CONTAINER_H */ diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index 76b2a3487b5d6f21528e9c301341eb27bc8fec1d..1722a5bfa3983d42baac558f224= 10e36eed375f5 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -25,6 +25,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pci_device.h" #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" #include "qemu/error-report.h" #include CONFIG_DEVICES /* CONFIG_VFIO_PCI */ =20 diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 6236ac7f1e686c9774ade172bf57a1e526b59939..88d4c5b3ecc617c5b93ca53cba0= 850666db3a67b 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -20,7 +20,7 @@ #include "hw/s390x/s390-pci-clp.h" #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" =20 /* * Get the current DMA available count from vfio. Returns true if vfio is diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 7c57bdd27b72731db5cf4f9446d954e143b4747e..75b5ebf4716c55d8c32a845c875= 981cef8fb5610 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -32,6 +32,7 @@ #include "trace.h" #include "qapi/error.h" #include "pci.h" +#include "hw/vfio/vfio-container.h" =20 VFIOGroupList vfio_group_list =3D QLIST_HEAD_INITIALIZER(vfio_group_list); diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 021cdedbfa483f0599ad3c858a77fc6570f1ace8..4adfd50967313d1a5c3c4033a57= c37eeb3a779a7 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -16,6 +16,7 @@ #include "exec/address-spaces.h" =20 #include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-container.h" #include "hw/hw.h" #include "exec/ram_addr.h" #include "qemu/error-report.h" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975981; cv=none; d=zohomail.com; s=zohoarc; b=A04yNPn7t7713kPPr9b9jLSPscTfdYdGM7sBOwHN87YSo5yDZq8PwHh4dS6b5I1sQdsEzvyRDXncooIJjRMfV7Worezk7+9pKSp2TPy5nQLeE8EnuGKpRcBGm3sJwPGY+yDgRUo6iDLBJTQmV34nXbsLhue9YHIts8+LRTz+V5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975981; 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=EDbc4jRBzANjUYXpR++jqrpf0gUiGJbREMzRVwZISZw=; b=Hwxn3VtD2dMpdqOjw1Ujc4bm+cO7vcz0IAxWziuD6UBNlNaYZ6N88EPakawClGHlL2qinSEkmN2yplnFv/vQxVqN11z4fYh6FSy+J6kjPcyFzUyKJlGIRWFMLtvcQ2OjPpKy30knAYsjuxE9Xad15kDBXVLswAnhbCQi7FWfP4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174297598140748.968368176501485; Wed, 26 Mar 2025 00:59:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLYs-00084S-Uc; Wed, 26 Mar 2025 03:52:30 -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 1txLYr-00083M-Kx for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:29 -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 1txLYq-0006Hb-0q for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:29 -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-613-aWMAQxRoOaOr1gjmGObiig-1; Wed, 26 Mar 2025 03:52:26 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 0335F196D2CF; Wed, 26 Mar 2025 07:52:25 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 45D9419560AB; Wed, 26 Mar 2025 07:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975547; 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=EDbc4jRBzANjUYXpR++jqrpf0gUiGJbREMzRVwZISZw=; b=P7qZt9G7uUia5I27Qx+yri0rrUAKnvY2RnGuMgiDirR9AFhoXquP8YkQs8OcFKMribeLF0 VYrceIJsN1qVZMcTE/7xHoLd97PNpObg+ZNEjVLELKfnse9wjT1+chx1FYbmTXS0qyimrn ahwDx7GevCTxGWR6DxcEs0Re9EDVMvY= X-MC-Unique: aWMAQxRoOaOr1gjmGObiig-1 X-Mimecast-MFC-AGG-ID: aWMAQxRoOaOr1gjmGObiig_1742975545 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 13/37] vfio: Make vfio_group_list static Date: Wed, 26 Mar 2025 08:50:58 +0100 Message-ID: <20250326075122.1299361-14-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975981930019000 vfio_group_list is only used in file "container.c". Reviewed-by: John Levon Reviewed-by: Zhenzhong Duan Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-13-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 -- hw/vfio/container.c | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index aebce091088f5027c31c7782a1683e763bd766ec..e23626856e6ff96939a4660f059= 833f166aa88e9 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -146,9 +146,7 @@ int vfio_kvm_device_del_fd(int fd, Error **errp); bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **er= rp); void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); =20 -typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; -extern VFIOGroupList vfio_group_list; extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; extern int vfio_kvm_device_fd; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 75b5ebf4716c55d8c32a845c875981cef8fb5610..8badeb98ec052ad1fa7b5d45bb1= 733b1184bc6fb 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -34,7 +34,8 @@ #include "pci.h" #include "hw/vfio/vfio-container.h" =20 -VFIOGroupList vfio_group_list =3D +typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; +static VFIOGroupList vfio_group_list =3D QLIST_HEAD_INITIALIZER(vfio_group_list); =20 static int vfio_ram_block_discard_disable(VFIOContainer *container, bool s= tate) --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976107; cv=none; d=zohomail.com; s=zohoarc; b=E+fuqgce9M72Mk9ArvyhZnD20uZqUE2FJAmjlmv1lnuG9/Csa22yYZDYifKyhxukY5iVPxojmmsjn+jdoXGRsxw+1C2hqYG6oJit/d9jHzQcwbKMrqNttuF2ohSyKWdwV61+c26o1U5xvgooVje3sC9HgB0IwwiLtEhkTG+cRps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976107; 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=DjSRON+Xutm3y59Hd26/mlUTyhZxzIo490emPlOEId0=; b=Ou3TnucYO8MAsgllHOV2xW+tgwWrH3SsfAWIUmETSlSnnVFoitH2KWCnPJW8DFpx90/+CHCWiyFdj3XqMxs07BmDbEYuLNA5cgcsZGwMrbXRx0n6Bxti5KI1rICzOgKJhhYSPJ8BRKZDbByAmk+F7AcexOWzZSAL1tlsW8l5Yoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976107546270.9106960851544; Wed, 26 Mar 2025 01:01:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZ5-0008QI-PR; Wed, 26 Mar 2025 03:52:44 -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 1txLYz-0008Hl-8K for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:37 -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 1txLYw-0006I8-Pe for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:36 -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-383-FIDqWiR4MlKWnP9TLtpQWw-1; Wed, 26 Mar 2025 03:52:30 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 EBAAD196D2D3; Wed, 26 Mar 2025 07:52:28 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 812D119560AB; Wed, 26 Mar 2025 07:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975553; 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=DjSRON+Xutm3y59Hd26/mlUTyhZxzIo490emPlOEId0=; b=QmG2OI/KXAtRTbkAzwhHOlNylo5qcUGiC5KSssbazDfxZ+Nm8tM+2Kz3JurmHmKzd+tsoo FstJwEJIIFZVTzlnV+eChQbGNvyWOa6wcNn0Y70upmCEFTueEK2KOy/jPt7bZkwyB3CLy/ xD7TeI/UodsuPt4uM6iSpVw7QYuGrzI= X-MC-Unique: FIDqWiR4MlKWnP9TLtpQWw-1 X-Mimecast-MFC-AGG-ID: FIDqWiR4MlKWnP9TLtpQWw_1742975549 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 14/37] vfio: Move VFIOAddressSpace helpers into container-base.c Date: Wed, 26 Mar 2025 08:50:59 +0100 Message-ID: <20250326075122.1299361-15-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976109546019100 VFIOAddressSpace is a common object used by VFIOContainerBase which is declared in "hw/vfio/vfio-container-base.h". Move the VFIOAddressSpace related services into "container-base.c". While at it, rename : vfio_get_address_space -> vfio_address_space_get vfio_put_address_space -> vfio_address_space_put to better reflect the namespace these routines belong to. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-common.h | 5 --- include/hw/vfio/vfio-container-base.h | 6 ++++ hw/ppc/spapr_pci_vfio.c | 5 ++- hw/vfio/common.c | 47 ------------------------- hw/vfio/container-base.c | 50 +++++++++++++++++++++++++++ hw/vfio/container.c | 6 ++-- hw/vfio/iommufd.c | 6 ++-- 7 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index e23626856e6ff96939a4660f059833f166aa88e9..b2d4ff68650b205dca42ef00c7d= fc7f2505b7e51 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -120,11 +120,6 @@ struct VFIODeviceOps { #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" =20 -VFIOAddressSpace *vfio_get_address_space(AddressSpace *as); -void vfio_put_address_space(VFIOAddressSpace *space); -void vfio_address_space_insert(VFIOAddressSpace *space, - VFIOContainerBase *bcontainer); - 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); diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 4cff9943ab4861a25d07b5ebd1200509ebfab12d..b33231b94013e0b535b77887109= a97f9128f1c15 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -71,6 +71,11 @@ typedef struct VFIORamDiscardListener { QLIST_ENTRY(VFIORamDiscardListener) next; } VFIORamDiscardListener; =20 +VFIOAddressSpace *vfio_address_space_get(AddressSpace *as); +void vfio_address_space_put(VFIOAddressSpace *space); +void vfio_address_space_insert(VFIOAddressSpace *space, + VFIOContainerBase *bcontainer); + int vfio_container_dma_map(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly); @@ -163,4 +168,5 @@ struct VFIOIOMMUClass { MemoryRegionSection *section); void (*release)(VFIOContainerBase *bcontainer); }; + #endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */ diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index 1722a5bfa3983d42baac558f22410e36eed375f5..e318d0d912f3e90d1289e4bc219= 5bf68418e5206 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -24,7 +24,6 @@ #include "hw/pci-host/spapr.h" #include "hw/pci/msix.h" #include "hw/pci/pci_device.h" -#include "hw/vfio/vfio-common.h" #include "hw/vfio/vfio-container.h" #include "qemu/error-report.h" #include CONFIG_DEVICES /* CONFIG_VFIO_PCI */ @@ -86,7 +85,7 @@ static int vfio_eeh_container_op(VFIOContainer *container= , uint32_t op) =20 static VFIOContainer *vfio_eeh_as_container(AddressSpace *as) { - VFIOAddressSpace *space =3D vfio_get_address_space(as); + VFIOAddressSpace *space =3D vfio_address_space_get(as); VFIOContainerBase *bcontainer =3D NULL; =20 if (QLIST_EMPTY(&space->containers)) { @@ -106,7 +105,7 @@ static VFIOContainer *vfio_eeh_as_container(AddressSpac= e *as) } =20 out: - vfio_put_address_space(space); + vfio_address_space_put(space); return container_of(bcontainer, VFIOContainer, bcontainer); } =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 33f7191c7fec76bb3f46b96e25dc1872808ccc8c..a8cece570a6092103a5cf573b53= 43e1d8817bde7 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -48,8 +48,6 @@ =20 VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); -static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =3D - QLIST_HEAD_INITIALIZER(vfio_address_spaces); =20 #ifdef CONFIG_KVM /* @@ -1393,51 +1391,6 @@ int vfio_kvm_device_del_fd(int fd, Error **errp) return 0; } =20 -VFIOAddressSpace *vfio_get_address_space(AddressSpace *as) -{ - VFIOAddressSpace *space; - - QLIST_FOREACH(space, &vfio_address_spaces, list) { - if (space->as =3D=3D as) { - return space; - } - } - - /* No suitable VFIOAddressSpace, create a new one */ - space =3D g_malloc0(sizeof(*space)); - space->as =3D as; - QLIST_INIT(&space->containers); - - if (QLIST_EMPTY(&vfio_address_spaces)) { - qemu_register_reset(vfio_reset_handler, NULL); - } - - QLIST_INSERT_HEAD(&vfio_address_spaces, space, list); - - return space; -} - -void vfio_put_address_space(VFIOAddressSpace *space) -{ - if (!QLIST_EMPTY(&space->containers)) { - return; - } - - QLIST_REMOVE(space, list); - g_free(space); - - if (QLIST_EMPTY(&vfio_address_spaces)) { - qemu_unregister_reset(vfio_reset_handler, NULL); - } -} - -void vfio_address_space_insert(VFIOAddressSpace *space, - VFIOContainerBase *bcontainer) -{ - QLIST_INSERT_HEAD(&space->containers, bcontainer, next); - bcontainer->space =3D space; -} - struct vfio_device_info *vfio_get_device_info(int fd) { struct vfio_device_info *info; diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 749a3fd29dd6fc9143f14edf7e4ac6238315fcce..2c2d8329e3cf0f21386cb0896dd= 366c8d0ccdb60 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -14,6 +14,56 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/vfio/vfio-container-base.h" +#include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ +#include "system/reset.h" + +static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =3D + QLIST_HEAD_INITIALIZER(vfio_address_spaces); + +VFIOAddressSpace *vfio_address_space_get(AddressSpace *as) +{ + VFIOAddressSpace *space; + + QLIST_FOREACH(space, &vfio_address_spaces, list) { + if (space->as =3D=3D as) { + return space; + } + } + + /* No suitable VFIOAddressSpace, create a new one */ + space =3D g_malloc0(sizeof(*space)); + space->as =3D as; + QLIST_INIT(&space->containers); + + if (QLIST_EMPTY(&vfio_address_spaces)) { + qemu_register_reset(vfio_reset_handler, NULL); + } + + QLIST_INSERT_HEAD(&vfio_address_spaces, space, list); + + return space; +} + +void vfio_address_space_put(VFIOAddressSpace *space) +{ + if (!QLIST_EMPTY(&space->containers)) { + return; + } + + QLIST_REMOVE(space, list); + g_free(space); + + if (QLIST_EMPTY(&vfio_address_spaces)) { + qemu_unregister_reset(vfio_reset_handler, NULL); + } +} + +void vfio_address_space_insert(VFIOAddressSpace *space, + VFIOContainerBase *bcontainer) +{ + QLIST_INSERT_HEAD(&space->containers, bcontainer, next); + bcontainer->space =3D space; +} =20 int vfio_container_dma_map(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 8badeb98ec052ad1fa7b5d45bb1733b1184bc6fb..9b86e24a4072e579bcdc2c060ce= 42608ee44ee2e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -546,7 +546,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, VFIOAddressSpace *space; VFIOIOMMUClass *vioc; =20 - space =3D vfio_get_address_space(as); + space =3D vfio_address_space_get(as); =20 /* * VFIO is currently incompatible with discarding of RAM insofar as the @@ -675,7 +675,7 @@ close_fd_exit: close(fd); =20 put_space_exit: - vfio_put_address_space(space); + vfio_address_space_put(space); =20 return false; } @@ -714,7 +714,7 @@ static void vfio_disconnect_container(VFIOGroup *group) close(container->fd); object_unref(container); =20 - vfio_put_address_space(space); + vfio_address_space_put(space); } } =20 diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 7196c4080125674ec58b1ebf02dad84b4387c355..a520d40afc00d79ae8617fd3c40= 433e228583b5a 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -486,7 +486,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, goto err_connect_bind; } =20 - space =3D vfio_get_address_space(as); + space =3D vfio_address_space_get(as); =20 /* * The HostIOMMUDevice data from legacy backend is static and doesn't = need @@ -606,7 +606,7 @@ err_discard_disable: err_attach_container: iommufd_cdev_container_destroy(container); err_alloc_ioas: - vfio_put_address_space(space); + vfio_address_space_put(space); iommufd_cdev_unbind_and_disconnect(vbasedev); err_connect_bind: close(vbasedev->fd); @@ -631,7 +631,7 @@ static void iommufd_cdev_detach(VFIODevice *vbasedev) vfio_cpr_unregister_container(bcontainer); iommufd_cdev_detach_container(vbasedev, container); iommufd_cdev_container_destroy(container); - vfio_put_address_space(space); + vfio_address_space_put(space); =20 iommufd_cdev_unbind_and_disconnect(vbasedev); close(vbasedev->fd); --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975621; cv=none; d=zohomail.com; s=zohoarc; b=le5ggnFQRd+lGGnymmGsqC9UFIpWy2naqQrHtx+rD6bMSM9x7FqbdeImMx/TAFdfbp/WVM9WN6kEbcVX3/fRuYQK80N+6m34FM4uPMfPA/axirTynJ+Ewn1gwlEQeK2/KBH4rgieadUKdwNl/anP0hrAbDMsZaESpAwmG3Y/lSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975621; 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=Jer0hzHOfemCPA34A9WeI+bx2/vH5fk/N8lzAilDwJ0=; b=Kpkg58ptcJ5/4n3sviWUNhqkeobfuSdZZW5myBgjgVeePAmIpc/RXZiPKKOHNNxjpla8bRHc0+DUoG5dEtkTlzNbjx3e8oVJ5IV/QsUCUvGAn4nJbY8alIkM7cQB4HdDXy+FLX4iHqtX9YY/Qu20uhgz6zC+YPSpuQeWGBLit2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174297562173647.06545215720996; Wed, 26 Mar 2025 00:53:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZK-0000OJ-RG; Wed, 26 Mar 2025 03:52:59 -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 1txLZ1-0008Le-2c for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:39 -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 1txLYz-0006IG-CP for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:38 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-jyrheO-QMU-qkwprBYT8fA-1; Wed, 26 Mar 2025 03:52:33 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32FBF180AB19; Wed, 26 Mar 2025 07:52:32 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 755CA19560AB; Wed, 26 Mar 2025 07:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975556; 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=Jer0hzHOfemCPA34A9WeI+bx2/vH5fk/N8lzAilDwJ0=; b=WLVdmsA9NUCbZ9SRXqlKSjyZuiZi+2aEeSfFIDgiN65iJgDjpHgPSLvLetji0qHvwPz7BC ufn6uzrmWxdXjSI6l0BdJBdclDbAsKguX726MsgjkjYcxNy8WZs1RE1TkTTJ8FdlMc3LK5 vaJV5RbuSxEqdBRbVuWVsfkv8nfW71s= X-MC-Unique: jyrheO-QMU-qkwprBYT8fA-1 X-Mimecast-MFC-AGG-ID: jyrheO-QMU-qkwprBYT8fA_1742975552 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 15/37] vfio: Move Host IOMMU type declarations into their respective files Date: Wed, 26 Mar 2025 08:51:00 +0100 Message-ID: <20250326075122.1299361-16-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975623326019000 These definitions don't have any use outside of their respective submodules. There is no need to expose them externally. Keep them private. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-15-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 5 ----- hw/vfio/container.c | 2 ++ hw/vfio/iommufd.c | 3 +++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index b2d4ff68650b205dca42ef00c7dfc7f2505b7e51..072b2c028f36234807c71b451a4= e3c7caefa7f14 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -115,11 +115,6 @@ struct VFIODeviceOps { int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f); }; =20 - -#define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" -#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ - TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" - 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); diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 9b86e24a4072e579bcdc2c060ce42608ee44ee2e..9aa9f6931f591211e46f57029df= 2ca194f9c3eaf 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -34,6 +34,8 @@ #include "pci.h" #include "hw/vfio/vfio-container.h" =20 +#define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" + typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; static VFIOGroupList vfio_group_list =3D QLIST_HEAD_INITIALIZER(vfio_group_list); diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index a520d40afc00d79ae8617fd3c40433e228583b5a..2ec15bc2692e2eb90299e5a1c09= ab6b738c69cf0 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -27,6 +27,9 @@ #include "pci.h" #include "vfio-iommufd.h" =20 +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" + static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr io= va, ram_addr_t size, void *vaddr, bool readonly) { --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975899; cv=none; d=zohomail.com; s=zohoarc; b=ZsFQ2k1qhmHVrsZKDsZXvrx2CBuftfNjTrrxvwxi5HBdw2K00Aqe1hduM4e1BKYuKrf2aHaDdRcU+yXfmv0SdPzKHLFdQWovhPRISPGVeMrDOKVDabWn1tMriH/Ct8dQhjxJyVFw8l6qq5g7hgxXvY3waJxzs3Arn+mEl7x+7L4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975899; 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=HXFchWed6Lh6Ij2c/uPcF3+XXunM8TGYrA54SMYNzWo=; b=EVa4UYJu4CnBPuu7s+hdieouysbm/AVmgvPek25NHWYNJ+VBRA+YvZSbiOO7CwQb6xUfN0ADZjZKtgcjxmkZsFW8AZNG1PoIkgWBIQxKqfaQLn54Zllgoy7zH1tBm50He6WlYoU5VueMaxFYKpbadVuWGAU1XMovr7yHC0rLq6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975899102103.01311289778027; Wed, 26 Mar 2025 00:58:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZK-00009P-1X; Wed, 26 Mar 2025 03:52:58 -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 1txLZ2-0008QJ-LE for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:41 -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 1txLZ0-0006IR-Ku for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:40 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-510-zGzuUbOwOsyNf6y4pHnG6g-1; Wed, 26 Mar 2025 03:52:36 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6EC401800259; Wed, 26 Mar 2025 07:52:35 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B16C319560AB; Wed, 26 Mar 2025 07:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975557; 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=HXFchWed6Lh6Ij2c/uPcF3+XXunM8TGYrA54SMYNzWo=; b=VWM7ieujLN64JGRLHa0O48NauWG+8R4CvoGPoPm1qbUq/JUloaJcCo9GJiFezXRgHnm520 CgWcpYxLHngDCIRyMxAG5HaUfbXA+loZ9vyXZNX/yfazNbLk+FM8L62ZxSK9p7uVwVabu7 YgvdOHB5Dsed7YIpG4iOExzfqNeDW74= X-MC-Unique: zGzuUbOwOsyNf6y4pHnG6g-1 X-Mimecast-MFC-AGG-ID: zGzuUbOwOsyNf6y4pHnG6g_1742975555 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 16/37] vfio: Introduce a new header file for helper services Date: Wed, 26 Mar 2025 08:51:01 +0100 Message-ID: <20250326075122.1299361-17-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975900997019100 Gather all helper routine declarations into "vfio-helpers.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-16-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/vfio-helpers.h | 26 ++++++++++++++++++++++++++ include/hw/vfio/vfio-common.h | 7 ------- hw/s390x/s390-pci-vfio.c | 1 + hw/vfio/common.c | 1 + hw/vfio/container.c | 1 + hw/vfio/helpers.c | 1 + hw/vfio/pci.c | 1 + hw/vfio/region.c | 1 + 8 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 hw/vfio/vfio-helpers.h diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h new file mode 100644 index 0000000000000000000000000000000000000000..d7e4dcba512a2a842c4a9d75e2d= 834bdf97c8f31 --- /dev/null +++ b/hw/vfio/vfio-helpers.h @@ -0,0 +1,26 @@ +/* + * VFIO helpers + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_HELPERS_H +#define HW_VFIO_VFIO_HELPERS_H + +#ifdef CONFIG_LINUX +#include + +struct vfio_info_cap_header * +vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); +struct vfio_info_cap_header * +vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); +struct vfio_info_cap_header * +vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); + +#endif + +int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); + +#endif /* HW_VFIO_VFIO_HELPERS_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 072b2c028f36234807c71b451a4e3c7caefa7f14..3487fc75a77e4413c3ef4ef6db6= 303ce17d6dc82 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -147,17 +147,10 @@ int vfio_get_region_info(VFIODevice *vbasedev, int in= dex, int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo); bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe); -struct vfio_info_cap_header * -vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, unsigned int *avail); -struct vfio_info_cap_header * -vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); -struct vfio_info_cap_header * -vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); #endif =20 -int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); bool vfio_devices_all_dirty_tracking_started( const VFIOContainerBase *bcontainer); bool diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 88d4c5b3ecc617c5b93ca53cba0850666db3a67b..1a76d4c00bf88a46623c9f848fb= cfeab91bd958c 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -21,6 +21,7 @@ #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" #include "hw/vfio/vfio-container.h" +#include "hw/vfio/vfio-helpers.h" =20 /* * Get the current DMA available count from vfio. Returns true if vfio is diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a8cece570a6092103a5cf573b5343e1d8817bde7..4b3f26d4c0ced17c93f6a1fab02= c85181d55f6be 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -45,6 +45,7 @@ #include "system/tcg.h" #include "system/tpm.h" #include "vfio-migration-internal.h" +#include "vfio-helpers.h" =20 VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 9aa9f6931f591211e46f57029df2ca194f9c3eaf..9293e626bc85aef5537d8aca500= 564f90c31faaf 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -33,6 +33,7 @@ #include "qapi/error.h" #include "pci.h" #include "hw/vfio/vfio-container.h" +#include "vfio-helpers.h" =20 #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" =20 diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 89403943a7a219e491b6812d50b27b7f1fd7b4a4..054ee6e31ebd080cc10516b9fc5= a0373725b63d8 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -30,6 +30,7 @@ #include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "vfio-helpers.h" =20 /* * Common VFIO interrupt disable diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 7457e81cdb07bc6657bb1514349c172a152cb540..8a18a5e3646f35f2a36ac73e791= 198d96d21fbb7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -46,6 +46,7 @@ #include "system/iommufd.h" #include "vfio-migration-internal.h" #include "hw/vfio/vfio-region.h" +#include "vfio-helpers.h" =20 #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" =20 diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 08cd69e7047ab950151832864a14af7af774ff3b..9049143abffa28bed333d110d1e= 01d68ad7f83be 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "vfio-helpers.h" =20 /* * IO Port/MMIO - Beware of the endians, VFIO is always little endian --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975909; cv=none; d=zohomail.com; s=zohoarc; b=VUnHfFLOl43JBcdZf3jluY5qaxuQlYrDAFtAyzjfCNW/nPj6Wn4HjkG6p1RBB/ZiDbcSs0RvfJ5oA+6N4XRswXhnuTzuDHxZqAhC3WBtp02Cd6dlcRy3+BYjkfWFAYO4i5itXcA76yyej4mBfjTbtL7f6VdA2sKvXIGEdHDgMyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975909; 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=NNouUQomu3bz3BD5i5HgLBY3ZdnxLjnaqIeCJiGQ3Bc=; b=B65lPIBNuMU+ZhjxnHLu67biyYARz0dmYJtfWJ+Q3+kdZ+bNHM9iYiRaKcM+DgPQ7MXb271PedRysvKW0VuBW39VLsRejoImZXSfQPh82EkdDPbqC3DeCM5zJU13vpPxAuC/fxZTQUC5Cq0gDc9A0cGnsTvaBMiSX+4t12Da1Zg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975909268162.00537498360984; Wed, 26 Mar 2025 00:58:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZN-0000eo-2o; Wed, 26 Mar 2025 03:53:01 -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 1txLZ8-0008Vb-PH for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52: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 1txLZ6-0006Iw-Q4 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:46 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-220-iKvEYD7kPVKFVy7qa1C04Q-1; Wed, 26 Mar 2025 03:52:39 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ABADD180049D; Wed, 26 Mar 2025 07:52:38 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EE15019560AB; Wed, 26 Mar 2025 07:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975564; 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=NNouUQomu3bz3BD5i5HgLBY3ZdnxLjnaqIeCJiGQ3Bc=; b=iQenmmVGH6KfFywIz2EYM+d8+LHx9v0IdV+q/0lphmZE9BkY2nLm8+PuD74/6gVbtGUske 575UOAojpsauFMocqjof+lV6qSAW8NknhoMWXAa27PgZ3byI+xGSSMXP1d18j28MGFAqDU sFk3crVxdhlSgs0Nadl2L+3EtZqa1uQ= X-MC-Unique: iKvEYD7kPVKFVy7qa1C04Q-1 X-Mimecast-MFC-AGG-ID: iKvEYD7kPVKFVy7qa1C04Q_1742975558 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 17/37] vfio: Move vfio_get_info_dma_avail() into helpers.c Date: Wed, 26 Mar 2025 08:51:02 +0100 Message-ID: <20250326075122.1299361-18-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975911011019100 vfio_get_info_dma_avail() is a low level routine similar to the other routines extracting capabilities from 'struct vfio_iommu_type1_info'. It belongs to file "helpers.c". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-17-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/vfio-helpers.h | 5 ++++- include/hw/vfio/vfio-common.h | 2 -- hw/vfio/container.c | 31 ------------------------------- hw/vfio/helpers.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h index d7e4dcba512a2a842c4a9d75e2d834bdf97c8f31..9af43878b8b90c0247221543423= a5aca8be2eef5 100644 --- a/hw/vfio/vfio-helpers.h +++ b/hw/vfio/vfio-helpers.h @@ -18,7 +18,10 @@ struct vfio_info_cap_header * vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); struct vfio_info_cap_header * vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); - +struct vfio_info_cap_header * +vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t= id); +bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, + unsigned int *avail); #endif =20 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 3487fc75a77e4413c3ef4ef6db6303ce17d6dc82..f5ec9fb5ba4616ece30e43ce38b= 3a4e46e2c9c3c 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -147,8 +147,6 @@ int vfio_get_region_info(VFIODevice *vbasedev, int inde= x, int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo); bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe); -bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, - unsigned int *avail); #endif =20 bool vfio_devices_all_dirty_tracking_started( diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 9293e626bc85aef5537d8aca500564f90c31faaf..6e9378434377f4b03176a16157c= 337ab1286c53e 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -278,37 +278,6 @@ static int vfio_legacy_query_dirty_bitmap(const VFIOCo= ntainerBase *bcontainer, return ret; } =20 -static struct vfio_info_cap_header * -vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t= id) -{ - if (!(info->flags & VFIO_IOMMU_INFO_CAPS)) { - return NULL; - } - - return vfio_get_cap((void *)info, info->cap_offset, id); -} - -bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, - unsigned int *avail) -{ - struct vfio_info_cap_header *hdr; - struct vfio_iommu_type1_info_dma_avail *cap; - - /* If the capability cannot be found, assume no DMA limiting */ - hdr =3D vfio_get_iommu_type1_info_cap(info, - VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL); - if (!hdr) { - return false; - } - - if (avail !=3D NULL) { - cap =3D (void *) hdr; - *avail =3D cap->avail; - } - - return true; -} - static bool vfio_get_info_iova_range(struct vfio_iommu_type1_info *info, VFIOContainerBase *bcontainer) { diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 054ee6e31ebd080cc10516b9fc5a0373725b63d8..1a584ba5f007995a16d2364faeb= 72cb2b22de4e9 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -222,6 +222,37 @@ retry: return 0; } =20 +struct vfio_info_cap_header * +vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t= id) +{ + if (!(info->flags & VFIO_IOMMU_INFO_CAPS)) { + return NULL; + } + + return vfio_get_cap((void *)info, info->cap_offset, id); +} + +bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, + unsigned int *avail) +{ + struct vfio_info_cap_header *hdr; + struct vfio_iommu_type1_info_dma_avail *cap; + + /* If the capability cannot be found, assume no DMA limiting */ + hdr =3D vfio_get_iommu_type1_info_cap(info, + VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL); + if (!hdr) { + return false; + } + + if (avail !=3D NULL) { + cap =3D (void *) hdr; + *avail =3D cap->avail; + } + + return true; +} + int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo) { --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976032; cv=none; d=zohomail.com; s=zohoarc; b=ef7lPwIEfIsTfu2fbQhkcpx888b/5y3Y6nwaIPP6/whxyUjj8rth3ALwqLneU6vWo+hbPVUekRmKIgJAl0XDcleViPd9SW2Z3qZSiIwfu3cJsgIYBlvbDpJNdveUWvQw1g6DBiqI+zxaBQInVyC1s0s6xjkH+gOyjyp5buIilBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976032; 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=CR5onqLi/nwk9XV1BwqHLz4Pmvnr+XtpFIJ+MyDpn3Y=; b=Idm8vz7xZfIZY8V1bwZlhI2Stt1/xiO9kqm7kafLW1nIgfPhFbMrz55ptblSC++1LvP0f5PkC4I3BFT6K8kT9Sd9cUrpaYb42rDMAX85j/hCFXzCwi8pIIg+D9pMHaxpFi00cT95KadlhI7cH9z58TRTrUTNRBWhYYjZ4XS+TGA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976032442698.7398875840371; Wed, 26 Mar 2025 01:00:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZM-0000ah-DB; Wed, 26 Mar 2025 03:53:00 -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 1txLZ9-0008W1-IS for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:47 -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 1txLZ7-0006J1-FO for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:47 -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-329-oB9fO4sIP2uqeMSqEl8TUw-1; Wed, 26 Mar 2025 03:52:43 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 E99931933B48; Wed, 26 Mar 2025 07:52:41 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3769B19560AB; Wed, 26 Mar 2025 07:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975564; 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=CR5onqLi/nwk9XV1BwqHLz4Pmvnr+XtpFIJ+MyDpn3Y=; b=fe/0An+PaqZm9wwjMTpdBPzG++HvxtQTmCYEL5wI8PWdirSJ/sxuJrOEoM9wloeregLHmw Rghx9V/69BviDz1MB4uneFZOF2ftEI+jS23xEsIeiQWCoQRGDjBrFI+tmH3tV7+HGYc/OL yLFthNxKm6hOL4FBivnSaOu6YUGUNi0= X-MC-Unique: oB9fO4sIP2uqeMSqEl8TUw-1 X-Mimecast-MFC-AGG-ID: oB9fO4sIP2uqeMSqEl8TUw_1742975562 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 18/37] vfio: Move vfio_kvm_device_add/del_fd() to helpers.c Date: Wed, 26 Mar 2025 08:51:03 +0100 Message-ID: <20250326075122.1299361-19-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976033508019100 vfio_kvm_device_add/del_fd() are low level routines. Move them with the other helpers. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-18-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/vfio-helpers.h | 3 ++ include/hw/vfio/vfio-common.h | 3 -- hw/vfio/common.c | 58 ---------------------------------- hw/vfio/helpers.c | 59 +++++++++++++++++++++++++++++++++++ hw/vfio/iommufd.c | 1 + hw/vfio/meson.build | 2 +- 6 files changed, 64 insertions(+), 62 deletions(-) diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h index 9af43878b8b90c0247221543423a5aca8be2eef5..5d91e33d27be1bdd8eb9b3ce74c= 39a4ac1991adc 100644 --- a/hw/vfio/vfio-helpers.h +++ b/hw/vfio/vfio-helpers.h @@ -26,4 +26,7 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info= *info, =20 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); =20 +int vfio_kvm_device_add_fd(int fd, Error **errp); +int vfio_kvm_device_del_fd(int fd, Error **errp); + #endif /* HW_VFIO_VFIO_HELPERS_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index f5ec9fb5ba4616ece30e43ce38b3a4e46e2c9c3c..5cf7ae617371a2f8a09e52b1b43= 8fa23703c6dd8 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -130,9 +130,6 @@ bool vfio_attach_device(char *name, VFIODevice *vbasede= v, void vfio_detach_device(VFIODevice *vbasedev); VFIODevice *vfio_get_vfio_device(Object *obj); =20 -int vfio_kvm_device_add_fd(int fd, Error **errp); -int vfio_kvm_device_del_fd(int fd, Error **errp); - bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **er= rp); void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 4b3f26d4c0ced17c93f6a1fab02c85181d55f6be..cbe69fb3225f7d30fbded348ace= a597b26f98651 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1334,64 +1334,6 @@ void vfio_reset_handler(void *opaque) } } =20 -int vfio_kvm_device_add_fd(int fd, Error **errp) -{ -#ifdef CONFIG_KVM - struct kvm_device_attr attr =3D { - .group =3D KVM_DEV_VFIO_FILE, - .attr =3D KVM_DEV_VFIO_FILE_ADD, - .addr =3D (uint64_t)(unsigned long)&fd, - }; - - if (!kvm_enabled()) { - return 0; - } - - if (vfio_kvm_device_fd < 0) { - struct kvm_create_device cd =3D { - .type =3D KVM_DEV_TYPE_VFIO, - }; - - if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) { - error_setg_errno(errp, errno, "Failed to create KVM VFIO devic= e"); - return -errno; - } - - vfio_kvm_device_fd =3D cd.fd; - } - - if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { - error_setg_errno(errp, errno, "Failed to add fd %d to KVM VFIO dev= ice", - fd); - return -errno; - } -#endif - return 0; -} - -int vfio_kvm_device_del_fd(int fd, Error **errp) -{ -#ifdef CONFIG_KVM - struct kvm_device_attr attr =3D { - .group =3D KVM_DEV_VFIO_FILE, - .attr =3D KVM_DEV_VFIO_FILE_DEL, - .addr =3D (uint64_t)(unsigned long)&fd, - }; - - if (vfio_kvm_device_fd < 0) { - error_setg(errp, "KVM VFIO device isn't created yet"); - return -EINVAL; - } - - if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { - error_setg_errno(errp, errno, - "Failed to remove fd %d from KVM VFIO device", fd= ); - return -errno; - } -#endif - return 0; -} - struct vfio_device_info *vfio_get_device_info(int fd) { struct vfio_device_info *info; diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 1a584ba5f007995a16d2364faeb72cb2b22de4e9..e6b75baa805241b4df28769338b= 15a6fe9b99501 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include =20 +#include "system/kvm.h" #include "hw/vfio/vfio-common.h" #include "hw/vfio/pci.h" #include "hw/hw.h" @@ -253,6 +254,64 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_i= nfo *info, return true; } =20 +int vfio_kvm_device_add_fd(int fd, Error **errp) +{ +#ifdef CONFIG_KVM + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_VFIO_FILE, + .attr =3D KVM_DEV_VFIO_FILE_ADD, + .addr =3D (uint64_t)(unsigned long)&fd, + }; + + if (!kvm_enabled()) { + return 0; + } + + if (vfio_kvm_device_fd < 0) { + struct kvm_create_device cd =3D { + .type =3D KVM_DEV_TYPE_VFIO, + }; + + if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) { + error_setg_errno(errp, errno, "Failed to create KVM VFIO devic= e"); + return -errno; + } + + vfio_kvm_device_fd =3D cd.fd; + } + + if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { + error_setg_errno(errp, errno, "Failed to add fd %d to KVM VFIO dev= ice", + fd); + return -errno; + } +#endif + return 0; +} + +int vfio_kvm_device_del_fd(int fd, Error **errp) +{ +#ifdef CONFIG_KVM + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_VFIO_FILE, + .attr =3D KVM_DEV_VFIO_FILE_DEL, + .addr =3D (uint64_t)(unsigned long)&fd, + }; + + if (vfio_kvm_device_fd < 0) { + error_setg(errp, "KVM VFIO device isn't created yet"); + return -EINVAL; + } + + if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { + error_setg_errno(errp, errno, + "Failed to remove fd %d from KVM VFIO device", fd= ); + return -errno; + } +#endif + return 0; +} + int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo) { diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 2ec15bc2692e2eb90299e5a1c09ab6b738c69cf0..85b5a8146ac401af6be8109c28e= a4c7a39e84521 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -26,6 +26,7 @@ #include "qemu/chardev_open.h" #include "pci.h" #include "vfio-iommufd.h" +#include "vfio-helpers.h" =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 07010c7c9e01a39ae3449c54d2027a2cdd0a7a4d..21795b3d19e5db0c93993c0cb4a= 951a70d260f10 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -2,6 +2,7 @@ vfio_ss =3D ss.source_set() vfio_ss.add(files( 'common.c', 'container.c', + 'helpers.c', )) vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( @@ -18,7 +19,6 @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) system_ss.add(when: 'CONFIG_VFIO', if_true: files( - 'helpers.c', 'container-base.c', 'migration.c', 'migration-multifd.c', --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975883; cv=none; d=zohomail.com; s=zohoarc; b=etHaPyddp0aIbdcKaITRrtZskYZteidVxvXNGg8+rZMqWwfqYS9gV1vwltSSEZ12QMAEvKbJsETgVI8d3cgsy4ek+kXRvhB415T8Wj1WBVjvhkr0z6jsIgeETEtKKxvF9T7Zw0Y2mpP4wYrst/tS1D6kI1TfflynZXUlO1EWxHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975883; 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=sAWrR38/JV9FJlStgGQGNi2QY9KAVYrhhNSJ/lySp/Q=; b=EBRnZhAcmHB2pIPo5RMyE1dntOP77d+nBGgTuThCA0HiiahT/l9pwbSGdiMEKTMtWAVb7XqbFXSaWSYQXFOUX47MKvgGnLYTe847n5TfZCRe/fJ+yQ48RaCUqxKCW6jFj1PKMQgaPftquFOAFm8CVaq2ZroacEsoGpmZ2AYq3WA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975883617337.3511617573886; Wed, 26 Mar 2025 00:58:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZS-00014j-HU; Wed, 26 Mar 2025 03:53:06 -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 1txLZG-0000Cd-NA for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:56 -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 1txLZD-0006JY-L6 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:53 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-7XWaZxsLPPWtQFNfX7UO6Q-1; Wed, 26 Mar 2025 03:52:47 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B76C1809CA3; Wed, 26 Mar 2025 07:52:46 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 732A919560AB; Wed, 26 Mar 2025 07:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975570; 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=sAWrR38/JV9FJlStgGQGNi2QY9KAVYrhhNSJ/lySp/Q=; b=R+hPB3YuiVvdiB75N7JhFG/1eeein1ezHuxuUyu0v9777zMnMhFwqnSoiu+uc7ETdRr4EV qSRFh08ehIuZ+vUNDr6/b/FjWrGEEB6Ne4/wpjL8Pp5x7IxXcngwhD9LBTIKzCHXu8LtFK rbLjRWUbQZqujf4ylLeJaMUjbFCe8fM= X-MC-Unique: 7XWaZxsLPPWtQFNfX7UO6Q-1 X-Mimecast-MFC-AGG-ID: 7XWaZxsLPPWtQFNfX7UO6Q_1742975566 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 19/37] vfio: Move vfio_get_device_info() to helpers.c Date: Wed, 26 Mar 2025 08:51:04 +0100 Message-ID: <20250326075122.1299361-20-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975885842019000 vfio_get_device_info() is a low level routine. Move it with the other helpers. Reviewed-by: Zhenzhong Duan Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-19-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/vfio-helpers.h | 1 + include/hw/vfio/vfio-common.h | 1 - hw/vfio/common.c | 24 ------------------------ hw/vfio/helpers.c | 24 ++++++++++++++++++++++++ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h index 5d91e33d27be1bdd8eb9b3ce74c39a4ac1991adc..dbcb68bbb0e12607f5ccf15f114= 530966c2cbcb2 100644 --- a/hw/vfio/vfio-helpers.h +++ b/hw/vfio/vfio-helpers.h @@ -25,6 +25,7 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info= *info, #endif =20 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); +struct vfio_device_info *vfio_get_device_info(int fd); =20 int vfio_kvm_device_add_fd(int fd, Error **errp); int vfio_kvm_device_del_fd(int fd, Error **errp); diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 5cf7ae617371a2f8a09e52b1b438fa23703c6dd8..75c48ebf5c21ea93aa8ac4c3aec= c63172b633f0e 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -122,7 +122,6 @@ bool vfio_set_irq_signaling(VFIODevice *vbasedev, int i= ndex, int subindex, int action, int fd, Error **errp); =20 void vfio_reset_handler(void *opaque); -struct vfio_device_info *vfio_get_device_info(int fd); bool vfio_device_is_mdev(VFIODevice *vbasedev); bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); bool vfio_attach_device(char *name, VFIODevice *vbasedev, diff --git a/hw/vfio/common.c b/hw/vfio/common.c index cbe69fb3225f7d30fbded348acea597b26f98651..2dcf70c66e81dddffb35a152da5= a18d27a05c6f1 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1334,30 +1334,6 @@ void vfio_reset_handler(void *opaque) } } =20 -struct vfio_device_info *vfio_get_device_info(int fd) -{ - struct vfio_device_info *info; - uint32_t argsz =3D sizeof(*info); - - info =3D g_malloc0(argsz); - -retry: - info->argsz =3D argsz; - - if (ioctl(fd, VFIO_DEVICE_GET_INFO, info)) { - g_free(info); - return NULL; - } - - if (info->argsz > argsz) { - argsz =3D info->argsz; - info =3D g_realloc(info, argsz); - goto retry; - } - - return info; -} - bool vfio_attach_device(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp) { diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index e6b75baa805241b4df28769338b15a6fe9b99501..b7f75b47af3a5d066eb51890383= 1214df6c3755a 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -312,6 +312,30 @@ int vfio_kvm_device_del_fd(int fd, Error **errp) return 0; } =20 +struct vfio_device_info *vfio_get_device_info(int fd) +{ + struct vfio_device_info *info; + uint32_t argsz =3D sizeof(*info); + + info =3D g_malloc0(argsz); + +retry: + info->argsz =3D argsz; + + if (ioctl(fd, VFIO_DEVICE_GET_INFO, info)) { + g_free(info); + return NULL; + } + + if (info->argsz > argsz) { + argsz =3D info->argsz; + info =3D g_realloc(info, argsz); + goto retry; + } + + return info; +} + int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo) { --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975922; cv=none; d=zohomail.com; s=zohoarc; b=bGbrxYVLMZ7umGSA5QHJ1sh1rLxrkhNJDAjDUmhz9Z/6Xs0oY4S0EBKPMcL7OyrCNAuw3MGYlswLCLQ5WyPfxZGkeNTBKWZsK/TMXQMdPmFFHtx46kXgOS/sJXUDlLuQyMAeFw8xfVg8a5+0j8StK+5MDqqRxA4FC7Nl2Ml09+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975922; 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=1XlTev6tZHF5I149yzouLAe8a0h8E9Fh+YFNOmeHyuw=; b=UwDA3tIPWpH9LE9vxoRmBUoM5X16arl0OIzCccbvZSAG7/j5pp1CDt7S9XbuXLBA6H5YGdvOxo9SUu9QdWMPbNZvS3mh8MPzmmPMgp8rXK9xDcpfi8Bk1KuvUoQjFuE8Smr0M/CJ2qFyk/EibfPStMJbRMdyyMD1e4YOeFgPrBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17429759229121007.6997520089544; Wed, 26 Mar 2025 00:58:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLao-0003cy-Cr; Wed, 26 Mar 2025 03:54:30 -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 1txLZX-0001Ie-1L for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:13 -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 1txLZS-0006LA-M3 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:10 -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-562-U8zDpFLJPYGIKTSasiDxcQ-1; Wed, 26 Mar 2025 03:52:53 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 01F7218EBE8F; Wed, 26 Mar 2025 07:52:50 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC84419560AB; Wed, 26 Mar 2025 07:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975586; 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=1XlTev6tZHF5I149yzouLAe8a0h8E9Fh+YFNOmeHyuw=; b=HKtnW83Yrllhfx5V+nz73KbbrjR8oPOjPjRwgTnRM0E4GUC2wPR2Kr7wzZbjsTo3SrX8h3 mCvVB332wM9TmnW8stofXCVEwpkC58zGRmm8sM7bZka/LU3gqQDJW7XzVG+DX1/WMNvdrd 7/ABcO/+swaF/ZFVlBm4owXmHAxFrLQ= X-MC-Unique: U8zDpFLJPYGIKTSasiDxcQ-1 X-Mimecast-MFC-AGG-ID: U8zDpFLJPYGIKTSasiDxcQ_1742975570 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 20/37] vfio: Introduce a new file for VFIODevice definitions Date: Wed, 26 Mar 2025 08:51:05 +0100 Message-ID: <20250326075122.1299361-21-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975923712019000 Move all VFIODevice related routines of "helpers.c" into a new "device.c" file. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon Reviewed-by: Zhenzhong Duan --- hw/vfio/device.c | 330 +++++++++++++++++++++++++++++++++++++++++++ hw/vfio/helpers.c | 303 --------------------------------------- hw/vfio/meson.build | 1 + hw/vfio/trace-events | 4 +- 4 files changed, 334 insertions(+), 304 deletions(-) create mode 100644 hw/vfio/device.c diff --git a/hw/vfio/device.c b/hw/vfio/device.c new file mode 100644 index 0000000000000000000000000000000000000000..21c6824430c49170b8d1b9a69ff= 51272f48096a4 --- /dev/null +++ b/hw/vfio/device.c @@ -0,0 +1,330 @@ +/* + * VFIO device + * + * Copyright Red Hat, Inc. 2012 + * + * Authors: + * Alex Williamson + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Based on qemu-kvm device-assignment: + * Adapted for KVM by Qumranet. + * Copyright (c) 2007, Neocleus, Alex Novik (alex@neocleus.com) + * Copyright (c) 2007, Neocleus, Guy Zana (guy@neocleus.com) + * Copyright (C) 2008, Qumranet, Amit Shah (amit.shah@qumranet.com) + * Copyright (C) 2008, Red Hat, Amit Shah (amit.shah@redhat.com) + * Copyright (C) 2008, IBM, Muli Ben-Yehuda (muli@il.ibm.com) + */ + +#include "qemu/osdep.h" +#include + +#include "hw/vfio/vfio-common.h" +#include "hw/vfio/pci.h" +#include "hw/hw.h" +#include "trace.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/units.h" +#include "monitor/monitor.h" +#include "vfio-helpers.h" + +/* + * Common VFIO interrupt disable + */ +void vfio_disable_irqindex(VFIODevice *vbasedev, int index) +{ + struct vfio_irq_set irq_set =3D { + .argsz =3D sizeof(irq_set), + .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER, + .index =3D index, + .start =3D 0, + .count =3D 0, + }; + + ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); +} + +void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index) +{ + struct vfio_irq_set irq_set =3D { + .argsz =3D sizeof(irq_set), + .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK, + .index =3D index, + .start =3D 0, + .count =3D 1, + }; + + ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); +} + +void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index) +{ + struct vfio_irq_set irq_set =3D { + .argsz =3D sizeof(irq_set), + .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_MASK, + .index =3D index, + .start =3D 0, + .count =3D 1, + }; + + ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); +} + +static inline const char *action_to_str(int action) +{ + switch (action) { + case VFIO_IRQ_SET_ACTION_MASK: + return "MASK"; + case VFIO_IRQ_SET_ACTION_UNMASK: + return "UNMASK"; + case VFIO_IRQ_SET_ACTION_TRIGGER: + return "TRIGGER"; + default: + return "UNKNOWN ACTION"; + } +} + +static const char *index_to_str(VFIODevice *vbasedev, int index) +{ + if (vbasedev->type !=3D VFIO_DEVICE_TYPE_PCI) { + return NULL; + } + + switch (index) { + case VFIO_PCI_INTX_IRQ_INDEX: + return "INTX"; + case VFIO_PCI_MSI_IRQ_INDEX: + return "MSI"; + case VFIO_PCI_MSIX_IRQ_INDEX: + return "MSIX"; + case VFIO_PCI_ERR_IRQ_INDEX: + return "ERR"; + case VFIO_PCI_REQ_IRQ_INDEX: + return "REQ"; + default: + return NULL; + } +} + +bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, + int action, int fd, Error **errp) +{ + ERRP_GUARD(); + g_autofree struct vfio_irq_set *irq_set =3D NULL; + int argsz; + const char *name; + int32_t *pfd; + + argsz =3D sizeof(*irq_set) + sizeof(*pfd); + + irq_set =3D g_malloc0(argsz); + irq_set->argsz =3D argsz; + irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | action; + irq_set->index =3D index; + irq_set->start =3D subindex; + irq_set->count =3D 1; + pfd =3D (int32_t *)&irq_set->data; + *pfd =3D fd; + + if (!ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { + return true; + } + + error_setg_errno(errp, errno, "VFIO_DEVICE_SET_IRQS failure"); + + name =3D index_to_str(vbasedev, index); + if (name) { + error_prepend(errp, "%s-%d: ", name, subindex); + } else { + error_prepend(errp, "index %d-%d: ", index, subindex); + } + error_prepend(errp, + "Failed to %s %s eventfd signaling for interrupt ", + fd < 0 ? "tear down" : "set up", action_to_str(action)); + return false; +} + +int vfio_get_region_info(VFIODevice *vbasedev, int index, + struct vfio_region_info **info) +{ + size_t argsz =3D sizeof(struct vfio_region_info); + + *info =3D g_malloc0(argsz); + + (*info)->index =3D index; +retry: + (*info)->argsz =3D argsz; + + if (ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, *info)) { + g_free(*info); + *info =3D NULL; + return -errno; + } + + if ((*info)->argsz > argsz) { + argsz =3D (*info)->argsz; + *info =3D g_realloc(*info, argsz); + + goto retry; + } + + return 0; +} + +int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, + uint32_t subtype, struct vfio_region_info **i= nfo) +{ + int i; + + for (i =3D 0; i < vbasedev->num_regions; i++) { + struct vfio_info_cap_header *hdr; + struct vfio_region_info_cap_type *cap_type; + + if (vfio_get_region_info(vbasedev, i, info)) { + continue; + } + + hdr =3D vfio_get_region_info_cap(*info, VFIO_REGION_INFO_CAP_TYPE); + if (!hdr) { + g_free(*info); + continue; + } + + cap_type =3D container_of(hdr, struct vfio_region_info_cap_type, h= eader); + + trace_vfio_get_dev_region(vbasedev->name, i, + cap_type->type, cap_type->subtype); + + if (cap_type->type =3D=3D type && cap_type->subtype =3D=3D subtype= ) { + return 0; + } + + g_free(*info); + } + + *info =3D NULL; + return -ENODEV; +} + +bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe) +{ + g_autofree struct vfio_region_info *info =3D NULL; + bool ret =3D false; + + if (!vfio_get_region_info(vbasedev, region, &info)) { + if (vfio_get_region_info_cap(info, cap_type)) { + ret =3D true; + } + } + + return ret; +} + +bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp) +{ + ERRP_GUARD(); + struct stat st; + + if (vbasedev->fd < 0) { + if (stat(vbasedev->sysfsdev, &st) < 0) { + error_setg_errno(errp, errno, "no such host device"); + error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->sysfsdev); + return false; + } + /* User may specify a name, e.g: VFIO platform device */ + if (!vbasedev->name) { + vbasedev->name =3D g_path_get_basename(vbasedev->sysfsdev); + } + } else { + if (!vbasedev->iommufd) { + error_setg(errp, "Use FD passing only with iommufd backend"); + return false; + } + /* + * Give a name with fd so any function printing out vbasedev->name + * will not break. + */ + if (!vbasedev->name) { + vbasedev->name =3D g_strdup_printf("VFIO_FD%d", vbasedev->fd); + } + } + + return true; +} + +void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) +{ + ERRP_GUARD(); + int fd =3D monitor_fd_param(monitor_cur(), str, errp); + + if (fd < 0) { + error_prepend(errp, "Could not parse remote object fd %s:", str); + return; + } + vbasedev->fd =3D fd; +} + +void vfio_device_init(VFIODevice *vbasedev, int type, VFIODeviceOps *ops, + DeviceState *dev, bool ram_discard) +{ + vbasedev->type =3D type; + vbasedev->ops =3D ops; + vbasedev->dev =3D dev; + vbasedev->fd =3D -1; + + vbasedev->ram_block_discard_allowed =3D ram_discard; +} + +int vfio_device_get_aw_bits(VFIODevice *vdev) +{ + /* + * iova_ranges is a sorted list. For old kernels that support + * VFIO but not support query of iova ranges, iova_ranges is NULL, + * in this case HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX(64) is returned. + */ + GList *l =3D g_list_last(vdev->bcontainer->iova_ranges); + + if (l) { + Range *range =3D l->data; + return range_get_last_bit(range) + 1; + } + + return HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX; +} + +bool vfio_device_is_mdev(VFIODevice *vbasedev) +{ + g_autofree char *subsys =3D NULL; + g_autofree char *tmp =3D NULL; + + if (!vbasedev->sysfsdev) { + return false; + } + + tmp =3D g_strdup_printf("%s/subsystem", vbasedev->sysfsdev); + subsys =3D realpath(tmp, NULL); + return subsys && (strcmp(subsys, "/sys/bus/mdev") =3D=3D 0); +} + +bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp) +{ + HostIOMMUDevice *hiod =3D vbasedev->hiod; + + if (!hiod) { + return true; + } + + return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp= ); +} + +VFIODevice *vfio_get_vfio_device(Object *obj) +{ + if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) { + return &VFIO_PCI(obj)->vbasedev; + } else { + return NULL; + } +} diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index b7f75b47af3a5d066eb518903831214df6c3755a..7ddc9797ef7659035d927e40a3b= 99a8f74dca2de 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -24,131 +24,10 @@ =20 #include "system/kvm.h" #include "hw/vfio/vfio-common.h" -#include "hw/vfio/pci.h" #include "hw/hw.h" -#include "trace.h" #include "qapi/error.h" -#include "qemu/error-report.h" -#include "qemu/units.h" -#include "monitor/monitor.h" #include "vfio-helpers.h" =20 -/* - * Common VFIO interrupt disable - */ -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) -{ - struct vfio_irq_set irq_set =3D { - .argsz =3D sizeof(irq_set), - .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER, - .index =3D index, - .start =3D 0, - .count =3D 0, - }; - - ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); -} - -void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index) -{ - struct vfio_irq_set irq_set =3D { - .argsz =3D sizeof(irq_set), - .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK, - .index =3D index, - .start =3D 0, - .count =3D 1, - }; - - ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); -} - -void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index) -{ - struct vfio_irq_set irq_set =3D { - .argsz =3D sizeof(irq_set), - .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_MASK, - .index =3D index, - .start =3D 0, - .count =3D 1, - }; - - ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); -} - -static inline const char *action_to_str(int action) -{ - switch (action) { - case VFIO_IRQ_SET_ACTION_MASK: - return "MASK"; - case VFIO_IRQ_SET_ACTION_UNMASK: - return "UNMASK"; - case VFIO_IRQ_SET_ACTION_TRIGGER: - return "TRIGGER"; - default: - return "UNKNOWN ACTION"; - } -} - -static const char *index_to_str(VFIODevice *vbasedev, int index) -{ - if (vbasedev->type !=3D VFIO_DEVICE_TYPE_PCI) { - return NULL; - } - - switch (index) { - case VFIO_PCI_INTX_IRQ_INDEX: - return "INTX"; - case VFIO_PCI_MSI_IRQ_INDEX: - return "MSI"; - case VFIO_PCI_MSIX_IRQ_INDEX: - return "MSIX"; - case VFIO_PCI_ERR_IRQ_INDEX: - return "ERR"; - case VFIO_PCI_REQ_IRQ_INDEX: - return "REQ"; - default: - return NULL; - } -} - -bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, - int action, int fd, Error **errp) -{ - ERRP_GUARD(); - g_autofree struct vfio_irq_set *irq_set =3D NULL; - int argsz; - const char *name; - int32_t *pfd; - - argsz =3D sizeof(*irq_set) + sizeof(*pfd); - - irq_set =3D g_malloc0(argsz); - irq_set->argsz =3D argsz; - irq_set->flags =3D VFIO_IRQ_SET_DATA_EVENTFD | action; - irq_set->index =3D index; - irq_set->start =3D subindex; - irq_set->count =3D 1; - pfd =3D (int32_t *)&irq_set->data; - *pfd =3D fd; - - if (!ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set)) { - return true; - } - - error_setg_errno(errp, errno, "VFIO_DEVICE_SET_IRQS failure"); - - name =3D index_to_str(vbasedev, index); - if (name) { - error_prepend(errp, "%s-%d: ", name, subindex); - } else { - error_prepend(errp, "index %d-%d: ", index, subindex); - } - error_prepend(errp, - "Failed to %s %s eventfd signaling for interrupt ", - fd < 0 ? "tear down" : "set up", action_to_str(action)); - return false; -} - int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size) { vbmap->pages =3D REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size= (); @@ -196,33 +75,6 @@ vfio_get_device_info_cap(struct vfio_device_info *info,= uint16_t id) return vfio_get_cap((void *)info, info->cap_offset, id); } =20 -int vfio_get_region_info(VFIODevice *vbasedev, int index, - struct vfio_region_info **info) -{ - size_t argsz =3D sizeof(struct vfio_region_info); - - *info =3D g_malloc0(argsz); - - (*info)->index =3D index; -retry: - (*info)->argsz =3D argsz; - - if (ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, *info)) { - g_free(*info); - *info =3D NULL; - return -errno; - } - - if ((*info)->argsz > argsz) { - argsz =3D (*info)->argsz; - *info =3D g_realloc(*info, argsz); - - goto retry; - } - - return 0; -} - struct vfio_info_cap_header * vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t= id) { @@ -335,158 +187,3 @@ retry: =20 return info; } - -int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, - uint32_t subtype, struct vfio_region_info **i= nfo) -{ - int i; - - for (i =3D 0; i < vbasedev->num_regions; i++) { - struct vfio_info_cap_header *hdr; - struct vfio_region_info_cap_type *cap_type; - - if (vfio_get_region_info(vbasedev, i, info)) { - continue; - } - - hdr =3D vfio_get_region_info_cap(*info, VFIO_REGION_INFO_CAP_TYPE); - if (!hdr) { - g_free(*info); - continue; - } - - cap_type =3D container_of(hdr, struct vfio_region_info_cap_type, h= eader); - - trace_vfio_get_dev_region(vbasedev->name, i, - cap_type->type, cap_type->subtype); - - if (cap_type->type =3D=3D type && cap_type->subtype =3D=3D subtype= ) { - return 0; - } - - g_free(*info); - } - - *info =3D NULL; - return -ENODEV; -} - -bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe) -{ - g_autofree struct vfio_region_info *info =3D NULL; - bool ret =3D false; - - if (!vfio_get_region_info(vbasedev, region, &info)) { - if (vfio_get_region_info_cap(info, cap_type)) { - ret =3D true; - } - } - - return ret; -} - -bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp) -{ - ERRP_GUARD(); - struct stat st; - - if (vbasedev->fd < 0) { - if (stat(vbasedev->sysfsdev, &st) < 0) { - error_setg_errno(errp, errno, "no such host device"); - error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->sysfsdev); - return false; - } - /* User may specify a name, e.g: VFIO platform device */ - if (!vbasedev->name) { - vbasedev->name =3D g_path_get_basename(vbasedev->sysfsdev); - } - } else { - if (!vbasedev->iommufd) { - error_setg(errp, "Use FD passing only with iommufd backend"); - return false; - } - /* - * Give a name with fd so any function printing out vbasedev->name - * will not break. - */ - if (!vbasedev->name) { - vbasedev->name =3D g_strdup_printf("VFIO_FD%d", vbasedev->fd); - } - } - - return true; -} - -void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p) -{ - ERRP_GUARD(); - int fd =3D monitor_fd_param(monitor_cur(), str, errp); - - if (fd < 0) { - error_prepend(errp, "Could not parse remote object fd %s:", str); - return; - } - vbasedev->fd =3D fd; -} - -void vfio_device_init(VFIODevice *vbasedev, int type, VFIODeviceOps *ops, - DeviceState *dev, bool ram_discard) -{ - vbasedev->type =3D type; - vbasedev->ops =3D ops; - vbasedev->dev =3D dev; - vbasedev->fd =3D -1; - - vbasedev->ram_block_discard_allowed =3D ram_discard; -} - -int vfio_device_get_aw_bits(VFIODevice *vdev) -{ - /* - * iova_ranges is a sorted list. For old kernels that support - * VFIO but not support query of iova ranges, iova_ranges is NULL, - * in this case HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX(64) is returned. - */ - GList *l =3D g_list_last(vdev->bcontainer->iova_ranges); - - if (l) { - Range *range =3D l->data; - return range_get_last_bit(range) + 1; - } - - return HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX; -} - -bool vfio_device_is_mdev(VFIODevice *vbasedev) -{ - g_autofree char *subsys =3D NULL; - g_autofree char *tmp =3D NULL; - - if (!vbasedev->sysfsdev) { - return false; - } - - tmp =3D g_strdup_printf("%s/subsystem", vbasedev->sysfsdev); - subsys =3D realpath(tmp, NULL); - return subsys && (strcmp(subsys, "/sys/bus/mdev") =3D=3D 0); -} - -bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp) -{ - HostIOMMUDevice *hiod =3D vbasedev->hiod; - - if (!hiod) { - return true; - } - - return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp= ); -} - -VFIODevice *vfio_get_vfio_device(Object *obj) -{ - if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) { - return &VFIO_PCI(obj)->vbasedev; - } else { - return NULL; - } -} diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 21795b3d19e5db0c93993c0cb4a951a70d260f10..60caa366175edee6bc69c0febeb= aef84e752e346 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -20,6 +20,7 @@ system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('= calxeda-xgmac.c')) system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'container-base.c', + 'device.c', 'migration.c', 'migration-multifd.c', 'cpr.c', diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 81f4130100c48012c15b5b4858446149a7eaf5b6..590d9674cf7bc47171516082aba= f398dda72b86d 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -105,7 +105,6 @@ vfio_disconnect_container(int fd) "close container->fd= =3D%d" vfio_put_group(int fd) "close group->fd=3D%d" vfio_get_device(const char * name, unsigned int flags, unsigned int num_re= gions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" vfio_put_base_device(int fd) "close vdev->fd=3D%d" -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" vfio_legacy_dma_unmap_overflow_workaround(void) "" vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 @@ -194,3 +193,6 @@ iommufd_cdev_fail_attach_existing_container(const char = *msg) " %s" iommufd_cdev_alloc_ioas(int iommufd, int ioas_id) " [iommufd=3D%d] new IOM= MUFD container with ioasid=3D%d" iommufd_cdev_device_info(char *name, int devfd, int num_irqs, int num_regi= ons, int flags) " %s (%d) num_irqs=3D%d num_regions=3D%d flags=3D%d" iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int = function, int dev_id) "\t%04x:%02x:%02x.%x devid %d" + +# device.c +vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975921; cv=none; d=zohomail.com; s=zohoarc; b=MNNueBnTVoKt6UOYeH9wgVaVWk17bqCeWtpeNpiB3ROPAICwR6NHKzUqYIiHWPhNCCh7WuooyYQUisI1xyBR2nz3ZKtYbx8a1pA0RRZhevGSKzWqlWXIsCoEQGcjqrZL0Qdcx+G2ZZ/Oz82ngQmIgRWbH4g7UaBhp/7fAe6rn1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975921; 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=42xjpOB3qjIU6YWboinIzrzdNR37ElSrZpwuXv64Xno=; b=iLzPfht9A/c5M0JjH4uxG7Euu0xWEnfS/jPknz4cZHAQQIXp9pOV+Xu8DPCPZjvlhCxV2x5wC029tdC1u/ZAq12iqNYf02JxJ9BbUZvYrhDkmHrhxI3u6w+NVcLfCwwLOb0aHXvU5XXHm4MDHtP6/QU9Z9fUYfKZMyDnL+pGInU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975921399863.7019936238034; Wed, 26 Mar 2025 00:58:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZO-0000m9-GU; Wed, 26 Mar 2025 03:53:02 -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 1txLZL-0000X0-IT for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:59 -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 1txLZJ-0006KF-4s for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:52:58 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-dmHndeCHMD-2aYLisfkPEw-1; Wed, 26 Mar 2025 03:52:54 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 81CD118007E1; Wed, 26 Mar 2025 07:52:53 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 81BBA19560AB; Wed, 26 Mar 2025 07:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975576; 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=42xjpOB3qjIU6YWboinIzrzdNR37ElSrZpwuXv64Xno=; b=DpZtY0rIxkJKbDhUdAkuYnCA+YD2Zu5kzjtJHC4MPS0xX9VxAPOTeZuB4gxLNWmBfiMgyl VjO1QcwTqowE3fxr/5GEtyImU9B73iiN5chmComb0X2CQiBKHeWFJ32fn1wmlOh57xFmGS 2mI54sAJBPj3bNRhaY/UbOUQ72ab2lQ= X-MC-Unique: dmHndeCHMD-2aYLisfkPEw-1 X-Mimecast-MFC-AGG-ID: dmHndeCHMD-2aYLisfkPEw_1742975573 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Steve Sistare Subject: [PATCH for-10.1 v2 21/37] vfio: Introduce new files for CPR definitions and declarations Date: Wed, 26 Mar 2025 08:51:06 +0100 Message-ID: <20250326075122.1299361-22-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975923001019100 Gather all CPR related declarations into "vfio-cpr.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". These were introduced in commit d9fa4223b30a ("vfio: register container for cpr"). Order file list in meson.build while at it. Cc: Steve Sistare Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/vfio-cpr.h | 15 +++++++++++++++ include/hw/vfio/vfio-common.h | 3 --- hw/vfio/container.c | 1 + hw/vfio/cpr.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/meson.build | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 hw/vfio/vfio-cpr.h diff --git a/hw/vfio/vfio-cpr.h b/hw/vfio/vfio-cpr.h new file mode 100644 index 0000000000000000000000000000000000000000..9e78b422623683509929f2982f0= be465306f4e99 --- /dev/null +++ b/hw/vfio/vfio-cpr.h @@ -0,0 +1,15 @@ +/* + * VFIO CPR + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_CPR_H +#define HW_VFIO_CPR_H + +bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **er= rp); +void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); + +#endif /* HW_VFIO_CPR_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 75c48ebf5c21ea93aa8ac4c3aecc63172b633f0e..c587ed08feabd0c4845d824960d= d0799e9ace69b 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -129,9 +129,6 @@ bool vfio_attach_device(char *name, VFIODevice *vbasede= v, void vfio_detach_device(VFIODevice *vbasedev); VFIODevice *vfio_get_vfio_device(Object *obj); =20 -bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **er= rp); -void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer); - typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 6e9378434377f4b03176a16157c337ab1286c53e..7436388a73a424b11e6bad9ce80= b86c3792242dd 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -34,6 +34,7 @@ #include "pci.h" #include "hw/vfio/vfio-container.h" #include "vfio-helpers.h" +#include "vfio-cpr.h" =20 #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" =20 diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 3d1c8d290a5e6b6d67e244931a9ef8c194a0b574..696987006b853227e76caedb3c7= f4e4be31cfa06 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -10,6 +10,7 @@ #include "migration/misc.h" #include "qapi/error.h" #include "system/runstate.h" +#include "vfio-cpr.h" =20 static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier, MigrationEvent *e, Error **errp) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 85b5a8146ac401af6be8109c28ea4c7a39e84521..a5bd189a86d70bd11ecb80384ac= 145a51979322b 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -27,6 +27,7 @@ #include "pci.h" #include "vfio-iommufd.h" #include "vfio-helpers.h" +#include "vfio-cpr.h" =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 60caa366175edee6bc69c0febebaef84e752e346..1f89bd28c13dea55bcfff476ce9= 9d51b453d8533 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -20,10 +20,10 @@ system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files= ('calxeda-xgmac.c')) system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'container-base.c', + 'cpr.c', 'device.c', 'migration.c', 'migration-multifd.c', - 'cpr.c', 'region.c', )) system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975971; cv=none; d=zohomail.com; s=zohoarc; b=T91uL3Govq8xgtO73ZR0C7bdUGZprRI9tCV5Iv65AgcUCeH+QLosvYol68w1xaZFk9Ii83zSh55vpodIJkWPhjpyHsh1e+ERpNOhQx+O1exhchmaJwD50q6rVjcc+dXJSwx4iv9aFcfmul7xZBRHmC2RiiMmUTb/6/TE9XyRN5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975971; 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=OpjgmTkV3hmshry9UGwYmI8t9xIzjay1XkRPGAgDH3Q=; b=KSaaxILBVYmYllfn2CGYwT2DTsA/fw1SIaGeSqB/E+SHX+ycJOPixmlMLvXjQdHu0e3ZN563okehJWD/AgkbeQr8WMClDFle+XOBMj6DQQi85plpSZ47rKbtQQXzJywBbM1mMByZO2+pCpeSejvCHHTI3ZJrlPQiazOs80jjswI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975971487859.6911213631872; Wed, 26 Mar 2025 00:59:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZV-0001F0-8u; Wed, 26 Mar 2025 03:53:09 -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 1txLZQ-0000yQ-AT for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:04 -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 1txLZO-0006Kc-Da for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:04 -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-60-ANQ5nVL_OA-R1hRJSmOxkA-1; Wed, 26 Mar 2025 03:52:57 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 BDED71903081; Wed, 26 Mar 2025 07:52:56 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0C40319560AB; Wed, 26 Mar 2025 07:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975581; 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=OpjgmTkV3hmshry9UGwYmI8t9xIzjay1XkRPGAgDH3Q=; b=S1KIa8nxDGG8S9Kb/ynNDKmGkA4CGY332oIvxDg+88LEqDX3qtG9zeAm4GGKpQnVV97OnJ lOIkCWsR8SpXUIXW2kzPzMLz3Z958nMX1NKKOS0q3P7IJBNGJKLNbkB6BVm+OW2DatHs/l NdDlXpcd7/OnL86Uwcx6BZxduin5OLU= X-MC-Unique: ANQ5nVL_OA-R1hRJSmOxkA-1 X-Mimecast-MFC-AGG-ID: ANQ5nVL_OA-R1hRJSmOxkA_1742975576 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 22/37] vfio: Move vfio_kvm_device_fd() into helpers.c Date: Wed, 26 Mar 2025 08:51:07 +0100 Message-ID: <20250326075122.1299361-23-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975973334019100 The vfio_kvm_device_add/del_fd() routines opening the VFIO pseudo device are defined in "helpers.c". Move 'vfio_kvm_device_fd' definition there and its declaration into "vfio-helpers.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-22-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/vfio-helpers.h | 2 ++ include/hw/vfio/vfio-common.h | 1 - hw/vfio/common.c | 11 ----------- hw/vfio/helpers.c | 11 +++++++++++ hw/vfio/spapr.c | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h index dbcb68bbb0e12607f5ccf15f114530966c2cbcb2..54a327ffbc04a2df364fdd78bd9= 7fe7e2065b38c 100644 --- a/hw/vfio/vfio-helpers.h +++ b/hw/vfio/vfio-helpers.h @@ -12,6 +12,8 @@ #ifdef CONFIG_LINUX #include =20 +extern int vfio_kvm_device_fd; + struct vfio_info_cap_header * vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); struct vfio_info_cap_header * diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index c587ed08feabd0c4845d824960dd0799e9ace69b..8b300e7768fb61af881f6a8b7ee= b75dc84c98ac3 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -132,7 +132,6 @@ VFIODevice *vfio_get_vfio_device(Object *obj); typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; extern VFIODeviceList vfio_device_list; extern const MemoryListener vfio_memory_listener; -extern int vfio_kvm_device_fd; =20 #ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index, diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 2dcf70c66e81dddffb35a152da5a18d27a05c6f1..91ffc5e1a37a3ba7ab50cb5f14c= be5d56f78949d 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -50,17 +50,6 @@ VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); =20 -#ifdef CONFIG_KVM -/* - * We have a single VFIO pseudo device per KVM VM. Once created it lives - * for the life of the VM. Closing the file descriptor only drops our - * reference to it and the device's reference to kvm. Therefore once - * initialized, this file descriptor is only released on QEMU exit and - * we'll re-use it should another vfio device be attached before then. - */ -int vfio_kvm_device_fd =3D -1; -#endif - /* * Device state interfaces */ diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 7ddc9797ef7659035d927e40a3b99a8f74dca2de..48bd61d5280967dffa509dcbaee= ee7a1ba01335a 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -106,6 +106,17 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_i= nfo *info, return true; } =20 +#ifdef CONFIG_KVM +/* + * We have a single VFIO pseudo device per KVM VM. Once created it lives + * for the life of the VM. Closing the file descriptor only drops our + * reference to it and the device's reference to kvm. Therefore once + * initialized, this file descriptor is only released on QEMU exit and + * we'll re-use it should another vfio device be attached before then. + */ +int vfio_kvm_device_fd =3D -1; +#endif + int vfio_kvm_device_add_fd(int fd, Error **errp) { #ifdef CONFIG_KVM diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 4adfd50967313d1a5c3c4033a57c37eeb3a779a7..ce6eabdf0334f7c80b1b2d1ab8b= 7ec23812619fd 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -15,13 +15,13 @@ #include "system/hostmem.h" #include "exec/address-spaces.h" =20 -#include "hw/vfio/vfio-common.h" #include "hw/vfio/vfio-container.h" #include "hw/hw.h" #include "exec/ram_addr.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "trace.h" +#include "vfio-helpers.h" =20 typedef struct VFIOHostDMAWindow { hwaddr min_iova; --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975613; cv=none; d=zohomail.com; s=zohoarc; b=fi7DHMG9Hdj7+MVy5cJzl4SYQzP97Rk2j97HP4n0/+X6iJbJIiZKMProcF2i4XCzycHSC7lgXZtz4xIgBsTt9/NzkFKiIwASDYxmG5JZPekDlmpiCn3wKc3BJYEy62dnDMtbmzw+H3uoDznq/gLe8ZObqNcR2mwdV78qkvmde8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975613; 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=YXs/BrZodkavsOGpUPq+JCibGC6B/NKzZdFnXf5deIk=; b=Zf7LVwAyifoC3YvAXTrXA3CA4HqS5FRGiaDWZcqRQaRi6JX7K/n6byeyENuPJl/UyjtLCyvaISqD1XX/q2rE31nfgGVeTE9fqVcOEIWK885ZshH1oMYK8/6UxKhkLNwfrweKqlie4pFTyB1dQBhP3kFPi7dbJNJexDgvVKIkyPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975613513753.0505033066698; Wed, 26 Mar 2025 00:53:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZe-0001JX-E8; Wed, 26 Mar 2025 03:53:18 -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 1txLZS-00014N-89 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:06 -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 1txLZQ-0006Kt-GO for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:05 -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-147-oryKbsEGMjmd3uMImiuprQ-1; Wed, 26 Mar 2025 03:53:01 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 2D06E19560BB; Wed, 26 Mar 2025 07:53:00 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47ADF19560AB; Wed, 26 Mar 2025 07:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975583; 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=YXs/BrZodkavsOGpUPq+JCibGC6B/NKzZdFnXf5deIk=; b=GYvpdTRDY6b9eVFqD9+O+Bh/UL5rQj8I5tszp2O2sZyh2WwDMh5NaosY3a4/d84DAfzowD mIQMQ6VcyQ36DYT09MvYdwzglGzHTL+jLqfwAZr2Rrl4GRvrH/CqEuvRNrzx9pK6+rLJCW d6cxCOUxNTtKajD2Yt4g08fA0aeipBE= X-MC-Unique: oryKbsEGMjmd3uMImiuprQ-1 X-Mimecast-MFC-AGG-ID: oryKbsEGMjmd3uMImiuprQ_1742975580 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 23/37] vfio: Move vfio_device_list into device.c Date: Wed, 26 Mar 2025 08:51:08 +0100 Message-ID: <20250326075122.1299361-24-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975616388019100 'vfio_device_list' is VFIODevice related. Move its definitions into "device.c". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-23-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/common.c | 3 --- hw/vfio/device.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 91ffc5e1a37a3ba7ab50cb5f14cbe5d56f78949d..f16d679e71244e225b831b2cc39= c49ee2b1cd940 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -47,9 +47,6 @@ #include "vfio-migration-internal.h" #include "vfio-helpers.h" =20 -VFIODeviceList vfio_device_list =3D - QLIST_HEAD_INITIALIZER(vfio_device_list); - /* * Device state interfaces */ diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 21c6824430c49170b8d1b9a69ff51272f48096a4..25fdba10a882e35392f26a10750= 9f80e4b1c880a 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -31,6 +31,9 @@ #include "monitor/monitor.h" #include "vfio-helpers.h" =20 +VFIODeviceList vfio_device_list =3D + QLIST_HEAD_INITIALIZER(vfio_device_list); + /* * Common VFIO interrupt disable */ --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976103; cv=none; d=zohomail.com; s=zohoarc; b=P6RY7sIf1sEChVbBWHztbE8ez0On3EOImXYIhS1QndE7g15/fkKLuE8n/ZT7YlLD785+IQeFtfqKSMXAtFeV9Cplac2xiideeKj3TRneM5Kln52zss4vwh3zLuf8T0Ve/1tmyD8khqm461W8UltDdmN8xPiFi36TQi9POi3vZk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976103; 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=zD5yAD2gRlCk+FYfUTDhpLVoTUf2tXdmeftmtVlIZ/o=; b=a+LBioT5V6Mnmmvu/66C/iFhhzfMGozwFT1/yD2BuxkynybW/7IWp73Mac2S+YvazAZK1JX09bVOJNzKQgyrh7u5yABGzXuWICraCJs6DBSjP7WWl9MFq6SujKFWU+ofFVzRxQWYuX2xSsoWZB4s8VEZDMU8jEs3ULGydhZL1/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976103970652.7751202168155; Wed, 26 Mar 2025 01:01:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZs-0001jS-P1; Wed, 26 Mar 2025 03:53: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 1txLZY-0001In-Ea for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:14 -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 1txLZV-0006LK-BG for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:12 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-106-Oy2u_N7MPciGRfmxIN7S5Q-1; Wed, 26 Mar 2025 03:53:05 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0C570180025A; Wed, 26 Mar 2025 07:53:04 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8E5C419560AB; Wed, 26 Mar 2025 07:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975588; 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=zD5yAD2gRlCk+FYfUTDhpLVoTUf2tXdmeftmtVlIZ/o=; b=axQFUTjtFDQwdcsvrefQ51bhv1hrF160ufEkoH++JAtF5o1/CN6qt/YU/rOfLzjYQB+IQG DnTkWDg4UkKD9KS/oUrqmqfbOTWnzLAVPtfuGNM9QKx63pfgFC1Q2byLwksVEpEPYFcThH VTtA0B+0iFGA7EBE0XMT4EwZDN0yuyM= X-MC-Unique: Oy2u_N7MPciGRfmxIN7S5Q-1 X-Mimecast-MFC-AGG-ID: Oy2u_N7MPciGRfmxIN7S5Q_1742975584 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 24/37] vfio: Move vfio_de/attach_device() into device.c Date: Wed, 26 Mar 2025 08:51:09 +0100 Message-ID: <20250326075122.1299361-25-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976105355019100 These routines are VFIODevice related. Move their definitions into "device.c". Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-24-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/common.c | 37 ------------------------------------- hw/vfio/device.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index f16d679e71244e225b831b2cc39c49ee2b1cd940..a4052526ece5fdee0e690ad1334= 16d1dc4eb1815 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1319,40 +1319,3 @@ void vfio_reset_handler(void *opaque) } } } - -bool vfio_attach_device(char *name, VFIODevice *vbasedev, - AddressSpace *as, Error **errp) -{ - const VFIOIOMMUClass *ops =3D - VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); - HostIOMMUDevice *hiod =3D NULL; - - if (vbasedev->iommufd) { - ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMM= UFD)); - } - - assert(ops); - - - if (!vbasedev->mdev) { - hiod =3D HOST_IOMMU_DEVICE(object_new(ops->hiod_typename)); - vbasedev->hiod =3D hiod; - } - - if (!ops->attach_device(name, vbasedev, as, errp)) { - object_unref(hiod); - vbasedev->hiod =3D NULL; - return false; - } - - return true; -} - -void vfio_detach_device(VFIODevice *vbasedev) -{ - if (!vbasedev->bcontainer) { - return; - } - object_unref(vbasedev->hiod); - VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); -} diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 25fdba10a882e35392f26a107509f80e4b1c880a..179c9fb8decc42dcd8d1b4fe10e= 7acaa2a6f2c7c 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -331,3 +331,40 @@ VFIODevice *vfio_get_vfio_device(Object *obj) return NULL; } } + +bool vfio_attach_device(char *name, VFIODevice *vbasedev, + AddressSpace *as, Error **errp) +{ + const VFIOIOMMUClass *ops =3D + VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); + HostIOMMUDevice *hiod =3D NULL; + + if (vbasedev->iommufd) { + ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMM= UFD)); + } + + assert(ops); + + + if (!vbasedev->mdev) { + hiod =3D HOST_IOMMU_DEVICE(object_new(ops->hiod_typename)); + vbasedev->hiod =3D hiod; + } + + if (!ops->attach_device(name, vbasedev, as, errp)) { + object_unref(hiod); + vbasedev->hiod =3D NULL; + return false; + } + + return true; +} + +void vfio_detach_device(VFIODevice *vbasedev) +{ + if (!vbasedev->bcontainer) { + return; + } + object_unref(vbasedev->hiod); + VFIO_IOMMU_GET_CLASS(vbasedev->bcontainer)->detach_device(vbasedev); +} --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975663; cv=none; d=zohomail.com; s=zohoarc; b=NYGyEJOiVlZLmspvO7aukxJkdTzfWCLAFyD00p9zqCS6Byde1c+KPHykiaLLrBPSWwKGQHYPPgSQm+Sshl6z86a/sz3329R7LUFLoicMRxXOhZmMCOtNVWruwdj0FD7bz4DSqCo1FTqGluMNyi6jtR4PYp3kT/5k3RfY4VK9jHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975663; 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=gj/gFT8FN/ASp8mRiX7o0p410g5BSlQcpz9PIz0IlUY=; b=RCCeIt6AzR8vHfOCQs9UjzpFud4IU9VBjCdAlhxtWyDjFr+utTqah3alZ7PPvNlwozAQ3SycRy8f1e737uIXnBYJs/7J4Det60Hqis9tOAUudEP5RmW5VunUp2mgZbPhj9L0xe2LfDtrh9iFDd5K948VLcFPeYTykAu2lCZU1Lk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975663412664.0351522114652; Wed, 26 Mar 2025 00:54:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZi-0001SX-Tj; Wed, 26 Mar 2025 03:53: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 1txLZa-0001JU-8y for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:17 -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 1txLZY-0006LZ-It for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:13 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-tf_PRfX_OqW0ys_siVN3Aw-1; Wed, 26 Mar 2025 03:53:08 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B362E180AF4D; Wed, 26 Mar 2025 07:53:07 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A93E19560AB; Wed, 26 Mar 2025 07:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975592; 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=gj/gFT8FN/ASp8mRiX7o0p410g5BSlQcpz9PIz0IlUY=; b=a+EhdOJdJ6QZJhngjjRPIiLPDN8/ClwNXqIJZjpYVbvDiq14g9bF1rKwB/87sfmyr49E1b 6bVD6LKaRq28g0jzHes++CtCj7GXsIH2y1fY/IWbaY6tSnPmFF6RJjwboXEpe/W4lFkkBQ yjw7lsh1RSewoeMZ+WK3D6P2NFYzV08= X-MC-Unique: tf_PRfX_OqW0ys_siVN3Aw-1 X-Mimecast-MFC-AGG-ID: tf_PRfX_OqW0ys_siVN3Aw_1742975587 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 25/37] vfio: Move vfio_reset_handler() into device.c Date: Wed, 26 Mar 2025 08:51:10 +0100 Message-ID: <20250326075122.1299361-26-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975664927019000 Pass-through devices of a VM are not necessarily in the same group and all groups/address_spaces need to be scanned when the machine is reset. Commit f16f39c3fc97 ("Implement PCI hot reset") introduced a VM reset handler for this purpose. Move it under device.c Also reintroduce the comment which explained the context and was lost along the way. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon Reviewed-by: Zhenzhong Duan --- hw/vfio/common.c | 18 ------------------ hw/vfio/device.c | 35 +++++++++++++++++++++++++++++++++++ hw/vfio/trace-events | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a4052526ece5fdee0e690ad133416d1dc4eb1815..e62bb3818c55a789e81fe50cebf= 7c6693228db31 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1301,21 +1301,3 @@ const MemoryListener vfio_memory_listener =3D { .log_global_stop =3D vfio_listener_log_global_stop, .log_sync =3D vfio_listener_log_sync, }; - -void vfio_reset_handler(void *opaque) -{ - VFIODevice *vbasedev; - - trace_vfio_reset_handler(); - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { - if (vbasedev->dev->realized) { - vbasedev->ops->vfio_compute_needs_reset(vbasedev); - } - } - - QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { - if (vbasedev->dev->realized && vbasedev->needs_reset) { - vbasedev->ops->vfio_hot_reset_multi(vbasedev); - } - } -} diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 179c9fb8decc42dcd8d1b4fe10e7acaa2a6f2c7c..e122c797c206c285ef26c3a56d8= 41d8c3be8b58b 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -34,6 +34,41 @@ VFIODeviceList vfio_device_list =3D QLIST_HEAD_INITIALIZER(vfio_device_list); =20 +/* + * We want to differentiate hot reset of multiple in-use devices vs + * hot reset of a single in-use device. VFIO_DEVICE_RESET will already + * handle the case of doing hot resets when there is only a single + * device per bus. The in-use here refers to how many VFIODevices are + * affected. A hot reset that affects multiple devices, but only a + * single in-use device, means that we can call it from our bus + * ->reset() callback since the extent is effectively a single + * device. This allows us to make use of it in the hotplug path. When + * there are multiple in-use devices, we can only trigger the hot + * reset during a system reset and thus from our reset handler. We + * separate _one vs _multi here so that we don't overlap and do a + * double reset on the system reset path where both our reset handler + * and ->reset() callback are used. Calling _one() will only do a hot + * reset for the one in-use devices case, calling _multi() will do + * nothing if a _one() would have been sufficient. + */ +void vfio_reset_handler(void *opaque) +{ + VFIODevice *vbasedev; + + trace_vfio_reset_handler(); + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { + if (vbasedev->dev->realized) { + vbasedev->ops->vfio_compute_needs_reset(vbasedev); + } + } + + QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { + if (vbasedev->dev->realized && vbasedev->needs_reset) { + vbasedev->ops->vfio_hot_reset_multi(vbasedev); + } + } +} + /* * Common VFIO interrupt disable */ diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 590d9674cf7bc47171516082abaf398dda72b86d..9fee7df8764978723f79dc60d3d= c796777278858 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -108,7 +108,6 @@ vfio_put_base_device(int fd) "close vdev->fd=3D%d" vfio_legacy_dma_unmap_overflow_workaround(void) "" vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 -vfio_reset_handler(void) "" =20 # region.c vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" @@ -196,3 +195,4 @@ iommufd_cdev_pci_hot_reset_dep_devices(int domain, int = bus, int slot, int functi =20 # device.c vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" +vfio_reset_handler(void) "" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742976098; cv=none; d=zohomail.com; s=zohoarc; b=EFM83JfBDjT/zZoMLhajbLIMIzte74a2ilsYY0cmbg9Iv1Hbfst3lZLg2cuCJheB9EjsvlNiVY9SxkE3zbFkwzbh8W7cLJmzWjwQIjHPR+Ne7qd3ptX8GJiQUFZIPQnqiNgBlalwVdi5oPF2htYEsW6eJK7ZaYSzk9AvtiDBUZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742976098; 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=bHYLBvLeKAhbi6/D4RsDuFpW87WUzEypQ+SXQsFrzRI=; b=hX2gncKEeOO715RCd1MIIN3psTzyrT+1vDwVpl52JfN6mzTedDuuiNclJ66VS4ONao3nWIhXON1e2CwQpHpubNk3b/xCNTTqub4ADICd/DusnzQWhjqVdY5cfZS2sBzm4msXf5uSzkVfRB/gdBiYT13DhYsjbqz3mJm9EGIoBFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742976098961784.5935806765076; Wed, 26 Mar 2025 01:01:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLZs-0001kw-PE; Wed, 26 Mar 2025 03:53: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 1txLZf-0001RW-Lu for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:20 -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 1txLZd-0006Lr-Ct for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:19 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-gV0qxKIyM7GC955mjzXpsw-1; Wed, 26 Mar 2025 03:53:12 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF4F31800266; Wed, 26 Mar 2025 07:53:10 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3CECF19560AB; Wed, 26 Mar 2025 07:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975596; 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=bHYLBvLeKAhbi6/D4RsDuFpW87WUzEypQ+SXQsFrzRI=; b=b/dlGw7TyGqG0YEMfy0bidmVlS8Hhbex4CNmaHtGRg7fO39ZwbjZYmePeCBbl2DmAs6Ekh NRyLo0mMCorNzhmvAufu4ucZNHp62ayE4lAWaimo/DPMyCOMUuq1ZC4SbYOuhClfxzPoVa Xb6sWFU9/DhgDhsefchpcXzNuQx1efc= X-MC-Unique: gV0qxKIyM7GC955mjzXpsw-1 X-Mimecast-MFC-AGG-ID: gV0qxKIyM7GC955mjzXpsw_1742975591 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 26/37] vfio: Move dirty tracking related services into container-base.c Date: Wed, 26 Mar 2025 08:51:11 +0100 Message-ID: <20250326075122.1299361-27-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742976103650019100 Routines of common.c : vfio_devices_all_dirty_tracking_started vfio_devices_all_device_dirty_tracking vfio_devices_query_dirty_bitmap vfio_get_dirty_bitmap are all related to dirty page tracking directly at the container level or at the container device level. Naming is a bit confusing. We will propose new names in the following changes. Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 9 -- include/hw/vfio/vfio-container-base.h | 7 ++ hw/vfio/common.c | 130 ------------------------ hw/vfio/container-base.c | 138 ++++++++++++++++++++++++++ hw/vfio/meson.build | 2 +- hw/vfio/trace-events | 4 +- 6 files changed, 149 insertions(+), 141 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8b300e7768fb61af881f6a8b7eeb75dc84c98ac3..a804af9f651f0916ca06b3f4f00= 9381eea385ba0 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -141,15 +141,6 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uin= t32_t type, bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe); #endif =20 -bool vfio_devices_all_dirty_tracking_started( - const VFIOContainerBase *bcontainer); -bool -vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer= ); -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, - uint64_t size, ram_addr_t ram_addr, Error **errp= ); - /* Returns 0 on success, or a negative errno. */ bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **err= p); diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index b33231b94013e0b535b77887109a97f9128f1c15..8575cdcb587dfe803808d452c7d= c6c81241a47cf 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -91,6 +91,13 @@ int vfio_container_set_dirty_page_tracking(VFIOContainer= Base *bcontainer, bool start, Error **errp); int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp); +bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcon= tainer); +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer); +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, + VFIOBitmap *vbmap, hwaddr iova, hwaddr= size, + Error **errp); +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, + uint64_t size, ram_addr_t ram_addr, Error **errp= ); =20 GList *vfio_container_get_iova_ranges(const VFIOContainerBase *bcontainer); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index e62bb3818c55a789e81fe50cebf7c6693228db31..85dedcbe5933c55c6fc25015d37= 01aba43b381a4 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -52,27 +52,6 @@ */ =20 =20 -static bool vfio_devices_all_device_dirty_tracking_started( - const VFIOContainerBase *bcontainer) -{ - VFIODevice *vbasedev; - - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { - if (!vbasedev->dirty_tracking) { - return false; - } - } - - return true; -} - -bool vfio_devices_all_dirty_tracking_started( - const VFIOContainerBase *bcontainer) -{ - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || - bcontainer->dirty_pages_started; -} - static bool vfio_log_sync_needed(const VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; @@ -97,22 +76,6 @@ static bool vfio_log_sync_needed(const VFIOContainerBase= *bcontainer) return true; } =20 -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer) -{ - VFIODevice *vbasedev; - - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { - if (vbasedev->device_dirty_page_tracking =3D=3D ON_OFF_AUTO_OFF) { - return false; - } - if (!vbasedev->dirty_pages_supported) { - return false; - } - } - - return true; -} - static bool vfio_listener_skipped_section(MemoryRegionSection *section) { return (!memory_region_is_ram(section->mr) && @@ -1010,99 +973,6 @@ static void vfio_listener_log_global_stop(MemoryListe= ner *listener) } } =20 -static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iov= a, - hwaddr size, void *bitmap) -{ - uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + - sizeof(struct vfio_device_feature_dma_logging_repo= rt), - sizeof(uint64_t))] =3D {}; - struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; - struct vfio_device_feature_dma_logging_report *report =3D - (struct vfio_device_feature_dma_logging_report *)feature->data; - - report->iova =3D iova; - report->length =3D size; - report->page_size =3D qemu_real_host_page_size(); - report->bitmap =3D (uintptr_t)bitmap; - - feature->argsz =3D sizeof(buf); - feature->flags =3D VFIO_DEVICE_FEATURE_GET | - VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT; - - if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { - return -errno; - } - - return 0; -} - -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) -{ - VFIODevice *vbasedev; - int ret; - - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { - ret =3D vfio_device_dma_logging_report(vbasedev, iova, size, - vbmap->bitmap); - if (ret) { - error_setg_errno(errp, -ret, - "%s: Failed to get DMA logging report, iova: " - "0x%" HWADDR_PRIx ", size: 0x%" HWADDR_PRIx, - vbasedev->name, iova, size); - - return ret; - } - } - - return 0; -} - -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, - uint64_t size, ram_addr_t ram_addr, Error **errp) -{ - bool all_device_dirty_tracking =3D - vfio_devices_all_device_dirty_tracking(bcontainer); - uint64_t dirty_pages; - VFIOBitmap vbmap; - int ret; - - if (!bcontainer->dirty_pages_supported && !all_device_dirty_tracking) { - cpu_physical_memory_set_dirty_range(ram_addr, size, - tcg_enabled() ? DIRTY_CLIENTS_= ALL : - DIRTY_CLIENTS_NOCODE); - return 0; - } - - ret =3D vfio_bitmap_alloc(&vbmap, size); - if (ret) { - error_setg_errno(errp, -ret, - "Failed to allocate dirty tracking bitmap"); - return ret; - } - - if (all_device_dirty_tracking) { - ret =3D vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, = size, - errp); - } else { - ret =3D vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova= , size, - errp); - } - - if (ret) { - goto out; - } - - dirty_pages =3D cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, r= am_addr, - vbmap.pages); - - trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pa= ges); -out: - g_free(vbmap.bitmap); - - return ret; -} - typedef struct { IOMMUNotifier n; VFIOGuestIOMMU *giommu; diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 2c2d8329e3cf0f21386cb0896dd366c8d0ccdb60..2844c5325efffade43022bfb517= a43ac372c4125 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -10,12 +10,20 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ =20 +#include +#include + +#include "system/tcg.h" #include "qemu/osdep.h" +#include "exec/ram_addr.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/vfio/vfio-container-base.h" #include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ #include "system/reset.h" +#include "vfio-helpers.h" + +#include "trace.h" =20 static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =3D QLIST_HEAD_INITIALIZER(vfio_address_spaces); @@ -143,6 +151,136 @@ int vfio_container_query_dirty_bitmap(const VFIOConta= inerBase *bcontainer, errp); } =20 +static bool vfio_devices_all_device_dirty_tracking_started( + const VFIOContainerBase *bcontainer) +{ + VFIODevice *vbasedev; + + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { + if (!vbasedev->dirty_tracking) { + return false; + } + } + + return true; +} + +bool vfio_devices_all_dirty_tracking_started( + const VFIOContainerBase *bcontainer) +{ + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || + bcontainer->dirty_pages_started; +} + +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer) +{ + VFIODevice *vbasedev; + + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { + if (vbasedev->device_dirty_page_tracking =3D=3D ON_OFF_AUTO_OFF) { + return false; + } + if (!vbasedev->dirty_pages_supported) { + return false; + } + } + + return true; +} + +static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iov= a, + hwaddr size, void *bitmap) +{ + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_dma_logging_repo= rt), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + struct vfio_device_feature_dma_logging_report *report =3D + (struct vfio_device_feature_dma_logging_report *)feature->data; + + report->iova =3D iova; + report->length =3D size; + report->page_size =3D qemu_real_host_page_size(); + report->bitmap =3D (uintptr_t)bitmap; + + feature->argsz =3D sizeof(buf); + feature->flags =3D VFIO_DEVICE_FEATURE_GET | + VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT; + + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + return -errno; + } + + return 0; +} + +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) +{ + VFIODevice *vbasedev; + int ret; + + QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { + ret =3D vfio_device_dma_logging_report(vbasedev, iova, size, + vbmap->bitmap); + if (ret) { + error_setg_errno(errp, -ret, + "%s: Failed to get DMA logging report, iova: " + "0x%" HWADDR_PRIx ", size: 0x%" HWADDR_PRIx, + vbasedev->name, iova, size); + + return ret; + } + } + + return 0; +} + +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, + uint64_t size, ram_addr_t ram_addr, Error **errp) +{ + bool all_device_dirty_tracking =3D + vfio_devices_all_device_dirty_tracking(bcontainer); + uint64_t dirty_pages; + VFIOBitmap vbmap; + int ret; + + if (!bcontainer->dirty_pages_supported && !all_device_dirty_tracking) { + cpu_physical_memory_set_dirty_range(ram_addr, size, + tcg_enabled() ? DIRTY_CLIENTS_= ALL : + DIRTY_CLIENTS_NOCODE); + return 0; + } + + ret =3D vfio_bitmap_alloc(&vbmap, size); + if (ret) { + error_setg_errno(errp, -ret, + "Failed to allocate dirty tracking bitmap"); + return ret; + } + + if (all_device_dirty_tracking) { + ret =3D vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, = size, + errp); + } else { + ret =3D vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova= , size, + errp); + } + + if (ret) { + goto out; + } + + dirty_pages =3D cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, r= am_addr, + vbmap.pages); + + trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pa= ges); +out: + g_free(vbmap.bitmap); + + return ret; +} + static gpointer copy_iova_range(gconstpointer src, gpointer data) { Range *source =3D (Range *)src; diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 1f89bd28c13dea55bcfff476ce99d51b453d8533..9c8a989db2d4578e97d864c5fd8= bcba125eab66a 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -1,6 +1,7 @@ vfio_ss =3D ss.source_set() vfio_ss.add(files( 'common.c', + 'container-base.c', 'container.c', 'helpers.c', )) @@ -19,7 +20,6 @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) system_ss.add(when: 'CONFIG_VFIO', if_true: files( - 'container-base.c', 'cpr.c', 'device.c', 'migration.c', diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 9fee7df8764978723f79dc60d3dc796777278858..d4cd09cb0f93485fe06984346f6= ac927603c5745 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -106,9 +106,11 @@ vfio_put_group(int fd) "close group->fd=3D%d" vfio_get_device(const char * name, unsigned int flags, unsigned int num_re= gions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" vfio_put_base_device(int fd) "close vdev->fd=3D%d" vfio_legacy_dma_unmap_overflow_workaround(void) "" -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 =20 +# container-base.c +vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 + # region.c vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint= 64_t data) " (%s:region%d+0x%"PRIx64", %d) =3D 0x%"PRIx64 --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975900; cv=none; d=zohomail.com; s=zohoarc; b=W/GBLhzcZdJDvq7hN4gE+X1VcQWsYuJxNUpvfz09sGB78A+D3S0zh2uXar9YMNxclfeCm4C7KwZ8Os3kn/BiABpFvr/bkgDfu6ryOSO9X6SpEH/1yrVK6S+mAEhi57vPqqa7C2t8JZk1jzEE8rhZcat18XTTlFTp2mbtw5VLnJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975900; 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=keP0c9SzpUpc6cKWkzSdI2mx47qicxSxVu+v5fOIbaQ=; b=fO0OWZ8CBGnVLt3oZrepq2kLnceaj0by2UL8ORxSZ1pZjPve/SWSZC0NCNZCuC5VIdMbgZIovL9OU6JNCeHte4PsJFfW/ILFRoY5PNwTIg33xMl4qa1HPTYaoaMDXVeCOPvsbhGIPEphhON83iBSNP9JFH/ZiBseQQvlXwdKz48= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975900771898.6250565995714; Wed, 26 Mar 2025 00:58:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLac-0002X0-7S; Wed, 26 Mar 2025 03:54:20 -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 1txLZi-0001bR-S4 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:23 -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 1txLZh-0006M6-7r for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:22 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-jKWS5g19MLysLsQlhAN7Kw-1; Wed, 26 Mar 2025 03:53:15 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 34DB41801A00; Wed, 26 Mar 2025 07:53:14 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 78A5419560AB; Wed, 26 Mar 2025 07:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975600; 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=keP0c9SzpUpc6cKWkzSdI2mx47qicxSxVu+v5fOIbaQ=; b=grcd3MvNaZvXHAsvOvvxG0xY6u+OOQ7TSeUyZg6dCufmCHZOlK3HFA1riVa6GW3pAG0xbk SsxYfhW5mewGx+c2caDj0T8SSl48+Twf9uz5/QYnrS5pa1V9dibo0Kr2uARZfaAkMF7dv7 hLTGp3nFeGySY9Z+AOhfU5NmkmKgOHA= X-MC-Unique: jKWS5g19MLysLsQlhAN7Kw-1 X-Mimecast-MFC-AGG-ID: jKWS5g19MLysLsQlhAN7Kw_1742975594 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 27/37] vfio: Make vfio_devices_query_dirty_bitmap() static Date: Wed, 26 Mar 2025 08:51:12 +0100 Message-ID: <20250326075122.1299361-28-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975902895019100 vfio_devices_query_dirty_bitmap() is only used in "container-base.c". Also, rename to vfio_container_devices_query_dirty_bitmap() to reflect with the prefix 'vfio_container_devices_' that it simply loops over the container's device list. This rename also frees the vfio_devices_query_dirty_bitmap() name which we will reuse in the next changes. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-container-base.h | 3 --- hw/vfio/container-base.c | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 8575cdcb587dfe803808d452c7dc6c81241a47cf..1227771dd896b5917366ef57810= 9b0ad92da2375 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -93,9 +93,6 @@ int vfio_container_query_dirty_bitmap(const VFIOContainer= Base *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp); bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcon= tainer); bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer); -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, - VFIOBitmap *vbmap, hwaddr iova, hwaddr= size, - Error **errp); int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, uint64_t size, ram_addr_t ram_addr, Error **errp= ); =20 diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 2844c5325efffade43022bfb517a43ac372c4125..4edbd39185375dee42ee6e6410d= a7b94635b5ab8 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -214,7 +214,7 @@ static int vfio_device_dma_logging_report(VFIODevice *v= basedev, hwaddr iova, return 0; } =20 -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, +static int vfio_container_devices_query_dirty_bitmap(const VFIOContainerBa= se *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) { VFIODevice *vbasedev; @@ -260,8 +260,8 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, } =20 if (all_device_dirty_tracking) { - ret =3D vfio_devices_query_dirty_bitmap(bcontainer, &vbmap, iova, = size, - errp); + ret =3D vfio_container_devices_query_dirty_bitmap(bcontainer, &vbm= ap, iova, size, + errp); } else { ret =3D vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova= , size, errp); --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975922; cv=none; d=zohomail.com; s=zohoarc; b=Ia6/bIsTMga3VhT/piq3xii0J8YyrCd5vkqSl99B1axG0RD4cfA4Z4L27ZsPh2oXkwlV5zRJHVYlhjy4PUK9P5IMxbgucpCUysbPjSBm/zfQeJeHnVzcYkDDAaVRnY7ADkHS5SIibKRa8Kx3Xgr7h4/7qVW8osjBDOPPdXhSUYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975922; 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=86Fv6SIivrK4hLdhpJhlEsO46bB0TTxWzzy9ieH/WSk=; b=GsjkDDI8Sfm0ITZnHjYFhgC0AnrQgszuChCU/fho1UsbuuGCpoD1axLolBwqAsvQUA3e/T/2jE6UolZYWjhal8RYEMkEWrOrX3+9rP9V+pmGc2hFEGBH0aZkGl6UitcDY20XBAbQSnJBs3Xd4Dj1UDG+JfwqJqclj4OLrCvZy8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975922887512.0888942866592; Wed, 26 Mar 2025 00:58:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLak-000390-TC; Wed, 26 Mar 2025 03:54:27 -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 1txLZm-0001l8-5b for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:28 -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 1txLZk-0006MH-F1 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:25 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-WnZq3LZcM7KlakNv1U6U9A-1; Wed, 26 Mar 2025 03:53:18 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8DF6C1800265; Wed, 26 Mar 2025 07:53:17 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B38E919560AB; Wed, 26 Mar 2025 07:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975603; 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=86Fv6SIivrK4hLdhpJhlEsO46bB0TTxWzzy9ieH/WSk=; b=CjbjsshLyZNJeKWVNr+/ak/T2TGaQJlVrN9kWf0ltKNnHlw9eYUKeMGD03vFjGcVbXf6Fh wJzrIuzgmaK6L2JVb5Fggc3dzSwXkvEfhH5tiTukC4bxg+GLJHnfhxRSq90fs+AVydjRr2 j4X5F3Mnqzg6Or3RKKhJo3ogtOsHPr0= X-MC-Unique: WnZq3LZcM7KlakNv1U6U9A-1 X-Mimecast-MFC-AGG-ID: WnZq3LZcM7KlakNv1U6U9A_1742975597 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 28/37] vfio: Make vfio_container_query_dirty_bitmap() static Date: Wed, 26 Mar 2025 08:51:13 +0100 Message-ID: <20250326075122.1299361-29-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975923700019000 vfio_container_query_dirty_bitmap() is only used in "container-base.c". Also, rename to vfio_container_vioc_query_dirty_bitmap() to reflect it is using the VFIO IOMMU backend device ->query_dirty_bitmap() handler. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-container-base.h | 2 -- hw/vfio/container-base.c | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 1227771dd896b5917366ef578109b0ad92da2375..04c87fe48bed75aa281a13f75a3= 6e345036a9163 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -89,8 +89,6 @@ void vfio_container_del_section_window(VFIOContainerBase = *bcontainer, MemoryRegionSection *section); int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, bool start, Error **errp); -int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp); bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcon= tainer); bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer); int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 4edbd39185375dee42ee6e6410da7b94635b5ab8..7f11aad339e713ea09123f36142= 5370d87762950 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -141,16 +141,6 @@ int vfio_container_set_dirty_page_tracking(VFIOContain= erBase *bcontainer, return ret; } =20 -int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp) -{ - VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); - - g_assert(vioc->query_dirty_bitmap); - return vioc->query_dirty_bitmap(bcontainer, vbmap, iova, size, - errp); -} - static bool vfio_devices_all_device_dirty_tracking_started( const VFIOContainerBase *bcontainer) { @@ -214,6 +204,16 @@ static int vfio_device_dma_logging_report(VFIODevice *= vbasedev, hwaddr iova, return 0; } =20 +static int vfio_container_vioc_query_dirty_bitmap(const VFIOContainerBase = *bcontainer, + VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **er= rp) +{ + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + g_assert(vioc->query_dirty_bitmap); + return vioc->query_dirty_bitmap(bcontainer, vbmap, iova, size, + errp); +} + static int vfio_container_devices_query_dirty_bitmap(const VFIOContainerBa= se *bcontainer, VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp) { @@ -263,8 +263,8 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, ret =3D vfio_container_devices_query_dirty_bitmap(bcontainer, &vbm= ap, iova, size, errp); } else { - ret =3D vfio_container_query_dirty_bitmap(bcontainer, &vbmap, iova= , size, - errp); + ret =3D vfio_container_vioc_query_dirty_bitmap(bcontainer, &vbmap,= iova, size, + errp); } =20 if (ret) { --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975941; cv=none; d=zohomail.com; s=zohoarc; b=UI4naQQrfYE40RCEa9gJdc2P8LEsKQV/ZF1c2WIAiekeobfHUXKudf4mRMuy6kWy4jwlAVFFYIRCER7SAIkPBs8GS70uVhWutbTY/9emnFFyL8e0Sx2HCZ30YVBR3RKXbhJXHkCzPXINN1goqrRclYpnnv5+ONp3YwfGRq8OPaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975941; 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=pMaTOPOFZ0gMWzIT7PkD6Nk+9uA8rHmJ3KckpsI7+8M=; b=Cd3VeSuvGAHTu5pI0YHsiJ0l7+aj0cOc3iTgEt5CJeiZCnpQCd701YAuoOX3Zv9QAoYHCVo+RoJqRmJDo/QulQMfVHst3oIcVN+LtFXES0CEa58nOkW7gShI1TpWLrET6G8yUHkaGFki4HbPE4gAxpInz2BTWOuAe5mbSsZwClM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975941116476.3215414143541; Wed, 26 Mar 2025 00:59:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLao-0003cw-CL; Wed, 26 Mar 2025 03:54:30 -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 1txLZq-0001lp-8k for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:32 -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 1txLZo-0006Ma-9p for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:29 -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-111-ETUviCZIPNK2jLizGqFvvQ-1; Wed, 26 Mar 2025 03:53:22 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 64E6E195606E; Wed, 26 Mar 2025 07:53:21 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EDD5C19560AB; Wed, 26 Mar 2025 07:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975606; 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=pMaTOPOFZ0gMWzIT7PkD6Nk+9uA8rHmJ3KckpsI7+8M=; b=P1sG03qTLf6qmYt1aE4zSJSSexgpO+WKE6owlc8EcKuBkREWmG6aucdSggxSdBLbIQ/zQH nhD8EjttFUlZ1iowYDI6HXKimZndB9tK++yzKmucx5XCtrPHi0vJWJBLfV0Y4ZgW/nDuYx OunsosTnPqseCd8dL64Va9X0yl4Y51s= X-MC-Unique: ETUviCZIPNK2jLizGqFvvQ-1 X-Mimecast-MFC-AGG-ID: ETUviCZIPNK2jLizGqFvvQ_1742975601 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 29/37] vfio: Rename vfio_devices_all_dirty_tracking_started() Date: Wed, 26 Mar 2025 08:51:14 +0100 Message-ID: <20250326075122.1299361-30-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975941994019000 Also rename vfio_devices_all_device_dirty_tracking_started() while at it and use the prefix 'vfio_container_devices_' for routines simply looping over the container's device list. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-container-base.h | 3 ++- hw/vfio/common.c | 2 +- hw/vfio/container-base.c | 6 +++--- hw/vfio/container.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 04c87fe48bed75aa281a13f75a36e345036a9163..d00db365991aabf7fdee0c93061= 97920d9524ed8 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -89,7 +89,8 @@ void vfio_container_del_section_window(VFIOContainerBase = *bcontainer, MemoryRegionSection *section); int vfio_container_set_dirty_page_tracking(VFIOContainerBase *bcontainer, bool start, Error **errp); -bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcon= tainer); +bool vfio_container_dirty_tracking_is_started( + const VFIOContainerBase *bcontainer); bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer); int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, uint64_t size, ram_addr_t ram_addr, Error **errp= ); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 85dedcbe5933c55c6fc25015d3701aba43b381a4..fae8756ade1f85c29a8567adef8= 7135ee111baba 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -56,7 +56,7 @@ static bool vfio_log_sync_needed(const VFIOContainerBase = *bcontainer) { VFIODevice *vbasedev; =20 - if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { + if (!vfio_container_dirty_tracking_is_started(bcontainer)) { return false; } =20 diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 7f11aad339e713ea09123f361425370d87762950..7121f68464b144bc397a3bccc36= 743b65232273c 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -141,7 +141,7 @@ int vfio_container_set_dirty_page_tracking(VFIOContaine= rBase *bcontainer, return ret; } =20 -static bool vfio_devices_all_device_dirty_tracking_started( +static bool vfio_container_devices_dirty_tracking_is_started( const VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; @@ -155,10 +155,10 @@ static bool vfio_devices_all_device_dirty_tracking_st= arted( return true; } =20 -bool vfio_devices_all_dirty_tracking_started( +bool vfio_container_dirty_tracking_is_started( const VFIOContainerBase *bcontainer) { - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || + return vfio_container_devices_dirty_tracking_is_started(bcontainer) || bcontainer->dirty_pages_started; } =20 diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 7436388a73a424b11e6bad9ce80b86c3792242dd..e827ae9167b780ec9776ab98974= 245defb57590d 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -137,7 +137,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBas= e *bcontainer, int ret; Error *local_err =3D NULL; =20 - if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) { + if (iotlb && vfio_container_dirty_tracking_is_started(bcontainer)) { if (!vfio_devices_all_device_dirty_tracking(bcontainer) && bcontainer->dirty_pages_supported) { return vfio_dma_unmap_bitmap(container, iova, size, iotlb); --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975717; cv=none; d=zohomail.com; s=zohoarc; b=eHa2oaAUn1hkvb8+0OUNeFiRjqPhBvkOgrlMK+3ed5JTov0+oKmopNBD8inLkVeUMQP+gsFJvy8e+k1MQMNzfIUTW2lwZJQwDcQrKwnZN7xFHdWIjr0LoXrtTwl3tMUaEMbZ2jfjrK/PHM5TEIKgmUZSwR9B9UzDHWJAv6DQVsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975717; 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=FI4pRHO2IRIWES2ACTKwJpnmDNXgn1a3Css3QmhEIqE=; b=AOLoU8w8wNVNGP3MR7a9scIGM35eyebGM6XYzcEXdqfi1XTzNucCf+R6RPMeNBBn03RjgL4FMDf1Tc5fLcTH3Z3wUZWSpn/lFeHTzbXPBfeB0U7MlYeK3fJ9vyPAm7d5EL3LxpAbdWDScgwunvo70VwdW3XX79OBFd2jXTSVY58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1742975717243310.66698187738496; Wed, 26 Mar 2025 00:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLaP-0002PZ-Pn; Wed, 26 Mar 2025 03:54:06 -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 1txLZr-0001rZ-Sy for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:32 -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 1txLZq-0006Ms-0q for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:31 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-263-xL5nWa21PI-j2gCFfUmK2Q-1; Wed, 26 Mar 2025 03:53:25 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A11521800A37; Wed, 26 Mar 2025 07:53:24 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E461919560AB; Wed, 26 Mar 2025 07:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975609; 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=FI4pRHO2IRIWES2ACTKwJpnmDNXgn1a3Css3QmhEIqE=; b=DuG82cGoulJPGubixJJhzPhWma4npAyk/74a/eA84ciLFHhoY9CZSDYs4kOXADaJRwBh1e DdazwfLsHDHT5LOROocH38RswCgwF9DUsbiVPW5kBegH07y1kNoK0O5JeTGLMrZ97FKN8P i50hv2bQoi+oFYtoOcZqHHLkmC49LM4= X-MC-Unique: xL5nWa21PI-j2gCFfUmK2Q-1 X-Mimecast-MFC-AGG-ID: xL5nWa21PI-j2gCFfUmK2Q_1742975604 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 30/37] vfio: Rename vfio_devices_all_device_dirty_tracking() Date: Wed, 26 Mar 2025 08:51:15 +0100 Message-ID: <20250326075122.1299361-31-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975719101019000 Use the prefix 'vfio_container_devices_' to reflect the routine simply loops over the container's device list. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-container-base.h | 3 ++- hw/vfio/common.c | 4 ++-- hw/vfio/container-base.c | 5 +++-- hw/vfio/container.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index d00db365991aabf7fdee0c9306197920d9524ed8..163d9b3c30b3093d2f40bb3d3ff= c0314519ac285 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -91,7 +91,8 @@ int vfio_container_set_dirty_page_tracking(VFIOContainerB= ase *bcontainer, bool start, Error **errp); bool vfio_container_dirty_tracking_is_started( const VFIOContainerBase *bcontainer); -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer); +bool vfio_container_devices_dirty_tracking_is_supported( + const VFIOContainerBase *bcontainer); int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, uint64_t size, ram_addr_t ram_addr, Error **errp= ); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index fae8756ade1f85c29a8567adef87135ee111baba..d063ea03c1cb4f475d421e626c7= 03875fecd97a8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -936,7 +936,7 @@ static bool vfio_listener_log_global_start(MemoryListen= er *listener, listener); bool ret; =20 - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { + if (vfio_container_devices_dirty_tracking_is_supported(bcontainer)) { ret =3D vfio_devices_dma_logging_start(bcontainer, errp); } else { ret =3D vfio_container_set_dirty_page_tracking(bcontainer, true, e= rrp) =3D=3D 0; @@ -955,7 +955,7 @@ static void vfio_listener_log_global_stop(MemoryListene= r *listener) Error *local_err =3D NULL; int ret =3D 0; =20 - if (vfio_devices_all_device_dirty_tracking(bcontainer)) { + if (vfio_container_devices_dirty_tracking_is_supported(bcontainer)) { vfio_devices_dma_logging_stop(bcontainer); } else { ret =3D vfio_container_set_dirty_page_tracking(bcontainer, false, diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 7121f68464b144bc397a3bccc36743b65232273c..648dd25676e5b25a7c414109888= b2796f890deac 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -162,7 +162,8 @@ bool vfio_container_dirty_tracking_is_started( bcontainer->dirty_pages_started; } =20 -bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcont= ainer) +bool vfio_container_devices_dirty_tracking_is_supported( + const VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; =20 @@ -240,7 +241,7 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp) { bool all_device_dirty_tracking =3D - vfio_devices_all_device_dirty_tracking(bcontainer); + vfio_container_devices_dirty_tracking_is_supported(bcontainer); uint64_t dirty_pages; VFIOBitmap vbmap; int ret; diff --git a/hw/vfio/container.c b/hw/vfio/container.c index e827ae9167b780ec9776ab98974245defb57590d..9ea03ed618f6aefe35f966c644c= bbc127ce7bf06 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -138,7 +138,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBas= e *bcontainer, Error *local_err =3D NULL; =20 if (iotlb && vfio_container_dirty_tracking_is_started(bcontainer)) { - if (!vfio_devices_all_device_dirty_tracking(bcontainer) && + if (!vfio_container_devices_dirty_tracking_is_supported(bcontainer= ) && bcontainer->dirty_pages_supported) { return vfio_dma_unmap_bitmap(container, iova, size, iotlb); } --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975880; cv=none; d=zohomail.com; s=zohoarc; b=E5BpRpoqmU3bnaRiKu43uNzvI051FWZE29FcGU7hoTW6tlqljt9/FKjYtZDY6qY977EjoqjYYUHWOZfgwKWdp+VxVTtLG8bxp6qblqyZonwjyC8LEQPdJyVDBg0+84wUMErnVhV5tiKe4/m6e/TMTLRbvS8WDKEiSvEGoTS4E+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975880; 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=IO0rCTQnEBMZG4ljiZ9rnXQAhDc15ChMvFDmExCJLBw=; b=PLqTPqVv/IQhToKv9TwgA9xuXyRNvacDQ+lMrvbmxndPeuJJT1n7OhrxlzH5z1ASa/2lVeyzmfy0s4RXIjPG7kAdig7sfRy8QelDFdCU5c9rVcLzHBRzOyryzFCYdk8Lprnsl9yE7RIPLMqvskkykrjjZZzmsfP7x9+2oxlXVYM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975880564490.6023822937336; Wed, 26 Mar 2025 00:58:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLag-0002h7-NU; Wed, 26 Mar 2025 03:54: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 1txLZv-0001uT-8K for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:39 -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 1txLZt-0006NJ-Ep for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:34 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-zoIMg7ysMmScaBNlN9I7NQ-1; Wed, 26 Mar 2025 03:53:29 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 059431800361; Wed, 26 Mar 2025 07:53:28 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2A44319560AD; Wed, 26 Mar 2025 07:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975612; 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=IO0rCTQnEBMZG4ljiZ9rnXQAhDc15ChMvFDmExCJLBw=; b=cKfdipgZRy5i/Dz0mnwAX1onWxzb7wY8FnUXMpWwZnq9ZGVJ3RiO+tATeaD1VVgTYGFaNu qG/0lydT94lg3BEaZatpUYnsMnbU05JOTe/Dqs+1yuHnlwkLnzdRGrrDAsYNhJbWHD5LKC G4u1PnAius+UTw5B9xkHsSlMdRDEeFo= X-MC-Unique: zoIMg7ysMmScaBNlN9I7NQ-1 X-Mimecast-MFC-AGG-ID: zoIMg7ysMmScaBNlN9I7NQ_1742975608 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 31/37] vfio: Rename vfio_get_dirty_bitmap() Date: Wed, 26 Mar 2025 08:51:16 +0100 Message-ID: <20250326075122.1299361-32-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975882918019100 vfio_container_query_dirty_bitmap() is consistent the VFIO container routine naming scheme and is now free to use. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- include/hw/vfio/vfio-container-base.h | 4 ++-- hw/vfio/common.c | 6 +++--- hw/vfio/container-base.c | 5 +++-- hw/vfio/container.c | 2 +- hw/vfio/trace-events | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 163d9b3c30b3093d2f40bb3d3ffc0314519ac285..a441932be779e5c6740da78f005= ed2c8320e7cb2 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -93,8 +93,8 @@ bool vfio_container_dirty_tracking_is_started( const VFIOContainerBase *bcontainer); bool vfio_container_devices_dirty_tracking_is_supported( const VFIOContainerBase *bcontainer); -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, - uint64_t size, ram_addr_t ram_addr, Error **errp= ); +int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, + uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp); =20 GList *vfio_container_get_iova_ranges(const VFIOContainerBase *bcontainer); =20 diff --git a/hw/vfio/common.c b/hw/vfio/common.c index d063ea03c1cb4f475d421e626c703875fecd97a8..26ced6d4fb04b0dedf399686db4= 0acaca5d85552 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1003,7 +1003,7 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier= *n, IOMMUTLBEntry *iotlb) goto out_unlock; } =20 - ret =3D vfio_get_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1, + ret =3D vfio_container_query_dirty_bitmap(bcontainer, iova, iotlb->add= r_mask + 1, translated_addr, &local_err); if (ret) { error_prepend(&local_err, @@ -1040,7 +1040,7 @@ static int vfio_ram_discard_get_dirty_bitmap(MemoryRe= gionSection *section, * Sync the whole mapped region (spanning multiple individual mappings) * in one go. */ - ret =3D vfio_get_dirty_bitmap(vrdl->bcontainer, iova, size, ram_addr, + ret =3D vfio_container_query_dirty_bitmap(vrdl->bcontainer, iova, size= , ram_addr, &local_err); if (ret) { error_report_err(local_err); @@ -1134,7 +1134,7 @@ static int vfio_sync_dirty_bitmap(VFIOContainerBase *= bcontainer, ram_addr =3D memory_region_get_ram_addr(section->mr) + section->offset_within_region; =20 - return vfio_get_dirty_bitmap(bcontainer, + return vfio_container_query_dirty_bitmap(bcontainer, REAL_HOST_PAGE_ALIGN(section->offset_within_address_spa= ce), int128_get64(section->size), ram_addr, er= rp); } diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 648dd25676e5b25a7c414109888b2796f890deac..a2e7a3b2e747d422f7a681fb09b= 1182e119c6d20 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -237,7 +237,7 @@ static int vfio_container_devices_query_dirty_bitmap(co= nst VFIOContainerBase *bc return 0; } =20 -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t io= va, +int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer,= uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp) { bool all_device_dirty_tracking =3D @@ -275,7 +275,8 @@ int vfio_get_dirty_bitmap(const VFIOContainerBase *bcon= tainer, uint64_t iova, dirty_pages =3D cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, r= am_addr, vbmap.pages); =20 - trace_vfio_get_dirty_bitmap(iova, size, vbmap.size, ram_addr, dirty_pa= ges); + trace_vfio_container_query_dirty_bitmap(iova, size, vbmap.size, ram_ad= dr, + dirty_pages); out: g_free(vbmap.bitmap); =20 diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 9ea03ed618f6aefe35f966c644cbbc127ce7bf06..c74e08e531a501313cab27c5772= 8a8c940d975be 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -169,7 +169,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBas= e *bcontainer, } =20 if (need_dirty_sync) { - ret =3D vfio_get_dirty_bitmap(bcontainer, iova, size, + ret =3D vfio_container_query_dirty_bitmap(bcontainer, iova, size, iotlb->translated_addr, &local_err); if (ret) { error_report_err(local_err); diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index d4cd09cb0f93485fe06984346f6ac927603c5745..aa0ba695fa38f7767bf506ec604= 046101186e7d4 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -109,7 +109,7 @@ vfio_legacy_dma_unmap_overflow_workaround(void) "" vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 =20 # container-base.c -vfio_get_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t bitmap_size, = uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size=3D 0x%"PRIx6= 4" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages=3D%"PRIu64 +vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t b= itmap_size, uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size= =3D 0x%"PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages= =3D%"PRIu64 =20 # region.c vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975945; cv=none; d=zohomail.com; s=zohoarc; b=UTR8NtgtwOxRIZI5i3ARohC36ohwHu7vJd/rPp/oeyz5f+9bIqwwnZKTNXRu/Le3d0Led+r5GuQUdqjZb90qD5etDi8A1ww7UN4v+ygA4OwMcKnyxtOodzfaol1ukEsTf44Tv2bL79ySC7zjIOb2W0mlwJitqubunA1PFstxlHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975945; 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=Mudhjy9Q19VTHxL3q5i9hzfzkQjrAedGaNQJCQ2PAfM=; b=UAxVoDqA7HJXBbFz63OklMzXAiBnK1Yt15YrRztjVjjjPveCAAbss28U+K1FJoOLYUJSG3dhyYJrqPrDTxrB6Lyn0dRDPCNat1yCq/RMckBT1z6hXKxvrjP7A+M5Z+nL4QXxqL8R/spDTaV6pOlLHGdXu8csr8CX9F58l1U28uo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975945765456.1273172133667; Wed, 26 Mar 2025 00:59:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLaj-0002wH-DB; Wed, 26 Mar 2025 03:54:25 -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 1txLZz-0001yx-QL for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:44 -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 1txLZy-0006Nf-48 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:39 -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-47-Rg1GwFMdMiKL0kEpWF5yTg-1; Wed, 26 Mar 2025 03:53:32 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 232CA1956073; Wed, 26 Mar 2025 07:53:31 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6669119560AB; Wed, 26 Mar 2025 07:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975617; 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=Mudhjy9Q19VTHxL3q5i9hzfzkQjrAedGaNQJCQ2PAfM=; b=cO4bpNTGo7qcKSG19tud53q9RGgIY8wmesaNuM+igH+HnnDV3isvrYmSxJUxnDg6GNHv/P JOkF0zq0OilpoFH1tkdluiUSx2UkSz3SdsBjT9ZPEHLrlSqTV5E/fqmS5sY/FmAtTXmEt8 SKMzJAPsG+AAQd/5ijzENdBmlrbQko4= X-MC-Unique: Rg1GwFMdMiKL0kEpWF5yTg-1 X-Mimecast-MFC-AGG-ID: Rg1GwFMdMiKL0kEpWF5yTg_1742975611 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 32/37] vfio: Introduce new files for VFIO MemoryListener Date: Wed, 26 Mar 2025 08:51:17 +0100 Message-ID: <20250326075122.1299361-33-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975947854019000 File "common.c" has been emptied of most of its definitions by the previous changes and the only definitions left are related to the VFIO MemoryListener handlers. Rename it to "listener.c" and introduce its associated "vfio-listener.h" header file for the declarations. Cleanup a little the includes while at it. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- hw/vfio/vfio-listener.h | 14 ++++++++++++++ include/hw/vfio/vfio-common.h | 1 - hw/vfio/container.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/{common.c =3D> listener.c} | 0 hw/vfio/meson.build | 2 +- hw/vfio/trace-events | 2 +- 7 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 hw/vfio/vfio-listener.h rename hw/vfio/{common.c =3D> listener.c} (100%) diff --git a/hw/vfio/vfio-listener.h b/hw/vfio/vfio-listener.h new file mode 100644 index 0000000000000000000000000000000000000000..93af6747b28955f038454a335b3= 61787f8364a3a --- /dev/null +++ b/hw/vfio/vfio-listener.h @@ -0,0 +1,14 @@ +/* + * VFIO MemoryListener services + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_LISTENER_H +#define HW_VFIO_VFIO_LISTENER_H + +extern const MemoryListener vfio_memory_listener; + +#endif /* HW_VFIO_VFIO_LISTENER_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index a804af9f651f0916ca06b3f4f009381eea385ba0..4ab6e18d3c798ab379b98a0a165= 04814ec0556b1 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -131,7 +131,6 @@ VFIODevice *vfio_get_vfio_device(Object *obj); =20 typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; extern VFIODeviceList vfio_device_list; -extern const MemoryListener vfio_memory_listener; =20 #ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index, diff --git a/hw/vfio/container.c b/hw/vfio/container.c index c74e08e531a501313cab27c57728a8c940d975be..acebb53dcb1b829d31cc31d9f7f= 2cc9599f952eb 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -35,6 +35,7 @@ #include "hw/vfio/vfio-container.h" #include "vfio-helpers.h" #include "vfio-cpr.h" +#include "vfio-listener.h" =20 #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy= -vfio" =20 diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index a5bd189a86d70bd11ecb80384ac145a51979322b..7488d21215b6eee78c9c51cfb22= 7d9c8c59c4978 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -28,6 +28,7 @@ #include "vfio-iommufd.h" #include "vfio-helpers.h" #include "vfio-cpr.h" +#include "vfio-listener.h" =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" diff --git a/hw/vfio/common.c b/hw/vfio/listener.c similarity index 100% rename from hw/vfio/common.c rename to hw/vfio/listener.c diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 9c8a989db2d4578e97d864c5fd8bcba125eab66a..bccb05098ce18968caaa4d5d8de= c3df0852d0398 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -1,6 +1,6 @@ vfio_ss =3D ss.source_set() vfio_ss.add(files( - 'common.c', + 'listener.c', 'container-base.c', 'container.c', 'helpers.c', diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index aa0ba695fa38f7767bf506ec604046101186e7d4..ddb1bcc24a9cdc405713ca04d4e= cc3d4a923ec42 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -89,7 +89,7 @@ vfio_pci_igd_bdsm_enabled(const char *name, int size) "%s= %dMB" vfio_pci_igd_host_bridge_enabled(const char *name) "%s" vfio_pci_igd_lpc_bridge_enabled(const char *name) "%s" =20 -# common.c +# listener.c vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_e= nd) "iommu %s @ 0x%"PRIx64" - 0x%"PRIx64 vfio_listener_region_skip(const char *name, uint64_t start, uint64_t end) = "SKIPPING %s 0x%"PRIx64" - 0x%"PRIx64 vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to = liobn fd %d" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975908; cv=none; d=zohomail.com; s=zohoarc; b=KEKn4V01x9fdHENJnOSArbkKMGCbIlHG7cKV5A8xyK4ahvCpV97V/EVnpcUydtUHAOs5Ic0j8JGteV168jGMEbR4+ptxlWcwJ+SGgmSngsGwtFoiTLLgaIIeP5yqs/sJeVabt7Ir0GWojLBgC8Wh2gXyjR7f1hUMeDH7qQyUoh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975908; 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=AKCBMigysHIEFn31ir28kT3wTH5VWbmtOeDvCW6va6M=; b=KqMzGBUmsYao3PIjZ9iFn/7/tEmDHJWrpgYMXGZW8AanpHl9bPgenfvkTunTV8z5Z203d1ro+p0L5y+irhDhholTGxFlZl3vTUhda3uR0XHr3/iRe5G3c0Ve/itWyFAUUgpFsOfTdBjzWGciph7qROo+ActAIbWLTQK9JAdPT5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975908946963.6259073734986; Wed, 26 Mar 2025 00:58:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLak-00034q-M3; Wed, 26 Mar 2025 03:54:26 -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 1txLa1-00022p-I5 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53: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 1txLa0-0006Nv-1e for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:41 -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-604-LRh5e1DnOVKs6fLTLqelGw-1; Wed, 26 Mar 2025 03:53:36 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 D47D4196D2CF; Wed, 26 Mar 2025 07:53:34 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A15CA19560AB; Wed, 26 Mar 2025 07:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975619; 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=AKCBMigysHIEFn31ir28kT3wTH5VWbmtOeDvCW6va6M=; b=UJpTW0JfYkUXBngjXldsKBaLcgDBJcKORck1Hy/7DvFnC3yiUDAzIK6Z8BqPiZg1BMdKBJ BpY6X8UCbH6akIJPSWxFJgBtKdB1Dy376dhm/locHojWwGtdt2H+OHmTGLxLL0018+k2oF mn1TOhlW/YPcQSAiUEzdJIUoNX2Af70= X-MC-Unique: LRh5e1DnOVKs6fLTLqelGw-1 X-Mimecast-MFC-AGG-ID: LRh5e1DnOVKs6fLTLqelGw_1742975614 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 33/37] vfio: Rename RAM discard related services Date: Wed, 26 Mar 2025 08:51:18 +0100 Message-ID: <20250326075122.1299361-34-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975909676019000 Rename some routines to better reflect the namespace they belong to. Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/listener.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index 26ced6d4fb04b0dedf399686db40acaca5d85552..07c8dc6ce343510dea20c5946e6= 4a23a57c0f91b 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -243,7 +243,7 @@ static int vfio_ram_discard_notify_populate(RamDiscardL= istener *rdl, return 0; } =20 -static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontain= er, +static void vfio_ram_discard_register_listener(VFIOContainerBase *bcontai= ner, MemoryRegionSection *sectio= n) { RamDiscardManager *rdm =3D memory_region_get_ram_discard_manager(secti= on->mr); @@ -318,7 +318,7 @@ static void vfio_register_ram_discard_listener(VFIOCont= ainerBase *bcontainer, } } =20 -static void vfio_unregister_ram_discard_listener(VFIOContainerBase *bconta= iner, +static void vfio_ram_discard_unregister_listener(VFIOContainerBase *bcont= ainer, MemoryRegionSection *sect= ion) { RamDiscardManager *rdm =3D memory_region_get_ram_discard_manager(secti= on->mr); @@ -505,7 +505,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, * about changes. */ if (memory_region_has_ram_discard_manager(section->mr)) { - vfio_register_ram_discard_listener(bcontainer, section); + vfio_ram_discard_register_listener(bcontainer, section); return; } =20 @@ -628,7 +628,7 @@ static void vfio_listener_region_del(MemoryListener *li= stener, pgmask =3D (1ULL << ctz64(bcontainer->pgsizes)) - 1; try_unmap =3D !((iova & pgmask) || (int128_get64(llsize) & pgmask)= ); } else if (memory_region_has_ram_discard_manager(section->mr)) { - vfio_unregister_ram_discard_listener(bcontainer, section); + vfio_ram_discard_unregister_listener(bcontainer, section); /* Unregistering will trigger an unmap. */ try_unmap =3D false; } @@ -1025,7 +1025,7 @@ out: } } =20 -static int vfio_ram_discard_get_dirty_bitmap(MemoryRegionSection *section, +static int vfio_ram_discard_query_dirty_bitmap(MemoryRegionSection *sectio= n, void *opaque) { const hwaddr size =3D int128_get64(section->size); @@ -1072,7 +1072,7 @@ vfio_sync_ram_discard_listener_dirty_bitmap(VFIOConta= inerBase *bcontainer, * which correspond to populated parts. Replay all populated parts. */ return ram_discard_manager_replay_populated(rdm, section, - vfio_ram_discard_get_dirty_b= itmap, + vfio_ram_discard_query_dir= ty_bitmap, &vrdl); } =20 --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975975; cv=none; d=zohomail.com; s=zohoarc; b=bpu+EiQ+NE5FO546mH17kYEZWFES8r0ljPfOjK2Rx1poZz8lBx93IPH/zcBQUlXiRwNI0BQSYUoxGU0AlR7zusG+itcjcB1/O/Udvd7GFHshBYJS/SiNKOHqSro0PzThjrSEP9PJHopt/kaEm9so9vYWV4O1LZYRdyCcfjPJzho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975975; 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=lld9Q74bpn3EN/UpGvKG5u/N5iLFSTuKTDjNkrkKkR4=; b=BIkS0ARWAObITyZltklZA1cxDtrcTYa0nh4ddgMIAAQbwMJ/1FZENL52PKYx+an+dkXQAzPrdwJtbfvxu+rGR6Q4puDeTNIk3WgNG1/v7uUHxKfLjyC2AeK6NXqAgVMEh5p2frb1FYrkRyEUyjRNeYUaj93GGppkAeBdouWKCRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174297597529664.21988744684586; Wed, 26 Mar 2025 00:59:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLat-00046Y-DT; Wed, 26 Mar 2025 03:54:36 -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 1txLa8-0002BL-2P for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53: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 1txLa6-0006OP-8j for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:47 -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-540--o5PBWxcOvivVoqNOa2tWg-1; Wed, 26 Mar 2025 03:53:40 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 CCBF019560BC; Wed, 26 Mar 2025 07:53:38 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D81C19560AB; Wed, 26 Mar 2025 07:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975625; 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=lld9Q74bpn3EN/UpGvKG5u/N5iLFSTuKTDjNkrkKkR4=; b=ZzttBFvEgOSdkJRAT7q+/Xg2x5HLaPPl/qMOFW0WSxVF7YBTIAiDwelLVOuVcN46SpRy70 H2nmIaWVj0ulQY+9UVerAdCIskQB9jHGyNbUTJ4nHVwRkuNCFIIqRfmfD1L30ptS41OzDW V04zbv4VVUC6TmUa7sbmImxtIcYtlBo= X-MC-Unique: -o5PBWxcOvivVoqNOa2tWg-1 X-Mimecast-MFC-AGG-ID: -o5PBWxcOvivVoqNOa2tWg_1742975618 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 34/37] vfio: Introduce vfio_listener_un/register() routines Date: Wed, 26 Mar 2025 08:51:19 +0100 Message-ID: <20250326075122.1299361-35-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975976112019000 This hides the MemoryListener implementation and makes the code common to both IOMMU backends, legacy and IOMMUFD. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: John Levon --- hw/vfio/vfio-listener.h | 3 ++- hw/vfio/container.c | 11 +++-------- hw/vfio/iommufd.c | 9 ++------- hw/vfio/listener.c | 22 +++++++++++++++++++++- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/hw/vfio/vfio-listener.h b/hw/vfio/vfio-listener.h index 93af6747b28955f038454a335b361787f8364a3a..eb69ddd374fa20683007cfc4e9a= 7bf6fe707f27d 100644 --- a/hw/vfio/vfio-listener.h +++ b/hw/vfio/vfio-listener.h @@ -9,6 +9,7 @@ #ifndef HW_VFIO_VFIO_LISTENER_H #define HW_VFIO_VFIO_LISTENER_H =20 -extern const MemoryListener vfio_memory_listener; +bool vfio_listener_register(VFIOContainerBase *bcontainer, Error **errp); +void vfio_listener_unregister(VFIOContainerBase *bcontainer); =20 #endif /* HW_VFIO_VFIO_LISTENER_H */ diff --git a/hw/vfio/container.c b/hw/vfio/container.c index acebb53dcb1b829d31cc31d9f7f2cc9599f952eb..f086e5c802f058c01ca740de338= 538106874fb03 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -616,12 +616,7 @@ static bool vfio_connect_container(VFIOGroup *group, A= ddressSpace *as, group->container =3D container; QLIST_INSERT_HEAD(&container->group_list, group, container_next); =20 - bcontainer->listener =3D vfio_memory_listener; - memory_listener_register(&bcontainer->listener, bcontainer->space->as); - - if (bcontainer->error) { - error_propagate_prepend(errp, bcontainer->error, - "memory listener initialization failed: "); + if (!vfio_listener_register(bcontainer, errp)) { goto listener_release_exit; } =20 @@ -631,7 +626,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, listener_release_exit: QLIST_REMOVE(group, container_next); vfio_kvm_device_del_group(group); - memory_listener_unregister(&bcontainer->listener); + vfio_listener_unregister(bcontainer); if (vioc->release) { vioc->release(bcontainer); } @@ -669,7 +664,7 @@ static void vfio_disconnect_container(VFIOGroup *group) * group. */ if (QLIST_EMPTY(&container->group_list)) { - memory_listener_unregister(&bcontainer->listener); + vfio_listener_unregister(bcontainer); if (vioc->release) { vioc->release(bcontainer); } diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 7488d21215b6eee78c9c51cfb227d9c8c59c4978..e47720247d6acfd6ea0e5a2e2a2= eecabfa62dce3 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -410,7 +410,7 @@ static void iommufd_cdev_container_destroy(VFIOIOMMUFDC= ontainer *container) if (!QLIST_EMPTY(&bcontainer->device_list)) { return; } - memory_listener_unregister(&bcontainer->listener); + vfio_listener_unregister(bcontainer); iommufd_backend_free_id(container->be, container->ioas_id); object_unref(container); } @@ -562,12 +562,7 @@ static bool iommufd_cdev_attach(const char *name, VFIO= Device *vbasedev, bcontainer->pgsizes =3D qemu_real_host_page_size(); } =20 - bcontainer->listener =3D vfio_memory_listener; - memory_listener_register(&bcontainer->listener, bcontainer->space->as); - - if (bcontainer->error) { - error_propagate_prepend(errp, bcontainer->error, - "memory listener initialization failed: "); + if (!vfio_listener_register(bcontainer, errp)) { goto err_listener_register; } =20 diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index 07c8dc6ce343510dea20c5946e64a23a57c0f91b..324dc47183be82933197017f473= f67cce6d7ec56 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -46,6 +46,7 @@ #include "system/tpm.h" #include "vfio-migration-internal.h" #include "vfio-helpers.h" +#include "vfio-listener.h" =20 /* * Device state interfaces @@ -1163,7 +1164,7 @@ static void vfio_listener_log_sync(MemoryListener *li= stener, } } =20 -const MemoryListener vfio_memory_listener =3D { +static const MemoryListener vfio_memory_listener =3D { .name =3D "vfio", .region_add =3D vfio_listener_region_add, .region_del =3D vfio_listener_region_del, @@ -1171,3 +1172,22 @@ const MemoryListener vfio_memory_listener =3D { .log_global_stop =3D vfio_listener_log_global_stop, .log_sync =3D vfio_listener_log_sync, }; + +bool vfio_listener_register(VFIOContainerBase *bcontainer, Error **errp) +{ + bcontainer->listener =3D vfio_memory_listener; + memory_listener_register(&bcontainer->listener, bcontainer->space->as); + + if (bcontainer->error) { + error_propagate_prepend(errp, bcontainer->error, + "memory listener initialization failed: "); + return false; + } + + return true; +} + +void vfio_listener_unregister(VFIOContainerBase *bcontainer) +{ + memory_listener_unregister(&bcontainer->listener); +} --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975928; cv=none; d=zohomail.com; s=zohoarc; b=XS1ExxkMN5QVe3lUwNEm6xQOrKIiypDNemzlFfWEyDyuzGJmukyW7K01yYY3ESNr6B4edTVcyGToMP7ajbMnFGsmHtFGPfIAUBe88mP/BzQf1zoIfy/FE8cOy1hVmCQoMF+NOJVDZSgoMZkQaDa4JaviZJgz6B9kwaiEoh1wxZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975928; 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=Nira7vj1rB2GdhYrLlNesycOcNFMOT5PMRQNK8MKLB8=; b=KjS+Os/nsDawBSrQFyZof2isYypo8gJo5DiMIj4YfYwwSUjl9Z/Jsv3QrTPtTkw4Su4e4eSWFB7qYjHArLPgTf+f7GgbJU4wZKLrmwXTE1/eK/MOG+u9vWAWOqCOZ1gsxWGBHdBTZZZEBEEzk55+YbJvc2CPcINxS/7TzQXvJ1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975928883457.953295334569; Wed, 26 Mar 2025 00:58:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLbU-0004bM-Vb; Wed, 26 Mar 2025 03:55:14 -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 1txLaA-0002DN-RJ for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:51 -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 1txLa8-0006OY-28 for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:50 -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-682-LhiJOTuTM8Ok58tEhaB6iQ-1; Wed, 26 Mar 2025 03:53:43 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 18697190308B; Wed, 26 Mar 2025 07:53:42 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5767919560AB; Wed, 26 Mar 2025 07:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975627; 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=Nira7vj1rB2GdhYrLlNesycOcNFMOT5PMRQNK8MKLB8=; b=a8LVptngbnwUUmVHEKR82BKj7agb9iM0M+aQYvQkwXDL3j/DouLtptqqngTWXFO/ff8pow OopT9Gm+Gkos4nkvvMLL+VhKgTuB5o+ftzf42TYpIubtArXIVpOQy7cg27GrughSSlpZAW RZGUglkXJIeY9JTnBLrNhxDwwc4lRiA= X-MC-Unique: LhiJOTuTM8Ok58tEhaB6iQ-1 X-Mimecast-MFC-AGG-ID: LhiJOTuTM8Ok58tEhaB6iQ_1742975622 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 35/37] vfio: Rename vfio-common.h to vfio-device.h Date: Wed, 26 Mar 2025 08:51:20 +0100 Message-ID: <20250326075122.1299361-36-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975930996019100 "hw/vfio/vfio-common.h" has been emptied of most of its declarations by the previous changes and the only declarations left are related to VFIODevice. Rename it to "hw/vfio/vfio-device.h" and make the necessary adjustments. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/migration-multifd.h | 2 +- hw/vfio/pci.h | 2 +- include/hw/s390x/vfio-ccw.h | 2 +- include/hw/vfio/{vfio-common.h =3D> vfio-device.h} | 0 include/hw/vfio/vfio-platform.h | 2 +- backends/iommufd.c | 2 +- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio/container-base.c | 2 +- hw/vfio/container.c | 2 +- hw/vfio/cpr.c | 2 +- hw/vfio/device.c | 2 +- hw/vfio/helpers.c | 2 +- hw/vfio/iommufd.c | 2 +- hw/vfio/listener.c | 2 +- hw/vfio/migration-multifd.c | 2 +- hw/vfio/migration.c | 2 +- hw/vfio/region.c | 4 ++-- 18 files changed, 18 insertions(+), 18 deletions(-) rename include/hw/vfio/{vfio-common.h =3D> vfio-device.h} (100%) diff --git a/hw/vfio/migration-multifd.h b/hw/vfio/migration-multifd.h index a664051eb8ae03bc41cb7f9362ace840f41066ff..0bab63211d30cef04c50e50b3ea= 57840915ffc2a 100644 --- a/hw/vfio/migration-multifd.h +++ b/hw/vfio/migration-multifd.h @@ -12,7 +12,7 @@ #ifndef HW_VFIO_MIGRATION_MULTIFD_H #define HW_VFIO_MIGRATION_MULTIFD_H =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" =20 bool vfio_multifd_setup(VFIODevice *vbasedev, bool alloc_multifd, Error **= errp); void vfio_multifd_cleanup(VFIODevice *vbasedev); diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 2071b725ea5236a971964750fde81485eb8b10a9..32f3fed043643df57b89f0de3dd= f6c930e5c6dd2 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -14,7 +14,7 @@ =20 #include "exec/memory.h" #include "hw/pci/pci_device.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "qemu/event_notifier.h" #include "qemu/queue.h" #include "qemu/timer.h" diff --git a/include/hw/s390x/vfio-ccw.h b/include/hw/s390x/vfio-ccw.h index 4209d27657c1fbde44c160445396bcab3f3fd2b0..1e0922dca11e6caada08c2aae82= bd3462ace35f5 100644 --- a/include/hw/s390x/vfio-ccw.h +++ b/include/hw/s390x/vfio-ccw.h @@ -14,7 +14,7 @@ #ifndef HW_VFIO_CCW_H #define HW_VFIO_CCW_H =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/s390x/s390-ccw.h" #include "hw/s390x/ccw-device.h" #include "qom/object.h" diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-device.h similarity index 100% rename from include/hw/vfio/vfio-common.h rename to include/hw/vfio/vfio-device.h diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platfor= m.h index 3191545717da51abc41d10cd3646cd047b4a676c..256d8500b70a2e985e975b0895e= 3cfca435ed8ed 100644 --- a/include/hw/vfio/vfio-platform.h +++ b/include/hw/vfio/vfio-platform.h @@ -17,7 +17,7 @@ #define HW_VFIO_VFIO_PLATFORM_H =20 #include "hw/sysbus.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "qemu/event_notifier.h" #include "qemu/queue.h" #include "qom/object.h" diff --git a/backends/iommufd.c b/backends/iommufd.c index d57da44755be3d7fdba74f7dbecfe6d1c89921ba..9587e4d99b131e88674326a5196= cfd2079560430 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -18,7 +18,7 @@ #include "qemu/error-report.h" #include "monitor/monitor.h" #include "trace.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include #include =20 diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index c7ab4ff57ada0ed0e5a76f52b5a05c86ca4fe0b4..4fdb74e33c427595a9b0a4d28b2= b5a70df951e4e 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -15,7 +15,7 @@ #include #include #include "qapi/error.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "system/iommufd.h" #include "hw/s390x/ap-device.h" #include "qemu/error-report.h" diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index e5e0d9e3e7ed124f242b3eda345bc973e418a64c..a40169bc85e51406822247f5b3e= f6da1f7f92881 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -21,7 +21,7 @@ #include =20 #include "qapi/error.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "system/iommufd.h" #include "hw/s390x/s390-ccw.h" #include "hw/s390x/vfio-ccw.h" diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index a2e7a3b2e747d422f7a681fb09b1182e119c6d20..45870b2e6ce03a440a5c4d18e8b= 3f2ef8a55193a 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -19,7 +19,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/vfio/vfio-container-base.h" -#include "hw/vfio/vfio-common.h" /* vfio_reset_handler */ +#include "hw/vfio/vfio-device.h" /* vfio_reset_handler */ #include "system/reset.h" #include "vfio-helpers.h" =20 diff --git a/hw/vfio/container.c b/hw/vfio/container.c index f086e5c802f058c01ca740de338538106874fb03..86a1a8e4e816d3605d406d76cbb= 0663112c3976b 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -22,7 +22,7 @@ #include #include =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 696987006b853227e76caedb3c7f4e4be31cfa06..3214184f97421a17b4d981facdc= adde3a1fcec9a 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -6,7 +6,7 @@ */ =20 #include "qemu/osdep.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "migration/misc.h" #include "qapi/error.h" #include "system/runstate.h" diff --git a/hw/vfio/device.c b/hw/vfio/device.c index e122c797c206c285ef26c3a56d841d8c3be8b58b..543750c3b13b53dbd6705d08ac8= cead0ebe49ed7 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -21,7 +21,7 @@ #include "qemu/osdep.h" #include =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/vfio/pci.h" #include "hw/hw.h" #include "trace.h" diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 48bd61d5280967dffa509dcbaeeee7a1ba01335a..d0dbab1d17132743ea5f5ed0f25= 701436be11945 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -23,7 +23,7 @@ #include =20 #include "system/kvm.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/hw.h" #include "qapi/error.h" #include "vfio-helpers.h" diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index e47720247d6acfd6ea0e5a2e2a2eecabfa62dce3..48db10542269111804643713270= 199657145accc 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -15,7 +15,7 @@ #include #include =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "qemu/error-report.h" #include "trace.h" #include "qapi/error.h" diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index 324dc47183be82933197017f473f67cce6d7ec56..05ce6f45a6944226d09bf1636f4= b8e277fd8d539 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -25,7 +25,7 @@ #endif #include =20 -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/vfio/pci.h" #include "exec/address-spaces.h" #include "exec/memory.h" diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c index 1eba74beb0f207804e9c80935eacb0de19589b85..ec622bdf168d00ad625ad7ecf80= 471f3e19e19f9 100644 --- a/hw/vfio/migration-multifd.c +++ b/hw/vfio/migration-multifd.c @@ -10,7 +10,7 @@ */ =20 #include "qemu/osdep.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/vfio/vfio-migration.h" #include "migration/misc.h" #include "qapi/error.h" diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 8d69de3c80eaedf9bf4b8bc9b25f6d722ae619b2..bda514b91969156491c0cd8c5c0= d1ac47ae8c45f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -16,7 +16,7 @@ #include =20 #include "system/runstate.h" -#include "hw/vfio/vfio-common.h" +#include "hw/vfio/vfio-device.h" #include "hw/vfio/vfio-migration.h" #include "migration/misc.h" #include "migration/savevm.h" diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 9049143abffa28bed333d110d1e01d68ad7f83be..010b5241e15c2063051fd780c33= 5fef80f214dc1 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -21,8 +21,8 @@ #include "qemu/osdep.h" #include =20 -#include "hw/vfio/vfio-common.h" -#include "hw/vfio/pci.h" +#include "hw/vfio/vfio-region.h" +#include "hw/vfio/vfio-device.h" #include "hw/hw.h" #include "trace.h" #include "qapi/error.h" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975905; cv=none; d=zohomail.com; s=zohoarc; b=EX0dDS9uJYvB1XE9gHfN2cU+07aREQBWkKv3uNNUej47SE4KSGSBgbqXhZ+pj/pFqYaettbux2ysTIzVtt+cogm1ngbMyVMm83Yoxj2fsw/m2AHZuPe34z9O2iud8TWMliLiZSgF3oJD6zGN1GX75I/n3Dtix9mTiSUqoL06CFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975905; 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=tZPtlQ+b4uFq9opv48e+VyrjKTSxUXlQUAA7InJL54A=; b=TFDujHxaL+cnsbUCYibzHvLuPU3DT5coog/AyCBJwbr9zmsFoQbUjrGSk9Rvh5oME9PxHwDLmO9W5W6S1PDD07cc2J4D2lBLkYTyxQbYrKvQp1foHExfPbFvLoCGd0TSRpZZFVo7ayt4NfkIL3Y5AS7XyAHdb6j//+746u4WEYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975905022880.1652316633968; Wed, 26 Mar 2025 00:58:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLcO-00059w-2M; Wed, 26 Mar 2025 03:56:12 -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 1txLaC-0002EV-HV for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1txLa9-0006Ok-8z for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:52 -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-331-rXOZssRoOUiFKzQ8IARHMw-1; Wed, 26 Mar 2025 03:53:46 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 977081956071; Wed, 26 Mar 2025 07:53:45 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95A6019560AB; Wed, 26 Mar 2025 07:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975628; 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=tZPtlQ+b4uFq9opv48e+VyrjKTSxUXlQUAA7InJL54A=; b=Ypyp3oR37J0LZoO+t8mhIDsSPia7Bw5pTT/F1Jep3xz3amtOFKkjyLb7xCHNxF50uMPZQb 8FA5uobL1LA0fZ/zEavsHTgIoKLCP+k1LJZKYT+FN7GbtoMpzQogIVYxRVh42DihHDow3x /jCMAaic9BUxnBBfjNScR1ThykviHvE= X-MC-Unique: rXOZssRoOUiFKzQ8IARHMw-1 X-Mimecast-MFC-AGG-ID: rXOZssRoOUiFKzQ8IARHMw_1742975625 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 36/37] vfio: Rename VFIODevice related services Date: Wed, 26 Mar 2025 08:51:21 +0100 Message-ID: <20250326075122.1299361-37-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975905949019000 Rename these routines : vfio_disable_irqindex -> vfio_device_irq_disable vfio_unmask_single_irqindex -> vfio_device_irq_unmask vfio_mask_single_irqindex -> vfio_device_irq_mask vfio_set_irq_signaling -> vfio_device_irq_set_signaling vfio_attach_device -> vfio_device_attach vfio_detach_device -> vfio_device_detach vfio_get_region_info -> vfio_device_get_region_info vfio_get_dev_region_info -> vfio_device_get_region_info_type vfio_has_region_cap -> vfio_device_has_region_cap vfio_reset_handler -> vfio_device_reset_hander to better reflect the namespace they belong to. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-device.h | 20 +++++++-------- hw/vfio/ap.c | 8 +++--- hw/vfio/ccw.c | 18 ++++++------- hw/vfio/container-base.c | 6 ++--- hw/vfio/container.c | 6 ++--- hw/vfio/device.c | 28 ++++++++++---------- hw/vfio/display.c | 2 +- hw/vfio/igd.c | 8 +++--- hw/vfio/pci.c | 48 +++++++++++++++++------------------ hw/vfio/platform.c | 10 ++++---- hw/vfio/region.c | 2 +- hw/vfio/trace-events | 8 +++--- 12 files changed, 82 insertions(+), 82 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 4ab6e18d3c798ab379b98a0a16504814ec0556b1..117b497b4386405629c5c1a5ce4= 3258b50d67540 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -115,29 +115,29 @@ struct VFIODeviceOps { int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f); }; =20 -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); -bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, +void vfio_device_irq_disable(VFIODevice *vbasedev, int index); +void vfio_device_irq_unmask(VFIODevice *vbasedev, int index); +void vfio_device_irq_mask(VFIODevice *vbasedev, int index); +bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int su= bindex, int action, int fd, Error **errp); =20 -void vfio_reset_handler(void *opaque); +void vfio_device_reset_handler(void *opaque); bool vfio_device_is_mdev(VFIODevice *vbasedev); bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); -bool vfio_attach_device(char *name, VFIODevice *vbasedev, +bool vfio_device_attach(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp); -void vfio_detach_device(VFIODevice *vbasedev); +void vfio_device_detach(VFIODevice *vbasedev); VFIODevice *vfio_get_vfio_device(Object *obj); =20 typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; extern VFIODeviceList vfio_device_list; =20 #ifdef CONFIG_LINUX -int vfio_get_region_info(VFIODevice *vbasedev, int index, +int vfio_device_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info); -int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, +int vfio_device_get_region_info_type(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo); -bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe); +bool vfio_device_has_region_cap(VFIODevice *vbasedev, int region, uint16_t= cap_type); #endif =20 /* Returns 0 on success, or a negative errno. */ diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 4fdb74e33c427595a9b0a4d28b2b5a70df951e4e..9000702aed960ccb69ca67ec052= f1ebe11ee1919 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -117,7 +117,7 @@ static bool vfio_ap_register_irq_notifier(VFIOAPDevice = *vapdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vapdev); =20 - if (!vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER,= fd, + if (!vfio_device_irq_set_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_T= RIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vapdev); event_notifier_cleanup(notifier); @@ -141,7 +141,7 @@ static void vfio_ap_unregister_irq_notifier(VFIOAPDevic= e *vapdev, return; } =20 - if (!vfio_set_irq_signaling(&vapdev->vdev, irq, 0, + if (!vfio_device_irq_set_signaling(&vapdev->vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vapdev->vdev.name); } @@ -162,7 +162,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **e= rrp) return; } =20 - if (!vfio_attach_device(vbasedev->name, vbasedev, + if (!vfio_device_attach(vbasedev->name, vbasedev, &address_space_memory, errp)) { goto error; } @@ -187,7 +187,7 @@ static void vfio_ap_unrealize(DeviceState *dev) VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(dev); =20 vfio_ap_unregister_irq_notifier(vapdev, VFIO_AP_REQ_IRQ_INDEX); - vfio_detach_device(&vapdev->vdev); + vfio_device_detach(&vapdev->vdev); g_free(vapdev->vdev.name); } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index a40169bc85e51406822247f5b3ef6da1f7f92881..490871c075f8db6c8a4a706b22e= ba966d84f2945 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -426,7 +426,7 @@ static bool vfio_ccw_register_irq_notifier(VFIOCCWDevic= e *vcdev, fd =3D event_notifier_get_fd(notifier); qemu_set_fd_handler(fd, fd_read, NULL, vcdev); =20 - if (!vfio_set_irq_signaling(vdev, irq, 0, + if (!vfio_device_irq_set_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vcdev); event_notifier_cleanup(notifier); @@ -456,7 +456,7 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, return; } =20 - if (!vfio_set_irq_signaling(&vcdev->vdev, irq, 0, + if (!vfio_device_irq_set_signaling(&vcdev->vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } @@ -488,7 +488,7 @@ static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) return false; } =20 - ret =3D vfio_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX, &info= ); + ret =3D vfio_device_get_region_info(vdev, VFIO_CCW_CONFIG_REGION_INDEX= , &info); if (ret) { error_setg_errno(errp, -ret, "vfio: Error getting config info"); return false; @@ -505,7 +505,7 @@ static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) g_free(info); =20 /* check for the optional async command region */ - ret =3D vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW, + ret =3D vfio_device_get_region_info_type(vdev, VFIO_REGION_TYPE_CCW, VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD, &inf= o); if (!ret) { vcdev->async_cmd_region_size =3D info->size; @@ -518,7 +518,7 @@ static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) g_free(info); } =20 - ret =3D vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW, + ret =3D vfio_device_get_region_info_type(vdev, VFIO_REGION_TYPE_CCW, VFIO_REGION_SUBTYPE_CCW_SCHIB, &info); if (!ret) { vcdev->schib_region_size =3D info->size; @@ -531,7 +531,7 @@ static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) g_free(info); } =20 - ret =3D vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW, + ret =3D vfio_device_get_region_info_type(vdev, VFIO_REGION_TYPE_CCW, VFIO_REGION_SUBTYPE_CCW_CRW, &info); =20 if (!ret) { @@ -583,7 +583,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) goto out_unrealize; } =20 - if (!vfio_attach_device(cdev->mdevid, vbasedev, + if (!vfio_device_attach(cdev->mdevid, vbasedev, &address_space_memory, errp)) { goto out_attach_dev_err; } @@ -620,7 +620,7 @@ out_irq_notifier_err: out_io_notifier_err: vfio_ccw_put_region(vcdev); out_region_err: - vfio_detach_device(vbasedev); + vfio_device_detach(vbasedev); out_attach_dev_err: g_free(vbasedev->name); out_unrealize: @@ -639,7 +639,7 @@ static void vfio_ccw_unrealize(DeviceState *dev) vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX); vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); vfio_ccw_put_region(vcdev); - vfio_detach_device(&vcdev->vdev); + vfio_device_detach(&vcdev->vdev); g_free(vcdev->vdev.name); =20 if (cdc->unrealize) { diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 45870b2e6ce03a440a5c4d18e8b3f2ef8a55193a..85641c43684ab332ea6153f3baa= 491e911d1572b 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -19,7 +19,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/vfio/vfio-container-base.h" -#include "hw/vfio/vfio-device.h" /* vfio_reset_handler */ +#include "hw/vfio/vfio-device.h" /* vfio_device_reset_handler */ #include "system/reset.h" #include "vfio-helpers.h" =20 @@ -44,7 +44,7 @@ VFIOAddressSpace *vfio_address_space_get(AddressSpace *as) QLIST_INIT(&space->containers); =20 if (QLIST_EMPTY(&vfio_address_spaces)) { - qemu_register_reset(vfio_reset_handler, NULL); + qemu_register_reset(vfio_device_reset_handler, NULL); } =20 QLIST_INSERT_HEAD(&vfio_address_spaces, space, list); @@ -62,7 +62,7 @@ void vfio_address_space_put(VFIOAddressSpace *space) g_free(space); =20 if (QLIST_EMPTY(&vfio_address_spaces)) { - qemu_unregister_reset(vfio_reset_handler, NULL); + qemu_unregister_reset(vfio_device_reset_handler, NULL); } } =20 diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 86a1a8e4e816d3605d406d76cbb0663112c3976b..721d10b64bc0304e73870faf3db= a74f79a6fd5ad 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -865,7 +865,7 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Er= ror **errp) } =20 /* - * vfio_attach_device: attach a device to a security context + * vfio_device_attach: attach a device to a security context * @name and @vbasedev->name are likely to be different depending * on the type of the device, hence the need for passing @name */ @@ -881,7 +881,7 @@ static bool vfio_legacy_attach_device(const char *name,= VFIODevice *vbasedev, return false; } =20 - trace_vfio_attach_device(vbasedev->name, groupid); + trace_vfio_device_attach(vbasedev->name, groupid); =20 if (!vfio_device_hiod_realize(vbasedev, errp)) { return false; @@ -919,7 +919,7 @@ static void vfio_legacy_detach_device(VFIODevice *vbase= dev) QLIST_REMOVE(vbasedev, global_next); QLIST_REMOVE(vbasedev, container_next); vbasedev->bcontainer =3D NULL; - trace_vfio_detach_device(vbasedev->name, group->groupid); + trace_vfio_device_detach(vbasedev->name, group->groupid); vfio_put_base_device(vbasedev); vfio_put_group(group); } diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 543750c3b13b53dbd6705d08ac8cead0ebe49ed7..05c3446db50ff129c5d3a69b12f= 4659c2f2dd30d 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -51,11 +51,11 @@ VFIODeviceList vfio_device_list =3D * reset for the one in-use devices case, calling _multi() will do * nothing if a _one() would have been sufficient. */ -void vfio_reset_handler(void *opaque) +void vfio_device_reset_handler(void *opaque) { VFIODevice *vbasedev; =20 - trace_vfio_reset_handler(); + trace_vfio_device_reset_handler(); QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) { if (vbasedev->dev->realized) { vbasedev->ops->vfio_compute_needs_reset(vbasedev); @@ -72,7 +72,7 @@ void vfio_reset_handler(void *opaque) /* * Common VFIO interrupt disable */ -void vfio_disable_irqindex(VFIODevice *vbasedev, int index) +void vfio_device_irq_disable(VFIODevice *vbasedev, int index) { struct vfio_irq_set irq_set =3D { .argsz =3D sizeof(irq_set), @@ -85,7 +85,7 @@ void vfio_disable_irqindex(VFIODevice *vbasedev, int inde= x) ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); } =20 -void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index) +void vfio_device_irq_unmask(VFIODevice *vbasedev, int index) { struct vfio_irq_set irq_set =3D { .argsz =3D sizeof(irq_set), @@ -98,7 +98,7 @@ void vfio_unmask_single_irqindex(VFIODevice *vbasedev, in= t index) ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, &irq_set); } =20 -void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index) +void vfio_device_irq_mask(VFIODevice *vbasedev, int index) { struct vfio_irq_set irq_set =3D { .argsz =3D sizeof(irq_set), @@ -147,7 +147,7 @@ static const char *index_to_str(VFIODevice *vbasedev, i= nt index) } } =20 -bool vfio_set_irq_signaling(VFIODevice *vbasedev, int index, int subindex, +bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int su= bindex, int action, int fd, Error **errp) { ERRP_GUARD(); @@ -185,7 +185,7 @@ bool vfio_set_irq_signaling(VFIODevice *vbasedev, int i= ndex, int subindex, return false; } =20 -int vfio_get_region_info(VFIODevice *vbasedev, int index, +int vfio_device_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info) { size_t argsz =3D sizeof(struct vfio_region_info); @@ -212,7 +212,7 @@ retry: return 0; } =20 -int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, +int vfio_device_get_region_info_type(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **i= nfo) { int i; @@ -221,7 +221,7 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint= 32_t type, struct vfio_info_cap_header *hdr; struct vfio_region_info_cap_type *cap_type; =20 - if (vfio_get_region_info(vbasedev, i, info)) { + if (vfio_device_get_region_info(vbasedev, i, info)) { continue; } =20 @@ -233,7 +233,7 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint= 32_t type, =20 cap_type =3D container_of(hdr, struct vfio_region_info_cap_type, h= eader); =20 - trace_vfio_get_dev_region(vbasedev->name, i, + trace_vfio_device_get_region_info_type(vbasedev->name, i, cap_type->type, cap_type->subtype); =20 if (cap_type->type =3D=3D type && cap_type->subtype =3D=3D subtype= ) { @@ -247,12 +247,12 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, ui= nt32_t type, return -ENODEV; } =20 -bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_ty= pe) +bool vfio_device_has_region_cap(VFIODevice *vbasedev, int region, uint16_t= cap_type) { g_autofree struct vfio_region_info *info =3D NULL; bool ret =3D false; =20 - if (!vfio_get_region_info(vbasedev, region, &info)) { + if (!vfio_device_get_region_info(vbasedev, region, &info)) { if (vfio_get_region_info_cap(info, cap_type)) { ret =3D true; } @@ -367,7 +367,7 @@ VFIODevice *vfio_get_vfio_device(Object *obj) } } =20 -bool vfio_attach_device(char *name, VFIODevice *vbasedev, +bool vfio_device_attach(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp) { const VFIOIOMMUClass *ops =3D @@ -395,7 +395,7 @@ bool vfio_attach_device(char *name, VFIODevice *vbasede= v, return true; } =20 -void vfio_detach_device(VFIODevice *vbasedev) +void vfio_device_detach(VFIODevice *vbasedev) { if (!vbasedev->bcontainer) { return; diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 8317917203d5e2713fff551ff4a122befba55cc2..9eed2774edd8dc78631583a86ef= cdbfad4eff027 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -130,7 +130,7 @@ static bool vfio_display_edid_init(VFIOPCIDevice *vdev,= Error **errp) int fd =3D vdev->vbasedev.fd; int ret; =20 - ret =3D vfio_get_dev_region_info(&vdev->vbasedev, + ret =3D vfio_device_get_region_info_type(&vdev->vbasedev, VFIO_REGION_TYPE_GFX, VFIO_REGION_SUBTYPE_GFX_EDID, &dpy->edid_info); diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 265fffc2aa52d032ba619b1c3759ecebad438033..7ecbb0e672879987c9603a44b33= 80519b84bdc0e 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -200,7 +200,7 @@ static bool vfio_pci_igd_setup_opregion(VFIOPCIDevice *= vdev, Error **errp) return false; } =20 - ret =3D vfio_get_dev_region_info(&vdev->vbasedev, + ret =3D vfio_device_get_region_info_type(&vdev->vbasedev, VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL, VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, &opregion); if (ret) { @@ -385,7 +385,7 @@ static bool vfio_pci_igd_setup_lpc_bridge(VFIOPCIDevice= *vdev, Error **errp) * Check whether we have all the vfio device specific regions to * support LPC quirk (added in Linux v4.6). */ - ret =3D vfio_get_dev_region_info(&vdev->vbasedev, + ret =3D vfio_device_get_region_info_type(&vdev->vbasedev, VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_I= NTEL, VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG, &lpc); if (ret) { @@ -393,7 +393,7 @@ static bool vfio_pci_igd_setup_lpc_bridge(VFIOPCIDevice= *vdev, Error **errp) return false; } =20 - ret =3D vfio_get_dev_region_info(&vdev->vbasedev, + ret =3D vfio_device_get_region_info_type(&vdev->vbasedev, VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_I= NTEL, VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG, &host); if (ret) { @@ -542,7 +542,7 @@ static bool vfio_pci_igd_config_quirk(VFIOPCIDevice *vd= ev, Error **errp) * there's no ROM, there's no point in setting up this quirk. * NB. We only seem to get BIOS ROMs, so UEFI VM would need CSM su= pport. */ - ret =3D vfio_get_region_info(&vdev->vbasedev, + ret =3D vfio_device_get_region_info(&vdev->vbasedev, VFIO_PCI_ROM_REGION_INDEX, &rom); if ((ret || !rom->size) && !vdev->pdev.romfile) { error_setg(&err, "Device has no ROM"); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8a18a5e3646f35f2a36ac73e791198d96d21fbb7..a787931d0c76284f105154398cc= 682ae61314e7d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -116,7 +116,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) =20 vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); - vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_unmask(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); } =20 static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) @@ -132,7 +132,7 @@ static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) =20 /* Get to a known interrupt state */ qemu_set_fd_handler(irq_fd, NULL, NULL, vdev); - vfio_mask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_mask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); =20 @@ -150,7 +150,7 @@ static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) goto fail_irqfd; } =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_= INDEX, 0, VFIO_IRQ_SET_ACTION_UNMASK, event_notifier_get_fd(&vdev->intx.unmask), errp)) { @@ -158,7 +158,7 @@ static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, E= rror **errp) } =20 /* Let'em rip */ - vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); =20 vdev->intx.kvm_accel =3D true; =20 @@ -173,7 +173,7 @@ fail_irqfd: event_notifier_cleanup(&vdev->intx.unmask); fail: qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev); - vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); return false; #else return true; @@ -191,7 +191,7 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) * Get to a known state, hardware masked, QEMU ready to accept new * interrupts, QEMU IRQ de-asserted. */ - vfio_mask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_mask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); =20 @@ -211,7 +211,7 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev) vdev->intx.kvm_accel =3D false; =20 /* If we've missed an event, let it re-fire through QEMU */ - vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); =20 trace_vfio_intx_disable_kvm(vdev->vbasedev.name); #endif @@ -300,7 +300,7 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error= **errp) fd =3D event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, = 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_= INDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); event_notifier_cleanup(&vdev->intx.interrupt); @@ -323,7 +323,7 @@ static void vfio_intx_disable(VFIOPCIDevice *vdev) =20 timer_del(vdev->intx.mmap_timer); vfio_intx_disable_kvm(vdev); - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); + vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX); vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); vfio_mmap_set_enabled(vdev, true); @@ -579,7 +579,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, =20 if (!vdev->defer_kvm_irq_routing) { if (vdev->msix->noresize && resizing) { - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX= ); + vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX); ret =3D vfio_enable_vectors(vdev, true); if (ret) { error_report("vfio: failed to enable vectors, %d", ret); @@ -594,7 +594,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, fd =3D event_notifier_get_fd(&vector->interrupt); } =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX, nr, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { @@ -639,7 +639,7 @@ static void vfio_msix_vector_release(PCIDevice *pdev, u= nsigned int nr) int32_t fd =3D event_notifier_get_fd(&vector->interrupt); Error *err =3D NULL; =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_= IRQ_INDEX, nr, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); @@ -836,7 +836,7 @@ static void vfio_msix_disable(VFIOPCIDevice *vdev) * Always clear MSI-X IRQ index. A PF device could have enabled * MSI-X with no vectors. See vfio_msix_enable(). */ - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); + vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX); =20 vfio_msi_disable_common(vdev); if (!vfio_intx_enable(vdev, &err)) { @@ -853,7 +853,7 @@ static void vfio_msi_disable(VFIOPCIDevice *vdev) { Error *err =3D NULL; =20 - vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSI_IRQ_INDEX); + vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSI_IRQ_INDEX); vfio_msi_disable_common(vdev); vfio_intx_enable(vdev, &err); if (err) { @@ -887,7 +887,7 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev) off_t off =3D 0; ssize_t bytes; =20 - if (vfio_get_region_info(&vdev->vbasedev, + if (vfio_device_get_region_info(&vdev->vbasedev, VFIO_PCI_ROM_REGION_INDEX, ®_info)) { error_report("vfio: Error getting ROM info: %m"); return; @@ -1381,7 +1381,7 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice = *vdev) * If the host driver allows mapping of a MSIX data, we are going to * do map the entire BAR and emulate MSIX table on top of that. */ - if (vfio_has_region_cap(&vdev->vbasedev, region->nr, + if (vfio_device_has_region_cap(&vdev->vbasedev, region->nr, VFIO_REGION_INFO_CAP_MSIX_MAPPABLE)) { return; } @@ -2675,7 +2675,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) g_autofree struct vfio_region_info *reg_info =3D NULL; int ret; =20 - ret =3D vfio_get_region_info(vbasedev, VFIO_PCI_VGA_REGION_INDEX, ®= _info); + ret =3D vfio_device_get_region_info(vbasedev, VFIO_PCI_VGA_REGION_INDE= X, ®_info); if (ret) { error_setg_errno(errp, -ret, "failed getting region info for VGA region index = %d", @@ -2773,7 +2773,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) QLIST_INIT(&vdev->bars[i].quirks); } =20 - ret =3D vfio_get_region_info(vbasedev, + ret =3D vfio_device_get_region_info(vbasedev, VFIO_PCI_CONFIG_REGION_INDEX, ®_info); if (ret) { error_setg_errno(errp, -ret, "failed to get config info"); @@ -2818,7 +2818,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) =20 static void vfio_pci_put_device(VFIOPCIDevice *vdev) { - vfio_detach_device(&vdev->vbasedev); + vfio_device_detach(&vdev->vbasedev); =20 g_free(vdev->vbasedev.name); g_free(vdev->msix); @@ -2870,7 +2870,7 @@ static void vfio_register_err_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->err_notifier); qemu_set_fd_handler(fd, vfio_err_notifier_handler, NULL, vdev); =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_I= NDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); @@ -2887,7 +2887,7 @@ static void vfio_unregister_err_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_I= NDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } @@ -2935,7 +2935,7 @@ static void vfio_register_req_notifier(VFIOPCIDevice = *vdev) fd =3D event_notifier_get_fd(&vdev->req_notifier); qemu_set_fd_handler(fd, vfio_req_notifier_handler, NULL, vdev); =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_I= NDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); qemu_set_fd_handler(fd, NULL, NULL, vdev); @@ -2953,7 +2953,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) return; } =20 - if (!vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, + if (!vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_I= NDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } @@ -3017,7 +3017,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) name =3D g_strdup(vbasedev->name); } =20 - if (!vfio_attach_device(name, vbasedev, + if (!vfio_device_attach(name, vbasedev, pci_device_iommu_address_space(pdev), errp)) { goto error; } diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 83b53d57149a343a00eb6d6f78c1cbea004dbaa2..4217e870063593a5be840047adf= 2870e9b2b89e4 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -119,7 +119,7 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp, =20 qemu_set_fd_handler(fd, (IOHandler *)handler, NULL, intp); =20 - if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + if (!vfio_device_irq_set_signaling(vbasedev, intp->pin, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); qemu_set_fd_handler(fd, NULL, NULL, NULL); @@ -301,7 +301,7 @@ static void vfio_platform_eoi(VFIODevice *vbasedev) =20 if (vfio_irq_is_automasked(intp)) { /* unmasks the physical level-sensitive IRQ */ - vfio_unmask_single_irqindex(vbasedev, intp->pin); + vfio_device_irq_unmask(vbasedev, intp->pin); } =20 /* a single IRQ can be active at a time */ @@ -357,7 +357,7 @@ static int vfio_set_resample_eventfd(VFIOINTp *intp) Error *err =3D NULL; =20 qemu_set_fd_handler(fd, NULL, NULL, NULL); - if (!vfio_set_irq_signaling(vbasedev, intp->pin, 0, + if (!vfio_device_irq_set_signaling(vbasedev, intp->pin, 0, VFIO_IRQ_SET_ACTION_UNMASK, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); return -EINVAL; @@ -547,7 +547,7 @@ static bool vfio_base_device_init(VFIODevice *vbasedev,= Error **errp) return false; } =20 - if (!vfio_attach_device(vbasedev->name, vbasedev, + if (!vfio_device_attach(vbasedev->name, vbasedev, &address_space_memory, errp)) { return false; } @@ -556,7 +556,7 @@ static bool vfio_base_device_init(VFIODevice *vbasedev,= Error **errp) return true; } =20 - vfio_detach_device(vbasedev); + vfio_device_detach(vbasedev); return false; } =20 diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 010b5241e15c2063051fd780c335fef80f214dc1..04bf9eb0987c0ac460e0a1c3ba5= abdf4a87f7499 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -185,7 +185,7 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasedev= , VFIORegion *region, g_autofree struct vfio_region_info *info =3D NULL; int ret; =20 - ret =3D vfio_get_region_info(vbasedev, index, &info); + ret =3D vfio_device_get_region_info(vbasedev, index, &info); if (ret) { return ret; } diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index ddb1bcc24a9cdc405713ca04d4ecc3d4a923ec42..8843560576935232a68a31d43e0= 0be520e0284be 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -37,8 +37,6 @@ vfio_pci_hot_reset_dep_devices(int domain, int bus, int s= lot, int function, int vfio_pci_hot_reset_result(const char *name, const char *result) "%s hot re= set: %s" vfio_populate_device_config(const char *name, unsigned long size, unsigned= long offset, unsigned long flags) "Device '%s' config: size: 0x%lx, offset= : 0x%lx, flags: 0x%lx" vfio_populate_device_get_irq_info_failure(const char *errstr) "VFIO_DEVICE= _GET_IRQ_INFO failure: %s" -vfio_attach_device(const char *name, int group_id) " (%s) group %d" -vfio_detach_device(const char *name, int group_id) " (%s) group %d" vfio_mdev(const char *name, bool is_mdev) " (%s) is_mdev %d" vfio_add_ext_cap_dropped(const char *name, uint16_t cap, uint16_t offset) = "%s 0x%x@0x%x" vfio_pci_reset(const char *name) " (%s)" @@ -196,5 +194,7 @@ iommufd_cdev_device_info(char *name, int devfd, int num= _irqs, int num_regions, i iommufd_cdev_pci_hot_reset_dep_devices(int domain, int bus, int slot, int = function, int dev_id) "\t%04x:%02x:%02x.%x devid %d" =20 # device.c -vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%08x" -vfio_reset_handler(void) "" +vfio_device_get_region_info_type(const char *name, int index, uint32_t typ= e, uint32_t subtype) "%s index %d, %08x/%08x" +vfio_device_reset_handler(void) "" +vfio_device_attach(const char *name, int group_id) " (%s) group %d" +vfio_device_detach(const char *name, int group_id) " (%s) group %d" --=20 2.49.0 From nobody Wed Apr 2 13:30:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1742975969; cv=none; d=zohomail.com; s=zohoarc; b=K1Ya1C6dQ84fsummumIUa4WJp96YWK5XwY0renIoSigIQa3s85Cqc5/3nOcPqjuBXj+d0aFgcI8sWia9nv0/UtdTCNxmOlQC8I5YLwBW1YeNZkzEGMIkQ9Ggi8Qbxa+hhflPMuCn4PB30UiUqPlbn1EbA1pA5+oPQT9gD+2L6OQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742975969; 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=Ym1v2fZBJ3CnZ1RPTd7he/nfGwa6xkIP+hhwDrCcC3g=; b=OouZZj9wb7MTMINlWXJESO6BK1LS99hfd5w3MS1C8HpKydHWppnK30M7mzzynUxLWUt0hBIfktI6w1puOMul52buQP3BnrEB2U4zrmJlSfxB6iGe6LOJ6/RSiTaDC4sRQCDTLoqbs4sIXx/1iyTtB7rySVCYz7v1ZZqWYxUMo+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1742975969499513.5997562656943; Wed, 26 Mar 2025 00:59:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1txLd0-00067V-6M; Wed, 26 Mar 2025 03:56: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 1txLaI-0002NU-AC for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:54: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 1txLaG-0006PM-4F for qemu-devel@nongnu.org; Wed, 26 Mar 2025 03:53:58 -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-445-nNHF_B_JOniGwDAIaBBFzQ-1; Wed, 26 Mar 2025 03:53:49 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 D28A0196D2CF; Wed, 26 Mar 2025 07:53:48 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.226.180]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 209C519560AB; Wed, 26 Mar 2025 07:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742975635; 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=Ym1v2fZBJ3CnZ1RPTd7he/nfGwa6xkIP+hhwDrCcC3g=; b=HKDq8DSva4QgQYknabaw3dRhXtEWyebO+z0aUhnyG05jza098kFJmFC2smZFslmK+dfJKO JBLeDabhxm+agR6j02XgmFQqwnZ/SBkgWX6yZQc8nHKe/vxb/+f8ppToy7AIwMV6USEJzD pHni5rkAa84bZ2AF/L0F/9W3B11LSqU= X-MC-Unique: nNHF_B_JOniGwDAIaBBFzQ-1 X-Mimecast-MFC-AGG-ID: nNHF_B_JOniGwDAIaBBFzQ_1742975628 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org, Alex Williamson Cc: Avihai Horon , Eric Auger , Zhenzhong Duan , John Levon , Joao Martins , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-10.1 v2 37/37] vfio: Rename VFIOContainer related services Date: Wed, 26 Mar 2025 08:51:22 +0100 Message-ID: <20250326075122.1299361-38-clg@redhat.com> In-Reply-To: <20250326075122.1299361-1-clg@redhat.com> References: <20250326075122.1299361-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.40 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1742975970155019000 Rename these routines : vfio_put_group -> vfio_group_put vfio_get_group -> vfio_group_get vfio_kvm_device_del_group -> vfio_group_del_kvm_device vfio_kvm_device_add_group -> vfio_group_add_kvm_device vfio_get_device -> vfio_device_get vfio_put_base_device -> vfio_device_put vfio_device_groupid -> vfio_device_get_groupid vfio_connect_container -> vfio_container_connect vfio_disconnect_container -> vfio_container_disconnect to better reflect the namespace they belong to. Reviewed-by: John Levon Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-30-clg@redha= t.com Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Zhenzhong Duan --- hw/vfio/container.c | 52 ++++++++++++++++++++++---------------------- hw/vfio/trace-events | 12 +++++----- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 721d10b64bc0304e73870faf3dba74f79a6fd5ad..23a337347007752556b7088295b= d783ec3a412fa 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -306,7 +306,7 @@ static bool vfio_get_info_iova_range(struct vfio_iommu_= type1_info *info, return true; } =20 -static void vfio_kvm_device_add_group(VFIOGroup *group) +static void vfio_group_add_kvm_device(VFIOGroup *group) { Error *err =3D NULL; =20 @@ -315,7 +315,7 @@ static void vfio_kvm_device_add_group(VFIOGroup *group) } } =20 -static void vfio_kvm_device_del_group(VFIOGroup *group) +static void vfio_group_del_kvm_device(VFIOGroup *group) { Error *err =3D NULL; =20 @@ -511,7 +511,7 @@ static bool vfio_legacy_setup(VFIOContainerBase *bconta= iner, Error **errp) return true; } =20 -static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as, +static bool vfio_container_connect(VFIOGroup *group, AddressSpace *as, Error **errp) { VFIOContainer *container; @@ -569,7 +569,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, } group->container =3D container; QLIST_INSERT_HEAD(&container->group_list, group, container_nex= t); - vfio_kvm_device_add_group(group); + vfio_group_add_kvm_device(group); return true; } } @@ -609,7 +609,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, goto enable_discards_exit; } =20 - vfio_kvm_device_add_group(group); + vfio_group_add_kvm_device(group); =20 vfio_address_space_insert(space, bcontainer); =20 @@ -625,7 +625,7 @@ static bool vfio_connect_container(VFIOGroup *group, Ad= dressSpace *as, return true; listener_release_exit: QLIST_REMOVE(group, container_next); - vfio_kvm_device_del_group(group); + vfio_group_del_kvm_device(group); vfio_listener_unregister(bcontainer); if (vioc->release) { vioc->release(bcontainer); @@ -649,7 +649,7 @@ put_space_exit: return false; } =20 -static void vfio_disconnect_container(VFIOGroup *group) +static void vfio_container_disconnect(VFIOGroup *group) { VFIOContainer *container =3D group->container; VFIOContainerBase *bcontainer =3D &container->bcontainer; @@ -678,7 +678,7 @@ static void vfio_disconnect_container(VFIOGroup *group) if (QLIST_EMPTY(&container->group_list)) { VFIOAddressSpace *space =3D bcontainer->space; =20 - trace_vfio_disconnect_container(container->fd); + trace_vfio_container_disconnect(container->fd); vfio_cpr_unregister_container(bcontainer); close(container->fd); object_unref(container); @@ -687,7 +687,7 @@ static void vfio_disconnect_container(VFIOGroup *group) } } =20 -static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **er= rp) +static VFIOGroup *vfio_group_get(int groupid, AddressSpace *as, Error **er= rp) { ERRP_GUARD(); VFIOGroup *group; @@ -731,7 +731,7 @@ static VFIOGroup *vfio_get_group(int groupid, AddressSp= ace *as, Error **errp) group->groupid =3D groupid; QLIST_INIT(&group->device_list); =20 - if (!vfio_connect_container(group, as, errp)) { + if (!vfio_container_connect(group, as, errp)) { error_prepend(errp, "failed to setup container for group %d: ", groupid); goto close_fd_exit; @@ -750,7 +750,7 @@ free_group_exit: return NULL; } =20 -static void vfio_put_group(VFIOGroup *group) +static void vfio_group_put(VFIOGroup *group) { if (!group || !QLIST_EMPTY(&group->device_list)) { return; @@ -759,15 +759,15 @@ static void vfio_put_group(VFIOGroup *group) if (!group->ram_block_discard_allowed) { vfio_ram_block_discard_disable(group->container, false); } - vfio_kvm_device_del_group(group); - vfio_disconnect_container(group); + vfio_group_del_kvm_device(group); + vfio_container_disconnect(group); QLIST_REMOVE(group, next); - trace_vfio_put_group(group->fd); + trace_vfio_group_put(group->fd); close(group->fd); g_free(group); } =20 -static bool vfio_get_device(VFIOGroup *group, const char *name, +static bool vfio_device_get(VFIOGroup *group, const char *name, VFIODevice *vbasedev, Error **errp) { g_autofree struct vfio_device_info *info =3D NULL; @@ -819,25 +819,25 @@ static bool vfio_get_device(VFIOGroup *group, const c= har *name, vbasedev->num_regions =3D info->num_regions; vbasedev->flags =3D info->flags; =20 - trace_vfio_get_device(name, info->flags, info->num_regions, info->num_= irqs); + trace_vfio_device_get(name, info->flags, info->num_regions, info->num_= irqs); =20 vbasedev->reset_works =3D !!(info->flags & VFIO_DEVICE_FLAGS_RESET); =20 return true; } =20 -static void vfio_put_base_device(VFIODevice *vbasedev) +static void vfio_device_put(VFIODevice *vbasedev) { if (!vbasedev->group) { return; } QLIST_REMOVE(vbasedev, next); vbasedev->group =3D NULL; - trace_vfio_put_base_device(vbasedev->fd); + trace_vfio_device_put(vbasedev->fd); close(vbasedev->fd); } =20 -static int vfio_device_groupid(VFIODevice *vbasedev, Error **errp) +static int vfio_device_get_groupid(VFIODevice *vbasedev, Error **errp) { char *tmp, group_path[PATH_MAX]; g_autofree char *group_name =3D NULL; @@ -872,7 +872,7 @@ static int vfio_device_groupid(VFIODevice *vbasedev, Er= ror **errp) static bool vfio_legacy_attach_device(const char *name, VFIODevice *vbased= ev, AddressSpace *as, Error **errp) { - int groupid =3D vfio_device_groupid(vbasedev, errp); + int groupid =3D vfio_device_get_groupid(vbasedev, errp); VFIODevice *vbasedev_iter; VFIOGroup *group; VFIOContainerBase *bcontainer; @@ -887,7 +887,7 @@ static bool vfio_legacy_attach_device(const char *name,= VFIODevice *vbasedev, return false; } =20 - group =3D vfio_get_group(groupid, as, errp); + group =3D vfio_group_get(groupid, as, errp); if (!group) { return false; } @@ -895,12 +895,12 @@ static bool vfio_legacy_attach_device(const char *nam= e, VFIODevice *vbasedev, QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (strcmp(vbasedev_iter->name, vbasedev->name) =3D=3D 0) { error_setg(errp, "device is already attached"); - vfio_put_group(group); + vfio_group_put(group); return false; } } - if (!vfio_get_device(group, name, vbasedev, errp)) { - vfio_put_group(group); + if (!vfio_device_get(group, name, vbasedev, errp)) { + vfio_group_put(group); return false; } =20 @@ -920,8 +920,8 @@ static void vfio_legacy_detach_device(VFIODevice *vbase= dev) QLIST_REMOVE(vbasedev, container_next); vbasedev->bcontainer =3D NULL; trace_vfio_device_detach(vbasedev->name, group->groupid); - vfio_put_base_device(vbasedev); - vfio_put_group(group); + vfio_device_put(vbasedev); + vfio_group_put(group); } =20 static int vfio_legacy_pci_hot_reset(VFIODevice *vbasedev, bool single) diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 8843560576935232a68a31d43e00be520e0284be..e90ec9bff8d5fa51afde7b55fb7= 36a8d51fef1b0 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -99,16 +99,18 @@ vfio_listener_region_add_no_dma_map(const char *name, u= int64_t iova, uint64_t si vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRI= x64" - 0x%"PRIx64 vfio_device_dirty_tracking_update(uint64_t start, uint64_t end, uint64_t m= in, uint64_t max) "section 0x%"PRIx64" - 0x%"PRIx64" -> update [0x%"PRIx64"= - 0x%"PRIx64"]" vfio_device_dirty_tracking_start(int nr_ranges, uint64_t min32, uint64_t m= ax32, uint64_t min64, uint64_t max64, uint64_t minpci, uint64_t maxpci) "nr= _ranges %d 32:[0x%"PRIx64" - 0x%"PRIx64"], 64:[0x%"PRIx64" - 0x%"PRIx64"], = pci64:[0x%"PRIx64" - 0x%"PRIx64"]" -vfio_disconnect_container(int fd) "close container->fd=3D%d" -vfio_put_group(int fd) "close group->fd=3D%d" -vfio_get_device(const char * name, unsigned int flags, unsigned int num_re= gions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" -vfio_put_base_device(int fd) "close vdev->fd=3D%d" -vfio_legacy_dma_unmap_overflow_workaround(void) "" vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 =20 # container-base.c vfio_container_query_dirty_bitmap(uint64_t iova, uint64_t size, uint64_t b= itmap_size, uint64_t start, uint64_t dirty_pages) "iova=3D0x%"PRIx64" size= =3D 0x%"PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64" dirty_pages= =3D%"PRIu64 =20 +# container.c +vfio_container_disconnect(int fd) "close container->fd=3D%d" +vfio_group_put(int fd) "close group->fd=3D%d" +vfio_device_get(const char * name, unsigned int flags, unsigned int num_re= gions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u" +vfio_device_put(int fd) "close vdev->fd=3D%d" +vfio_legacy_dma_unmap_overflow_workaround(void) "" + # region.c vfio_region_write(const char *name, int index, uint64_t addr, uint64_t dat= a, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint= 64_t data) " (%s:region%d+0x%"PRIx64", %d) =3D 0x%"PRIx64 --=20 2.49.0