Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Christoph Hellwig
On Mon, Feb 22, 2021 at 01:55:23PM -0400, Jason Gunthorpe wrote: > > +static bool strict_mmio_maps = true; > > +module_param_named(strict_mmio_maps, strict_mmio_maps, bool, 0644); > > +MODULE_PARM_DESC(strict_mmio_maps, > > +"Restrict to safe DMA mappings of device memory (true)."); >

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Peter Xu
On Thu, Feb 25, 2021 at 03:17:14PM -0400, Jason Gunthorpe wrote: > It is a use-after-free. Once the PFN is programmed into the IOMMU it > becomes completely divorced from the VMA. Remember there is no > pin_user_page here, so the PFN has no reference count. > > If the owner of the VMA decided to

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Jason Gunthorpe
On Thu, Feb 25, 2021 at 02:06:46PM -0500, Peter Xu wrote: > Agreed. I saw discussions around on redefining the vm_pgoff namespace, I > can't > say I followed that closely either, but yes it definitely makes sense to > always > use an unified namespace. Maybe we should even comment it

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Peter Xu
On Thu, Feb 25, 2021 at 02:19:45PM -0400, Jason Gunthorpe wrote: > On Thu, Feb 25, 2021 at 12:54:57PM -0500, Peter Xu wrote: > > > I can't say I fully understand the whole rational behind 5cbf3264bc71, but > > that > > commit still sounds reasonable to me, since I don't see why VFIO cannot do >

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Jason Gunthorpe
On Thu, Feb 25, 2021 at 12:54:57PM -0500, Peter Xu wrote: > I can't say I fully understand the whole rational behind 5cbf3264bc71, but > that > commit still sounds reasonable to me, since I don't see why VFIO cannot do > VFIO_IOMMU_MAP_DMA upon another memory range that's neither anonymous

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-25 Thread Peter Xu
On Wed, Feb 24, 2021 at 08:22:16PM -0400, Jason Gunthorpe wrote: > On Wed, Feb 24, 2021 at 02:55:08PM -0700, Alex Williamson wrote: > > > > > +static bool strict_mmio_maps = true; > > > > +module_param_named(strict_mmio_maps, strict_mmio_maps, bool, 0644); > > > >

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-24 Thread Jason Gunthorpe
On Wed, Feb 24, 2021 at 02:55:08PM -0700, Alex Williamson wrote: > > > +static bool strict_mmio_maps = true; > > > +module_param_named(strict_mmio_maps, strict_mmio_maps, bool, 0644); > > > +MODULE_PARM_DESC(strict_mmio_maps, > > > + "Restrict to safe DMA mappings of device memory

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-24 Thread Alex Williamson
On Mon, 22 Feb 2021 13:55:23 -0400 Jason Gunthorpe wrote: > On Mon, Feb 22, 2021 at 09:52:32AM -0700, Alex Williamson wrote: > > Introduce a new default strict MMIO mapping mode where the vma for > > a VM_PFNMAP mapping must be backed by a vfio device. This allows > > holding a reference to the

Re: [RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-22 Thread Jason Gunthorpe
On Mon, Feb 22, 2021 at 09:52:32AM -0700, Alex Williamson wrote: > Introduce a new default strict MMIO mapping mode where the vma for > a VM_PFNMAP mapping must be backed by a vfio device. This allows > holding a reference to the device and registering a notifier for the > device, which

[RFC PATCH 10/10] vfio/type1: Register device notifier

2021-02-22 Thread Alex Williamson
Introduce a new default strict MMIO mapping mode where the vma for a VM_PFNMAP mapping must be backed by a vfio device. This allows holding a reference to the device and registering a notifier for the device, which additionally keeps the device in an IOMMU context for the extent of the DMA