Re: [PATCH v2] vfio/type1: Use follow_pte()

2021-02-22 Thread Alex Williamson
On Tue, 16 Feb 2021 15:49:34 -0700 Alex Williamson wrote: > follow_pfn() doesn't make sure that we're using the correct page > protections, get the pte with follow_pte() so that we can test > protections and get the pfn from the pte. > > Fixes: 5cbf3264bc71 ("vfio/type1: Fi

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

2021-02-22 Thread Alex Williamson
mapping. On notification of device release, automatically drop the DMA mappings for it. Signed-off-by: Alex Williamson --- drivers/vfio/vfio_iommu_type1.c | 124 +++ 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b

[RFC PATCH 08/10] vfio/type1: Refactor pfn_list clearing

2021-02-22 Thread Alex Williamson
Pull code out to a function for re-use. Signed-off-by: Alex Williamson --- drivers/vfio/vfio_iommu_type1.c | 57 +++ 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index

[RFC PATCH 07/10] vfio/pci: Notify on device release

2021-02-22 Thread Alex Williamson
Trigger a release notifier call when open reference count is zero. Signed-off-by: Alex Williamson --- drivers/vfio/pci/vfio_pci.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index f9529bac6c97..fb8307430e24 100644

[RFC PATCH 09/10] vfio/type1: Pass iommu and dma objects through to vaddr_get_pfn

2021-02-22 Thread Alex Williamson
We'll need these to track vfio device mappings. Signed-off-by: Alex Williamson --- drivers/vfio/vfio_iommu_type1.c | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index

[RFC PATCH 06/10] vfio: Add a device notifier interface

2021-02-22 Thread Alex Williamson
minimally respond to the release event by asynchronously removing notifiers. Signed-off-by: Alex Williamson --- drivers/vfio/Kconfig |1 + drivers/vfio/vfio.c | 35 +++ include/linux/vfio.h |9 + 3 files changed, 45 insertions(+) diff --git

[RFC PATCH 05/10] vfio: Create a vfio_device from vma lookup

2021-02-22 Thread Alex Williamson
be able to directly increment the vfio_device reference. Implemented only for vfio-pci for now. Suggested-by: Jason Gunthorpe Signed-off-by: Alex Williamson --- drivers/vfio/pci/vfio_pci.c |6 -- drivers/vfio/vfio.c | 24 include/linux/vfio.h

[RFC PATCH 04/10] vfio/pci: Use vfio_device_unmap_mapping_range()

2021-02-22 Thread Alex Williamson
-by: Alex Williamson --- drivers/vfio/pci/vfio_pci.c | 217 --- drivers/vfio/pci/vfio_pci_private.h |3 2 files changed, 28 insertions(+), 192 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index f0a1d05f0137

[RFC PATCH 00/10] vfio: Device memory DMA mapping improvements

2021-02-22 Thread Alex Williamson
IOMMU interfaces to modify protection bits, and it's not clear an IOMMU fault is absolutely better than the bus error. Thanks, Alex [1]https://lore.kernel.org/kvm/161315658638.7320.9686203003395567745.st...@gimli.home/T/#m64859ccd7d92f39a924759c7423f2dcf7d367c84 --- Alex Williamson (10): vfio

[RFC PATCH 03/10] vfio: Export unmap_mapping_range() wrapper

2021-02-22 Thread Alex Williamson
Allow bus drivers to use vfio pseudo fs mapping to zap all mmaps across a range of their device files. Signed-off-by: Alex Williamson --- drivers/vfio/vfio.c |7 +++ include/linux/vfio.h |2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c

[RFC PATCH 02/10] vfio: Update vfio_add_group_dev() API

2021-02-22 Thread Alex Williamson
Rather than an errno, return a pointer to the opaque vfio_device to allow the bus driver to call into vfio-core without additional lookups and references. Note that bus drivers are still required to use vfio_del_group_dev() to teardown the vfio_device. Signed-off-by: Alex Williamson

[RFC PATCH 01/10] vfio: Create vfio_fs_type with inode per device

2021-02-22 Thread Alex Williamson
By linking all the device fds we provide to userspace to an address space through a new pseudo fs, we can use tools like unmap_mapping_range() to zap all vmas associated with a device. Suggested-by: Jason Gunthorpe Signed-off-by: Alex Williamson --- drivers/vfio/vfio.c | 54

Re: [PATCH 1/3] vfio: Introduce vma ops registration and notifier

2021-02-19 Thread Alex Williamson
On Thu, 18 Feb 2021 19:04:04 -0400 Jason Gunthorpe wrote: > On Thu, Feb 18, 2021 at 02:56:06PM -0700, Alex Williamson wrote: > > > Looks pretty slick. I won't claim it's fully gelled in my head yet, > > but AIUI you're creating these inodes on your new pseudo fs and >

Re: [PATCH 1/3] vfio: Introduce vma ops registration and notifier

2021-02-18 Thread Alex Williamson
On Wed, 17 Feb 2021 21:12:09 -0400 Jason Gunthorpe wrote: > On Fri, Feb 12, 2021 at 05:20:57PM -0400, Jason Gunthorpe wrote: > > On Fri, Feb 12, 2021 at 12:27:39PM -0700, Alex Williamson wrote: > > > Create an interface through vfio-core where a vfio bus driver (ex. &

Re: [PATCH 3/3] vfio/type1: batch page pinning

2021-02-18 Thread Alex Williamson
On Wed, 3 Feb 2021 15:47:56 -0500 Daniel Jordan wrote: > Pinning one 4K page at a time is inefficient, so do it in batches of 512 > instead. This is just an optimization with no functional change > intended, and in particular the driver still calls iommu_map() with the > largest physically

[PATCH v2] vfio/type1: Use follow_pte()

2021-02-16 Thread Alex Williamson
son Gunthorpe Reviewed-by: Cornelia Huck Signed-off-by: Alex Williamson --- v2: Update to current follow_pte() API, add Reviews drivers/vfio/vfio_iommu_type1.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_

Re: [PATCH] vfio/type1: Use follow_pte()

2021-02-12 Thread Alex Williamson
On Fri, 12 Feb 2021 15:08:51 -0400 Jason Gunthorpe wrote: > On Fri, Feb 12, 2021 at 12:01:50PM -0700, Alex Williamson wrote: > > follow_pfn() doesn't make sure that we're using the correct page > > protections, get the pte with follow_pte() so that we can test > > protec

[PATCH 2/3] vfio/pci: Implement vm_ops registration

2021-02-12 Thread Alex Williamson
. The close notifier is implemented for when the device is released, rather than closing the vma to avoid possibly breaking userspace (ie. mmap -> dma map -> munmap is currently allowed and maintains the dma mapping to the device). Signed-off-by: Alex Williamson --- drivers/vfio/pci/K

[PATCH 3/3] vfio/type1: Implement vma registration and restriction

2021-02-12 Thread Alex Williamson
this support. A new module option is provided to opt-out should this conflict with existing use cases. Signed-off-by: Alex Williamson --- drivers/vfio/vfio_iommu_type1.c | 192 +++ 1 file changed, 155 insertions(+), 37 deletions(-) diff --git a/drivers/vfio

[PATCH 1/3] vfio: Introduce vma ops registration and notifier

2021-02-12 Thread Alex Williamson
and register a notifier for relavant changes to the device mapping. For now we define only a notifier action for closing the device. Signed-off-by: Alex Williamson --- drivers/vfio/vfio.c | 120 ++ include/linux/vfio.h | 20 2 files

[PATCH 0/3] vfio: Device memory DMA mapping improvements

2021-02-12 Thread Alex Williamson
this same with that method. Thanks, Alex [1]https://lore.kernel.org/kvm/158947414729.12590.4345248265094886807.st...@gimli.home/ --- Alex Williamson (3): vfio: Introduce vma ops registration and notifier vfio/pci: Implement vm_ops registration vfio/type1: Implement vma registration

[PATCH] vfio/type1: Use follow_pte()

2021-02-12 Thread Alex Williamson
follow_pfn() doesn't make sure that we're using the correct page protections, get the pte with follow_pte() so that we can test protections and get the pfn from the pte. Fixes: 5cbf3264bc71 ("vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn()") Signed-off-by: Al

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-11 Thread Alex Williamson
On Thu, 11 Feb 2021 08:44:26 + Christoph Hellwig wrote: > On Tue, Feb 02, 2021 at 04:59:23PM -0700, Alex Williamson wrote: > > vfio-pci-igd support knows very little about the device, we're > > effectively just exposing a firmware table and some of the host bridge > > co

Re: [PATCH v2 0/9] Introduce vfio-pci-core subsystem

2021-02-10 Thread Alex Williamson
On Wed, 10 Feb 2021 09:34:52 -0400 Jason Gunthorpe wrote: > On Wed, Feb 10, 2021 at 07:52:08AM +, Tian, Kevin wrote: > > > This subsystem framework will also ease on adding vendor specific > > > functionality to VFIO devices in the future by allowing another module > > > to provide the

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-02 Thread Alex Williamson
On Tue, 2 Feb 2021 19:06:04 -0400 Jason Gunthorpe wrote: > On Tue, Feb 02, 2021 at 02:30:13PM -0700, Alex Williamson wrote: > > > The first set of users already fail this specification though, we can't > > base it strictly on device and vendor IDs, we need wildcards, class &

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-02 Thread Alex Williamson
On Tue, 2 Feb 2021 22:59:27 +0200 Max Gurtovoy wrote: > On 2/2/2021 10:44 PM, Jason Gunthorpe wrote: > > On Tue, Feb 02, 2021 at 12:37:23PM -0700, Alex Williamson wrote: > > > >> For the most part, this explicit bind interface is redundant to > >> driv

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-02 Thread Alex Williamson
On Tue, 2 Feb 2021 14:50:17 -0400 Jason Gunthorpe wrote: > On Tue, Feb 02, 2021 at 10:54:55AM -0700, Alex Williamson wrote: > > > As noted previously, if we start adding ids for vfio drivers then we > > create conflicts with the native host driver. We cannot register a &

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-02 Thread Alex Williamson
On Tue, 2 Feb 2021 19:41:16 +0200 Max Gurtovoy wrote: > On 2/2/2021 6:06 PM, Cornelia Huck wrote: > > On Mon, 1 Feb 2021 11:42:30 -0700 > > Alex Williamson wrote: > > > >> On Mon, 1 Feb 2021 12:49:12 -0500 > >> Matthew Rosato wrote: > >>

Re: [PATCH] vfio/iommu_type1: Mantainance a counter for non_pinned_groups

2021-02-02 Thread Alex Williamson
On Mon, 25 Jan 2021 10:46:42 +0800 Keqian Zhu wrote: > With this counter, we never need to traverse all groups to update > pinned_scope of vfio_iommu. > > Suggested-by: Alex Williamson > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vf

Re: [PATCH v3 0/2] vfio/iommu_type1: some fixes

2021-02-02 Thread Alex Williamson
On Fri, 22 Jan 2021 17:26:33 +0800 Keqian Zhu wrote: > v3: > - Populate bitmap unconditionally. > - Sanity check notifier when remove all domains. > > v2: > - Address suggestions from Alex. > - Remove unnecessary patches. > > > Keqian Zhu (2): > vfio/iommu_type1: Populate full dirty

Re: [PATCH 5/9] vfio-pci/zdev: remove unused vdev argument

2021-02-02 Thread Alex Williamson
On Tue, 2 Feb 2021 08:57:55 +0100 Cornelia Huck wrote: > On Mon, 1 Feb 2021 16:28:24 + > Max Gurtovoy wrote: > > > Zdev static functions does not use vdev argument. Remove it. > > s/does not use/do not use the/ > > > > > Signed-off-by: Max Gurtovoy > > --- > >

Re: [PATCH 6/9] vfio-pci/zdev: fix possible segmentation fault issue

2021-02-01 Thread Alex Williamson
On Mon, 1 Feb 2021 12:08:45 -0500 Matthew Rosato wrote: > On 2/1/21 11:52 AM, Cornelia Huck wrote: > > On Mon, 1 Feb 2021 16:28:25 + > > Max Gurtovoy wrote: > > > >> In case allocation fails, we must behave correctly and exit with error. > >> > >> Signed-off-by: Max Gurtovoy > > > >

Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd

2021-02-01 Thread Alex Williamson
On Mon, 1 Feb 2021 12:49:12 -0500 Matthew Rosato wrote: > On 2/1/21 12:14 PM, Cornelia Huck wrote: > > On Mon, 1 Feb 2021 16:28:27 + > > Max Gurtovoy wrote: > > > >> This patch doesn't change any logic but only align to the concept of > >> vfio_pci_core extensions. Extensions that are

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-02-01 Thread Alex Williamson
On Mon, 1 Feb 2021 11:40:45 +0200 Max Gurtovoy wrote: > On 2/1/2021 6:32 AM, Alex Williamson wrote: > > On Sun, 31 Jan 2021 20:46:40 +0200 > > Max Gurtovoy wrote: > > > >> On 1/28/2021 11:02 PM, Alex Williamson wrote: > >>> On Thu, 28 Jan 2021

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-01-31 Thread Alex Williamson
On Sun, 31 Jan 2021 20:46:40 +0200 Max Gurtovoy wrote: > On 1/28/2021 11:02 PM, Alex Williamson wrote: > > On Thu, 28 Jan 2021 17:29:30 +0100 > > Cornelia Huck wrote: > > > >> On Tue, 26 Jan 2021 15:27:43 +0200 > >> Max Gurtovoy wrote: > >&

Re: [RFC PATCH v1 1/4] vfio/type1: Add a bitmap to track IOPF mapped pages

2021-01-29 Thread Alex Williamson
On Mon, 25 Jan 2021 17:03:59 +0800 Shenming Lu wrote: > When IOPF enabled, the pages are pinned and mapped on demand, we add > a bitmap to track them. > > Signed-off-by: Shenming Lu > --- > drivers/vfio/vfio_iommu_type1.c | 12 > 1 file changed, 12 insertions(+) > > diff --git

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-01-29 Thread Alex Williamson
On Mon, 25 Jan 2021 17:03:58 +0800 Shenming Lu wrote: > Hi, > > The static pinning and mapping problem in VFIO and possible solutions > have been discussed a lot [1, 2]. One of the solutions is to add I/O > page fault support for VFIO devices. Different from those relatively > complicated

Re: [RFC PATCH v1 3/4] vfio: Try to enable IOPF for VFIO devices

2021-01-29 Thread Alex Williamson
On Mon, 25 Jan 2021 17:04:01 +0800 Shenming Lu wrote: > If IOMMU_DEV_FEAT_IOPF is set for the VFIO device, which means that > the delivering of page faults of this device from the IOMMU is enabled, > we register the VFIO page fault handler to complete the whole faulting > path (HW+SW). And add a

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-01-28 Thread Alex Williamson
On Thu, 28 Jan 2021 17:29:30 +0100 Cornelia Huck wrote: > On Tue, 26 Jan 2021 15:27:43 +0200 > Max Gurtovoy wrote: > > On 1/26/2021 5:34 AM, Alex Williamson wrote: > > > On Mon, 25 Jan 2021 20:45:22 -0400 > > > Jason Gunthorpe wrote: > > > > >

Re: [PATCH v3 2/2] vfio/iommu_type1: Fix some sanity checks in detach group

2021-01-27 Thread Alex Williamson
On Fri, 22 Jan 2021 17:26:35 +0800 Keqian Zhu wrote: > vfio_sanity_check_pfn_list() is used to check whether pfn_list and > notifier are empty when remove the external domain, so it makes a > wrong assumption that only external domain will use the pinning > interface. > > Now we apply the

Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-27 Thread Alex Williamson
On Wed, 27 Jan 2021 09:23:04 -0500 Matthew Rosato wrote: > On 1/26/21 6:18 PM, Alex Williamson wrote: > > On Mon, 25 Jan 2021 09:40:38 -0500 > > Matthew Rosato wrote: > > > >> On 1/22/21 6:48 PM, Alex Williamson wrote: > >>> On Tue, 19 Jan 2021

Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-27 Thread Alex Williamson
On Mon, 25 Jan 2021 09:40:38 -0500 Matthew Rosato wrote: > On 1/22/21 6:48 PM, Alex Williamson wrote: > > On Tue, 19 Jan 2021 15:02:30 -0500 > > Matthew Rosato wrote: > > > >> Some s390 PCI devices (e.g. ISM) perform I/O operations that have very >

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-01-26 Thread Alex Williamson
On Mon, 25 Jan 2021 20:45:22 -0400 Jason Gunthorpe wrote: > On Mon, Jan 25, 2021 at 04:31:51PM -0700, Alex Williamson wrote: > > > We're supposed to be enlightened by a vendor driver that does nothing > > more than pass the opaque device_data through to the core functions,

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-01-25 Thread Alex Williamson
On Mon, 25 Jan 2021 14:04:40 -0400 Jason Gunthorpe wrote: > On Mon, Jan 25, 2021 at 05:20:35PM +0100, Cornelia Huck wrote: > > > I think you cut out an important part of Alex' comment, so let me > > repost it here: > > Yes, I've already respnded to this. Not really. For example, how can

Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-22 Thread Alex Williamson
On Tue, 19 Jan 2021 15:02:30 -0500 Matthew Rosato wrote: > Some s390 PCI devices (e.g. ISM) perform I/O operations that have very > specific requirements in terms of alignment as well as the patterns in > which the data is read/written. Allowing these to proceed through the > typical

Re: [PATCH RFC v1 0/3] Introduce vfio-pci-core subsystem

2021-01-22 Thread Alex Williamson
On Sun, 17 Jan 2021 18:15:31 + Max Gurtovoy wrote: > Hi Alex and Cornelia, > > This series split the vfio_pci driver into 2 parts: pci driver and a > subsystem driver that will also be library of code. The pci driver, > vfio_pci.ko will be used as before and it will bind to the subsystem >

Re: [PATCH 4/4] vfio-pci/zdev: Introduce the zPCI I/O vfio region

2021-01-21 Thread Alex Williamson
On Wed, 20 Jan 2021 14:21:59 +0100 Niklas Schnelle wrote: > On 1/19/21 9:02 PM, Matthew Rosato wrote: > > Some s390 PCI devices (e.g. ISM) perform I/O operations that have very > .. snip ... > > + > > +static size_t vfio_pci_zdev_io_rw(struct vfio_pci_device *vdev, > > +

Re: [PATCH v2 2/2] vfio/iommu_type1: Sanity check pfn_list when remove vfio_dma

2021-01-21 Thread Alex Williamson
On Mon, 18 Jan 2021 21:16:08 +0800 Keqian Zhu wrote: > On 2021/1/16 3:14, Alex Williamson wrote: > > On Fri, 15 Jan 2021 17:26:43 +0800 > > Keqian Zhu wrote: > > > >> vfio_sanity_check_pfn_list() is used to check whether pfn_list of > >> vfio_dma is em

Re: [PATCH v2 1/2] vfio/iommu_type1: Populate full dirty when detach non-pinned group

2021-01-21 Thread Alex Williamson
On Mon, 18 Jan 2021 20:25:09 +0800 Keqian Zhu wrote: > On 2021/1/16 2:01, Alex Williamson wrote: > > On Fri, 15 Jan 2021 17:26:42 +0800 > > Keqian Zhu wrote: > > > >> If a group with non-pinned-page dirty scope is detached with dirty > >> logging enab

Re: [RFC v3 2/2] vfio/platform: msi: add Broadcom platform devices

2021-01-19 Thread Alex Williamson
On Fri, 15 Jan 2021 10:24:33 +0100 Auger Eric wrote: > Hi Vikas, > On 1/15/21 7:35 AM, Vikas Gupta wrote: > > Hi Eric, > > > > On Tue, Jan 12, 2021 at 2:52 PM Auger Eric wrote: > >> > >> Hi Vikas, > >> > >> On 12/14/20 6:45 PM, Vikas Gupta wrote: > >>> Add msi support for Broadcom platform

Re: [PATCH 6/6] vfio/iommu_type1: Drop parameter "pgsize" of update_user_bitmap

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:44:01 +0800 Keqian Zhu wrote: > We always use the smallest supported page size of vfio_iommu as > pgsize. Drop parameter "pgsize" of update_user_bitmap. > > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vfio_iommu_type1.c | 9 - > 1 file changed, 4

Re: [PATCH 5/6] vfio/iommu_type1: Drop parameter "pgsize" of vfio_iova_dirty_bitmap

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:44:00 +0800 Keqian Zhu wrote: > We always use the smallest supported page size of vfio_iommu as > pgsize. Remove parameter "pgsize" of vfio_iova_dirty_bitmap. > > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vfio_iommu_type1.c | 8 > 1 file changed, 4

Re: [PATCH 4/6] vfio/iommu_type1: Drop parameter "pgsize" of vfio_dma_bitmap_alloc_all

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:43:59 +0800 Keqian Zhu wrote: > We always use the smallest supported page size of vfio_iommu as > pgsize. Remove parameter "pgsize" of vfio_dma_bitmap_alloc_all. > > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vfio_iommu_type1.c | 8 +++- > 1 file changed, 3

Re: [PATCH 3/6] vfio/iommu_type1: Initially set the pinned_page_dirty_scope

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:43:58 +0800 Keqian Zhu wrote: > For now there are 3 ways to promote the pinned_page_dirty_scope > status of vfio_iommu: > > 1. Through vfio pin interface. > 2. Detach a group without pinned_dirty_scope. > 3. Attach a group with pinned_dirty_scope. > > For point 3, the

Re: [PATCH 2/6] vfio/iommu_type1: Ignore external domain when promote pinned_scope

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:43:57 +0800 Keqian Zhu wrote: > The pinned_scope of external domain's groups are always true, that's > to say we can safely ignore external domain when promote pinned_scope > status of vfio_iommu. > > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vfio_iommu_type1.c | 14

Re: [PATCH 1/6] vfio/iommu_type1: Make an explicit "promote" semantic

2021-01-15 Thread Alex Williamson
On Thu, 7 Jan 2021 12:43:56 +0800 Keqian Zhu wrote: > When we want to promote the pinned_page_dirty_scope of vfio_iommu, > we call the "update" function to visit all vfio_group, but when we > want to downgrade this, we can set the flag as false directly. I agree that the transition can only go

Re: [PATCH v2 2/2] vfio/iommu_type1: Sanity check pfn_list when remove vfio_dma

2021-01-15 Thread Alex Williamson
On Fri, 15 Jan 2021 17:26:43 +0800 Keqian Zhu wrote: > vfio_sanity_check_pfn_list() is used to check whether pfn_list of > vfio_dma is empty when remove the external domain, so it makes a > wrong assumption that only external domain will add pfn to dma pfn_list. > > Now we apply this check when

Re: [PATCH v2 1/2] vfio/iommu_type1: Populate full dirty when detach non-pinned group

2021-01-15 Thread Alex Williamson
p be present to trigger the full bitmap when the user > retrieves the dirty bitmap. > > Fixes: d6a4c185660c ("vfio iommu: Implementation of ioctl for dirty pages > tracking") > Suggested-by: Alex Williamson > Signed-off-by: Keqian Zhu > --- > drivers/vfio/vfio_i

Re: [PATCH 1/5] vfio/iommu_type1: Fixes vfio_dma_populate_bitmap to avoid dirty lose

2021-01-14 Thread Alex Williamson
On Thu, 14 Jan 2021 21:05:23 +0800 Keqian Zhu wrote: > Hi Alex, > > On 2021/1/13 5:20, Alex Williamson wrote: > > On Thu, 7 Jan 2021 17:28:57 +0800 > > Keqian Zhu wrote: > > > >> Defer checking whether vfio_dma is of fully-dirty in update_user_b

Re: [PATCH 1/5] vfio/iommu_type1: Fixes vfio_dma_populate_bitmap to avoid dirty lose

2021-01-13 Thread Alex Williamson
On Wed, 13 Jan 2021 18:05:43 +0530 Kirti Wankhede wrote: > On 1/13/2021 2:50 AM, Alex Williamson wrote: > > On Thu, 7 Jan 2021 17:28:57 +0800 > > Keqian Zhu wrote: > > > >> Defer checking whether vfio_dma is of fully-dirty in update_user_bitmap > >>

Re: [PATCH 1/5] vfio/iommu_type1: Fixes vfio_dma_populate_bitmap to avoid dirty lose

2021-01-12 Thread Alex Williamson
On Thu, 7 Jan 2021 17:28:57 +0800 Keqian Zhu wrote: > Defer checking whether vfio_dma is of fully-dirty in update_user_bitmap > is easy to lose dirty log. For example, after promoting pinned_scope of > vfio_iommu, vfio_dma is not considered as fully-dirty, then we may lose > dirty log that

Re: [PATCH 4/5] vfio/iommu_type1: Carefully use unmap_unpin_all during dirty tracking

2021-01-12 Thread Alex Williamson
On Tue, 12 Jan 2021 20:04:38 +0800 Keqian Zhu wrote: > On 2021/1/12 5:49, Alex Williamson wrote: > > On Thu, 7 Jan 2021 17:29:00 +0800 > > Keqian Zhu wrote: > > > >> If we detach group during dirty page tracking, we shouldn't remove > >>

Re: [PATCH 4/5] vfio/iommu_type1: Carefully use unmap_unpin_all during dirty tracking

2021-01-11 Thread Alex Williamson
On Thu, 7 Jan 2021 17:29:00 +0800 Keqian Zhu wrote: > If we detach group during dirty page tracking, we shouldn't remove > vfio_dma, because dirty log will lose. > > But we don't prevent unmap_unpin_all in vfio_iommu_release, because > under normal procedure, dirty tracking has been stopped.

Re: [v3] PCI: Add pci reset quirk for Huawei Intelligent NIC virtual function

2021-01-04 Thread Alex Williamson
++++ > 1 file changed, 77 insertions(+) Reviewed-by: Alex Williamson > > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c > index f70692ac79c5..9c310012ef19 100644 > --- a/drivers/pci/quirks.c > +++ b/drivers/pci/quirks.c > @@

[GIT PULL] VFIO updates for v5.11-rc1

2020-12-16 Thread Alex Williamson
Hi Linus, The following changes since commit b65054597872ce3aefbc6a666385eabdf9e288da: Linux 5.10-rc6 (2020-11-29 15:50:50 -0800) are available in the Git repository at: git://github.com/awilliam/linux-vfio.git tags/vfio-v5.11-rc1 for you to fetch changes up to

Re: [PATCH 4/7] vfio: iommu_type1: Fix missing dirty page when promote pinned_scope

2020-12-15 Thread Alex Williamson
On Tue, 15 Dec 2020 17:37:11 +0800 zhukeqian wrote: > Hi Alex, > > On 2020/12/15 8:04, Alex Williamson wrote: > > On Thu, 10 Dec 2020 15:34:22 +0800 > > Keqian Zhu wrote: > > > >> When we pin or detach a group which is not dirty tracking capable, >

Re: [PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin

2020-12-14 Thread Alex Williamson
On Fri, 11 Dec 2020 14:51:47 +0800 zhukeqian wrote: > On 2020/12/11 3:16, Alex Williamson wrote: > > On Thu, 10 Dec 2020 15:34:19 +0800 > > Keqian Zhu wrote: > > > >> Currently we do not clear added dirty bit of bitmap when unwind > >> pin, so if pi

Re: [PATCH 4/7] vfio: iommu_type1: Fix missing dirty page when promote pinned_scope

2020-12-14 Thread Alex Williamson
On Thu, 10 Dec 2020 15:34:22 +0800 Keqian Zhu wrote: > When we pin or detach a group which is not dirty tracking capable, > we will try to promote pinned_scope of vfio_iommu. > > If we succeed to do so, vfio only report pinned_scope as dirty to > userspace next time, but these memory written

Re: [PATCH v4 1/1] vfio/type1: Add vfio_group_iommu_domain()

2020-12-10 Thread Alex Williamson
On Wed, 9 Dec 2020 09:44:44 +0800 Lu Baolu wrote: > Add the API for getting the domain from a vfio group. This could be used > by the physical device drivers which rely on the vfio/mdev framework for > mediated device user level access. The typical use case like below: > > unsigned int

Re: [v2] PCI: Add pci reset quirk for Huawei Intelligent NIC virtual function

2020-12-10 Thread Alex Williamson
On Wed, 2 Dec 2020 19:34:50 +0800 Chiqijun wrote: > When multiple VFs do FLR at the same time, the firmware is > processed serially, resulting in some VF FLRs being delayed more > than 100ms, when the virtual machine restarts and the device > driver is loaded, the firmware is doing the

Re: [PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin

2020-12-10 Thread Alex Williamson
On Thu, 10 Dec 2020 15:34:19 +0800 Keqian Zhu wrote: > Currently we do not clear added dirty bit of bitmap when unwind > pin, so if pin failed at halfway, we set unnecessary dirty bit > in bitmap. Clearing added dirty bit when unwind pin, userspace > will see less dirty page, which can save much

Re: [RFC PATCH] vfio/pci: Allow force needs_pm_restore as specified by device:vendor

2020-12-09 Thread Alex Williamson
On Wed, 9 Dec 2020 13:14:00 +0800 Colin Xu wrote: > On 11/27/20 11:35 PM, Alex Williamson wrote: > > On Fri, 27 Nov 2020 11:53:39 +0800 > > Colin Xu wrote: > > > >> On 11/25/20 11:53 PM, Alex Williamson wrote: > >>> On Wed, 25 Nov

Re: [PATCH] PCI: Add pci reset quirk for Huawei Intelligent NIC virtual function

2020-12-03 Thread Alex Williamson
On Thu, 3 Dec 2020 19:29:17 +0800 Chiqijun wrote: > On 2020/12/3 1:46, Alex Williamson wrote: > > On Wed, 2 Dec 2020 17:18:12 +0800 > > Chiqijun wrote: > > > >> On 2020/11/30 23:46, Alex Williamson wrote: > >>> On Sat, 28 Nov 2020

Re: [PATCH] vfio/pci: Move dummy_resources_list init in vfio_pci_probe()

2020-12-03 Thread Alex Williamson
On Fri, 13 Nov 2020 18:52:02 +0100 Eric Auger wrote: > In case an error occurs in vfio_pci_enable() before the call to > vfio_pci_probe_mmaps(), vfio_pci_disable() will try to iterate > on an uninitialized list and cause a kernel panic. > > Lets move to the initialization to vfio_pci_probe()

Re: [PATCH v1 2/5] vfio: platform: Switch to use platform_get_mem_or_io_resource()

2020-12-03 Thread Alex Williamson
On Tue, 27 Oct 2020 19:58:03 +0200 Andy Shevchenko wrote: > Switch to use new platform_get_mem_or_io_resource() instead of > home grown analogue. > > Cc: Eric Auger > Cc: Alex Williamson > Cc: Cornelia Huck > Cc: k...@vger.kernel.org > Signed-off-by: Andy Shevchenk

Re: [PATCH] vfio iommu type1: Bypass the vma permission check in vfio_pin_pages_remote()

2020-12-03 Thread Alex Williamson
On Thu, 3 Dec 2020 10:43:22 -0500 Peter Xu wrote: > On Thu, Dec 03, 2020 at 11:20:02AM +, Stefan Hajnoczi wrote: > > On Wed, Dec 02, 2020 at 10:45:11AM -0500, Peter Xu wrote: > > > On Wed, Dec 02, 2020 at 02:33:56PM +, Stefan Hajnoczi wrote: > > > > On Wed, Nov 25, 2020 at 10:57:11AM

Re: [PATCH v3 1/1] vfio/type1: Add vfio_group_domain()

2020-12-02 Thread Alex Williamson
On Tue, 1 Dec 2020 09:23:28 +0800 Lu Baolu wrote: > Add the API for getting the domain from a vfio group. This could be used > by the physical device drivers which rely on the vfio/mdev framework for > mediated device user level access. The typical use case like below: > > unsigned int

Re: [PATCH] PCI: Add pci reset quirk for Huawei Intelligent NIC virtual function

2020-12-02 Thread Alex Williamson
On Wed, 2 Dec 2020 17:18:12 +0800 Chiqijun wrote: > On 2020/11/30 23:46, Alex Williamson wrote: > > On Sat, 28 Nov 2020 17:29:19 -0600 > > Bjorn Helgaas wrote: > > > >> [+cc Alex] > >> > >> On Sat, Nov 28, 2020 at 02:18:25PM +0800, Chiqijun wro

Re: [PATCH v2 1/1] vfio/type1: Add vfio_group_domain()

2020-11-30 Thread Alex Williamson
On Thu, 26 Nov 2020 09:27:26 +0800 Lu Baolu wrote: > Add the API for getting the domain from a vfio group. This could be used > by the physical device drivers which rely on the vfio/mdev framework for > mediated device user level access. The typical use case like below: > > unsigned int

Re: [PATCH] PCI: Add pci reset quirk for Huawei Intelligent NIC virtual function

2020-11-30 Thread Alex Williamson
On Sat, 28 Nov 2020 17:29:19 -0600 Bjorn Helgaas wrote: > [+cc Alex] > > On Sat, Nov 28, 2020 at 02:18:25PM +0800, Chiqijun wrote: > > When multiple VFs do FLR at the same time, the firmware is > > processed serially, resulting in some VF FLRs being delayed more > > than 100ms, when the virtual

Re: [RFC PATCH] vfio/pci: Allow force needs_pm_restore as specified by device:vendor

2020-11-27 Thread Alex Williamson
On Fri, 27 Nov 2020 11:53:39 +0800 Colin Xu wrote: > On 11/25/20 11:53 PM, Alex Williamson wrote: > > On Wed, 25 Nov 2020 10:18:24 +0800 > > Colin Xu wrote: > > > >> Force specific device listed in params pm_restore_ids to follow > >> device state save

Re: [RFC PATCH] vfio/pci: Allow force needs_pm_restore as specified by device:vendor

2020-11-25 Thread Alex Williamson
b/drivers/vfio/pci/vfio_pci.c > index e6190173482c..50a4141c9e1d 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -34,6 +34,15 @@ > #define DRIVER_AUTHOR "Alex Williamson " > #define DRIVER_DESC "VFIO PCI - User Level me

Re: [PATCH v11 01/13] vfio: VFIO_IOMMU_SET_PASID_TABLE

2020-11-24 Thread Alex Williamson
On Mon, 16 Nov 2020 12:00:18 +0100 Eric Auger wrote: > From: "Liu, Yi L" > > This patch adds an VFIO_IOMMU_SET_PASID_TABLE ioctl > which aims to pass the virtual iommu guest configuration > to the host. This latter takes the form of the so-called > PASID table. > > Signed-off-by: Jacob Pan >

Re: [PATCH] vfio iommu type1: Bypass the vma permission check in vfio_pin_pages_remote()

2020-11-24 Thread Alex Williamson
On Mon, 23 Nov 2020 02:37:32 + Justin He wrote: > Hi Alex, thanks for the comments. > See mine below: > > > -Original Message- > > From: Alex Williamson > > Sent: Friday, November 20, 2020 1:05 AM > > To: Justin He > > Cc: Cornelia Huck

Re: [PATCH] vfio iommu type1: Bypass the vma permission check in vfio_pin_pages_remote()

2020-11-19 Thread Alex Williamson
On Thu, 19 Nov 2020 22:27:37 +0800 Jia He wrote: > The permission of vfio iommu is different and incompatible with vma > permission. If the iotlb->perm is IOMMU_NONE (e.g. qemu side), qemu will > simply call unmap ioctl() instead of mapping. Hence vfio_dma_map() can't > map a dma region with

Re: [PATCH 1/1] vfio/type1: Add subdev_ioasid callback to vfio_iommu_driver_ops

2020-11-16 Thread Alex Williamson
On Thu, 12 Nov 2020 10:24:07 +0800 Lu Baolu wrote: > Add API for getting the ioasid of a subdevice (vfio/mdev). This calls > into the backend IOMMU module to get the actual value or error number > if ioasid for subdevice is not supported. The physical device driver > implementations which rely

Re: [PATCH] vfio iommu type1: Improve vfio_iommu_type1_pin_pages performance

2020-11-16 Thread Alex Williamson
On Mon, 16 Nov 2020 21:47:33 +0800 "xuxiaoyang (C)" wrote: > On 2020/11/14 0:44, Alex Williamson wrote: > > On Tue, 10 Nov 2020 21:42:33 +0800 > > "xuxiaoyang (C)" wrote: > > > >> vfio_iommu_type1_pin_pages is very inefficient beca

Re: [PATCH] vfio iommu type1: Improve vfio_iommu_type1_pin_pages performance

2020-11-13 Thread Alex Williamson
On Tue, 10 Nov 2020 21:42:33 +0800 "xuxiaoyang (C)" wrote: > vfio_iommu_type1_pin_pages is very inefficient because > it is processed page by page when calling vfio_pin_page_external. > Added contiguous_vaddr_get_pfn to process continuous pages > to reduce the number of loops, thereby improving

Re: [PATCH] vfio iommu type1: Improve vfio_iommu_type1_pin_pages performance

2020-11-11 Thread Alex Williamson
On Tue, 10 Nov 2020 21:42:33 +0800 "xuxiaoyang (C)" wrote: > vfio_iommu_type1_pin_pages is very inefficient because > it is processed page by page when calling vfio_pin_page_external. > Added contiguous_vaddr_get_pfn to process continuous pages > to reduce the number of loops, thereby improving

Re: [RFC, v0 1/3] vfio/platform: add support for msi

2020-11-09 Thread Alex Williamson
On Mon, 9 Nov 2020 12:11:15 +0530 Vikas Gupta wrote: > Hi Alex, > > On Fri, Nov 6, 2020 at 8:42 AM Alex Williamson > wrote: > > > > On Fri, 6 Nov 2020 08:24:26 +0530 > > Vikas Gupta wrote: > > > > > Hi Alex, > > > > > &g

Re: [PATCH 2/3] vfio/virqfd: Drain events from eventfd in virqfd_wakeup()

2020-11-06 Thread Alex Williamson
On Tue, 27 Oct 2020 13:55:22 + David Woodhouse wrote: > From: David Woodhouse > > Don't allow the events to accumulate in the eventfd counter, drain them > as they are handled. > > Signed-off-by: David Woodhouse > --- Acked-by: Alex Williamson Paolo, I assume yo

Re: [PATCH v2 1/2] sched/wait: Add add_wait_queue_priority()

2020-11-06 Thread Alex Williamson
On Fri, 6 Nov 2020 11:17:21 +0100 Paolo Bonzini wrote: > On 04/11/20 10:35, David Woodhouse wrote: > > On Wed, 2020-10-28 at 15:35 +0100, Peter Zijlstra wrote: > >> On Tue, Oct 27, 2020 at 02:39:43PM +, David Woodhouse wrote: > >>> From: David Woodhouse > >>> > >>> This allows an

Re: [RFC, v0 1/3] vfio/platform: add support for msi

2020-11-05 Thread Alex Williamson
On Fri, 6 Nov 2020 08:24:26 +0530 Vikas Gupta wrote: > Hi Alex, > > On Thu, Nov 5, 2020 at 12:38 PM Alex Williamson > wrote: > > > > On Thu, 5 Nov 2020 11:32:55 +0530 > > Vikas Gupta wrote: > > > > > diff --git a/include/uapi/linux/v

[GIT PULL] VFIO fixes for v5.10-rc3

2020-11-05 Thread Alex Williamson
) - fsl-mc static function declaration (Diana Craciun) - Fix ioeventfd sleeping under spinlock (Alex Williamson) - Fix pm reference count leak in vfio-platform (Zhang Qilong) - Allow opening IGD device w/o OpRegion support (Fred Gao

Re: [RFC, v0 1/3] vfio/platform: add support for msi

2020-11-04 Thread Alex Williamson
On Thu, 5 Nov 2020 11:32:55 +0530 Vikas Gupta wrote: > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > index 2f313a238a8f..aab051e8338d 100644 > --- a/include/uapi/linux/vfio.h > +++ b/include/uapi/linux/vfio.h > @@ -203,6 +203,7 @@ struct vfio_device_info { > #define

Re: [PATCH] vfio/fsl-mc: Make vfio_fsl_mc_irqs_allocate static

2020-11-03 Thread Alex Williamson
On Mon, 26 Oct 2020 18:53:36 +0200 Diana Craciun wrote: > Fixed compiler warning: > drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c:16:5: warning: no previous > prototype for function 'vfio_fsl_mc_irqs_allocate' [-Wmissing-prototypes] >^ > drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c:16:1: note:

Re: [PATCH 1/2] vfio/fsl-mc: return -EFAULT if copy_to_user() fails

2020-11-03 Thread Alex Williamson
On Fri, 23 Oct 2020 14:34:50 +0300 Dan Carpenter wrote: > The copy_to_user() function returns the number of bytes remaining to be > copied, but this code should return -EFAULT. > > Fixes: df747bcd5b21 ("vfio/fsl-mc: Implement VFIO_DEVICE_GET_REGION_INFO > ioctl call") > Signed-off-by: Dan

Re: [PATCH] vfio/type1: Use the new helper to find vfio_group

2020-11-03 Thread Alex Williamson
On Thu, 22 Oct 2020 20:24:17 +0800 Zenghui Yu wrote: > When attaching a new group to the container, let's use the new helper > vfio_iommu_find_iommu_group() to check if it's already attached. There > is no functional change. > > Also take this chance to add a missing blank line. > >

Re: [PATCH 1/2] vfio/fsl-mc: return -EFAULT if copy_to_user() fails

2020-11-02 Thread Alex Williamson
Thanks, Dan. Diana, can I get an ack for this? Thanks, Alex On Fri, 23 Oct 2020 14:34:50 +0300 Dan Carpenter wrote: > The copy_to_user() function returns the number of bytes remaining to be > copied, but this code should return -EFAULT. > > Fixes: df747bcd5b21 ("vfio/fsl-mc: Implement

Re: [PATCH 2/2] vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()

2020-11-02 Thread Alex Williamson
Hi Diana, same for this one. Thanks, Alex On Fri, 23 Oct 2020 14:29:47 +0300 Dan Carpenter wrote: > My static analsysis tool complains that the "index" can be negative. > There are some checks in do_mmap() which try to prevent underflows but > I don't know if they are sufficient for this

<    1   2   3   4   5   6   7   8   9   10   >