[PATCH v4 11/13] vfio: Remove iommu group notifier

2021-12-16 Thread Lu Baolu
-by: Lu Baolu --- drivers/vfio/vfio.c | 147 1 file changed, 147 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 6426b29e73a2..539f5da9eb34 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -71,7 +71,6 @@ struct

[PATCH v4 09/13] vfio: Remove use of vfio_group_viable()

2021-12-16 Thread Lu Baolu
The only remaining reference is in GROUP_GET_STATUS, which could be called at any time when group fd is valid. Here we just replace the vfio_group_viable() by directly calling iommu core to get viability status. Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 18 ++ 1 file c

[PATCH v4 10/13] vfio: Delete the unbound_list

2021-12-16 Thread Lu Baolu
_group_dev() returns, so simply delete the unbound_list entirely. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 74 ++--- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/d

[PATCH v4 08/13] vfio: Set DMA USER ownership for VFIO devices

2021-12-16 Thread Lu Baolu
Set DMA_OWNER_PRIVATE_DOMAIN_USER when an iommu group is set to a container, and release DMA_OWNER_USER once the iommu group is unset from a container. Signed-off-by: Lu Baolu --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 + drivers/vfio/pci/vfio_pci.c | 3 +++ drivers/vfio/platform

[PATCH v4 07/13] iommu: Add iommu_at[de]tach_device_shared() for multi-device groups

2021-12-16 Thread Lu Baolu
n multiple drivers sharing the group claim the DMA_OWNER_PRIVATE_DOMAIN ownership. The first call of iommu_attach_device_shared() attaches the domain to the group. Other drivers could join it later. The domain will be detached from the group after all drivers unjoin it. Signed-off-by: Jason Gunthorp

[PATCH v4 06/13] iommu: Expose group variants of dma ownership interfaces

2021-12-16 Thread Lu Baolu
is viable to user assignment for compatibility with VFIO_GROUP_FLAGS_VIABLE. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 21 +++ drivers/iommu/iommu.c | 47 ++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/include

[PATCH v4 05/13] iommu: Add security context management for assigned devices

2021-12-16 Thread Lu Baolu
controlled iommu_domain. Correspondingly, the default domain should be reattached after the last DMA_OWNER_USER is released. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 35 --- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/iommu

[PATCH v4 04/13] PCI: portdrv: Suppress kernel DMA ownership auto-claiming

2021-12-16 Thread Lu Baolu
Suggested-by: Kevin Tian Signed-off-by: Lu Baolu --- drivers/pci/pcie/portdrv_pci.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 35eca6277a96..c48a8734f9c4 100644 --- a/drivers/pci/pcie/portdrv_p

[PATCH v4 03/13] PCI: pci_stub: Suppress kernel DMA ownership auto-claiming

2021-12-16 Thread Lu Baolu
the DMA ownership to vfio. Signed-off-by: Lu Baolu --- drivers/pci/pci-stub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index e408099fea52..6324c68602b4 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -36,6 +36,9

[PATCH v4 02/13] driver core: Set DMA ownership during driver bind/unbind

2021-12-16 Thread Lu Baolu
to userspace. Suggested-by: Jason Gunthorpe Link: https://lore.kernel.org/linux-iommu/20210922123931.gi327...@nvidia.com/ Link: https://lore.kernel.org/linux-iommu/20210928115751.gk964...@nvidia.com/ Signed-off-by: Lu Baolu --- include/linux/device/driver.h | 2 ++ drivers/base/dd.c

[PATCH v4 01/13] iommu: Add device dma ownership set/release interfaces

2021-12-16 Thread Lu Baolu
ted by multiple users simultaneously. Vice versa, the owner type should be released after the user access permission is withdrawn. Signed-off-by: Jason Gunthorpe Signed-off-by: Kevin Tian Signed-off-by: Lu Baolu --- include/linux/iommu.h | 34 drivers/iommu/iommu.c |

[PATCH v4 00/13] Fix BUG_ON in vfio_iommu_group_notifier()

2021-12-16 Thread Lu Baolu
com/LuBaolu/intel-iommu/commits/iommu-dma-ownership-v4 Merry Christmas to you all! Best regards, baolu Jason Gunthorpe (2): vfio: Delete the unbound_list drm/tegra: Use the iommu dma_owner mechanism Lu Baolu (11): iommu: Add device dma ownership set/release interfaces driver core: Set DMA

[PATCH 1/1] iommu/vt-d: Remove unused macros

