From nobody Mon Feb 9 07:55:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1589402532; cv=none; d=zohomail.com; s=zohoarc; b=PGWlfBkievkSgfWBKaIPYZOTDrAZ3gL6SZFyF2E4CdTt5w6a1HJgFwShHpY0kNzQqyPa9bTPtwoBLVAiY401LkAHgDf2XKPkvP27Tu1pXxRGnTPRCwRgAyNk4ltqru4RAkuGA2bStqLH1+8RJKLtxdALbTDmMRGURrAYy3+K8W8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589402532; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uVBua6PfRlOu5xrjJ3GYKVz9O8f2lW6+Lw2fqrCfW6U=; b=RbWxhYAihEvZaUMC0AIoI2qcHQ1DDAZhcsvV1tFlXnkdLRDRmIGTC6LUpxx2KT/BEVtn9hjJw9VOdqIMbhyJzpoM+XhfUJTu4mmr0FRTO/So1hPCRZ+B5j247ZR/b73YECvtJmUE3O0sYPftrwxxiwZT/dQeeasdORGMmNPVtVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589402532487547.4445278860434; Wed, 13 May 2020 13:42:12 -0700 (PDT) Received: from localhost ([::1]:55654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYyCh-00063q-8J for importer@patchew.org; Wed, 13 May 2020 16:42:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYy9K-0008Hi-CD for qemu-devel@nongnu.org; Wed, 13 May 2020 16:38:42 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:11773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYy9J-00070w-5A for qemu-devel@nongnu.org; Wed, 13 May 2020 16:38:42 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 13 May 2020 13:37:25 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 13 May 2020 13:38:39 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 13 May 2020 20:38:39 +0000 Received: from kwankhede-dev.nvidia.com (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 13 May 2020 20:38:33 +0000 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 13 May 2020 13:38:39 -0700 From: Kirti Wankhede To: , Subject: [PATCH Kernel v19 7/8] vfio iommu: Add migration capability to report supported features Date: Thu, 14 May 2020 01:34:38 +0530 Message-ID: <1589400279-28522-8-git-send-email-kwankhede@nvidia.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1589400279-28522-1-git-send-email-kwankhede@nvidia.com> References: <1589400279-28522-1-git-send-email-kwankhede@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1589402245; bh=uVBua6PfRlOu5xrjJ3GYKVz9O8f2lW6+Lw2fqrCfW6U=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=jaQ9JMFDYakW9Pm6GuX0y2ZZ+kQH4yYrvT8sGe33V6F3/+kGGyk1b11tcZAi9TIfQ GIjsxaeOVxGtImtow5Jf2EDypMQwY45i0DtjaXKrwi2Cl30YZ2PCdsfGiiqSv28gwt BuMnjIEzI8X4kxUSJzbislwACDrcg0fp+DZQ/x4wwkppVmGL/rZ+gCdDB9vDlHf8Df 7MLsECXFX2ku7Kc9HApT2+H5TCaJSzGTWsRCyZcVHAiP4pCxfqCdrwu4/Wl7n/9u1T qE+K9BDOqcwGLfUudMi+oQBpp7l43JznPrcYFOmVOsDkUmwC+zfuKnjxqFS0Hf4PLg w/91hzU7qOGOg== 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=216.228.121.64; envelope-from=kwankhede@nvidia.com; helo=hqnvemgate25.nvidia.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/13 16:26:46 X-ACL-Warn: Detected OS = Windows 7 or 8 [fuzzy] X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.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_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhengxiao.zx@Alibaba-inc.com, kevin.tian@intel.com, yi.l.liu@intel.com, yan.y.zhao@intel.com, kvm@vger.kernel.org, eskultet@redhat.com, ziye.yang@intel.com, qemu-devel@nongnu.org, cohuck@redhat.com, shuangtai.tst@alibaba-inc.com, dgilbert@redhat.com, zhi.a.wang@intel.com, mlevitsk@redhat.com, pasic@linux.ibm.com, aik@ozlabs.ru, Kirti Wankhede , eauger@redhat.com, felipe@nutanix.com, jonathan.davies@nutanix.com, changpeng.liu@intel.com, Ken.Xue@amd.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added migration capability in IOMMU info chain. User application should check IOMMU info chain for migration capability to use dirty page tracking feature provided by kernel module. User application must check page sizes supported and maximum dirty bitmap size returned by this capability structure for ioctls used to get dirty bitmap. Signed-off-by: Kirti Wankhede --- drivers/vfio/vfio_iommu_type1.c | 24 +++++++++++++++++++++++- include/uapi/linux/vfio.h | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 4358be26ff80..77351497a9c2 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2389,6 +2389,22 @@ static int vfio_iommu_iova_build_caps(struct vfio_io= mmu *iommu, return ret; } =20 +static int vfio_iommu_migration_build_caps(struct vfio_iommu *iommu, + struct vfio_info_cap *caps) +{ + struct vfio_iommu_type1_info_cap_migration cap_mig; + + cap_mig.header.id =3D VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION; + cap_mig.header.version =3D 1; + cap_mig.flags =3D VFIO_IOMMU_INFO_CAPS_MIGRATION_DIRTY_PAGE_TRACK; + + /* support minimum pgsize */ + cap_mig.pgsize_bitmap =3D (size_t)1 << __ffs(iommu->pgsize_bitmap); + cap_mig.max_dirty_bitmap_size =3D DIRTY_BITMAP_SIZE_MAX; + + return vfio_info_add_capability(caps, &cap_mig.header, sizeof(cap_mig)); +} + static long vfio_iommu_type1_ioctl(void *iommu_data, unsigned int cmd, unsigned long arg) { @@ -2433,10 +2449,16 @@ static long vfio_iommu_type1_ioctl(void *iommu_data, mutex_lock(&iommu->lock); info.flags =3D VFIO_IOMMU_INFO_PGSIZES; =20 + vfio_pgsize_bitmap(iommu); info.iova_pgsizes =3D iommu->pgsize_bitmap; =20 - ret =3D vfio_iommu_iova_build_caps(iommu, &caps); + ret =3D vfio_iommu_migration_build_caps(iommu, &caps); + + if (!ret) + ret =3D vfio_iommu_iova_build_caps(iommu, &caps); + mutex_unlock(&iommu->lock); + if (ret) return ret; =20 diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index e3cbf8b78623..c90604322798 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -1013,6 +1013,27 @@ struct vfio_iommu_type1_info_cap_iova_range { struct vfio_iova_range iova_ranges[]; }; =20 +/* + * The migration capability allows to report supported features for migrat= ion. + * + * The structures below define version 1 of this capability. + * + * pgsize_bitmap: Kernel driver returns supported page sizes bitmap for di= rty + * page tracking. + * max_dirty_bitmap_size: Kernel driver returns maximum supported dirty bi= tmap + * size in bytes to be used by user application for ioctls to get dirty bi= tmap. + */ +#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 1 + +struct vfio_iommu_type1_info_cap_migration { + struct vfio_info_cap_header header; + __u32 flags; + /* supports dirty page tracking */ +#define VFIO_IOMMU_INFO_CAPS_MIGRATION_DIRTY_PAGE_TRACK (1 << 0) + __u64 pgsize_bitmap; + __u64 max_dirty_bitmap_size; /* in bytes */ +}; + #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) =20 /** --=20 2.7.0