Re: [RFC PATCH] iommu/amd: fix a race in fetch_pte()

2020-04-07 Thread Qian Cai
> On Apr 6, 2020, at 10:12 PM, Qian Cai wrote: > > fetch_pte() could race with increase_address_space() because it held no > lock from iommu_unmap_page(). On the CPU that runs fetch_pte() it could > see a stale domain->pt_root and a new increased domain->mode from > increase_address_space().

[git pull] IOMMU Updates for Linux v5.7

2020-04-07 Thread Joerg Roedel
Hi Linus, The following changes since commit 16fbf79b0f83bc752cee8589279f1ebfe57b3b6e: Linux 5.6-rc7 (2020-03-22 18:31:56 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git tags/iommu-updates-v5.7 for you to fetch changes up to

Re: [PATCH v1 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free)

2020-04-07 Thread Alex Williamson
On Tue, 7 Apr 2020 04:42:02 + "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Friday, April 3, 2020 11:14 PM > > > > On Fri, 3 Apr 2020 05:58:55 + > > "Tian, Kevin" wrote: > > > > > > From: Alex Williamson > > > > Sent: Friday, April 3, 2020 1:50 AM > > > > > > > > On Sun,

Re: [PATCH 03/10] iommu/ioasid: Introduce per set allocation APIs

2020-04-07 Thread Jean-Philippe Brucker
On Mon, Apr 06, 2020 at 01:02:45PM -0700, Jacob Pan wrote: > > > + sdata = kzalloc(sizeof(*sdata), GFP_KERNEL); > > > + if (!sdata) > > > + return -ENOMEM; > > > > I don't understand why we need this structure at all, nor why we need > > the SID. Users have already allocated an

Re: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-07 Thread Alex Williamson
On Tue, 7 Apr 2020 04:26:23 + "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Saturday, April 4, 2020 1:26 AM > [...] > > > > > + if (!pasid_cap.control_reg.paside) { > > > > > + pr_debug("%s: its PF's PASID capability is not > > > > > enabled\n", > > > > > +

Re: [PATCH 05/10] iommu/ioasid: Create an IOASID set for host SVA use

2020-04-07 Thread Jean-Philippe Brucker
On Mon, Apr 06, 2020 at 08:33:53AM -0700, Jacob Pan wrote: > Hi Jean, > > On Wed, 1 Apr 2020 15:53:16 +0200 > Jean-Philippe Brucker wrote: > > > On Wed, Mar 25, 2020 at 10:55:26AM -0700, Jacob Pan wrote: > > > Bare metal SVA allocates IOASIDs for native process addresses. This > > > should be

RE: [PATCH v1 6/8] vfio/type1: Bind guest page tables to host

2020-04-07 Thread Liu, Yi L
Hi Jean, > From: Jean-Philippe Brucker < jean-phili...@linaro.org > > Sent: Friday, April 3, 2020 4:35 PM > Subject: Re: [PATCH v1 6/8] vfio/type1: Bind guest page tables to host > > On Thu, Apr 02, 2020 at 08:05:29AM +, Liu, Yi L wrote: > > > > > > static long vfio_iommu_type1_ioctl(void

Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device

2020-04-07 Thread Alexey Kardashevskiy
On 07/04/2020 03:17, Christoph Hellwig wrote: > On Mon, Apr 06, 2020 at 11:25:09PM +1000, Alexey Kardashevskiy wrote: Do you see any serious problem with this approach? Thanks! >>> >>> Do you have a link to the whole branch? The github UI is unfortunately >>> unusable for that (or I'm

RE: [PATCH v1 5/8] vfio/type1: Report 1st-level/stage-1 format to userspace

2020-04-07 Thread Liu, Yi L
Hi Jean, > From: Jean-Philippe Brucker > Sent: Friday, April 3, 2020 4:23 PM > To: Auger Eric > userspace > > On Wed, Apr 01, 2020 at 03:01:12PM +0200, Auger Eric wrote: > > >>> header = vfio_info_cap_add(caps, sizeof(*nesting_cap), > > >>>

[RFC PATCH 18/34] iommu/arm-smmu: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the arm-smmu and arm-smmu-v3 drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu-v3.c | 42

[RFC PATCH 30/34] iommu/omap: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the OMAP IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 49 ++ 1 file

[RFC PATCH 21/34] iommu/virtio: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the VirtIO IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/virtio-iommu.c | 41 +--- 1 file

[RFC PATCH 22/34] iommu/msm: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the MSM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/msm_iommu.c | 34 +++--- 1 file

[RFC PATCH 08/34] iommu: Move default domain allocation to iommu_probe_device()

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Well, not really. The call to iommu_alloc_default_domain() in iommu_group_get_for_dev() has to stay around as long as there are IOMMU drivers using the add/remove_device() call-backs instead of probe/release_device(). Those drivers expect that iommu_group_get_for_dev()

[RFC PATCH 28/34] iommu/renesas: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Renesas IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 60 +- 1

[RFC PATCH 10/34] iommu: Move new probe_device path to separate function

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel This makes it easier to remove to old code-path when all drivers are converted. As a side effect that it also fixes the error cleanup path. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 69 --- 1 file changed, 46

[RFC PATCH 13/34] iommu: Export bus_iommu_probe() and make is safe for re-probing

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Add a check to the bus_iommu_probe() call-path to make sure it ignores devices which have already been successfully probed. Then export the bus_iommu_probe() function so it can be used by IOMMU drivers. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 6 +-

[RFC PATCH 19/34] iommu/pamu: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the PAMU IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/fsl_pamu_domain.c | 22 +- 1 file changed, 5

[RFC PATCH 16/34] iommu/vt-d: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Intel IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 67 - 1 file

[RFC PATCH 34/34] iommu: Unexport iommu_group_get_for_dev()

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel The function is now only used in IOMMU core code and shouldn't be used outside of it anyway, so remove the export for it. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 4 ++-- include/linux/iommu.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff

[RFC PATCH 15/34] iommu/amd: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the AMD IOMMU Driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 71 --- 1 file

[RFC PATCH 32/34] iommu/exynos: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Exynos IOMMU drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/exynos-iommu.c | 23 ++- 1 file changed, 6

[RFC PATCH 26/34] iommu/rockchip: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Rockchip IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/rockchip-iommu.c | 26 +++--- 1 file

[RFC PATCH 14/34] iommu/amd: Remove dev_data->passthrough

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Make use of generic IOMMU infrastructure to gather the same information carried in dev_data->passthrough and remove the struct member. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 10 +- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed, 5

[RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel This is required to convert the arm-smmu driver to the probe/release_device() interface. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/arm-smmu.c

[RFC PATCH 05/34] iommu/amd: Remove dma_mask check from check_device()

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel The check was only needed for the DMA-API implementation in the AMD IOMMU driver, which no longer exists. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c

[RFC PATCH 11/34] iommu: Split off default domain allocation from group assignment

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel When a bus is initialized with iommu-ops, all devices on the bus are scanned and iommu-groups are allocated for them, and each groups will also get a default domain allocated. Until now this happened as soon as the group was created and the first device added to it. When

[RFC PATCH 12/34] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel After the previous changes the iommu group may not have a default domain when iommu_group_add_device() is called. With no default domain iommu_group_create_direct_mappings() will do nothing and no direct mappings will be created. Rename iommu_group_create_direct_mappings() to

[RFC PATCH 04/34] iommu/vt-d: Wire up iommu_ops->def_domain_type

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel The Intel VT-d driver already has a matching function to determine the default domain type for a device. Wire it up in intel_iommu_ops. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git

[RFC PATCH 31/34] iommu/exynos: Create iommu_device in struct exynos_iommu_owner

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel The 'struct exynos_iommu_owner' is an umbrella for multiple SYSMMU instances attached to one master. As such all these instances are handled the same, they are all configured with the same iommu_domain, for example. The IOMMU core code expects each device to have only one

[RFC PATCH 27/34] iommu/tegra: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Tegra IOMMU drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-gart.c | 24 ++--

[RFC PATCH 25/34] iommu/qcom: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the QCOM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 24 +++- 1 file changed, 7

[RFC PATCH 23/34] iommu/mediatek: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu.c | 24 ++-- 1 file changed, 6

[RFC PATCH 06/34] iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel When check_device() fails on the device, it is not handled by the IOMMU and amd_iommu_add_device() needs to return -ENODEV. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git

[RFC PATCH 20/34] iommu/s390: Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the S390 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/s390-iommu.c | 22 ++ 1 file changed, 6

[RFC PATCH 24/34] iommu/mediatek-v1 Convert to probe/release_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek-v1 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu_v1.c | 50 +++- 1

[RFC PATCH 07/34] iommu: Add probe_device() and remove_device() call-backs

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Add call-backs to 'struct iommu_ops' as an alternative to the add_device() and remove_device() call-backs, which will be removed when all drivers are converted. The new call-backs will not setupt IOMMU groups and domains anymore, so also add a probe_finalize() call-back where

[RFC PATCH 33/34] iommu: Remove add_device()/remove_device() code-paths

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel All drivers are converted to use the probe/release_device() call-backs, so the add_device/remove_device() pointers are unused and the code using them can be removed. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 145 --

[RFC PATCH 29/34] iommu/omap: Remove orphan_dev tracking

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Remove the tracking of device which could not be probed because their IOMMU is not probed yet. Replace it with a call to bus_iommu_probe() when a new IOMMU is probed. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 54 +++--- 1

[RFC PATCH 02/34] iommu: Add def_domain_type() callback in iommu_ops

2020-04-07 Thread Joerg Roedel
From: Sai Praneeth Prakhya Some devices are reqired to use a specific type (identity or dma) of default domain when they are used with a vendor iommu. When the system level default domain type is different from it, the vendor iommu driver has to request a new default domain with

[RFC PATCH 00/34] iommu: Move iommu_group setup to IOMMU core code

2020-04-07 Thread Joerg Roedel
Hi, here is a patch-set to remove all calls of iommu_group_get_for_dev() from the IOMMU drivers and move the per-device group setup and default domain allocation into the IOMMU core code. This eliminates some ugly back and forth between IOMMU core code and the IOMMU drivers, where the driver

[RFC PATCH 09/34] iommu: Keep a list of allocated groups in __iommu_probe_device()

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel This is needed to defer default_domain allocation for new IOMMU groups until all devices have been added to the group. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c

[RFC PATCH 01/34] iommu: Move default domain allocation to separate function

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Move the code out of iommu_group_get_for_dev() into a separate function. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 74 ++- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/iommu/iommu.c

[RFC PATCH 03/34] iommu/amd: Implement iommu_ops->def_domain_type call-back

2020-04-07 Thread Joerg Roedel
From: Joerg Roedel Implement the new def_domain_type call-back for the AMD IOMMU driver. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index

RE: [PATCH v1 5/8] vfio/type1: Report 1st-level/stage-1 format to userspace

2020-04-07 Thread Liu, Yi L
> From: Liu, Yi L > Sent: Tuesday, April 7, 2020 5:43 PM > > > We don't, the PASID spaces are per-VM on Arm, so this function should > > consult the IOMMU driver before setting flags. As you said on patch 3, > > nested doesn't necessarily imply PASID support. The SMMUv2 does not > > support PASID

RE: [PATCH v1 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free)

2020-04-07 Thread Liu, Yi L
Hi Alex, > From: Alex Williamson > Sent: Saturday, April 4, 2020 1:50 AM > Subject: Re: [PATCH v1 1/8] vfio: Add VFIO_IOMMU_PASID_REQUEST(alloc/free) > > On Fri, 3 Apr 2020 13:12:50 + > "Liu, Yi L" wrote: > > > Hi Alex, > > > > > From: Alex Williamson > > > Sent: Friday, April 3, 2020

RE: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-07 Thread Tian, Kevin
> From: Alex Williamson > Sent: Tuesday, April 7, 2020 11:58 PM > > On Tue, 7 Apr 2020 04:26:23 + > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Saturday, April 4, 2020 1:26 AM > > [...] > > > > > > + if (!pasid_cap.control_reg.paside) { > > > > > > +

RE: [PATCH v1 7/8] vfio/type1: Add VFIO_IOMMU_CACHE_INVALIDATE

2020-04-07 Thread Liu, Yi L
Hi Alex, > From: Alex Williamson > Sent: Friday, April 3, 2020 11:35 PM > Subject: Re: [PATCH v1 7/8] vfio/type1: Add VFIO_IOMMU_CACHE_INVALIDATE > > On Fri, 3 Apr 2020 06:39:22 + > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Friday, April 3, 2020 4:24 AM > > > > > >

Re: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-07 Thread Raj, Ashok
Hi Alex + Bjorn FWIW I can't understand why PCI SIG went different ways with ATS, where its enumerated on PF and VF. But for PASID and PRI its only in PF. I'm checking with our internal SIG reps to followup on that. On Tue, Apr 07, 2020 at 09:58:01AM -0600, Alex Williamson wrote: > > Is