linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] vfio: device fd address space and vfio-pci mmap invalidation cleanup
@ 2021-08-05 17:06 Alex Williamson
  2021-08-05 17:08 ` [PATCH 5/7] mm/interval_tree.c: Export vma interval tree iterators Alex Williamson
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Williamson @ 2021-08-05 17:06 UTC (permalink / raw)
  To: alex.williamson
  Cc: Andrew Morton, Jason Gunthorpe, linux-mm, linux-kernel, kvm, jgg, peterx

vfio-pci currently goes through some pretty nasty locking algorithms
since commit abafbc551fdd ("vfio-pci: Invalidate mmaps and block MMIO
access on disabled memory") was added to invalidate and re-fault mmaps
to device MMIO around cases where device memory is disabled.  This
series greatly simplifies that by making use of an address space on
the vfio device file descriptor, as suggested by Jason Gunthorpe.
This allows us to use unmap_mapping_range() on the device fd to zap
such mappings, and by creating a vma-to-pfn callback, we can implement
a reverse function to restore all mappings.

This series was originally part of a larger series which also added a
callback to get a vfio device from a vma, which allows the IOMMU
backend to limit pfnmaps to vfio device memory.  The long term goal
is to implement the vma-to-pfn for all vfio device drivers to enable
this in the IOMMU backend and proceed with a mechanism to also
invalidate DMA mappings to device memory while disabled.

Given my slow progress towards that longer goal, I'd like to get this
in as an interim cleanup as it seems worthwhile on its own.  I'll
intend to rework this on top of Jason's device_open/close series.
Thanks,

Alex

---

Alex Williamson (7):
      vfio: Create vfio_fs_type with inode per device
      vfio: Export unmap_mapping_range() wrapper
      vfio/pci: Use vfio_device_unmap_mapping_range()
      vfio,vfio-pci: Add vma to pfn callback
      mm/interval_tree.c: Export vma interval tree iterators
      vfio: Add vfio_device_io_remap_mapping_range()
      vfio/pci: Remove map-on-fault behavior


 drivers/vfio/pci/vfio_pci.c         | 279 +++++++---------------------
 drivers/vfio/pci/vfio_pci_config.c  |   8 +-
 drivers/vfio/pci/vfio_pci_private.h |   5 +-
 drivers/vfio/vfio.c                 |  69 ++++++-
 include/linux/vfio.h                |  10 +
 mm/interval_tree.c                  |   3 +
 6 files changed, 156 insertions(+), 218 deletions(-)



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

* [PATCH 5/7] mm/interval_tree.c: Export vma interval tree iterators
  2021-08-05 17:06 [PATCH 0/7] vfio: device fd address space and vfio-pci mmap invalidation cleanup Alex Williamson
@ 2021-08-05 17:08 ` Alex Williamson
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2021-08-05 17:08 UTC (permalink / raw)
  To: alex.williamson; +Cc: Andrew Morton, linux-mm, linux-kernel, kvm, jgg, peterx

In order to make use of vma_interval_tree_foreach() from a module
we need to export the first and next interators.  vfio code would
like to use this foreach helper to create a remapping helper,
essentially the reverse of unmap_mapping_range() for specific vmas
mapping vfio device memory.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 mm/interval_tree.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/interval_tree.c b/mm/interval_tree.c
index 32e390c42c53..faa50767496c 100644
--- a/mm/interval_tree.c
+++ b/mm/interval_tree.c
@@ -24,6 +24,9 @@ INTERVAL_TREE_DEFINE(struct vm_area_struct, shared.rb,
 		     unsigned long, shared.rb_subtree_last,
 		     vma_start_pgoff, vma_last_pgoff, /* empty */, vma_interval_tree)
 
+EXPORT_SYMBOL_GPL(vma_interval_tree_iter_first);
+EXPORT_SYMBOL_GPL(vma_interval_tree_iter_next);
+
 /* Insert node immediately after prev in the interval tree */
 void vma_interval_tree_insert_after(struct vm_area_struct *node,
 				    struct vm_area_struct *prev,




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

end of thread, other threads:[~2021-08-05 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 17:06 [PATCH 0/7] vfio: device fd address space and vfio-pci mmap invalidation cleanup Alex Williamson
2021-08-05 17:08 ` [PATCH 5/7] mm/interval_tree.c: Export vma interval tree iterators Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).