Re: [PATCH v2] ACPI: VIOT: Fix ACS setup

2022-06-30 Thread Jean-Philippe Brucker
uce a new acpi_viot_early_init() > routine that allows to call pci_request_acs() before the scan. > > While at it, guard the call to pci_request_acs() with #ifdef > CONFIG_PCI. > > Fixes: 3cf485540e7b ("ACPI: Add driver for the VIOT table") > Signed-off-by: Eric Auger

Re: [PATCH] ACPI: VIOT: Fix ACS setup

2022-06-29 Thread Jean-Philippe Brucker
Hi Eric, On Mon, Jun 27, 2022 at 02:55:34PM +0200, Eric Auger wrote: > Currently acpi_viot_init() gets called after the pci > device has been scanned and pci_enable_acs() has been called. > So pci_request_acs() fails to be taken into account leading > to wrong single iommu group topologies when de

Re: [PATCH v9 10/11] iommu: Per-domain I/O page fault handling

2022-06-28 Thread Jean-Philippe Brucker
On Tue, Jun 28, 2022 at 07:53:39PM +0800, Baolu Lu wrote: > > > > Once the iopf_handle_single() is removed, the name of > > > > iopf_handle_group() looks a little weired > > > > > > > > and confused, does this group mean the iommu group (domain) ? > > > > while I take some minutes to > > > > > >

Re: [PATCH v9 10/11] iommu: Per-domain I/O page fault handling

