Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-12 Thread Jason Gunthorpe
On Fri, Mar 12, 2021 at 01:58:44PM -0700, Alex Williamson wrote: > Yeah, we can indeed use memalloc_nofs_save/restore(). It seems we're > trying to allocate something for pfnmap tracking and that enables lots > of lockdep specific tests. Is it valid to wrap io_remap_pfn_range() > around

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-12 Thread Alex Williamson
On Fri, 12 Mar 2021 13:09:38 -0700 Alex Williamson wrote: > On Fri, 12 Mar 2021 15:41:47 -0400 > Jason Gunthorpe wrote: > > > == > WARNING: possible circular locking dependency detected > 5.12.0-rc1+ #18 Not tainted >

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-12 Thread Alex Williamson
On Fri, 12 Mar 2021 15:41:47 -0400 Jason Gunthorpe wrote: > On Fri, Mar 12, 2021 at 12:16:11PM -0700, Alex Williamson wrote: > > On Wed, 10 Mar 2021 14:40:11 -0400 > > Jason Gunthorpe wrote: > > > > > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > > > > > I think

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-12 Thread Jason Gunthorpe
On Fri, Mar 12, 2021 at 12:16:11PM -0700, Alex Williamson wrote: > On Wed, 10 Mar 2021 14:40:11 -0400 > Jason Gunthorpe wrote: > > > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > > > I think after the address_space changes this should try to stick with > > > > a

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-12 Thread Alex Williamson
On Wed, 10 Mar 2021 14:40:11 -0400 Jason Gunthorpe wrote: > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > I think after the address_space changes this should try to stick with > > > a normal io_rmap_pfn_range() done outside the fault handler. > > > > I assume

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-11 Thread Peter Xu
On Thu, Mar 11, 2021 at 11:35:24AM +, Christoph Hellwig wrote: > On Wed, Mar 10, 2021 at 03:06:07PM -0500, Peter Xu wrote: > > On Wed, Mar 10, 2021 at 02:40:11PM -0400, Jason Gunthorpe wrote: > > > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > > > > > I think after

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-11 Thread Christoph Hellwig
On Wed, Mar 10, 2021 at 03:06:07PM -0500, Peter Xu wrote: > On Wed, Mar 10, 2021 at 02:40:11PM -0400, Jason Gunthorpe wrote: > > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > > > I think after the address_space changes this should try to stick with > > > > a normal

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-10 Thread Peter Xu
On Wed, Mar 10, 2021 at 02:40:11PM -0400, Jason Gunthorpe wrote: > On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > > > I think after the address_space changes this should try to stick with > > > a normal io_rmap_pfn_range() done outside the fault handler. > > > > I assume

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-10 Thread Jason Gunthorpe
On Wed, Mar 10, 2021 at 11:34:06AM -0700, Alex Williamson wrote: > > I think after the address_space changes this should try to stick with > > a normal io_rmap_pfn_range() done outside the fault handler. > > I assume you're suggesting calling io_remap_pfn_range() when device > memory is enabled,

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-10 Thread Alex Williamson
On Wed, 10 Mar 2021 14:14:46 -0400 Jason Gunthorpe wrote: > On Wed, Mar 10, 2021 at 10:53:29AM -0700, Alex Williamson wrote: > > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > index 65e7e6b44578..ae723808e08b 100644 > > +++ b/drivers/vfio/pci/vfio_pci.c > > @@

Re: [PATCH] vfio/pci: Handle concurrent vma faults

2021-03-10 Thread Jason Gunthorpe
On Wed, Mar 10, 2021 at 10:53:29AM -0700, Alex Williamson wrote: > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index 65e7e6b44578..ae723808e08b 100644 > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -1573,6 +1573,11 @@ static int __vfio_pci_add_vma(struct vfio_pci_device >

[PATCH] vfio/pci: Handle concurrent vma faults

2021-03-10 Thread Alex Williamson
vfio_pci_mmap_fault() incorrectly makes use of io_remap_pfn_range() from within a vm_ops fault handler. This function will trigger a BUG_ON if it encounters a populated pte within the remapped range, where any fault is meant to populate the entire vma. Concurrent inflight faults to the same vma