From nobody Fri Nov 14 22:18:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1759982658; cv=none; d=zohomail.com; s=zohoarc; b=nPpLlMe20JdgfxOBHiklF4eVW/FIa8gTbTmAdvRnNfWbVfxZxJe2oG2KYZ8wTIHRbn43Y0nFpkyha1qQhCDphbaef6mpPNTwpavWS9H1IZ4tINA+nWVazV+jJfdDiiBBEx8D9uK67Er3hHsWBm1QTmyqBHwFjHSo3XDfJ54zxf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759982658; 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=/LbnznsnmxYQYUfdSXhX7lsm9hvMxQzfkEIx50PM+UA=; b=LHMg7yDdWgqyirV+rd7SP9jLGkxy0OUVoY2B3i3Hj/FYLzKVJ3RTt4rqnnG5a3iEWg8KzuLyUzhsxDMnYbBPMfSl29QuwQOKvS5kw+46GicVMsalRbTfHSxybD5gCZzFoykle0qwZ27xWrmBSkqjQxfaqnanVi9fnZeEjtVQO98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759982658860223.6672013618596; Wed, 8 Oct 2025 21:04:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6hrQ-0005o2-Cu; Thu, 09 Oct 2025 00:02: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 1v6hrN-0005nX-NY for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:34 -0400 Received: from mgamail.intel.com ([198.175.65.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v6hrA-0002at-6W for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:29 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:15 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759982540; x=1791518540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=evj+FWN+i7qsqXS7v2uC/zwnpEBYRbN8B5CyZzFZPpE=; b=Of3iehMqD8yZE5aC4YlpeB2I8ZY9f+57I6CfikbzQYjMxfbnJqZN3Mv5 4J6DKAbis3AEZpoJIkTumhPJ31/JTFdFp0tkooJnvW/xIBtX592bo78Xu nEbaYY61YcevtOPGJxlBdx4eQMUku9QcrqrhIh/w67AwsFcoSbxVcbqHi VpOCYp57ZVE8l5qmCnQ8xWn7iKf7HtnJ4t8dw8NFh7eqnyFmSwHUNmn+Z hGfgFEVUBm7pm+efvHpA+fagwiut312KgudfQw1NwL/do7tsQs21wF2zn q9bUHfhga3s/EzbXZyInHwGsX6kPqe5AQ0syZz+G7S3WNTcifTCz43tHB w==; X-CSE-ConnectionGUID: PttsmK2iSXKJbj6ZhKy9Yw== X-CSE-MsgGUID: 6lRjydUhRz+xQ4Ic7oGa/g== X-IronPort-AV: E=McAfee;i="6800,10657,11576"; a="84804130" X-IronPort-AV: E=Sophos;i="6.19,215,1754982000"; d="scan'208";a="84804130" X-CSE-ConnectionGUID: SmsCK5cBRrWfAIDz6N2tuw== X-CSE-MsgGUID: v4yxI6IcSP6snJtCvpi+2g== X-ExtLoop1: 1 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, levon@movementarian.org, Zhenzhong Duan Subject: [PATCH v2 1/3] vfio/container: Support unmap all in one ioctl() Date: Thu, 9 Oct 2025 00:01:32 -0400 Message-ID: <20251009040134.334251-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20251009040134.334251-1-zhenzhong.duan@intel.com> References: <20251009040134.334251-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=198.175.65.9; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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 @intel.com) X-ZM-MESSAGEID: 1759982660666154100 Content-Type: text/plain; charset="utf-8" VFIO type1 kernel uAPI supports unmapping whole address space in one call since commit c19650995374 ("vfio/type1: implement unmap all"). Use the unmap_all variant whenever it's supported in kernel. Opportunistically pass VFIOLegacyContainer pointer in low level function vfio_legacy_dma_unmap_one(). Co-developed-by: John Levon Signed-off-by: John Levon Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-container-legacy.h | 1 + hw/vfio/container-legacy.c | 38 ++++++++++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/hw/vfio/vfio-container-legacy.h b/include/hw/vfio/vfio= -container-legacy.h index 74a72df018..ffd594e80d 100644 --- a/include/hw/vfio/vfio-container-legacy.h +++ b/include/hw/vfio/vfio-container-legacy.h @@ -30,6 +30,7 @@ struct VFIOLegacyContainer { =20 int fd; /* /dev/vfio/vfio, empowered by the attached groups */ unsigned iommu_type; + bool unmap_all_supported; QLIST_HEAD(, VFIOGroup) group_list; VFIOContainerCPR cpr; }; diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c index a3615d7b5d..8e9639603e 100644 --- a/hw/vfio/container-legacy.c +++ b/hw/vfio/container-legacy.c @@ -121,14 +121,14 @@ unmap_exit: return ret; } =20 -static int vfio_legacy_dma_unmap_one(const VFIOContainer *bcontainer, +static int vfio_legacy_dma_unmap_one(const VFIOLegacyContainer *container, hwaddr iova, uint64_t size, - IOMMUTLBEntry *iotlb) + uint32_t flags, IOMMUTLBEntry *iotlb) { - const VFIOLegacyContainer *container =3D VFIO_IOMMU_LEGACY(bcontainer); + const VFIOContainer *bcontainer =3D VFIO_IOMMU(container); struct vfio_iommu_type1_dma_unmap unmap =3D { .argsz =3D sizeof(unmap), - .flags =3D 0, + .flags =3D flags, .iova =3D iova, .size =3D size, }; @@ -170,25 +170,28 @@ static int vfio_legacy_dma_unmap(const VFIOContainer = *bcontainer, hwaddr iova, uint64_t size, IOMMUTLBEntry *iotlb, bool unmap_all) { + const VFIOLegacyContainer *container =3D VFIO_IOMMU_LEGACY(bcontainer); + uint32_t flags =3D 0; int ret; =20 if (unmap_all) { - /* The unmap ioctl doesn't accept a full 64-bit span. */ - Int128 llsize =3D int128_rshift(int128_2_64(), 1); - - ret =3D vfio_legacy_dma_unmap_one(bcontainer, 0, int128_get64(llsi= ze), - iotlb); + if (container->unmap_all_supported) { + flags =3D VFIO_DMA_UNMAP_FLAG_ALL; + } else { + /* The unmap ioctl doesn't accept a full 64-bit span. */ + Int128 llsize =3D int128_rshift(int128_2_64(), 1); + size =3D int128_get64(llsize); + + ret =3D vfio_legacy_dma_unmap_one(container, 0, size, flags, i= otlb); + if (ret) { + return ret; + } =20 - if (ret =3D=3D 0) { - ret =3D vfio_legacy_dma_unmap_one(bcontainer, int128_get64(lls= ize), - int128_get64(llsize), iotlb); + iova =3D size; } - - } else { - ret =3D vfio_legacy_dma_unmap_one(bcontainer, iova, size, iotlb); } =20 - return ret; + return vfio_legacy_dma_unmap_one(container, iova, size, flags, iotlb); } =20 static int vfio_legacy_dma_map(const VFIOContainer *bcontainer, hwaddr iov= a, @@ -519,6 +522,9 @@ static bool vfio_legacy_setup(VFIOContainer *bcontainer= , Error **errp) =20 vfio_get_info_iova_range(info, bcontainer); =20 + ret =3D ioctl(container->fd, VFIO_CHECK_EXTENSION, VFIO_UNMAP_ALL); + container->unmap_all_supported =3D !!ret; + vfio_get_iommu_info_migration(container, info); return true; } --=20 2.47.1 From nobody Fri Nov 14 22:18:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1759982652; cv=none; d=zohomail.com; s=zohoarc; b=UaxhUfgvco88MBLfViqXBzhikeHSKYKi6bplaclRQIyAvtozuZTrtAU8Krf1vztTxX637lbOMxqcc9k2MHN/YSgVLe11nhjbi4uoBCOAa4L5l8kUKlSj2mDifRzQdVyTADkefsnmhMKDWK5pA0Jm7NyAWIWf220gld4ybtYYfQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759982652; 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=qextd0yJob/GXwLBENv/FWabWI3i7wsKvy0BjufbGYs=; b=HHTgbX3y187p6I9IdF3ivrq/sf+le6cS1ne/vOSOw9BRQcRREa+C5mDvgs5+n6DgZKQ+HTzmFtjOXmMqewiq6BSRmqlg9YURy5chP3zh045XGpfgj60kwzrt4ECrCA62m2Ou+76UOK9jY/XTxe2g5rWBGF2xIEam09RtK4zJmL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759982652644638.471085104176; Wed, 8 Oct 2025 21:04:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6hrR-0005oL-CN; Thu, 09 Oct 2025 00:02:37 -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 1v6hrN-0005nY-O9 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:34 -0400 Received: from mgamail.intel.com ([198.175.65.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v6hrD-0002b2-7c for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:27 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:16 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:15 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759982543; x=1791518543; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bCM8JqnsTf0uHErOG5tcVjKaa7+Cl/EZ1hBjD9sT9ks=; b=ccqYM7+AoInKZIxebHgkRPb5/i4TbLCElxTUkvJF2LbmlAIn0yMbfIVZ oY2sM3v4/cuxQ2zKSHVPNy0T2G1N44Pw9mT3amEuqf134BAnG5OIvRqtx kHnjolhBYj3R8NN5iBE7gQTw1C0B/TS+b+LgY11XnIZTqBjmWUC7Rs50X wvVcITdzUZlCGVfHyh3SEcSaDT3hTd7aWlxB/vc3muUhfCo1WGDwPwHjv F8w6tSYL3lyzqtf+FihTGH7Ti1P1mitwSzwEKvIb/f3SxNk2N92RrxmYP i+XQ/yw57s0LjA0N6TmWZQ/T0ElkYknLdMgzPXVu+F+d5298NMfCM4IoH Q==; X-CSE-ConnectionGUID: WabdLdWvQnWiiRDEcbXVRw== X-CSE-MsgGUID: POaZ8RMrR/+U5mwTRFNlUg== X-IronPort-AV: E=McAfee;i="6800,10657,11576"; a="84804135" X-IronPort-AV: E=Sophos;i="6.19,215,1754982000"; d="scan'208";a="84804135" X-CSE-ConnectionGUID: NTDe3AgXTLy1/i4THWbCyQ== X-CSE-MsgGUID: /nXASSMWSNqLMlCvYYJGcw== X-ExtLoop1: 1 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, levon@movementarian.org, Zhenzhong Duan Subject: [PATCH v2 2/3] vfio/iommufd: Support unmap all in one ioctl() Date: Thu, 9 Oct 2025 00:01:33 -0400 Message-ID: <20251009040134.334251-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20251009040134.334251-1-zhenzhong.duan@intel.com> References: <20251009040134.334251-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=198.175.65.9; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1759982655147154100 Content-Type: text/plain; charset="utf-8" IOMMUFD kernel uAPI supports unmapping whole address space in one call with [iova, size] set to [0, UINT64_MAX], this can simplify iommufd_cdev_unmap() a bit. See iommufd_ioas_unmap() in kernel for details. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/iommufd.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 68470d552e..336f8fdb04 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -62,21 +62,8 @@ static int iommufd_cdev_unmap(const VFIOContainer *bcont= ainer, { const VFIOIOMMUFDContainer *container =3D VFIO_IOMMU_IOMMUFD(bcontaine= r); =20 - /* unmap in halves */ if (unmap_all) { - Int128 llsize =3D int128_rshift(int128_2_64(), 1); - int ret; - - ret =3D iommufd_backend_unmap_dma(container->be, container->ioas_i= d, - 0, int128_get64(llsize)); - - if (ret =3D=3D 0) { - ret =3D iommufd_backend_unmap_dma(container->be, container->io= as_id, - int128_get64(llsize), - int128_get64(llsize)); - } - - return ret; + size =3D UINT64_MAX; } =20 /* TODO: Handle dma_unmap_bitmap with iotlb args (migration) */ --=20 2.47.1 From nobody Fri Nov 14 22:18:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1759982651; cv=none; d=zohomail.com; s=zohoarc; b=KQc1TIfMTikUbi/AvBb/BgDTiytptlB3UnTxh6isP+5ZpyKioJwSoePYbl+wV2gz3u3qkYHMC44172WUjRvOx+cT+3GQMRvkY5qYWFeRJqlAGaaH1nMXEW9sYAiFphcc+iSzgCntNyO6PLTmYzaxhapjTVZaHY4cdTdVNwi/qH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759982651; 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=t9gqbSYcx7p4UVBTTYF+Rr26wrVOLg95jJwNm9ZVjpM=; b=FvVdrL6rilfIFOHNy12CD97UlDGTsTooczHszavvKont4G4ZsJMuKs6WDVce/AILGAi6ISMG7y57LTg9l7IzajxJWc2Z+isJT6mVYnBITGSpeLVuVxDf6IN/pHasZzj2OIRCl/vQc4o2umdjGYqABNRIOW0GpPAURbOTeeN2TZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759982651662313.22833138890246; Wed, 8 Oct 2025 21:04:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6hrV-0005pB-7O; Thu, 09 Oct 2025 00:02:41 -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 1v6hrR-0005on-Lw for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:37 -0400 Received: from mgamail.intel.com ([198.175.65.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v6hrO-0002b2-N6 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 00:02:37 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:19 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2025 21:02:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1759982554; x=1791518554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TzkxlI9egdrmunNPSgwi9HKMSBaqWR2wtWxaRxMmwsQ=; b=lj+dZJLKFGujPLWHPcidORvbT88abCeaLw9Vb+m0/bHOry6mO704jODf sl7WVBE8GT7lxPlJt4qdtnPEnedG/MWretwr1aN8xeS7ip2Zn3sj3UZ/V hXGLbXjGUUo9fNkHgKCzb8ZQ749JnpLDby/86kJQn+jXxmrl/Pt87yb8q 12BXvOS+/FaNZLMmdXHjCHF95f1621wdIccTn44CVWgLwm6kYGg2VzoU1 N8B+RLhkNLKfheWF+npuRV5lpFHX9bLR+iGp/4PtM1eaafHditZEMcDDl X4PcPhKnF0rx//nbPXrsS/84HjeSqKATDNt/6UgXGYlawE+oQ4Jsn5zrq w==; X-CSE-ConnectionGUID: 3rAKCaFtSNOattLRp4LMhw== X-CSE-MsgGUID: 2oUCAbUdSS++Znx9HfK3sw== X-IronPort-AV: E=McAfee;i="6800,10657,11576"; a="84804140" X-IronPort-AV: E=Sophos;i="6.19,215,1754982000"; d="scan'208";a="84804140" X-CSE-ConnectionGUID: REoNhCpSTrejJvw8ppHTlA== X-CSE-MsgGUID: ZZggSNDkRDGI8QpW0HPtaQ== X-ExtLoop1: 1 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, levon@movementarian.org, Zhenzhong Duan Subject: [PATCH v2 3/3] vfio/listener: Add an assertion for unmap_all Date: Thu, 9 Oct 2025 00:01:34 -0400 Message-ID: <20251009040134.334251-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20251009040134.334251-1-zhenzhong.duan@intel.com> References: <20251009040134.334251-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=198.175.65.9; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -47 X-Spam_score: -4.8 X-Spam_bar: ---- X-Spam_report: (-4.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1759982655038154100 Currently the maximum of iommu address space is 64bit. So when a maximum iommu memory section is deleted, it's in scope [0, 2^64). Add a assertion for that. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/listener.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index c6bb58f520..62766d8c46 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -715,6 +715,7 @@ static void vfio_listener_region_del(MemoryListener *li= stener, bool unmap_all =3D false; =20 if (int128_eq(llsize, int128_2_64())) { + assert(!iova); unmap_all =3D true; llsize =3D int128_zero(); } --=20 2.47.1