2021-12-15 Thread Lu Baolu
These macros has no reference in the tree anymore. Cleanup them. Signed-off-by: Lu Baolu --- include/linux/intel-svm.h | 6 -- 1 file changed, 6 deletions(-) diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h index 57cceecbe37f..1b73bab7eeff 100644 --- a/include/linux/intel

Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-15 Thread Lu Baolu
Hi Greg, On 2021/12/13 8:50, Lu Baolu wrote: On 12/10/21 9:23 AM, Lu Baolu wrote: Hi Greg, Jason and Christoph, On 12/9/21 9:20 AM, Lu Baolu wrote: On 12/7/21 9:16 PM, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 10:57:25AM +0800, Lu Baolu wrote: On 12/6/21 11:06 PM, Jason Gunthorpe

Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-12 Thread Lu Baolu
On 12/10/21 9:23 AM, Lu Baolu wrote: Hi Greg, Jason and Christoph, On 12/9/21 9:20 AM, Lu Baolu wrote: On 12/7/21 9:16 PM, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 10:57:25AM +0800, Lu Baolu wrote: On 12/6/21 11:06 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 06:36:27AM -0800

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-09 Thread Lu Baolu
On 2021/12/10 7:21, Jacob Pan wrote: On Thu, 9 Dec 2021 10:32:43 +0800, Lu Baolu wrote: On 12/9/21 3:16 AM, Jacob Pan wrote: Hi Jason, On Wed, 8 Dec 2021 09:22:55 -0400, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 05:47:13AM -0800, Jacob Pan wrote: Between DMA requests with and without

Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-09 Thread Lu Baolu
Hi Greg, Jason and Christoph, On 12/9/21 9:20 AM, Lu Baolu wrote: On 12/7/21 9:16 PM, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 10:57:25AM +0800, Lu Baolu wrote: On 12/6/21 11:06 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 06:36:27AM -0800, Christoph Hellwig wrote: I really hate

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-08 Thread Lu Baolu
On 12/9/21 3:16 AM, Jacob Pan wrote: Hi Jason, On Wed, 8 Dec 2021 09:22:55 -0400, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 05:47:13AM -0800, Jacob Pan wrote: Between DMA requests with and without PASID (legacy), DMA mapping APIs are used indiscriminately on a device. Therefore, we

