[PATCH v4 13/13] drm/tegra: Use the iommu dma_owner mechanism

2021-12-16 Thread Lu Baolu
From: Jason Gunthorpe Tegra joins many platform devices onto the same iommu_domain and builds sort-of a DMA API on top of it. Given that iommu_attach/detatch_device_shared() has supported this usage model. Each device that wants to use the special domain will use suppress_auto_claim_dma_owner

[PATCH v4 12/13] iommu: Remove iommu group changes notifier

2021-12-16 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 v4 10/13] vfio: Delete the unbound_list

2021-12-16 Thread Lu Baolu
From: Jason Gunthorpe commit 60720a0fc646 ("vfio: Add device tracking during unbind") added the unbound list to plug a problem with KVM where KVM_DEV_VFIO_GROUP_DEL relied on vfio_group_get_external_user() succeeding to return the vfio_group from a group file descriptor. The unbound list allowed

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

2021-12-16 Thread Lu Baolu
As DMA USER ownership is claimed for the iommu group when a vfio group is added to a vfio container, the vfio group viability is guaranteed as long as group->container_users > 0. Remove those unnecessary group viability checks which are only hit when group->container_users is not zero. The only

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

2021-12-16 Thread Lu Baolu
The iommu core and driver core have been enhanced to avoid unsafe driver binding to a live group after iommu_group_set_dma_owner(PRIVATE_USER) has been called. There's no need to register iommu group notifier. This removes the iommu group notifer which contains BUG_ON() and WARN(). Signed-off-by:

[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 +++

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

2021-12-16 Thread Lu Baolu
The iommu_attach/detach_device() interfaces were exposed for the device drivers to attach/detach their own domains. The commit <426a273834eae> ("iommu: Limit iommu_attach/detach_device to device with their own group") restricted them to singleton groups to avoid different device in a group

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

2021-12-16 Thread Lu Baolu
The vfio needs to set DMA_OWNER_PRIVATE_DOMAIN_USER for the entire group when attaching it to a vfio container. Expose group variants of setting/ releasing dma ownership for this purpose. This also exposes the helper iommu_group_dma_owner_unclaimed() for vfio to report to userspace if the group

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

2021-12-16 Thread Lu Baolu
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. The existing vfio framework allows the portdrv driver to be bound to the bridge while its downstream devices are assigned to user space.

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

2021-12-16 Thread Lu Baolu
When an iommu group has DMA_OWNER_PRIVATE_DOMAIN_USER set for the first time, it is a contract that the group could be assigned to userspace from now on. The group must be detached from the default iommu domain and all devices in this group are blocked from doing DMA until it is attached to a user

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

2021-12-16 Thread Lu Baolu
Hi folks, The iommu group is the minimal isolation boundary for DMA. Devices in a group can access each other's MMIO registers via peer to peer DMA and also need share the same I/O address space. Once the I/O address space is assigned to user control it is no longer available to the dma_map*

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

2021-12-16 Thread Lu Baolu
>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 kernel driver through the kernel DMA API. DMA_OWNER_PRIVATE_DOMAIN: Device DMAs are

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

2021-12-16 Thread Lu Baolu
The pci_dma_configure() marks the iommu_group as containing only devices with kernel drivers that manage DMA. Avoid this default behavior for the pci_stub because it does not program any DMA itself. This allows the pci_stub still able to be used by the admin to block driver binding after applying

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

2021-12-16 Thread Lu Baolu
This extends really_probe() to allow checking for dma ownership conflict during the driver binding process. By default, the DMA_OWNER_DMA_API is claimed for the bound driver before calling its .probe() callback. If this operation fails (e.g. the iommu group of the target device already has the

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

2021-12-16 Thread Lu Baolu
On 12/6/21 9:58 AM, Lu Baolu wrote: Hi folks, The iommu group is the minimal isolation boundary for DMA. Devices in a group can access each other's MMIO registers via peer to peer DMA and also need share the same I/O address space. Once the I/O address space is assigned to user control it is

Re: [PATCH v2 03/11] drm/tegra: vic: Fix DMA API misuse

2021-12-16 Thread Thierry Reding
On Fri, Dec 10, 2021 at 05:54:44PM +, Robin Murphy wrote: > Upon failure, dma_alloc_coherent() returns NULL. If that does happen, > passing some uninitialised stack contents to dma_mapping_error() - which > belongs to a different API in the first place - has precious little > chance of

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

2021-12-16 Thread Christoph Hellwig
On Thu, Dec 16, 2021 at 09:17:03AM +0800, Lu Baolu wrote: > These macros has no reference in the tree anymore. Cleanup them. > > Signed-off-by: Lu Baolu Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list

Re: [PATCH v2 04/11] iommu/iova: Squash entry_dtor abstraction

2021-12-16 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 03/11] drm/tegra: vic: Fix DMA API misuse

2021-12-16 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2 05/11] iommu/iova: Squash flush_cb abstraction

