All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH Kernel v18 0/7] KABIs to support migration for VFIO devices
@ 2020-05-04 15:58 ` Kirti Wankhede
  0 siblings, 0 replies; 39+ messages in thread
From: Kirti Wankhede @ 2020-05-04 15:58 UTC (permalink / raw)
  To: alex.williamson, cjia
  Cc: kevin.tian, ziye.yang, changpeng.liu, yi.l.liu, mlevitsk,
	eskultet, cohuck, dgilbert, jonathan.davies, eauger, aik, pasic,
	felipe, Zhengxiao.zx, shuangtai.tst, Ken.Xue, zhi.a.wang,
	yan.y.zhao, qemu-devel, kvm, Kirti Wankhede

Hi,

This patch set adds:
* IOCTL VFIO_IOMMU_DIRTY_PAGES to get dirty pages bitmap with
  respect to IOMMU container rather than per device. All pages pinned by
  vendor driver through vfio_pin_pages external API has to be marked as
  dirty during  migration. When IOMMU capable device is present in the
  container and all pages are pinned and mapped, then all pages are marked
  dirty.
  When there are CPU writes, CPU dirty page tracking can identify dirtied
  pages, but any page pinned by vendor driver can also be written by
  device. As of now there is no device which has hardware support for
  dirty page tracking. So all pages which are pinned should be considered
  as dirty.
  This ioctl is also used to start/stop dirty pages tracking for pinned and
  unpinned pages while migration is active.

* Updated IOCTL VFIO_IOMMU_UNMAP_DMA to get dirty pages bitmap before
  unmapping IO virtual address range.
  With vIOMMU, during pre-copy phase of migration, while CPUs are still
  running, IO virtual address unmap can happen while device still keeping
  reference of guest pfns. Those pages should be reported as dirty before
  unmap, so that VFIO user space application can copy content of those
  pages from source to destination.

* Patch 7 detect if IOMMU capable device driver is smart to report pages
  to be marked dirty by pinning pages using vfio_pin_pages() API.


Yet TODO:
Since there is no device which has hardware support for system memmory
dirty bitmap tracking, right now there is no other API from vendor driver
to VFIO IOMMU module to report dirty pages. In future, when such hardware
support will be implemented, an API will be required such that vendor
driver could report dirty pages to VFIO module during migration phases.

Adding revision history from previous QEMU patch set to understand KABI
changes done till now

v17 -> v18
- Add migration capability to the capability chain for VFIO_IOMMU_GET_INFO
  ioctl
- Updated UMAP_DMA ioctl to return bitmap of multiple vfio_dma

v16 -> v17
- Fixed errors reported by kbuild test robot <lkp@intel.com> on i386

v15 -> v16
- Minor edits and nit picks (Auger Eric)
- On copying bitmap to user, re-populated bitmap only for pinned pages,
  excluding unmapped pages and CPU dirtied pages.
- Patches are on tag: next-20200318 and 1-3 patches from Yan's series
  https://lkml.org/lkml/2020/3/12/1255

v14 -> v15
- Minor edits and nit picks.
- In the verification of user allocated bitmap memory, added check of
   maximum size.
- Patches are on tag: next-20200318 and 1-3 patches from Yan's series
  https://lkml.org/lkml/2020/3/12/1255

v13 -> v14
- Added struct vfio_bitmap to kabi. updated structure
  vfio_iommu_type1_dirty_bitmap_get and vfio_iommu_type1_dma_unmap.
- All small changes suggested by Alex.
- Patches are on tag: next-20200318 and 1-3 patches from Yan's series
  https://lkml.org/lkml/2020/3/12/1255

v12 -> v13
- Changed bitmap allocation in vfio_iommu_type1 to per vfio_dma
- Changed VFIO_IOMMU_DIRTY_PAGES ioctl behaviour to be per vfio_dma range.
- Changed vfio_iommu_type1_dirty_bitmap structure to have separate data
  field.

v11 -> v12
- Changed bitmap allocation in vfio_iommu_type1.
- Remove atomicity of ref_count.
- Updated comments for migration device state structure about error
  reporting.
- Nit picks from v11 reviews

v10 -> v11
- Fix pin pages API to free vpfn if it is marked as unpinned tracking page.
- Added proposal to detect if IOMMU capable device calls external pin pages
  API to mark pages dirty.
- Nit picks from v10 reviews

v9 -> v10:
- Updated existing VFIO_IOMMU_UNMAP_DMA ioctl to get dirty pages bitmap
  during unmap while migration is active
- Added flag in VFIO_IOMMU_GET_INFO to indicate driver support dirty page
  tracking.
- If iommu_mapped, mark all pages dirty.
- Added unpinned pages tracking while migration is active.
- Updated comments for migration device state structure with bit
  combination table and state transition details.

v8 -> v9:
- Split patch set in 2 sets, Kernel and QEMU.
- Dirty pages bitmap is queried from IOMMU container rather than from
  vendor driver for per device. Added 2 ioctls to achieve this.

v7 -> v8:
- Updated comments for KABI
- Added BAR address validation check during PCI device's config space load
  as suggested by Dr. David Alan Gilbert.
- Changed vfio_migration_set_state() to set or clear device state flags.
- Some nit fixes.

v6 -> v7:
- Fix build failures.

v5 -> v6:
- Fix build failure.

v4 -> v5:
- Added decriptive comment about the sequence of access of members of
  structure vfio_device_migration_info to be followed based on Alex's
  suggestion
- Updated get dirty pages sequence.
- As per Cornelia Huck's suggestion, added callbacks to VFIODeviceOps to
  get_object, save_config and load_config.
- Fixed multiple nit picks.
- Tested live migration with multiple vfio device assigned to a VM.

v3 -> v4:
- Added one more bit for _RESUMING flag to be set explicitly.
- data_offset field is read-only for user space application.
- data_size is read for every iteration before reading data from migration,
  that is removed assumption that data will be till end of migration
  region.
- If vendor driver supports mappable sparsed region, map those region
  during setup state of save/load, similarly unmap those from cleanup
  routines.
- Handles race condition that causes data corruption in migration region
  during save device state by adding mutex and serialiaing save_buffer and
  get_dirty_pages routines.
- Skip called get_dirty_pages routine for mapped MMIO region of device.
- Added trace events.
- Split into multiple functional patches.

v2 -> v3:
- Removed enum of VFIO device states. Defined VFIO device state with 2
  bits.
- Re-structured vfio_device_migration_info to keep it minimal and defined
  action on read and write access on its members.

v1 -> v2:
- Defined MIGRATION region type and sub-type which should be used with
  region type capability.
- Re-structured vfio_device_migration_info. This structure will be placed
  at 0th offset of migration region.
- Replaced ioctl with read/write for trapped part of migration region.
- Added both type of access support, trapped or mmapped, for data section
  of the region.
- Moved PCI device functions to pci file.
- Added iteration to get dirty page bitmap until bitmap for all requested
  pages are copied.

Thanks,
Kirti




Kirti Wankhede (7):
  vfio: UAPI for migration interface for device state
  vfio iommu: Remove atomicity of ref_count of pinned pages
  vfio iommu: Add ioctl definition for dirty pages tracking.
  vfio iommu: Implementation of ioctl for dirty pages tracking.
  vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap
  vfio iommu: Add migration capability to report supported features
  vfio: Selective dirty page tracking if IOMMU backed device pins pages

 drivers/vfio/vfio.c             |  13 +-
 drivers/vfio/vfio_iommu_type1.c | 464 ++++++++++++++++++++++++++++++++++++++--
 include/linux/vfio.h            |   4 +-
 include/uapi/linux/vfio.h       | 308 ++++++++++++++++++++++++++
 4 files changed, 770 insertions(+), 19 deletions(-)

-- 
2.7.0


^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: [PATCH Kernel v18 5/7] vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap
@ 2020-05-05 18:49 kbuild test robot
  0 siblings, 0 replies; 39+ messages in thread
From: kbuild test robot @ 2020-05-05 18:49 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 15398 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <1588607939-26441-6-git-send-email-kwankhede@nvidia.com>
References: <1588607939-26441-6-git-send-email-kwankhede@nvidia.com>
TO: Kirti Wankhede <kwankhede@nvidia.com>
TO: alex.williamson(a)redhat.com
TO: cjia(a)nvidia.com
CC: kevin.tian(a)intel.com
CC: ziye.yang(a)intel.com
CC: changpeng.liu(a)intel.com
CC: yi.l.liu(a)intel.com
CC: mlevitsk(a)redhat.com
CC: eskultet(a)redhat.com
CC: cohuck(a)redhat.com
CC: dgilbert(a)redhat.com
CC: jonathan.davies(a)nutanix.com

Hi Kirti,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v5.7-rc4]
[also build test WARNING on next-20200505]
[cannot apply to vfio/next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kirti-Wankhede/KABIs-to-support-migration-for-VFIO-devices/20200505-084649
base:    0e698dfa282211e414076f9dc7e83c1c288314fd
reproduce:
        # apt-get install sparse
        # sparse version: 
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

   drivers/vfio/vfio_iommu_type1.c:1087:58: sparse: warning: incorrect type in argument 5 (different address spaces)
>> drivers/vfio/vfio_iommu_type1.c:1087:58: sparse:    expected unsigned long long [noderef] [usertype] <asn:1> *bitmap
>> drivers/vfio/vfio_iommu_type1.c:1087:58: sparse:    got unsigned long long [usertype] *

# https://github.com/0day-ci/linux/commit/5935872fe363ec9158528a84142d4f3c93da8383
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 5935872fe363ec9158528a84142d4f3c93da8383
vim +1087 drivers/vfio/vfio_iommu_type1.c

352e6a6499fe9c Kirti Wankhede  2020-05-04   984  
73fa0d10d077d9 Alex Williamson 2012-07-31   985  static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
5935872fe363ec Kirti Wankhede  2020-05-04   986  			     struct vfio_iommu_type1_dma_unmap *unmap,
5935872fe363ec Kirti Wankhede  2020-05-04   987  			     struct vfio_bitmap *bitmap)
73fa0d10d077d9 Alex Williamson 2012-07-31   988  {
73fa0d10d077d9 Alex Williamson 2012-07-31   989  	uint64_t mask;
c086de818dd81c Kirti Wankhede  2016-11-17   990  	struct vfio_dma *dma, *dma_last = NULL;
1ef3e2bc04223f Alex Williamson 2014-02-26   991  	size_t unmapped = 0;
c086de818dd81c Kirti Wankhede  2016-11-17   992  	int ret = 0, retries = 0;
5935872fe363ec Kirti Wankhede  2020-05-04   993  	unsigned long *final_bitmap = NULL, *temp_bitmap = NULL;
73fa0d10d077d9 Alex Williamson 2012-07-31   994  
1ef3e2bc04223f Alex Williamson 2014-02-26   995  	mask = ((uint64_t)1 << __ffs(vfio_pgsize_bitmap(iommu))) - 1;
73fa0d10d077d9 Alex Williamson 2012-07-31   996  
73fa0d10d077d9 Alex Williamson 2012-07-31   997  	if (unmap->iova & mask)
73fa0d10d077d9 Alex Williamson 2012-07-31   998  		return -EINVAL;
f5bfdbf252ad54 Alex Williamson 2013-06-25   999  	if (!unmap->size || unmap->size & mask)
73fa0d10d077d9 Alex Williamson 2012-07-31  1000  		return -EINVAL;
58fec830fc1920 Alex Williamson 2019-01-07  1001  	if (unmap->iova + unmap->size - 1 < unmap->iova ||
71a7d3d78e3ca5 Dan Carpenter   2017-10-20  1002  	    unmap->size > SIZE_MAX)
71a7d3d78e3ca5 Dan Carpenter   2017-10-20  1003  		return -EINVAL;
73fa0d10d077d9 Alex Williamson 2012-07-31  1004  
73fa0d10d077d9 Alex Williamson 2012-07-31  1005  	WARN_ON(mask & PAGE_MASK);
c086de818dd81c Kirti Wankhede  2016-11-17  1006  again:
73fa0d10d077d9 Alex Williamson 2012-07-31  1007  	mutex_lock(&iommu->lock);
73fa0d10d077d9 Alex Williamson 2012-07-31  1008  
1ef3e2bc04223f Alex Williamson 2014-02-26  1009  	/*
1ef3e2bc04223f Alex Williamson 2014-02-26  1010  	 * vfio-iommu-type1 (v1) - User mappings were coalesced together to
1ef3e2bc04223f Alex Williamson 2014-02-26  1011  	 * avoid tracking individual mappings.  This means that the granularity
1ef3e2bc04223f Alex Williamson 2014-02-26  1012  	 * of the original mapping was lost and the user was allowed to attempt
1ef3e2bc04223f Alex Williamson 2014-02-26  1013  	 * to unmap any range.  Depending on the contiguousness of physical
1ef3e2bc04223f Alex Williamson 2014-02-26  1014  	 * memory and page sizes supported by the IOMMU, arbitrary unmaps may
1ef3e2bc04223f Alex Williamson 2014-02-26  1015  	 * or may not have worked.  We only guaranteed unmap granularity
1ef3e2bc04223f Alex Williamson 2014-02-26  1016  	 * matching the original mapping; even though it was untracked here,
1ef3e2bc04223f Alex Williamson 2014-02-26  1017  	 * the original mappings are reflected in IOMMU mappings.  This
1ef3e2bc04223f Alex Williamson 2014-02-26  1018  	 * resulted in a couple unusual behaviors.  First, if a range is not
1ef3e2bc04223f Alex Williamson 2014-02-26  1019  	 * able to be unmapped, ex. a set of 4k pages that was mapped as a
1ef3e2bc04223f Alex Williamson 2014-02-26  1020  	 * 2M hugepage into the IOMMU, the unmap ioctl returns success but with
1ef3e2bc04223f Alex Williamson 2014-02-26  1021  	 * a zero sized unmap.  Also, if an unmap request overlaps the first
1ef3e2bc04223f Alex Williamson 2014-02-26  1022  	 * address of a hugepage, the IOMMU will unmap the entire hugepage.
1ef3e2bc04223f Alex Williamson 2014-02-26  1023  	 * This also returns success and the returned unmap size reflects the
1ef3e2bc04223f Alex Williamson 2014-02-26  1024  	 * actual size unmapped.
1ef3e2bc04223f Alex Williamson 2014-02-26  1025  	 *
1ef3e2bc04223f Alex Williamson 2014-02-26  1026  	 * We attempt to maintain compatibility with this "v1" interface, but
1ef3e2bc04223f Alex Williamson 2014-02-26  1027  	 * we take control out of the hands of the IOMMU.  Therefore, an unmap
1ef3e2bc04223f Alex Williamson 2014-02-26  1028  	 * request offset from the beginning of the original mapping will
1ef3e2bc04223f Alex Williamson 2014-02-26  1029  	 * return success with zero sized unmap.  And an unmap request covering
1ef3e2bc04223f Alex Williamson 2014-02-26  1030  	 * the first iova of mapping will unmap the entire range.
1ef3e2bc04223f Alex Williamson 2014-02-26  1031  	 *
1ef3e2bc04223f Alex Williamson 2014-02-26  1032  	 * The v2 version of this interface intends to be more deterministic.
1ef3e2bc04223f Alex Williamson 2014-02-26  1033  	 * Unmap requests must fully cover previous mappings.  Multiple
1ef3e2bc04223f Alex Williamson 2014-02-26  1034  	 * mappings may still be unmaped by specifying large ranges, but there
1ef3e2bc04223f Alex Williamson 2014-02-26  1035  	 * must not be any previous mappings bisected by the range.  An error
1ef3e2bc04223f Alex Williamson 2014-02-26  1036  	 * will be returned if these conditions are not met.  The v2 interface
1ef3e2bc04223f Alex Williamson 2014-02-26  1037  	 * will only return success and a size of zero if there were no
1ef3e2bc04223f Alex Williamson 2014-02-26  1038  	 * mappings within the range.
1ef3e2bc04223f Alex Williamson 2014-02-26  1039  	 */
1ef3e2bc04223f Alex Williamson 2014-02-26  1040  	if (iommu->v2) {
7c03f428464333 Kirti Wankhede  2016-12-06  1041  		dma = vfio_find_dma(iommu, unmap->iova, 1);
1ef3e2bc04223f Alex Williamson 2014-02-26  1042  		if (dma && dma->iova != unmap->iova) {
1ef3e2bc04223f Alex Williamson 2014-02-26  1043  			ret = -EINVAL;
1ef3e2bc04223f Alex Williamson 2014-02-26  1044  			goto unlock;
1ef3e2bc04223f Alex Williamson 2014-02-26  1045  		}
5935872fe363ec Kirti Wankhede  2020-05-04  1046  
1ef3e2bc04223f Alex Williamson 2014-02-26  1047  		dma = vfio_find_dma(iommu, unmap->iova + unmap->size - 1, 0);
1ef3e2bc04223f Alex Williamson 2014-02-26  1048  		if (dma && dma->iova + dma->size != unmap->iova + unmap->size) {
1ef3e2bc04223f Alex Williamson 2014-02-26  1049  			ret = -EINVAL;
1ef3e2bc04223f Alex Williamson 2014-02-26  1050  			goto unlock;
1ef3e2bc04223f Alex Williamson 2014-02-26  1051  		}
1ef3e2bc04223f Alex Williamson 2014-02-26  1052  	}
1ef3e2bc04223f Alex Williamson 2014-02-26  1053  
5935872fe363ec Kirti Wankhede  2020-05-04  1054  	if ((unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) &&
5935872fe363ec Kirti Wankhede  2020-05-04  1055  	     iommu->dirty_page_tracking) {
5935872fe363ec Kirti Wankhede  2020-05-04  1056  		final_bitmap = kvzalloc(bitmap->size, GFP_KERNEL);
5935872fe363ec Kirti Wankhede  2020-05-04  1057  		if (!final_bitmap) {
5935872fe363ec Kirti Wankhede  2020-05-04  1058  			ret = -ENOMEM;
5935872fe363ec Kirti Wankhede  2020-05-04  1059  			goto unlock;
5935872fe363ec Kirti Wankhede  2020-05-04  1060  		}
5935872fe363ec Kirti Wankhede  2020-05-04  1061  
5935872fe363ec Kirti Wankhede  2020-05-04  1062  		temp_bitmap = kvzalloc(bitmap->size, GFP_KERNEL);
5935872fe363ec Kirti Wankhede  2020-05-04  1063  		if (!temp_bitmap) {
5935872fe363ec Kirti Wankhede  2020-05-04  1064  			ret = -ENOMEM;
5935872fe363ec Kirti Wankhede  2020-05-04  1065  			kfree(final_bitmap);
5935872fe363ec Kirti Wankhede  2020-05-04  1066  			goto unlock;
5935872fe363ec Kirti Wankhede  2020-05-04  1067  		}
5935872fe363ec Kirti Wankhede  2020-05-04  1068  	}
5935872fe363ec Kirti Wankhede  2020-05-04  1069  
166fd7d94afdac Alex Williamson 2013-06-21  1070  	while ((dma = vfio_find_dma(iommu, unmap->iova, unmap->size))) {
1ef3e2bc04223f Alex Williamson 2014-02-26  1071  		if (!iommu->v2 && unmap->iova > dma->iova)
166fd7d94afdac Alex Williamson 2013-06-21  1072  			break;
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1073  		/*
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1074  		 * Task with same address space who mapped this iova range is
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1075  		 * allowed to unmap the iova range.
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1076  		 */
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1077  		if (dma->task->mm != current->mm)
8f0d5bb95f763c Kirti Wankhede  2016-11-17  1078  			break;
c086de818dd81c Kirti Wankhede  2016-11-17  1079  
5935872fe363ec Kirti Wankhede  2020-05-04  1080  		if ((unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) &&
5935872fe363ec Kirti Wankhede  2020-05-04  1081  		     iommu->dirty_page_tracking) {
5935872fe363ec Kirti Wankhede  2020-05-04  1082  			unsigned long pgshift = __ffs(bitmap->pgsize);
5935872fe363ec Kirti Wankhede  2020-05-04  1083  			unsigned int npages = dma->size >> pgshift;
5935872fe363ec Kirti Wankhede  2020-05-04  1084  			unsigned int shift;
5935872fe363ec Kirti Wankhede  2020-05-04  1085  
5935872fe363ec Kirti Wankhede  2020-05-04  1086  			vfio_iova_dirty_bitmap(iommu, dma->iova, dma->size,
5935872fe363ec Kirti Wankhede  2020-05-04 @1087  					bitmap->pgsize, (u64 *)temp_bitmap);
5935872fe363ec Kirti Wankhede  2020-05-04  1088  
5935872fe363ec Kirti Wankhede  2020-05-04  1089  			shift = (dma->iova - unmap->iova) >> pgshift;
5935872fe363ec Kirti Wankhede  2020-05-04  1090  			if (shift)
5935872fe363ec Kirti Wankhede  2020-05-04  1091  				bitmap_shift_left(temp_bitmap, temp_bitmap,
5935872fe363ec Kirti Wankhede  2020-05-04  1092  						  shift, npages);
5935872fe363ec Kirti Wankhede  2020-05-04  1093  			bitmap_or(final_bitmap, final_bitmap, temp_bitmap,
5935872fe363ec Kirti Wankhede  2020-05-04  1094  				  shift + npages);
5935872fe363ec Kirti Wankhede  2020-05-04  1095  			memset(temp_bitmap, 0, bitmap->size);
5935872fe363ec Kirti Wankhede  2020-05-04  1096  		}
5935872fe363ec Kirti Wankhede  2020-05-04  1097  
c086de818dd81c Kirti Wankhede  2016-11-17  1098  		if (!RB_EMPTY_ROOT(&dma->pfn_list)) {
c086de818dd81c Kirti Wankhede  2016-11-17  1099  			struct vfio_iommu_type1_dma_unmap nb_unmap;
c086de818dd81c Kirti Wankhede  2016-11-17  1100  
c086de818dd81c Kirti Wankhede  2016-11-17  1101  			if (dma_last == dma) {
c086de818dd81c Kirti Wankhede  2016-11-17  1102  				BUG_ON(++retries > 10);
c086de818dd81c Kirti Wankhede  2016-11-17  1103  			} else {
c086de818dd81c Kirti Wankhede  2016-11-17  1104  				dma_last = dma;
c086de818dd81c Kirti Wankhede  2016-11-17  1105  				retries = 0;
c086de818dd81c Kirti Wankhede  2016-11-17  1106  			}
c086de818dd81c Kirti Wankhede  2016-11-17  1107  
c086de818dd81c Kirti Wankhede  2016-11-17  1108  			nb_unmap.iova = dma->iova;
c086de818dd81c Kirti Wankhede  2016-11-17  1109  			nb_unmap.size = dma->size;
c086de818dd81c Kirti Wankhede  2016-11-17  1110  
c086de818dd81c Kirti Wankhede  2016-11-17  1111  			/*
c086de818dd81c Kirti Wankhede  2016-11-17  1112  			 * Notify anyone (mdev vendor drivers) to invalidate and
c086de818dd81c Kirti Wankhede  2016-11-17  1113  			 * unmap iovas within the range we're about to unmap.
c086de818dd81c Kirti Wankhede  2016-11-17  1114  			 * Vendor drivers MUST unpin pages in response to an
c086de818dd81c Kirti Wankhede  2016-11-17  1115  			 * invalidation.
c086de818dd81c Kirti Wankhede  2016-11-17  1116  			 */
c086de818dd81c Kirti Wankhede  2016-11-17  1117  			mutex_unlock(&iommu->lock);
c086de818dd81c Kirti Wankhede  2016-11-17  1118  			blocking_notifier_call_chain(&iommu->notifier,
c086de818dd81c Kirti Wankhede  2016-11-17  1119  						    VFIO_IOMMU_NOTIFY_DMA_UNMAP,
c086de818dd81c Kirti Wankhede  2016-11-17  1120  						    &nb_unmap);
c086de818dd81c Kirti Wankhede  2016-11-17  1121  			goto again;
c086de818dd81c Kirti Wankhede  2016-11-17  1122  		}
1ef3e2bc04223f Alex Williamson 2014-02-26  1123  		unmapped += dma->size;
1ef3e2bc04223f Alex Williamson 2014-02-26  1124  		vfio_remove_dma(iommu, dma);
166fd7d94afdac Alex Williamson 2013-06-21  1125  	}
cd9b22685e4ccd Alex Williamson 2013-06-21  1126  
1ef3e2bc04223f Alex Williamson 2014-02-26  1127  unlock:
5935872fe363ec Kirti Wankhede  2020-05-04  1128  	if ((unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) &&
5935872fe363ec Kirti Wankhede  2020-05-04  1129  	     iommu->dirty_page_tracking && final_bitmap) {
5935872fe363ec Kirti Wankhede  2020-05-04  1130  		if (copy_to_user((void __user *)bitmap->data, final_bitmap,
5935872fe363ec Kirti Wankhede  2020-05-04  1131  				 bitmap->size))
5935872fe363ec Kirti Wankhede  2020-05-04  1132  			ret = -EFAULT;
5935872fe363ec Kirti Wankhede  2020-05-04  1133  
5935872fe363ec Kirti Wankhede  2020-05-04  1134  		kfree(final_bitmap);
5935872fe363ec Kirti Wankhede  2020-05-04  1135  		kfree(temp_bitmap);
5935872fe363ec Kirti Wankhede  2020-05-04  1136  	}
5935872fe363ec Kirti Wankhede  2020-05-04  1137  
73fa0d10d077d9 Alex Williamson 2012-07-31  1138  	mutex_unlock(&iommu->lock);
166fd7d94afdac Alex Williamson 2013-06-21  1139  
1ef3e2bc04223f Alex Williamson 2014-02-26  1140  	/* Report how much was unmapped */
166fd7d94afdac Alex Williamson 2013-06-21  1141  	unmap->size = unmapped;
166fd7d94afdac Alex Williamson 2013-06-21  1142  
166fd7d94afdac Alex Williamson 2013-06-21  1143  	return ret;
166fd7d94afdac Alex Williamson 2013-06-21  1144  }
166fd7d94afdac Alex Williamson 2013-06-21  1145  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2020-05-13 20:28 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 15:58 [PATCH Kernel v18 0/7] KABIs to support migration for VFIO devices Kirti Wankhede
2020-05-04 15:58 ` Kirti Wankhede
2020-05-04 15:58 ` [PATCH Kernel v18 1/7] vfio: UAPI for migration interface for device state Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-04 15:58 ` [PATCH Kernel v18 2/7] vfio iommu: Remove atomicity of ref_count of pinned pages Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-04 15:58 ` [PATCH Kernel v18 3/7] vfio iommu: Add ioctl definition for dirty pages tracking Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-04 15:58 ` [PATCH Kernel v18 4/7] vfio iommu: Implementation of ioctl " Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-06  8:15   ` Yan Zhao
2020-05-06  8:15     ` Yan Zhao
2020-05-06 19:42     ` Kirti Wankhede
2020-05-06 19:42       ` Kirti Wankhede
2020-05-07 18:19       ` Alex Williamson
2020-05-07 18:19         ` Alex Williamson
2020-05-06 10:54   ` Cornelia Huck
2020-05-06 10:54     ` Cornelia Huck
2020-05-13 20:26     ` Kirti Wankhede
2020-05-13 20:26       ` Kirti Wankhede
2020-05-04 15:58 ` [PATCH Kernel v18 5/7] vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-06 22:25   ` Alex Williamson
2020-05-06 22:25     ` Alex Williamson
2020-05-12 20:30     ` Kirti Wankhede
2020-05-12 20:30       ` Kirti Wankhede
2020-05-12 21:21       ` Alex Williamson
2020-05-12 21:21         ` Alex Williamson
2020-05-04 15:58 ` [PATCH Kernel v18 6/7] vfio iommu: Add migration capability to report supported features Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-06 22:27   ` Alex Williamson
2020-05-06 22:27     ` Alex Williamson
2020-05-07  5:37     ` Kirti Wankhede
2020-05-07  5:37       ` Kirti Wankhede
2020-05-07 15:17       ` Alex Williamson
2020-05-07 15:17         ` Alex Williamson
2020-05-04 15:58 ` [PATCH Kernel v18 7/7] vfio: Selective dirty page tracking if IOMMU backed device pins pages Kirti Wankhede
2020-05-04 15:58   ` Kirti Wankhede
2020-05-05 18:49 [PATCH Kernel v18 5/7] vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.