vfio-pci: Fault mmaps to enable vma tracking
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 28 Apr 2020 19:12:20 +0000 (13:12 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 12 Sep 2020 11:39:11 +0000 (13:39 +0200)
commitbe52e6223e66c00b775d799dda403b7c5a49a2c4
tree5da4230d2c50d1c66b676cb0ece42542f44b1a04
parente0dc293b49c41981e6f71d026f83bc6d8702365d
vfio-pci: Fault mmaps to enable vma tracking

commit 11c4cd07ba111a09f49625f9e4c851d83daf0a22 upstream.

Rather than calling remap_pfn_range() when a region is mmap'd, setup
a vm_ops handler to support dynamic faulting of the range on access.
This allows us to manage a list of vmas actively mapping the area that
we can later use to invalidate those mappings.  The open callback
invalidates the vma range so that all tracking is inserted in the
fault handler and removed in the close handler.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
[Ajay: Regenerated the patch for v4.14]
Signed-off-by: Ajay Kaher <akaher@vmware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vfio/pci/vfio_pci.c
drivers/vfio/pci/vfio_pci_private.h