From nobody Thu Sep 19 01:13:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1721428204; cv=none; d=zohomail.com; s=zohoarc; b=Gx/onfo6HtaXUjK5qf6Mo/3Pp6PFKxPwr7V8jZI9FtnvTzUtD5uA502bSDHcWhY9HClgGmQ5pQ+fxdGf5YeIWDLP9o5gs2+IxoHnksGJMJzObu0qdsepNd5T7cwGA3VYuOJ2tx9Lj7R4axvnLuFM5q5M5Xi+/+gYTLMK2RqcwKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721428204; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Y/WlHq74swFTeW5SEntl+tpnI+j131zUsPVk97tyYKs=; b=ivmYmrYuDVN8fV9uwiP7EmUaGtvQG3ExVXjcfZGq1wDPj+EOW6itclCUWkRQwoIjvpcs8hcu6pEDdIQl16pLrwkokmpATQ1TxgV3HHcanfu19qAAcD0Gd8WVGn71tkuTAVu1vNkU/d8l4swr8SDdUbZ/gJ025+nNTQt/hZs1pOM= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721428204533436.8624363907637; Fri, 19 Jul 2024 15:30:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUw69-0003n1-Ad; Fri, 19 Jul 2024 18:29: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 1sUw68-0003mX-2i for qemu-devel@nongnu.org; Fri, 19 Jul 2024 18:29:08 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sUw65-0005L6-QO for qemu-devel@nongnu.org; Fri, 19 Jul 2024 18:29:07 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46JMQqBL014761; Fri, 19 Jul 2024 22:29:02 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40g0wy8048-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Jul 2024 22:29:01 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46JLL0E7021786; Fri, 19 Jul 2024 22:20:03 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40dwewegm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Jul 2024 22:20:03 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 46JMK3IF036443; Fri, 19 Jul 2024 22:20:03 GMT Received: from joaomart-mac.nl.oracle.com (dhcp-10-175-14-236.vpn.oracle.com [10.175.14.236]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 40dweweghg-1; Fri, 19 Jul 2024 22:20:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=Y /WlHq74swFTeW5SEntl+tpnI+j131zUsPVk97tyYKs=; b=gbtiIg7I7Z7VwtzQS AB+U3kcd/N/lmjRXKbx3P+n9aue7pj5iAlUz4c+KE1mJ7xOpptknmL2M0Z2MREsK wwGK9YVz0g/StHQtToaJDf5BfCkDDyQMr49uptR0mV96RQUJnANUbK7QuNfC8/wV 9ENBVmgXrtGbTISf/XikzArfZtbiDxZUlymgiVBEkmyGMjtgHetxSeap8xfK/CT5 xDjur50pxUHjVSj0A17oOku2rraQVxFhti45bMzUGnRB6aUYcuDS3sC7vVLolabb kIyx2aubG9NGVWpsMKpB2QethhuEENkbcWo46bxhZgTo1am2nl0jeSvyexSWV9EN +i3Ew== From: Joao Martins To: qemu-devel@nongnu.org Cc: Yi Liu , Eric Auger , Zhenzhong Duan , Alex Williamson , Cedric Le Goater , Jason Gunthorpe , Avihai Horon , Joao Martins Subject: [PATCH v5.1 12/13] vfio/migration: Don't block migration device dirty tracking is unsupported Date: Fri, 19 Jul 2024 23:19:46 +0100 Message-Id: <20240719221946.97794-1-joao.m.martins@oracle.com> In-Reply-To: <20240719120501.81279-1-joao.m.martins@oracle.com> References: <20240719120501.81279-1-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-19_08,2024-07-18_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407190165 X-Proofpoint-ORIG-GUID: lsDZ5O5gs0Y7MhJDWR_omS_tNV7-yExK X-Proofpoint-GUID: lsDZ5O5gs0Y7MhJDWR_omS_tNV7-yExK 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=205.220.177.32; envelope-from=joao.m.martins@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @oracle.com) X-ZM-MESSAGEID: 1721428206294116600 Content-Type: text/plain; charset="utf-8" By default VFIO migration is set to auto, which will support live migration if the migration capability is set *and* also dirty page tracking is supported. For testing purposes one can force enable without dirty page tracking via enable-migration=3Don, but that option is generally left for testing purposes. So starting with IOMMU dirty tracking it can use to accomodate the lack of VF dirty page tracking allowing us to minimize the VF requirements for migration and thus enabling migration by default for those too. While at it change the error messages to mention IOMMU dirty tracking as well. Signed-off-by: Joao Martins --- Same patch as v5, but fixes builds that have CONFIG_IOMMUFD=3Dn Sending just this one as it doesn't justify sending the whole series again. --- hw/vfio/iommufd.c | 2 +- hw/vfio/migration.c | 11 ++++++----- include/hw/vfio/vfio-common.h | 8 ++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 7dd5d43ce06a..a998e8578552 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -111,7 +111,7 @@ static void iommufd_cdev_unbind_and_disconnect(VFIODevi= ce *vbasedev) iommufd_backend_disconnect(vbasedev->iommufd); } =20 -static bool iommufd_hwpt_dirty_tracking(VFIOIOASHwpt *hwpt) +bool iommufd_hwpt_dirty_tracking(VFIOIOASHwpt *hwpt) { return hwpt && hwpt->hwpt_flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING; } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 34d4be2ce1b1..63ffa46c9652 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -1036,16 +1036,17 @@ bool vfio_migration_realize(VFIODevice *vbasedev, E= rror **errp) return !vfio_block_migration(vbasedev, err, errp); } =20 - if (!vbasedev->dirty_pages_supported) { + if (!vbasedev->dirty_pages_supported && + !iommufd_hwpt_dirty_tracking(vbasedev->hwpt)) { if (vbasedev->enable_migration =3D=3D ON_OFF_AUTO_AUTO) { error_setg(&err, - "%s: VFIO device doesn't support device dirty track= ing", - vbasedev->name); + "%s: VFIO device doesn't support device and " + "IOMMU dirty tracking", vbasedev->name); goto add_blocker; } =20 - warn_report("%s: VFIO device doesn't support device dirty tracking= ", - vbasedev->name); + warn_report("%s: VFIO device doesn't support device and " + "IOMMU dirty tracking", vbasedev->name); } =20 ret =3D vfio_block_multiple_devices_migration(vbasedev, errp); diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 7e530c7869dc..333cabbf4362 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -299,6 +299,14 @@ int vfio_devices_query_dirty_bitmap(const VFIOContaine= rBase *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= ); +#ifdef CONFIG_IOMMUFD +bool iommufd_hwpt_dirty_tracking(VFIOIOASHwpt *hwpt); +#else +static inline bool iommufd_hwpt_dirty_tracking(VFIOIOASHwpt *hwpt) +{ + return false; +} +#endif =20 /* Returns 0 on success, or a negative errno. */ bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); --=20 2.39.3