2022-06-28 Thread Jean-Philippe Brucker
On Tue, Jun 28, 2022 at 08:39:36AM +, Tian, Kevin wrote: > > From: Lu Baolu > > Sent: Tuesday, June 21, 2022 10:44 PM > > > > Tweak the I/O page fault handling framework to route the page faults to > > the domain and call the page fault handler retrieved from the domain. > > This makes the I/

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-20 Thread Jean-Philippe Brucker
On Fri, Jun 17, 2022 at 10:23:13PM +0800, Zhangfei Gao wrote: > @@ -312,12 +345,20 @@ static ssize_t available_instances_show(struct device > *dev, >                 char *buf) >  { > struct uacce_device *uacce = to_uacce_device(dev); > +    ssize_t ret; > > -    if (!uacce->ops->get_ava

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-20 Thread Jean-Philippe Brucker
e the queue state to indicate whether it is usable or not. I think we just need to extend that to all ops. How about the following patch? Unfortunately it still has the lock disparity between ioctl and mmap because of the circular lockking with mmap_sem, I don't know how to make that cleaner.

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-16 Thread Jean-Philippe Brucker
On Thu, Jun 16, 2022 at 12:10:18PM +0800, Zhangfei Gao wrote: > > > diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c > > > index 281c54003edc..b6219c6bfb48 100644 > > > --- a/drivers/misc/uacce/uacce.c > > > +++ b/drivers/misc/uacce/uacce.c > > > @@ -136,9 +136,16 @@ static int

Re: [PATCH] uacce: fix concurrency of fops_open and uacce_remove

2022-06-15 Thread Jean-Philippe Brucker
Hi, On Fri, Jun 10, 2022 at 08:34:23PM +0800, Zhangfei Gao wrote: > The uacce parent's module can be removed when uacce is working, > which may cause troubles. > > If rmmod/uacce_remove happens just after fops_open: bind_queue, > the uacce_remove can not remove the bound queue since it is not > a

Re: [PATCH v7 03/10] iommu/sva: Add iommu_sva_domain support

2022-05-25 Thread Jean-Philippe Brucker
On Wed, May 25, 2022 at 11:07:49AM +0100, Robin Murphy wrote: > > Did you mean @handler and @handler_token staffs below? > > > > struct iommu_domain { > >     unsigned type; > >     const struct iommu_domain_ops *ops; > >     unsigned long pgsize_bitmap;    /* Bitmap of page sizes i

Re: [PATCH v7 06/10] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

2022-05-25 Thread Jean-Philippe Brucker
On Wed, May 25, 2022 at 02:04:49AM +, Tian, Kevin wrote: > > From: Jean-Philippe Brucker > > Sent: Tuesday, May 24, 2022 6:58 PM > > > > On Tue, May 24, 2022 at 10:22:28AM +, Tian, Kevin wrote: > > > > From: Lu Baolu > > > > Sent: Th

Re: [PATCH v7 06/10] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

2022-05-24 Thread Jean-Philippe Brucker
On Tue, May 24, 2022 at 10:22:28AM +, Tian, Kevin wrote: > > From: Lu Baolu > > Sent: Thursday, May 19, 2022 3:21 PM > > > > The existing iommu SVA interfaces are implemented by calling the SVA > > specific iommu ops provided by the IOMMU drivers. There's no need for > > any SVA specific ops

Re: [PATCH v7 06/10] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

2022-05-20 Thread Jean-Philippe Brucker
On Fri, May 20, 2022 at 02:38:12PM +0800, Baolu Lu wrote: > On 2022/5/20 00:39, Jean-Philippe Brucker wrote: > > > +struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct > > > mm_struct *mm) > > > +{ > > > + struct iommu_sva_domain *sva_doma

Re: [PATCH v7 08/10] iommu: Prepare IOMMU domain for IOPF

2022-05-19 Thread Jean-Philippe Brucker
could be further routed and > handled. > > This also prepares the SVA implementation to be the first consumer of > the per-domain page fault handling model. > > Suggested-by: Jean-Philippe Brucker > Signed-off-by: Lu Baolu > --- > include/linux/iommu.h | 3 ++ >

Re: [PATCH v7 06/10] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

2022-05-19 Thread Jean-Philippe Brucker
On Thu, May 19, 2022 at 03:20:43PM +0800, Lu Baolu wrote: > The existing iommu SVA interfaces are implemented by calling the SVA > specific iommu ops provided by the IOMMU drivers. There's no need for > any SVA specific ops in iommu_ops vector anymore as we can achieve > this through the generic at

Re: [PATCH v7 05/10] arm-smmu-v3/sva: Add SVA domain support

2022-05-19 Thread Jean-Philippe Brucker
On Thu, May 19, 2022 at 03:20:42PM +0800, Lu Baolu wrote: > Add support for domain ops callbacks for an SVA domain. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker (I'll try to take some time next cycle to clean up the driver following this change) > --- >

Re: [PATCH v7 03/10] iommu/sva: Add iommu_sva_domain support

2022-05-19 Thread Jean-Philippe Brucker
interfaces only apply to devices > belonging to the singleton groups, and the singleton is immutable in > fabric i.e. not affected by hotplug. > > The iommu_set/block_device_pasid() can be used for other purposes, > such as kernel DMA with pasid, mediation device, etc. Hence, it is

Re: [PATCH v7 02/10] iommu: Remove SVM_FLAG_SUPERVISOR_MODE support

2022-05-19 Thread Jean-Philippe Brucker
...@nvidia.com/ > Signed-off-by: Jacob Pan > Signed-off-by: Lu Baolu > Reviewed-by: Jason Gunthorpe For the SMMU bits Reviewed-by: Jean-Philippe Brucker > --- > include/linux/intel-iommu.h | 3 +- > include/linux/intel-svm.h | 13 - &

Re: [PATCH v7 01/10] iommu: Add pasids field in struct iommu_device

2022-05-19 Thread Jean-Philippe Brucker
Hi Baolu, On Thu, May 19, 2022 at 03:20:38PM +0800, Lu Baolu wrote: > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 88817a3376ef..6e2cd082c670 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/ar

Re: [PATCH v6 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-12 Thread Jean-Philippe Brucker
On Wed, May 11, 2022 at 09:02:40AM -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 08:54:39AM +0100, Jean-Philippe Brucker wrote: > > > > > Then 'detach pasid' is: > > > > > > > > > > iommu_ops->blocking_domain->ops->attac

Re: [PATCH v6 02/12] iommu: Add pasid_bits field in struct dev_iommu

2022-05-11 Thread Jean-Philippe Brucker
On Wed, May 11, 2022 at 10:25:48AM +0800, Baolu Lu wrote: > On 2022/5/10 22:34, Jason Gunthorpe wrote: > > On Tue, May 10, 2022 at 02:17:28PM +0800, Lu Baolu wrote: > > > > > int iommu_device_register(struct iommu_device *iommu, > > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > >

Re: [PATCH v6 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-11 Thread Jean-Philippe Brucker
On Wed, May 11, 2022 at 04:09:14AM +, Tian, Kevin wrote: > > From: Baolu Lu > > Sent: Wednesday, May 11, 2022 10:32 AM > > > > On 2022/5/10 22:02, Jason Gunthorpe wrote: > > > On Tue, May 10, 2022 at 02:17:29PM +0800, Lu Baolu wrote: > > > > > >> This adds a pair of common domain ops for this

Re: [PATCH v5 10/12] iommu: Prepare IOMMU domain for IOPF

2022-05-05 Thread Jean-Philippe Brucker
Hi Baolu, On Thu, May 05, 2022 at 04:31:38PM +0800, Baolu Lu wrote: > On 2022/5/4 02:20, Jean-Philippe Brucker wrote: > > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > > index 7cae631c1baa..33449523afbe 100644 > > > --- a/drivers/iommu/iommu.c >

Re: [PATCH v5 12/12] iommu: Rename iommu-sva-lib.{c,h}

2022-05-03 Thread Jean-Philippe Brucker
On Mon, May 02, 2022 at 09:48:42AM +0800, Lu Baolu wrote: > Rename iommu-sva-lib.c[h] to iommu-sva.c[h] as it contains all code > for SVA implementation in iommu core. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker > --- > drivers/iommu/{iommu-sva-lib.h =&

Re: [PATCH v5 11/12] iommu: Per-domain I/O page fault handling

2022-05-03 Thread Jean-Philippe Brucker
scenarios as long as they have an IOMMU domain and install a page > fault handler in it. Some unused functions are also removed to avoid > dead code. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker > --- > drivers/iommu/iommu-sva-lib.h | 1 - > d

Re: [PATCH v5 10/12] iommu: Prepare IOMMU domain for IOPF

2022-05-03 Thread Jean-Philippe Brucker
On Mon, May 02, 2022 at 09:48:40AM +0800, Lu Baolu wrote: > This adds some mechanisms around the iommu_domain so that the I/O page > fault handling framework could route a page fault to the domain and > call the fault handler from it. > > Add pointers to the page fault handler and its private data

Re: [PATCH v5 09/12] iommu: Remove SVA related callbacks from iommu ops

2022-05-03 Thread Jean-Philippe Brucker
On Mon, May 02, 2022 at 09:48:39AM +0800, Lu Baolu wrote: > These ops'es have been replaced with the dev_attach/detach_pasid domain > ops'es. There's no need for them anymore. Remove them to avoid dead > code. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Phili

Re: [PATCH v5 07/12] arm-smmu-v3/sva: Add SVA domain support

2022-05-03 Thread Jean-Philippe Brucker
On Mon, May 02, 2022 at 09:48:37AM +0800, Lu Baolu wrote: > Add support for SVA domain allocation and provide an SVA-specific > iommu_domain_ops. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 14 +++ > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 42 +

Re: [PATCH v5 04/12] iommu/sva: Basic data structures for SVA

2022-05-03 Thread Jean-Philippe Brucker
On Mon, May 02, 2022 at 09:48:34AM +0800, Lu Baolu wrote: > Use below data structures for SVA implementation in the IOMMU core: > > - struct iommu_sva_ioas > Represent the I/O address space shared with an application CPU address > space. This structure has a 1:1 relationship with an mm_struct.

Re: [PATCH v5 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-03 Thread Jean-Philippe Brucker
utable in fabric i.e. not affected by hotplug. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker just a nit below > --- > include/linux/iommu.h | 21 > drivers/iommu/iommu.c | 76 +++ > 2 files changed, 97 insert

Re: [PATCH v5 02/12] iommu: Add pasid_bits field in struct dev_iommu

2022-05-03 Thread Jean-Philippe Brucker
for PCI devices. So the status is > that non-PCI SVA hasn't been supported yet. Setting this field only for > PCI devices has no functional change. > > Signed-off-by: Lu Baolu Reviewed-by: Jean-Philippe Brucker > --- > include/linux/iommu.h | 1

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-05-03 Thread Jean-Philippe Brucker
On Sat, Apr 30, 2022 at 03:33:17PM +0800, Baolu Lu wrote: > Jean, another quick question about the iommu_sva_bind_device() > > /** > * iommu_sva_bind_device() - Bind a process address space to a device > * @dev: the device > * @mm: the mm to bind, caller must hold a reference to it > * @drvdat

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-29 Thread Jean-Philippe Brucker
On Fri, Apr 29, 2022 at 06:51:17AM -0700, Fenghua Yu wrote: > Hi, Baolu, > > On Fri, Apr 29, 2022 at 03:53:57PM +0800, Baolu Lu wrote: > > On 2022/4/28 16:39, Jean-Philippe Brucker wrote: > > > > The address space is what the OOM killer is after. That gets refcounted

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-28 Thread Jean-Philippe Brucker
On Thu, Apr 28, 2022 at 08:09:04AM -0700, Dave Hansen wrote: > On 4/25/22 21:20, Fenghua Yu wrote: > >>From 84aa68f6174439d863c40cdc2db0e1b89d620dd0 Mon Sep 17 00:00:00 2001 > > From: Fenghua Yu > > Date: Fri, 15 Apr 2022 00:51:33 -0700 > > Subject: [PATCH] iommu/sva: Fix PASID use-after-free issu

Re: [PATCH v4 11/12] iommu: Per-domain I/O page fault handling

2022-04-28 Thread Jean-Philippe Brucker
On Thu, Apr 21, 2022 at 01:21:20PM +0800, Lu Baolu wrote: > static void iopf_handle_group(struct work_struct *work) > { > struct iopf_group *group; > @@ -134,12 +78,23 @@ static void iopf_handle_group(struct work_struct *work) > group = container_of(work, struct iopf_group, work); >

Re: [PATCH v4 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-04-28 Thread Jean-Philippe Brucker
On Thu, Apr 21, 2022 at 01:21:12PM +0800, Lu Baolu wrote: > Attaching an IOMMU domain to a PASID of a device is a generic operation > for modern IOMMU drivers which support PASID-granular DMA address > translation. Currently visible usage scenarios include (but not limited): > > - SVA (Shared Vir

Re: [PATCH v4 10/12] iommu: Prepare IOMMU domain for IOPF

2022-04-28 Thread Jean-Philippe Brucker
Hi Baolu, On Thu, Apr 21, 2022 at 01:21:19PM +0800, Lu Baolu wrote: > +/* > + * Get the attached domain for asynchronous usage, for example the I/O > + * page fault handling framework. The caller get a reference counter > + * of the domain automatically on a successful return and should put > + *

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-28 Thread Jean-Philippe Brucker
drop() to track mm->mm_count. > > > __mmdrop() is called only after mm->mm_count is zero. So freeing the PASID > > > in __mmdrop() guarantees the PASID is safely freed only after no device > > > is bound to the mm. > > > > > > Fixes: 701fac40384f (&

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-28 Thread Jean-Philippe Brucker
On Tue, Apr 26, 2022 at 04:31:57PM -0700, Dave Hansen wrote: > On 4/26/22 09:48, Jean-Philippe Brucker wrote: > > On Tue, Apr 26, 2022 at 08:27:00AM -0700, Dave Hansen wrote: > >> On 4/25/22 09:40, Jean-Philippe Brucker wrote: > >>> The problem is that we'd h

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-26 Thread Jean-Philippe Brucker
On Tue, Apr 26, 2022 at 08:27:00AM -0700, Dave Hansen wrote: > On 4/25/22 09:40, Jean-Philippe Brucker wrote: > > The problem is that we'd have to request the device driver to stop DMA > > before we can destroy the context and free the PASID. We did consider > > doing

[PATCH v2] iommu/arm-smmu-v3-sva: Fix mm use-after-free

2022-04-26 Thread Jean-Philippe Brucker
f-by: Jean-Philippe Brucker --- v2: Add missing include --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 22

Re: [PATCH] iommu/arm-smmu-v3-sva: Fix mm use-after-free

2022-04-26 Thread Jean-Philippe Brucker
On Tue, Apr 26, 2022 at 08:20:52PM +0800, zhangfei@foxmail.com wrote: > Hi, Jean > > On 2022/4/26 下午6:04, Jean-Philippe Brucker wrote: > > We currently call arm64_mm_context_put() without holding a reference to > > the mm, which can result in use-after-free. Call

[PATCH] iommu/arm-smmu-v3-sva: Fix mm use-after-free

2022-04-26 Thread Jean-Philippe Brucker
f-by: Jean-Philippe Brucker --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 582114f94da0..c93477a2d7f1 10

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jean-Philippe Brucker
On Mon, Apr 25, 2022 at 08:55:46AM -0700, Dave Hansen wrote: > On 4/25/22 07:26, Jean-Philippe Brucker wrote: > >> > >> How does the IOMMU hardware know that all activity to a given PASID is > >> finished? That activity should, today, be independent of an mm or a

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jean-Philippe Brucker
Hi Jacob, On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: > Hi Jean-Philippe, > > On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker > wrote: > > > On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > > > On 4/25/22 06:53, Jean-Philip

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jean-Philippe Brucker
On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > On 4/25/22 06:53, Jean-Philippe Brucker wrote: > > On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com wrote: > >>>> On 5.17 > >>>> fops_release is called automatically, as well as

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jean-Philippe Brucker
On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com wrote: > > > On 5.17 > > > fops_release is called automatically, as well as iommu_sva_unbind_device. > > > On 5.18-rc1. > > > fops_release is not called, have to manually call close(fd) > > Right that's weird > Looks it is caused by

Re: Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-22 Thread Jean-Philippe Brucker
On Fri, Apr 22, 2022 at 09:15:01PM +0800, zhangfei@foxmail.com wrote: > > I'm trying to piece together what happens from the kernel point of view. > > > > * master process with mm A opens a queue fd through uacce, which calls > >iommu_sva_bind_device(dev, A) -> PASID 1 > > > > * master fo

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-22 Thread Jean-Philippe Brucker
On Fri, Apr 22, 2022 at 05:03:10PM +0800, zhangfei@foxmail.com wrote: [...] > > Have tested, still got some issue with our openssl-engine. > > > > 1. If openssl-engine does not register rsa, nginx works well. > > > > 2. If openssl-engine register rsa, nginx also works, but ioasid is not > > f

Re: [PATCH 12/13] iommu/virtio: Clean up bus_set_iommu()

2022-04-21 Thread Jean-Philippe Brucker
r_fmt(fmt) KBUILD_MODNAME ": " fmt > > -#include > #include > #include > #include isn't needed anymore either. In any case it looks great, thanks Reviewed-by: Jean-Philippe Brucker and tested on QEMU (so only PCI for now) > @@ -1146,26 +1145,6 @@ static int

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-20 Thread Jean-Philippe Brucker
d. There used to be an mmgrab() preventing this but it went away during a rewrite. To fix both we could just move mmput() at the end of unbind() but I'd rather do a proper cleanup removing the release() notifier right away. Zhangfei, could you try the patch below? Thanks, Jean --- 8< ---

Re: [PATCH] iommu/arm-smmu-v3: Fix size calculation in arm_smmu_mm_invalidate_range()

2022-04-20 Thread Jean-Philippe Brucker
est platforms didn't support range invalidation, so __arm_smmu_tlb_inv_range() would always use PAGE_SIZE as increment. Reviewed-by: Jean-Philippe Brucker > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) >

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-12 Thread Jean-Philippe Brucker
Hi, On Tue, Apr 12, 2022 at 07:36:21AM -0700, Dave Hansen wrote: > On 4/12/22 00:04, zhangfei@foxmail.com wrote: > > master process quit, mmput ->  mm_pasid_drop->ioasid_free > > But this ignore driver's iommu_sva_unbind_device function, > > iommu_sva_bind_device and iommu_sva_unbind_device ar

Re: [PATCH RFC 10/11] iommu: Make IOPF handling framework generic

2022-03-22 Thread Jean-Philippe Brucker
On Tue, Mar 22, 2022 at 10:24:26AM +, Tian, Kevin wrote: > > From: Jean-Philippe Brucker > > Sent: Tuesday, March 22, 2022 6:06 PM > > > > On Tue, Mar 22, 2022 at 01:00:08AM +, Tian, Kevin wrote: > > > > From: Jean-Philippe Brucker > >

Re: [PATCH RFC 10/11] iommu: Make IOPF handling framework generic

2022-03-22 Thread Jean-Philippe Brucker
On Tue, Mar 22, 2022 at 01:00:08AM +, Tian, Kevin wrote: > > From: Jean-Philippe Brucker > > Sent: Monday, March 21, 2022 7:42 PM > > > > Hi Kevin, > > > > On Mon, Mar 21, 2022 at 08:09:36AM +, Tian, Kevin wrote: > > > > From: Lu Bao

Re: [PATCH RFC 10/11] iommu: Make IOPF handling framework generic

2022-03-22 Thread Jean-Philippe Brucker
On Tue, Mar 22, 2022 at 01:03:14PM +0800, Lu Baolu wrote: > On 2022/3/21 20:43, Jason Gunthorpe wrote: > > On Mon, Mar 21, 2022 at 11:42:16AM +0000, Jean-Philippe Brucker wrote: > > > > > I tend to disagree with that last part. The fault is caused by a specific > >

Re: [PATCH RFC 10/11] iommu: Make IOPF handling framework generic

2022-03-21 Thread Jean-Philippe Brucker
Hi Kevin, On Mon, Mar 21, 2022 at 08:09:36AM +, Tian, Kevin wrote: > > From: Lu Baolu > > Sent: Sunday, March 20, 2022 2:40 PM > > > > The existing IOPF handling framework only handles the I/O page faults for > > SVA. Ginven that we are able to link iommu domain with each I/O page fault, > >

Re: [PATCH RFC 10/11] iommu: Make IOPF handling framework generic

2022-03-21 Thread Jean-Philippe Brucker
On Sun, Mar 20, 2022 at 02:40:29PM +0800, Lu Baolu wrote: > The existing IOPF handling framework only handles the I/O page faults for > SVA. Ginven that we are able to link iommu domain with each I/O page fault, > we can now make the I/O page fault handling framework more general for > more types o

Re: [PATCH RFC 08/11] iommu: Handle IO page faults directly

2022-03-21 Thread Jean-Philippe Brucker
On Sun, Mar 20, 2022 at 02:40:27PM +0800, Lu Baolu wrote: > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index c0966fc9b686..4f90b71c6f6e 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -27,6 +27,8 @@ > #include > #include > > +#include "iommu-sva-lib.h

Re: [PATCH RFC 06/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-21 Thread Jean-Philippe Brucker
On Sun, Mar 20, 2022 at 02:40:25PM +0800, Lu Baolu wrote: > diff --git a/drivers/iommu/iommu-sva-lib.c b/drivers/iommu/iommu-sva-lib.c > index 106506143896..47cf98e661ff 100644 > --- a/drivers/iommu/iommu-sva-lib.c > +++ b/drivers/iommu/iommu-sva-lib.c > @@ -3,6 +3,8 @@ > * Helpers for IOMMU driv

Re: [PATCH RFC 05/11] arm-smmu-v3/sva: Add SVA domain support

2022-03-21 Thread Jean-Philippe Brucker
On Sun, Mar 20, 2022 at 02:40:24PM +0800, Lu Baolu wrote: > Add support for SVA domain allocation and provide an SVA-specific > iommu_domain_ops. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 14 ++ > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 45 ++

Re: [PATCH RFC 01/11] iommu: Add pasid_bits field in struct dev_iommu

2022-03-21 Thread Jean-Philippe Brucker
Hi Baolu, On Sun, Mar 20, 2022 at 02:40:20PM +0800, Lu Baolu wrote: > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 627a3ed5ee8f..8e262210b5ad 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/ar

Re: [PATCH v2 8/8] iommu: Remove unused driver data in sva_bind_device

2022-03-15 Thread Jean-Philippe Brucker
On Mon, Mar 14, 2022 at 10:07:12PM -0700, Jacob Pan wrote: > No one is using drvdata for sva_bind_device after kernel SVA support is > removed from VT-d driver. Remove the drvdata parameter as well. > > Signed-off-by: Jacob Pan Reviewed-by: Jean-Philippe Brucker > --- >

Re: [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops

2022-03-15 Thread Jean-Philippe Brucker
On Mon, Mar 14, 2022 at 10:07:06PM -0700, Jacob Pan wrote: > From: Lu Baolu > > An IOMMU domain represents an address space which can be attached by > devices that perform DMA within a domain. However, for platforms with > PASID capability the domain attachment needs be handled at device+PASID >

Re: [PATCH 7/7] iommu: Add iommu_domain::domain_ops

2022-01-26 Thread Jean-Philippe Brucker
On Mon, Jan 24, 2022 at 12:33:02PM -0400, Jason Gunthorpe wrote: > On Mon, Jan 24, 2022 at 10:16:07AM +0000, Jean-Philippe Brucker wrote: > > On Mon, Jan 24, 2022 at 09:58:18AM +, Tian, Kevin wrote: > > > > From: Lu Baolu > > > > Sent:

Re: [PATCH 7/7] iommu: Add iommu_domain::domain_ops

2022-01-24 Thread Jean-Philippe Brucker
On Mon, Jan 24, 2022 at 09:58:18AM +, Tian, Kevin wrote: > > From: Lu Baolu > > Sent: Monday, January 24, 2022 3:11 PM > > +/** > > + * struct domain_ops - per-domain ops > > + * @attach_dev: attach an iommu domain to a device > > + * @detach_dev: detach an iommu domain from a device > > What

Re: [PATCH 1/2] dt-bindings: Add Arm SMMUv3 PMCG binding

2021-12-10 Thread Jean-Philippe Brucker
On Thu, Nov 18, 2021 at 03:50:54PM +, Robin Murphy wrote: > > > + An SMMUv3 may have several Performance Monitor Counter Group (PMCG). > > > + They are standalone performance monitoring units that support both > > > + architected and IMPLEMENTATION DEFINED event counters. > > > > Humm, I do

Re: [PATCH] iommu/arm-smmu-v3: Constify arm_smmu_mmu_notifier_ops

2021-12-10 Thread Jean-Philippe Brucker
> in read-only memory. > > Signed-off-by: Rikard Falkeborn Reviewed-by: Jean-Philippe Brucker > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c

Re: [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA

2021-12-10 Thread Jean-Philippe Brucker
On Thu, Dec 09, 2021 at 10:14:04AM -0800, Jacob Pan wrote: > > This looks like we're just one step away from device drivers needing > > multiple PASIDs for kernel DMA so I'm trying to figure out how to evolve > > the API towards that. It's probably as simple as keeping a kernel IOASID > > set at fi

Re: [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA

2021-12-09 Thread Jean-Philippe Brucker
Hi Jacob, On Tue, Dec 07, 2021 at 05:47:11AM -0800, Jacob Pan wrote: > In-kernel DMA is managed by DMA mapping APIs, which supports per device > addressing mode for legacy DMA requests. With the introduction of > Process Address Space ID (PASID), device DMA can now target at a finer > granularity

Re: [RFC v16 1/9] iommu: Introduce attach/detach_pasid_table API

2021-12-08 Thread Jean-Philippe Brucker
On Wed, Dec 08, 2021 at 08:56:16AM -0400, Jason Gunthorpe wrote: > From a progress perspective I would like to start with simple 'page > tables in userspace', ie no PASID in this step. > > 'page tables in userspace' means an iommufd ioctl to create an > iommu_domain where the IOMMU HW is directly

[PATCH v3 2/5] iommu/virtio: Support bypass domains

2021-12-01 Thread Jean-Philippe Brucker
identity mappings in this case. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 80930ce04a16

[PATCH v3 3/5] iommu/virtio: Sort reserved regions

2021-12-01 Thread Jean-Philippe Brucker
To ease identity mapping support, keep the list of reserved regions sorted. Reviewed-by: Eric Auger Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/virtio

[PATCH v3 4/5] iommu/virtio: Pass end address to viommu_add_mapping()

2021-12-01 Thread Jean-Philippe Brucker
size will most certainly be smaller than 2^64. Reviewed-by: Eric Auger Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/virtio

[PATCH v3 1/5] iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG

2021-12-01 Thread Jean-Philippe Brucker
Add definitions for the VIRTIO_IOMMU_F_BYPASS_CONFIG, which supersedes VIRTIO_IOMMU_F_BYPASS. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- include/uapi/linux/virtio_iommu.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux

[PATCH v3 5/5] iommu/virtio: Support identity-mapped domains

2021-12-01 Thread Jean-Philippe Brucker
evice itself to only perform DMA to suitable locations. In some cases it may even be desirable to perform DMA to MMIO regions. Reviewed-by: Eric Auger Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 61 +--- 1

[PATCH v3 0/5] iommu/virtio: Add identity domains

2021-12-01 Thread Jean-Philippe Brucker
/?h=virtio-iommu/bypass Jean-Philippe Brucker (5): iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG iommu/virtio: Support bypass domains iommu/virtio: Sort reserved regions iommu/virtio: Pass end address to viommu_add_mapping() iommu/virtio: Support identity-mapped domains

Re: [PATCH v2 5/5] iommu/virtio: Support identity-mapped domains

2021-11-29 Thread Jean-Philippe Brucker
On Sat, Nov 27, 2021 at 06:09:56PM +0100, Eric Auger wrote: > > - vdomain->viommu = 0; > > + vdomain->viommu = NULL; > nit: that change could have been done in patch 2 Ah yes, I changed that in v2 but fixed up the wrong patch > > return -EOP

Re: [PATCH v2 4/5] iommu/virtio: Pass end address to viommu_add_mapping()

2021-11-29 Thread Jean-Philippe Brucker
On Sat, Nov 27, 2021 at 06:09:56PM -0500, Michael S. Tsirkin wrote: > > > -static int viommu_add_mapping(struct viommu_domain *vdomain, unsigned > > > long iova, > > > - phys_addr_t paddr, size_t size, u32 flags) > > > +static int viommu_add_mapping(struct viommu_domain *vdom

Re: [PATCH v2 2/5] iommu/virtio: Support bypass domains

2021-11-29 Thread Jean-Philippe Brucker
On Sat, Nov 27, 2021 at 05:18:28PM +0100, Eric Auger wrote: > Hi Jean, > > On 11/23/21 4:52 PM, Jean-Philippe Brucker wrote: > > The VIRTIO_IOMMU_F_BYPASS_CONFIG feature adds a new flag to the ATTACH > > request, that creates a bypass domain. Use it to enable identity >

Re: [PATCH v2 1/5] iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG

2021-11-29 Thread Jean-Philippe Brucker
Hi Eric, On Sat, Nov 27, 2021 at 08:59:25AM +0100, Eric Auger wrote: > > @@ -36,6 +37,8 @@ struct virtio_iommu_config { > > struct virtio_iommu_range_32domain_range; > > /* Probe buffer size */ > > __le32 probe_size; > > + __u8

[PATCH v2 4/5] iommu/virtio: Pass end address to viommu_add_mapping()

2021-11-23 Thread Jean-Philippe Brucker
size will most certainly be smaller than 2^64. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio

[PATCH v2 5/5] iommu/virtio: Support identity-mapped domains

2021-11-23 Thread Jean-Philippe Brucker
evice itself to only perform DMA to suitable locations. In some cases it may even be desirable to perform DMA to MMIO regions. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 63 +--- 1 file changed, 58 insertions(

[PATCH v2 3/5] iommu/virtio: Sort reserved regions

2021-11-23 Thread Jean-Philippe Brucker
To ease identity mapping support, keep the list of reserved regions sorted. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu

[PATCH v2 2/5] iommu/virtio: Support bypass domains

2021-11-23 Thread Jean-Philippe Brucker
identity mappings in this case. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/virtio-iommu.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 80930ce04a16

[PATCH v2 1/5] iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG

2021-11-23 Thread Jean-Philippe Brucker
Add definitions for the VIRTIO_IOMMU_F_BYPASS_CONFIG, which supersedes VIRTIO_IOMMU_F_BYPASS. Reviewed-by: Kevin Tian Signed-off-by: Jean-Philippe Brucker --- include/uapi/linux/virtio_iommu.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux

[PATCH v2 0/5] iommu/virtio: Add identity domains

2021-11-23 Thread Jean-Philippe Brucker
r.net/git/qemu/log/?h=virtio-iommu/bypass Jean-Philippe Brucker (5): iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG iommu/virtio: Support bypass domains iommu/virtio: Sort reserved regions iommu/virtio: Pass end address to viommu_add_mapping() iommu/virtio: Support identity-m

[PATCH v2 3/3] perf/smmuv3: Synthesize IIDR from CoreSight ID registers

2021-11-17 Thread Jean-Philippe Brucker
Signed-off-by: Jean-Philippe Brucker --- drivers/perf/arm_smmuv3_pmu.c | 55 ++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 19697617153a..598d6978280d 100644 --- a/drivers/perf

[PATCH v2 2/3] perf/smmuv3: Add devicetree support

2021-11-17 Thread Jean-Philippe Brucker
Add device-tree support to the SMMUv3 PMCG driver. Signed-off-by: Jay Chen Signed-off-by: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- drivers/perf/arm_smmuv3_pmu.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers

[PATCH v2 1/3] dt-bindings: Add Arm SMMUv3 PMCG binding

2021-11-17 Thread Jean-Philippe Brucker
each TBU). Signed-off-by: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- .../bindings/perf/arm,smmu-v3-pmcg.yaml | 70 +++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/arm,smmu-v3-pmcg.yaml diff --git a/Documentation

[PATCH v2 0/3] perf/smmuv3: Support devicetree

2021-11-17 Thread Jean-Philippe Brucker
more common across the tree.) [1] https://lore.kernel.org/linux-iommu/2026113536.69758-1-jean-phili...@linaro.org/ Jean-Philippe Brucker (2): dt-bindings: Add Arm SMMUv3 PMCG binding perf/smmuv3: Add devicetree support Robin Murphy (1): perf/smmuv3: Synthesize IIDR from CoreSight ID regi

Re: [PATCH 0/2] perf/smmuv3: Support devicetree

2021-11-16 Thread Jean-Philippe Brucker
On Tue, Nov 16, 2021 at 05:00:14PM +, Robin Murphy wrote: > On 2021-11-16 15:42, Jean-Philippe Brucker wrote: > > On Tue, Nov 16, 2021 at 12:02:47PM +, Robin Murphy wrote: > > > On 2021-11-16 11:35, Jean-Philippe Brucker wrote: > > > > Add devicetree bind

Re: [PATCH 1/2] dt-bindings: Add Arm SMMUv3 PMCG binding

2021-11-16 Thread Jean-Philippe Brucker
On Tue, Nov 16, 2021 at 08:02:53AM -0600, Rob Herring wrote: > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' > on your patch (DT_CHECKER_FLAGS is new in v5.13): > > yamllint warnings/errors: > ./Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml:24:9: > [warni

Re: [PATCH 2/2] perf/smmuv3: Add devicetree support

2021-11-16 Thread Jean-Philippe Brucker
On Tue, Nov 16, 2021 at 12:06:36PM +, John Garry wrote: > On 16/11/2021 11:35, Jean-Philippe Brucker wrote: > > Add device-tree support to the SMMUv3 PMCG. One small cosmetic change > > while factoring the option mask printout: don't display it when zero, it > > on

Re: [PATCH 0/2] perf/smmuv3: Support devicetree

2021-11-16 Thread Jean-Philippe Brucker
On Tue, Nov 16, 2021 at 12:02:47PM +, Robin Murphy wrote: > On 2021-11-16 11:35, Jean-Philippe Brucker wrote: > > Add devicetree binding for the SMMUv3 PMU, called Performance Monitoring > > Counter Group (PMCG) in the spec. Each SMMUv3 implementation can have > > multi

[PATCH 1/2] dt-bindings: Add Arm SMMUv3 PMCG binding

2021-11-16 Thread Jean-Philippe Brucker
each TBU). Signed-off-by: Jean-Philippe Brucker --- .../bindings/iommu/arm,smmu-v3-pmcg.yaml | 67 +++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml diff --git a/Documentation/devicetree/bindings/iommu/arm

[PATCH 0/2] perf/smmuv3: Support devicetree

2021-11-16 Thread Jean-Philippe Brucker
itoring-Unit [3] https://jpbrucker.net/git/linux/log/?h=smmu/pmu-dt Jean-Philippe Brucker (2): dt-bindings: Add Arm SMMUv3 PMCG binding perf/smmuv3: Add devicetree support .../bindings/iommu/arm,smmu-v3-pmcg.yaml | 67 +++ drivers/perf/arm_smmuv3_pmu.c

[PATCH 2/2] perf/smmuv3: Add devicetree support

2021-11-16 Thread Jean-Philippe Brucker
Add device-tree support to the SMMUv3 PMCG. One small cosmetic change while factoring the option mask printout: don't display it when zero, it only contains one erratum at the moment. Signed-off-by: Jay Chen Signed-off-by: Jean-Philippe Brucker --- drivers/perf/arm_smmuv3_pmu.c

Re: [PATCH 0/5] iommu/virtio: Add identity domains

2021-10-22 Thread Jean-Philippe Brucker
On Fri, Oct 22, 2021 at 06:16:27AM -0400, Michael S. Tsirkin wrote: > On Wed, Oct 13, 2021 at 01:10:48PM +0100, Jean-Philippe Brucker wrote: > > Support identity domains, allowing to only enable IOMMU protection for a > > subset of endpoints (those assigned to userspace, for

Re: [RFC 10/20] iommu/iommufd: Add IOMMU_DEVICE_GET_INFO

2021-10-22 Thread Jean-Philippe Brucker
On Thu, Oct 21, 2021 at 08:22:23PM -0300, Jason Gunthorpe wrote: > On Thu, Oct 21, 2021 at 03:58:02PM +0100, Jean-Philippe Brucker wrote: > > On Thu, Oct 21, 2021 at 02:26:00AM +, Tian, Kevin wrote: > > > > I'll leave it to Jean to confirm. If only coherent DMA can be

Re: [RFC 10/20] iommu/iommufd: Add IOMMU_DEVICE_GET_INFO

2021-10-21 Thread Jean-Philippe Brucker
On Thu, Oct 21, 2021 at 02:26:00AM +, Tian, Kevin wrote: > > I'll leave it to Jean to confirm. If only coherent DMA can be used in > > the guest on other platforms, suppose VFIO should not blindly set > > IOMMU_CACHE and in concept it should deny assigning a non-coherent > > device since no co-

  1   2   3   4   5   6   7   8   9   10   >