Re: [PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-08 Thread Lu Baolu
On 12/9/21 9:56 AM, Tian, Kevin wrote: From: Jacob Pan Sent: Thursday, December 9, 2021 2:50 AM Can a device issue DMA requests with PASID even there's no system IOMMU or the system IOMMU is disabled? Good point. If IOMMU is not enabled, device cannot issue DMA requests with PASID. This

Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-08 Thread Lu Baolu
On 12/7/21 9:16 PM, Jason Gunthorpe wrote: On Tue, Dec 07, 2021 at 10:57:25AM +0800, Lu Baolu wrote: On 12/6/21 11:06 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 06:36:27AM -0800, Christoph Hellwig wrote: I really hate the amount of boilerplate code that having this in each bus type

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

2021-12-07 Thread Lu Baolu
Hi Eric, On 12/7/21 6:22 PM, Eric Auger wrote: On 12/6/21 11:48 AM, Joerg Roedel wrote: On Wed, Oct 27, 2021 at 12:44:20PM +0200, Eric Auger wrote: Signed-off-by: Jean-Philippe Brucker Signed-off-by: Liu, Yi L Signed-off-by: Ashok Raj Signed-off-by: Jacob Pan Signed-off-by: Eric Auger This

Re: [PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-07 Thread Lu Baolu
Hi Jacob, On 12/7/21 9:47 PM, Jacob Pan wrote: DMA mapping API is the de facto standard for in-kernel DMA. It operates on a per device/RID basis which is not PASID-aware. Some modern devices such as Intel Data Streaming Accelerator, PASID is required for certain work submissions. To allow such

Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-06 Thread Lu Baolu
On 12/6/21 11:06 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 06:36:27AM -0800, Christoph Hellwig wrote: I really hate the amount of boilerplate code that having this in each bus type causes. +1 I liked the first version of this series better with the code near really_probe(). Can we

Re: [PATCH v3 18/18] drm/tegra: Use the iommu dma_owner mechanism

2021-12-06 Thread Lu Baolu
On 12/6/21 8:40 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 09:59:03AM +0800, Lu Baolu wrote: @@ -941,48 +944,44 @@ int host1x_client_iommu_attach(struct host1x_client *client) * not the shared IOMMU domain, don't try to attach it to a different * domain. This allows

Re: [PATCH v3 12/18] iommu: Add iommu_at[de]tach_device_shared() for multi-device groups

2021-12-06 Thread Lu Baolu
On 12/6/21 10:43 PM, Christoph Hellwig wrote: The new helpers really could use a kerneldoc comment. Also no need for the refcount_t with it's atomic operations for attach_cnt either. Yes. Agreed. Best regards, baolu ___ iommu mailing list

Re: [PATCH v3 01/18] iommu: Add device dma ownership set/release interfaces

2021-12-06 Thread Lu Baolu
On 12/6/21 10:42 PM, Christoph Hellwig wrote: On Mon, Dec 06, 2021 at 09:58:46AM +0800, Lu Baolu wrote: >From the perspective of who is initiating the device to do DMA, device DMA could be divided into the following types: DMA_OWNER_DMA_API: Device DMAs are initiated by a ker

Re: [PATCH v3 01/18] iommu: Add device dma ownership set/release interfaces

2021-12-06 Thread Lu Baolu
On 12/6/21 11:01 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 02:35:55PM +0100, Joerg Roedel wrote: On Mon, Dec 06, 2021 at 09:58:46AM +0800, Lu Baolu wrote: >From the perspective of who is initiating the device to do DMA, device DMA could be divided into the following ty

Re: [PATCH v3 03/18] driver core: platform: Rename platform_dma_configure()

2021-12-06 Thread Lu Baolu
On 12/6/21 11:04 PM, Jason Gunthorpe wrote: On Mon, Dec 06, 2021 at 06:47:45AM -0800, Christoph Hellwig wrote: On Mon, Dec 06, 2021 at 10:45:35AM -0400, Jason Gunthorpe via iommu wrote: IIRC the only thing this function does is touch ACPI and OF stuff? Isn't that firmware? AFAICT amba uses

Re: [PATCH v2 00/17] Fix BUG_ON in vfio_iommu_group_notifier()

2021-12-05 Thread Lu Baolu
On 11/28/21 10:50 AM, Lu Baolu wrote: The original post and intent of this series is here. https://lore.kernel.org/linux-iommu/2025020552.2378167-1-baolu...@linux.intel.com/ Change log: v1: initial post - https://lore.kernel.org/linux-iommu/2025020552.2378167-1-baolu

[PATCH v3 18/18] drm/tegra: Use the iommu dma_owner mechanism

2021-12-05 Thread Lu Baolu
and call iommu_attach_device_shared() which will use dma owner framework to lock out other usages of the group and refcount the domain attachment. When the last device calls detatch the domain will be disconnected. Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu Tested-by: Dmitry Osipenko

[PATCH v3 17/18] iommu: Remove iommu group changes notifier

2021-12-05 Thread Lu Baolu
The iommu group changes notifer is not referenced in the tree. Remove it to avoid dead code. Suggested-by: Christoph Hellwig Signed-off-by: Lu Baolu --- include/linux/iommu.h | 23 - drivers/iommu/iommu.c | 75 --- 2 files changed, 98

[PATCH v3 16/18] vfio: Remove iommu group notifier

2021-12-05 Thread Lu Baolu
-by: Lu Baolu --- drivers/vfio/vfio.c | 147 1 file changed, 147 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 5c81346367b1..33d984ff3cc5 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -71,7 +71,6 @@ struct

[PATCH v3 15/18] vfio: Delete the unbound_list

2021-12-05 Thread Lu Baolu
_group_dev() returns, so simply delete the unbound_list entirely. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 74 ++--- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/d

[PATCH v3 14/18] vfio: Remove use of vfio_group_viable()

2021-12-05 Thread Lu Baolu
The only remaining reference is in GROUP_GET_STATUS, which could be called at any time when group fd is valid. Here we just replace the vfio_group_viable() by directly calling iommu core to get viability status. Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 18 ++ 1 file c

[PATCH v3 13/18] vfio: Set DMA USER ownership for VFIO devices

2021-12-05 Thread Lu Baolu
Set DMA_OWNER_PRIVATE_DOMAIN_USER when an iommu group is set to a container, and release DMA_OWNER_USER once the iommu group is unset from a container. Signed-off-by: Lu Baolu --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 + drivers/vfio/pci/vfio_pci.c | 1 + drivers/vfio/platform

[PATCH v3 12/18] iommu: Add iommu_at[de]tach_device_shared() for multi-device groups

2021-12-05 Thread Lu Baolu
n multiple drivers sharing the group claim the DMA_OWNER_PRIVATE_DOMAIN ownership. The first call of iommu_attach_device_shared() attaches the domain to the group. Other drivers could join it later. The domain will be detached from the group after all drivers unjoin it. Signed-off-by: Jason Gunthorp

[PATCH v3 11/18] iommu: Expose group variants of dma ownership interfaces

2021-12-05 Thread Lu Baolu
is viable to user assignment for compatibility with VFIO_GROUP_FLAGS_VIABLE. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 21 drivers/iommu/iommu.c | 58 +++ 2 files changed, 79 insertions(+) diff --git a/include/linux/iommu.h b

[PATCH v3 10/18] iommu: Add security context management for assigned devices

2021-12-05 Thread Lu Baolu
controlled iommu_domain. Correspondingly, the default domain should be reattached after the last DMA_OWNER_USER is released. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 42 +++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers

[PATCH v3 09/18] PCI: portdrv: Suppress kernel DMA ownership auto-claiming

2021-12-05 Thread Lu Baolu
Suggested-by: Kevin Tian Signed-off-by: Lu Baolu --- drivers/pci/pcie/portdrv_pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 35eca6277a96..c66a83f2c987 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/driver

[PATCH v3 08/18] PCI: pci_stub: Suppress kernel DMA ownership auto-claiming

2021-12-05 Thread Lu Baolu
the DMA ownership to vfio. Signed-off-by: Lu Baolu --- drivers/pci/pci-stub.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index e408099fea52..14b9b9f2ad2b 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -36,6 +36,7

[PATCH v3 06/18] bus: fsl-mc: Add driver dma ownership management

2021-12-05 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/fsl/mc.h | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 26 -- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index e026f6c48b49..3a26421ee3dc

[PATCH v3 07/18] PCI: Add driver dma ownership management

2021-12-05 Thread Lu Baolu
a device to userspace. Signed-off-by: Lu Baolu --- include/linux/pci.h | 5 + drivers/pci/pci-driver.c | 21 + 2 files changed, 26 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 18a75c8e615c..1b29af0ab43b 100644 --- a/include/linux/pci.h

[PATCH v3 05/18] amba: Add driver dma ownership management

2021-12-05 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/amba/bus.h | 1 + drivers/amba/bus.c | 30 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index edfcf7a14dcd..745c5a60ddd8 100644

[PATCH v3 03/18] driver core: platform: Rename platform_dma_configure()

2021-12-05 Thread Lu Baolu
The platform_dma_configure() is shared between platform and amba bus drivers. Rename the common helper to firmware_dma_configure() so that both platform and amba bus drivers could customize their dma_configure callbacks. Signed-off-by: Lu Baolu --- include/linux/platform_device.h | 2

[PATCH v3 04/18] driver core: platform: Add driver dma ownership management

2021-12-05 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/platform_device.h | 1 + drivers/base/platform.c | 30 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 4381c34af7e0

[PATCH v3 02/18] driver core: Add dma_cleanup callback in bus_type

2021-12-05 Thread Lu Baolu
://lore.kernel.org/linux-iommu/20210922123931.gi327...@nvidia.com/ Link: https://lore.kernel.org/linux-iommu/20210928115751.gk964...@nvidia.com/ Signed-off-by: Lu Baolu --- include/linux/device/bus.h | 3 +++ drivers/base/dd.c | 7 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git

[PATCH v3 01/18] iommu: Add device dma ownership set/release interfaces

2021-12-05 Thread Lu Baolu
ted by multiple users simultaneously. Vice versa, the owner type should be released after the user access permission is withdrawn. Signed-off-by: Jason Gunthorpe Signed-off-by: Kevin Tian Signed-off-by: Lu Baolu --- include/linux/iommu.h | 36 + drivers/iommu/iommu.c |

[PATCH v3 00/18] Fix BUG_ON in vfio_iommu_group_notifier()

2021-12-05 Thread Lu Baolu
s based on v5.16-rc3 and available on github: https://github.com/LuBaolu/intel-iommu/commits/iommu-dma-ownership-v3 Best regards, baolu Jason Gunthorpe (2): vfio: Delete the unbound_list drm/tegra: Use the iommu dma_owner mechanism Lu Baolu (16): iommu: Add device dma ownership set/release interface

Re: [PATCH v2 02/17] driver core: Add dma_unconfigure callback in bus_type

2021-11-28 Thread Lu Baolu
On 11/28/21 4:02 PM, Greg Kroah-Hartman wrote: On Sun, Nov 28, 2021 at 10:50:36AM +0800, Lu Baolu wrote: The bus_type structure defines dma_configure() callback for bus drivers to configure DMA on the devices. This adds the paired dma_unconfigure() callback and calls it during driver unbinding

Re: [PATCH v2 00/17] Fix BUG_ON in vfio_iommu_group_notifier()

2021-11-28 Thread Lu Baolu
Hi Greg, On 11/28/21 4:10 PM, Greg Kroah-Hartman wrote: On Sun, Nov 28, 2021 at 10:50:34AM +0800, Lu Baolu wrote: The original post and intent of this series is here. https://lore.kernel.org/linux-iommu/2025020552.2378167-1-baolu...@linux.intel.com/ Please put the intent in the message

[PATCH v2 17/17] drm/tegra: Use the iommu dma_owner mechanism

2021-11-27 Thread Lu Baolu
and call iommu_attach_device_shared() which will use dma owner framework to lock out other usages of the group and refcount the domain attachment. When the last device calls detatch the domain will be disconnected. Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/gpu/drm/tegra

[PATCH v2 16/17] iommu: Remove iommu group changes notifier

2021-11-27 Thread Lu Baolu
The iommu group changes notifer is not referenced in the tree. Remove it to avoid dead code. Suggested-by: Christoph Hellwig Signed-off-by: Lu Baolu --- include/linux/iommu.h | 23 - drivers/iommu/iommu.c | 75 --- 2 files changed, 98

[PATCH v2 15/17] vfio: Remove iommu group notifier

2021-11-27 Thread Lu Baolu
-by: Lu Baolu --- drivers/vfio/vfio.c | 147 1 file changed, 147 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 5c81346367b1..33d984ff3cc5 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -71,7 +71,6 @@ struct

[PATCH v2 14/17] vfio: Delete the unbound_list

2021-11-27 Thread Lu Baolu
_group_dev() returns, so simply delete the unbound_list entirely. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 74 ++--- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/d

[PATCH v2 13/17] vfio: Remove use of vfio_group_viable()

2021-11-27 Thread Lu Baolu
The only remaining reference is in GROUP_GET_STATUS, which could be called at any time when group fd is valid. Here we just replace the vfio_group_viable() by directly calling iommu core to get viability status. Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 18 ++ 1 file c

[PATCH v2 12/17] vfio: Set DMA USER ownership for VFIO devices

2021-11-27 Thread Lu Baolu
Set DMA_OWNER_PRIVATE_DOMAIN_USER when an iommu group is set to a container, and release DMA_OWNER_USER once the iommu group is unset from a container. Signed-off-by: Lu Baolu --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 + drivers/vfio/pci/vfio_pci.c | 1 + drivers/vfio/platform

[PATCH v2 11/17] iommu: Add iommu_at[de]tach_device_shared() for multi-device groups

2021-11-27 Thread Lu Baolu
n multiple drivers sharing the group claim the DMA_OWNER_PRIVATE_DOMAIN ownership. The first call of iommu_attach_device_shared() attaches the domain to the group. Other drivers could join it later. The domain will be detached from the group after all drivers unjoin it. Signed-off-by: Jason Gunthorp

[PATCH v2 10/17] iommu: Expose group variants of dma ownership interfaces

2021-11-27 Thread Lu Baolu
is viable to user assignment for compatibility with VFIO_GROUP_FLAGS_VIABLE. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 21 drivers/iommu/iommu.c | 58 +++ 2 files changed, 79 insertions(+) diff --git a/include/linux/iommu.h b

[PATCH v2 09/17] iommu: Add security context management for assigned devices

2021-11-27 Thread Lu Baolu
controlled iommu_domain. Correspondingly, the default domain should be reattached after the last DMA_OWNER_USER is released. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 42 +++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers

[PATCH v2 08/17] PCI: portdrv: Suppress kernel DMA ownership auto-claiming

2021-11-27 Thread Lu Baolu
Suggested-by: Kevin Tian Signed-off-by: Lu Baolu --- drivers/pci/pcie/portdrv_pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 35eca6277a96..c66a83f2c987 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/driver

[PATCH v2 07/17] PCI: pci_stub: Suppress kernel DMA ownership auto-claiming

2021-11-27 Thread Lu Baolu
the DMA ownership to vfio. Signed-off-by: Lu Baolu --- drivers/pci/pci-stub.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index e408099fea52..14b9b9f2ad2b 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -36,6 +36,7

[PATCH v2 06/17] bus: fsl-mc: Add driver dma ownership management

2021-11-27 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/fsl/mc.h | 5 + drivers/bus/fsl-mc/fsl-mc-bus.c | 26 -- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index e026f6c48b49..3a26421ee3dc

[PATCH v2 05/17] amba: Add driver dma ownership management

2021-11-27 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/amba/bus.h | 1 + drivers/amba/bus.c | 30 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index edfcf7a14dcd..745c5a60ddd8 100644

[PATCH v2 04/17] driver core: platform: Add driver dma ownership management

2021-11-27 Thread Lu Baolu
to userspace. Signed-off-by: Lu Baolu --- include/linux/platform_device.h | 1 + drivers/base/platform.c | 30 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 7c96f169d274

[PATCH v2 03/17] PCI: Add driver dma ownership management

2021-11-27 Thread Lu Baolu
a device to userspace. Signed-off-by: Lu Baolu --- include/linux/pci.h | 5 + drivers/pci/pci-driver.c | 21 + 2 files changed, 26 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 18a75c8e615c..1b29af0ab43b 100644 --- a/include/linux/pci.h

[PATCH v2 02/17] driver core: Add dma_unconfigure callback in bus_type

2021-11-27 Thread Lu Baolu
://lore.kernel.org/linux-iommu/20210922123931.gi327...@nvidia.com/ Link: https://lore.kernel.org/linux-iommu/20210928115751.gk964...@nvidia.com/ Signed-off-by: Lu Baolu --- include/linux/device/bus.h | 3 +++ drivers/base/dd.c | 7 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git

[PATCH v2 01/17] iommu: Add device dma ownership set/release interfaces

2021-11-27 Thread Lu Baolu
ted by multiple users simultaneously. Vice versa, the owner type should be released after the user access permission is withdrawn. Signed-off-by: Jason Gunthorpe Signed-off-by: Kevin Tian Signed-off-by: Lu Baolu --- include/linux/iommu.h | 36 + drivers/iommu/iommu.c |

[PATCH v2 00/17] Fix BUG_ON in vfio_iommu_group_notifier()

2021-11-27 Thread Lu Baolu
-iommu/commits/iommu-dma-ownership-v2 Best regards, baolu Jason Gunthorpe (2): vfio: Delete the unbound_list drm/tegra: Use the iommu dma_owner mechanism Lu Baolu (15): iommu: Add device dma ownership set/release interfaces driver core: Add dma_unconfigure callback in bus_type PCI: Add

Re: [PATCH v2 0/2] iommu/vt-d: Fixes for v5.16-rc3

2021-11-26 Thread Lu Baolu
On 11/27/21 5:57 AM, Joerg Roedel wrote: On Fri, Nov 26, 2021 at 09:55:54PM +0800, Lu Baolu wrote: Update this series with a fix for an issue reported by Intel 0-day robot. Sorry for the inconvenience. Replaced those with the previous fixes, thanks. Please just send a fix on-top next time

[PATCH v2 2/2] iommu/vt-d: Fix unmap_pages support

2021-11-26 Thread Lu Baolu
el.org/all/20211002124012.18186-1-ajaygargn...@gmail.com/ Link: https://lore.kernel.org/r/163659074748.1617923.12716161410774184024.stgit@omen Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel

[PATCH v2 0/2] iommu/vt-d: Fixes for v5.16-rc3

2021-11-26 Thread Lu Baolu
Hi Joerg, Update this series with a fix for an issue reported by Intel 0-day robot. Sorry for the inconvenience. Best regards, baolu change log: v1: https://lore.kernel.org/all/20211122032458.2549761-1-baolu...@linux.intel.com/ v2: For the patch titled "iommu/vt-d: Fix unmap_pages support",

[PATCH v2 1/2] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock()

2021-11-26 Thread Lu Baolu
Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/40cc077ca5f543614eab2a10e84d29dd190273f6.1636217517.git.christophe.jail...@wanadoo.fr Signed-off-by: Lu Baolu --- drivers/iommu/intel/cap_audit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i

Re: [PATCH 2/2] iommu/vt-d: Fix unmap_pages support

2021-11-26 Thread Lu Baolu
On 2021/11/22 11:24, Lu Baolu wrote: From: Alex Williamson When supporting only the .map and .unmap callbacks of iommu_ops, the IOMMU driver can make assumptions about the size and alignment used for mappings based on the driver provided pgsize_bitmap. VT-d previously used essentially

Re: [PATCH 1/2] iommu/vt-d: Remove unused PASID_DISABLED

2021-11-23 Thread Lu Baolu
On 2021/11/23 18:55, Joerg Roedel wrote: From: Joerg Roedel The macro is unused after commit 00ecd5401349a so it can be removed. Reported-by: Linus Torvalds Fixes: 00ecd5401349a ("iommu/vt-d: Clean up unused PASID updating functions") Reviewed-by: Lu Baolu Best regards, baol

[PATCH 2/2] iommu/vt-d: Fix unmap_pages support

2021-11-21 Thread Lu Baolu
el.org/all/20211002124012.18186-1-ajaygargn...@gmail.com/ Link: https://lore.kernel.org/r/163659074748.1617923.12716161410774184024.stgit@omen Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c

[PATCH 1/2] iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock()

2021-11-21 Thread Lu Baolu
Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/40cc077ca5f543614eab2a10e84d29dd190273f6.1636217517.git.christophe.jail...@wanadoo.fr Signed-off-by: Lu Baolu --- drivers/iommu/intel/cap_audit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i

[PATCH 0/2] iommu/vt-d: Fixes for v5.16-rc3

2021-11-21 Thread Lu Baolu
Please consider them for the iommu/fix branch. Best regards, Lu Baolu Alex Williamson (1): iommu/vt-d: Fix unmap_pages support Christophe JAILLET (1): iommu/vt-d: Fix an unbalanced rcu_read_lock/rcu_read_unlock() drivers/iommu/intel/cap_audit.c | 5 +++-- drivers/iommu/intel/iommu.c | 2

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-20 Thread Lu Baolu
Hi Joerg, On 11/19/21 11:06 PM, Jörg Rödel wrote: On Fri, Nov 19, 2021 at 07:14:10PM +0800, Lu Baolu wrote: The singleton group requirement for iommu_attach/detach_device() was added by below commit: commit 426a273834eae65abcfc7132a21a85b3151e0bce Author: Joerg Roedel Date: Thu May 28 18

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-19 Thread Lu Baolu
On 2021/11/19 13:44, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Thursday, November 18, 2021 9:33 PM In concept a singleton group is different from a multi-devices group which has only one device bound to driver... Really? Why? I don't see it that way.. A singleton group is just a

Re: [PATCH] iommu/vt-d: Fix unmap_pages support

2021-11-18 Thread Lu Baolu
Hi Jerry, On 11/19/21 3:48 AM, Jerry Snitselaar wrote: On Fri, 2021-11-12 at 10:59 +0800, Lu Baolu wrote: Hi Alex, On 11/11/21 8:32 AM, Alex Williamson wrote: When supporting only the .map and .unmap callbacks of iommu_ops, the IOMMU driver can make assumptions about the size and alignment

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-17 Thread Lu Baolu
On 11/17/21 9:35 PM, Jason Gunthorpe wrote: On Wed, Nov 17, 2021 at 01:22:19PM +0800, Lu Baolu wrote: Hi Jason, On 11/16/21 9:46 PM, Jason Gunthorpe wrote: On Tue, Nov 16, 2021 at 09:57:30AM +0800, Lu Baolu wrote: Hi Christoph, On 11/15/21 9:14 PM, Christoph Hellwig wrote: On Mon, Nov 15

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-16 Thread Lu Baolu
Hi Jason, On 11/16/21 9:46 PM, Jason Gunthorpe wrote: On Tue, Nov 16, 2021 at 09:57:30AM +0800, Lu Baolu wrote: Hi Christoph, On 11/15/21 9:14 PM, Christoph Hellwig wrote: On Mon, Nov 15, 2021 at 10:05:42AM +0800, Lu Baolu wrote: +enum iommu_dma_owner { + DMA_OWNER_NONE

Re: [PATCH 06/11] iommu: Expose group variants of dma ownership interfaces

2021-11-16 Thread Lu Baolu
Hi Christoph, On 2021/11/15 21:27, Christoph Hellwig wrote: On Mon, Nov 15, 2021 at 10:05:47AM +0800, Lu Baolu wrote: The vfio needs to set DMA_OWNER_USER for the entire group when attaching The vfio subsystem? driver? "vfio subsystem" it to a vfio container. So expose grou

Re: [PATCH 05/11] iommu: Add security context management for assigned devices

2021-11-15 Thread Lu Baolu
On 2021/11/15 21:22, Christoph Hellwig wrote: On Mon, Nov 15, 2021 at 10:05:46AM +0800, Lu Baolu wrote: + /* +* The UNMANAGED domain should be detached before all USER +* owners have been released

Re: [PATCH 04/11] PCI: portdrv: Suppress kernel DMA ownership auto-claiming

2021-11-15 Thread Lu Baolu
Hi Bjorn, On 2021/11/16 4:44, Bjorn Helgaas wrote: On Mon, Nov 15, 2021 at 10:05:45AM +0800, Lu Baolu wrote: IOMMU grouping on PCI necessitates that if we lack isolation on a bridge then all of the downstream devices will be part of the same IOMMU group as the bridge. I think this means

Re: [PATCH 03/11] PCI: pci_stub: Suppress kernel DMA ownership auto-claiming

2021-11-15 Thread Lu Baolu
Hi Bjorn, On 11/16/21 6:17 AM, Bjorn Helgaas wrote: On Mon, Nov 15, 2021 at 10:05:44AM +0800, Lu Baolu wrote: pci_stub allows the admin to block driver binding on a device and make it permanently shared with userspace. Since pci_stub does not do DMA, it is safe. However the admin must

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-15 Thread Lu Baolu
Hi Christoph, On 11/15/21 9:14 PM, Christoph Hellwig wrote: On Mon, Nov 15, 2021 at 10:05:42AM +0800, Lu Baolu wrote: +enum iommu_dma_owner { + DMA_OWNER_NONE, + DMA_OWNER_KERNEL, + DMA_OWNER_USER, +}; + + enum iommu_dma_owner dma_owner; + refcount_t owner_cnt

Re: [PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-15 Thread Lu Baolu
Hi Bjorn, On 11/16/21 4:38 AM, Bjorn Helgaas wrote: On Mon, Nov 15, 2021 at 10:05:42AM +0800, Lu Baolu wrote: From the perspective of who is initiating the device to do DMA, device DMA could be divided into the following types: DMA_OWNER_KERNEL: kernel device driver intiates the DMA

[PATCH 11/11] iommu: Remove iommu group changes notifier

2021-11-14 Thread Lu Baolu
The iommu group changes notifer is not referenced in the tree. Remove it to avoid dead code. Suggested-by: Christoph Hellwig Signed-off-by: Lu Baolu --- include/linux/iommu.h | 23 - drivers/iommu/iommu.c | 75 --- 2 files changed, 98

[PATCH 10/11] vfio: Remove iommu group notifier

2021-11-14 Thread Lu Baolu
-by: Lu Baolu --- drivers/vfio/vfio.c | 147 1 file changed, 147 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 8c317d1a0f3c..c74e10044af4 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -71,7 +71,6 @@ struct

[PATCH 09/11] vfio: Delete the unbound_list

2021-11-14 Thread Lu Baolu
_group_dev() returns, so simply delete the unbound_list entirely. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 74 ++--- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/d

[PATCH 08/11] vfio: Remove use of vfio_group_viable()

2021-11-14 Thread Lu Baolu
The only remaining reference is in GROUP_GET_STATUS, which could be called at any time when group fd is valid. Here we just replace the vfio_group_viable() by directly calling iommu core to get viability status. Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 18 ++ 1 file c

[PATCH 07/11] vfio: Use DMA_OWNER_USER to declaim passthrough devices

2021-11-14 Thread Lu Baolu
Set DMA_OWNER_USER when an iommu group is set to a container, and release DMA_OWNER_USER once the iommu group is unset from a container. Signed-off-by: Lu Baolu --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 + drivers/vfio/pci/vfio_pci.c | 3 +++ drivers/vfio/platform/vfio_amba.c

[PATCH 06/11] iommu: Expose group variants of dma ownership interfaces

2021-11-14 Thread Lu Baolu
assignment, for compatibility with VFIO_GROUP_FLAGS_VIABLE. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 21 drivers/iommu/iommu.c | 57 +++ 2 files changed, 78 insertions(+) diff --git a/include/linux/iommu.h b/include/linux

[PATCH 05/11] iommu: Add security context management for assigned devices

2021-11-14 Thread Lu Baolu
. Vice versa, the default domain should be re-attached to the group after the last DMA_OWNER_USER is released. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers

[PATCH 04/11] PCI: portdrv: Suppress kernel DMA ownership auto-claiming

2021-11-14 Thread Lu Baolu
-by: Jason Gunthorpe Suggested-by: Kevin Tian Signed-off-by: Lu Baolu --- drivers/pci/pcie/portdrv_pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 35eca6277a96..1285862a9aa8 100644 --- a/drivers/pci/pcie/portdrv_p

[PATCH 03/11] PCI: pci_stub: Suppress kernel DMA ownership auto-claiming

2021-11-14 Thread Lu Baolu
pci_stub allows the admin to block driver binding on a device and make it permanently shared with userspace. Since pci_stub does not do DMA, it is safe. However the admin must understand that using pci_stub allows userspace to attack whatever device it was bound to. Signed-off-by: Lu Baolu

[PATCH 02/11] driver core: Set DMA ownership during driver bind/unbind

2021-11-14 Thread Lu Baolu
to userspace. Suggested-by: Jason Gunthorpe Link: https://lore.kernel.org/linux-iommu/20210922123931.gi327...@nvidia.com/ Link: https://lore.kernel.org/linux-iommu/20210928115751.gk964...@nvidia.com/ Signed-off-by: Lu Baolu --- include/linux/device/driver.h | 7 ++- drivers/base/dd.c

[PATCH 01/11] iommu: Add device dma ownership set/release interfaces

2021-11-14 Thread Lu Baolu
off-by: Kevin Tian Signed-off-by: Lu Baolu --- include/linux/iommu.h | 31 drivers/iommu/iommu.c | 106 ++ 2 files changed, 137 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d2f3435e7d17..f77eb9e7788a 100

[PATCH 00/11] Fix BUG_ON in vfio_iommu_group_notifier()

2021-11-14 Thread Lu Baolu
, not BUG_ON failures. Patch partitions: [PATCH 1-2]: Detect DMA ownership conflicts during driver binding; [PATCH 3-6]: Add security context management for assigned devices; [PATCH 7-11]: Various cleanups. Ideas contributed by: Jason Gunthorpe Kevin Tian Ashok Raj Lu Baolu Review

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