[RFC PATCH 18/18] ioasid: Add /dev/ioasid for userspace

2021-02-27 Thread Jacob Pan
From: Liu Yi L I/O Address Space IDs (IOASIDs) is used to tag DMA requests to target multiple DMA address spaces for physical devices. Its PCI terminology is called PASID (Process Address Space ID). Platforms with PASID support can provide PASID granularity DMA isolation, which is very useful for

[PATCH V4 13/18] iommu/ioasid: Add a workqueue for cleanup work

2021-02-27 Thread Jacob Pan
An IOASID can have multiple users, such as IOMMU driver, KVM, and device drivers. The atomic IOASID notifier is used to inform users of IOASID state change. For example, the IOASID_NOTIFY_UNBIND event is issued when the IOASID is no longer bound to an address space. This requires ordered actions

[PATCH V4 01/18] docs: Document IO Address Space ID (IOASID) APIs

2021-02-27 Thread Jacob Pan
IOASID is used to identify address spaces that can be targeted by device DMA. It is a system-wide resource that is essential to its many users. This document is an attempt to help developers from all vendors navigate the APIs. At this time, ARM SMMU and Intel’s Scalable IO Virtualization (SIOV) ena

[PATCH V4 11/18] iommu/ioasid: Add ownership check in guest bind

2021-02-27 Thread Jacob Pan
Bind guest page table call comes with an IOASID provided by the userspace. To prevent attacks by malicious users, we must ensure the IOASID was allocated under the same process. This patch adds a new API that will perform an ownership check that is based on whether the IOASID belongs to the ioasi

[RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-02-27 Thread Jacob Pan
IOASIDs are used to associate DMA requests with virtual address spaces. They are a system-wide limited resource made available to the userspace applications. Let it be VMs or user-space device drivers. This RFC patch introduces a cgroup controller to address the following problems: 1. Some user ap

[PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-02-27 Thread Jacob Pan
ioasid_set was introduced as an arbitrary token that is shared by a group of IOASIDs. For example, two IOASIDs allocated via the same ioasid_set pointer belong to the same set. For guest SVA usages, system-wide IOASID resources need to be partitioned such that each VM can have its own quota and be

[PATCH V4 09/18] iommu/ioasid: Introduce notification APIs

2021-02-27 Thread Jacob Pan
Relations among IOASID users largely follow a publisher-subscriber pattern. E.g. to support guest SVA on Intel Scalable I/O Virtualization (SIOV) enabled platforms, VFIO, IOMMU, device drivers, KVM are all users of IOASIDs. When a state change occurs, VFIO publishes the change event that needs to b

[PATCH V4 03/18] iommu/ioasid: Add a separate function for detach data

2021-02-27 Thread Jacob Pan
IOASID private data can be cleared by ioasid_attach_data() with a NULL data pointer. A common use case is for a caller to free the data afterward. ioasid_attach_data() calls synchronize_rcu() before return such that free data can be sure without outstanding readers. However, since synchronize_rcu()

[PATCH V4 14/18] iommu/vt-d: Listen to IOASID notifications

2021-02-27 Thread Jacob Pan
On Intel Scalable I/O Virtualization (SIOV) enabled platforms, IOMMU driver is one of the users of IOASIDs. In normal flow, callers will perform IOASID allocation, bind, unbind, and free in order. However, for guest SVA, IOASID free could come before unbind as guest is untrusted. This patch registe

[RFC PATCH 16/18] iommu/ioasid: Consult IOASIDs cgroup for allocation

2021-02-27 Thread Jacob Pan
Once IOASIDs cgroup is active, we must consult the limitation set up by the cgroups during allocation. Freeing IOASIDs also need to return the quota back to the cgroup. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/d

[PATCH V4 10/18] iommu/ioasid: Support mm token type ioasid_set notifications

2021-02-27 Thread Jacob Pan
As a system-wide resource, IOASID is often shared by multiple kernel subsystems that are independent of each other. However, at the ioasid_set level, these kernel subsystems must communicate with each other for ownership checking, event notifications, etc. For example, on Intel Scalable IO Virtuali

[RFC PATCH 17/18] docs: cgroup-v1: Add IOASIDs controller

2021-02-27 Thread Jacob Pan
Signed-off-by: Jacob Pan --- Documentation/admin-guide/cgroup-v1/index.rst | 1 + .../admin-guide/cgroup-v1/ioasids.rst | 110 ++ 2 files changed, 111 insertions(+) create mode 100644 Documentation/admin-guide/cgroup-v1/ioasids.rst diff --git a/Documentation/admin-guid

[PATCH V4 04/18] iommu/ioasid: Support setting system-wide capacity

2021-02-27 Thread Jacob Pan
IOASID is a system-wide resource that could vary on different systems. The default capacity is 20 bits as defined in the PCI-E specifications. This patch adds a function to allow adjusting system IOASID capacity. For VT-d this is set during boot as part of the Intel IOMMU initialization. APIs also

[PATCH V4 08/18] iommu/ioasid: Introduce ioasid_set private ID

2021-02-27 Thread Jacob Pan
When an IOASID set is used for guest SVA, each VM will acquire its ioasid_set for IOASID allocations. IOASIDs within the VM must have a host/physical IOASID backing, mapping between guest and host IOASIDs can be non-identical. IOASID set private ID (SPID) is introduced in this patch to be used as g

[PATCH V4 07/18] iommu/ioasid: Add ioasid_set iterator helper functions

2021-02-27 Thread Jacob Pan
Users of an ioasid_set may not keep track of all the IOASIDs allocated under the set. When collective actions are needed for each IOASIDs, it is useful to iterate over all the IOASIDs within the set. For example, when the ioasid_set is freed, the user might perform the same cleanup operation on eac

[PATCH V4 00/18] IOASID extensions for guest SVA

2021-02-27 Thread Jacob Pan
I/O Address Space ID (IOASID) core code was introduced in v5.5 as a generic kernel allocator service for both PCIe Process Address Space ID (PASID) and ARM SMMU's Substream ID. IOASIDs are used to associate DMA requests with virtual address spaces, including both host and guest. In addition to pro

[PATCH V4 02/18] iommu/ioasid: Rename ioasid_set_data()

2021-02-27 Thread Jacob Pan
Rename ioasid_set_data() to ioasid_attach_data() to avoid confusion with struct ioasid_set. ioasid_set is a group of IOASIDs that share a common token. Reviewed-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 6 +++--- drivers/iommu/ioasid.c| 6 +++--- inc

[PATCH V4 12/18] iommu/vt-d: Remove mm reference for guest SVA

2021-02-27 Thread Jacob Pan
Now that IOASID core keeps track of the IOASID to mm_struct ownership in the forms of ioasid_set with IOASID_SET_TYPE_MM token type, there is no need to keep the same mapping in VT-d driver specific data. Native SVM usage is not affected by the change. Signed-off-by: Jacob Pan --- drivers/iommu/

[PATCH V4 06/18] iommu/ioasid: Add free function and states

2021-02-27 Thread Jacob Pan
When an actively used IOASID is freed due to exceptions, users must be notified to perform the cleanup. The IOASID shall be put in a pending state until all users completed their cleanup work. This patch adds ioasid_free() function to let the caller initiate the freeing process. Both ioasid_free()

Re: [PATCH 5/6] driver core: lift dma_default_coherent into common code

2021-02-27 Thread Maciej W. Rozycki
On Mon, 22 Feb 2021, Maciej W. Rozycki wrote: > > > I haven't booted Linux on my Malta for a while now, but it turns out to > > > work just fine, and your patch set does not regress it booting multi-user > > > NFS-rooted over FDDI. > > > > > > I note however that the system does not reboot pro

Re: [PATCHv2 2/2] iommu/arm-smmu-qcom: Move the adreno smmu specific impl earlier

2021-02-27 Thread Sai Prakash Ranjan
Hi Bjorn, On 2021-02-27 00:44, Bjorn Andersson wrote: > On Fri 26 Feb 12:23 CST 2021, Rob Clark wrote: > > > The current logic picks one of: > 1) is the compatible mentioned in qcom_smmu_impl_of_match[] > 2) is the compatible an adreno > 3) no quirks needed > > The change flips the order of the

Re: [PATCH] iommu/tegra-smmu: Fix mc errors on tegra124-nyan

2021-02-27 Thread Dmitry Osipenko
25.02.2021 09:27, Nicolin Chen пишет: ... >> The partially revert should be okay, but it's not clear to me what makes >> difference for T124 since I don't see that problem on T30, which also >> has active display at a boot time. > > Hmm..do you see ->attach_dev() is called from host1x_client_iommu