On Mon, Feb 22, 2021 at 09:50:22AM -0700, Alex Williamson wrote: > This is a re-implementation of [1] following suggestions and code from > Jason Gunthorpe. This is lightly tested but seems functional and > throws no lockdep warnings. In this series we tremendously simplify > zapping of vmas mapping device memory using unmap_mapping_range(), we > create a protocol for looking up a vfio_device from a vma and provide > an interface to get a reference from that vma, using that device > reference, the caller can register a notifier for the device to > trigger on events such as device release. This notifier is only > enabled here for vfio-pci, but both the vma policy and the notifier > trigger should be trivial to add to any vfio bus driver after RFC. > > Does this look more like the direction we should go? Yep, it seems pretty good already, see my remarks in each patch For security only vfio_device's that have been enabled for P2P, set the vm_pgoff to the pfn, and trigger invalidation, should be used with this mechanism. I'd add some global opt-in so vfio_device_get_from_vma() will refuse to return vfio_device's that don't declare they have support. Add a flags member to vfio_device_ops would get it done fairly cleanly Jason