2021-12-16 Thread Christoph Hellwig
> @@ -147,7 +142,7 @@ struct iova *reserve_iova(struct iova_domain *iovad, > unsigned long pfn_lo, > unsigned long pfn_hi); > void init_iova_domain(struct iova_domain *iovad, unsigned long granule, > unsigned long start_pfn); > -int init_iova_flush_queue(struct iova_domain *iovad,

Re: [PATCH V7 1/5] swiotlb: Add swiotlb bounce buffer remap function for HV IVM

2021-12-16 Thread Wei Liu
On Wed, Dec 15, 2021 at 01:00:38PM +0800, Tianyu Lan wrote: > > > On 12/15/2021 6:40 AM, Dave Hansen wrote: > > On 12/14/21 2:23 PM, Tom Lendacky wrote: > > > > I don't really understand how this can be more general any *not* get > > > > utilized by the existing SEV support. > > > > > > The

Re: [PATCH v2 02/11] gpu: host1x: Add missing DMA API include

2021-12-16 Thread Thierry Reding
On Fri, Dec 10, 2021 at 05:54:43PM +, Robin Murphy wrote: > Host1x seems to be relying on picking up dma-mapping.h transitively from > iova.h, which has no reason to include it in the first place. Fix the > former issue before we totally break things by fixing the latter one. > > CC: Thierry

Re: [PATCH v2 00/33] Separate struct slab from struct page

2021-12-16 Thread Vlastimil Babka
On 12/16/21 00:38, Roman Gushchin wrote: > On Tue, Dec 14, 2021 at 05:03:12PM -0800, Roman Gushchin wrote: >> On Tue, Dec 14, 2021 at 01:57:22PM +0100, Vlastimil Babka wrote: >> > On 12/1/21 19:14, Vlastimil Babka wrote: >> > > Folks from non-slab subsystems are Cc'd only to patches affecting

[PATCH] drm/tegra: Add missing DMA API includes

2021-12-16 Thread Robin Murphy
Include dma-mapping.h directly in the remaining places that touch the DMA API, to avoid imminent breakage from refactoring other headers. Signed-off-by: Robin Murphy --- This makes arm64 allmodconfig build cleanly for me with the IOVA series, so hopefully is the last of it...

Re: [PATCH v2 00/33] Separate struct slab from struct page

2021-12-16 Thread Hyeonggon Yoo
On Tue, Dec 14, 2021 at 01:57:22PM +0100, Vlastimil Babka wrote: > On 12/1/21 19:14, Vlastimil Babka wrote: > > Folks from non-slab subsystems are Cc'd only to patches affecting them, and > > this cover letter. > > > > Series also available in git, based on 5.16-rc3: > >

Re: [PATCH] iommu: Use correctly sized arguments for bit field

2021-12-16 Thread Yury Norov
On Wed, Dec 15, 2021 at 3:24 PM Kees Cook wrote: > > The find.h APIs are designed to be used only on unsigned long arguments. > This can technically result in a over-read, but it is harmless in this > case. Regardless, fix it to avoid the warning seen under -Warray-bounds, > which we'd like to

[PATCH] iommu/virtio: Fix typo in a comment

2021-12-16 Thread Xiang wangx
The double `as' in a comment is repeated, thus it should be removed. Signed-off-by: Xiang wangx --- drivers/iommu/virtio-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index c9e8367d2962..162bd07e32fe

Re: [patch V3 00/35] genirq/msi, PCI/MSI: Spring cleaning - Part 2

2021-12-16 Thread Thomas Gleixner
Nishanth, On Wed, Dec 15 2021 at 19:45, Nishanth Menon wrote: > On 17:35-20211215, Thomas Gleixner wrote: > Thanks once again for your help. Hope we can roll in the fixes for > part3. Sure, it's only the one-liner for ti sci. Got it folded already. Thanks for your help and testing! tglx