[PATCH RFC 11/11] iommu: Rename iommu-sva-lib.{c,h}

2022-03-19 Thread Lu Baolu
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 --- drivers/iommu/{iommu-sva-lib.h => iommu-sva.h} | 0 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +

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

2022-03-19 Thread Lu Baolu
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 of page faults. Signed-off-by: Lu Baolu --- include/linux/iommu.

[PATCH RFC 09/11] iommu: Add iommu_get_domain_for_dev_pasid()

2022-03-19 Thread Lu Baolu
This adds a helper to retrieve the iommu_domain which has been attached to a {device, pasid}. One usage scenario of this helper exists in the I/O page fault handling framework, where {device, pasid} was reported by hardware, and software needs to retrieve the attached domain for further routing. S

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

2022-03-19 Thread Lu Baolu
Directly call the IO page fault handler in iommu_report_device_fault() unless the device driver registered its own page fault handler. There is no need to explicitly register the fault handler in IOMMU drivers. Signed-off-by: Lu Baolu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 13 +---

[PATCH RFC 07/11] iommu: Remove SVA related callbacks from iommu ops

2022-03-19 Thread Lu Baolu
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 --- include/linux/intel-iommu.h | 4 -- include/linux/iommu.h | 8 --- drivers/iom

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

2022-03-19 Thread Lu Baolu
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 attach/detach_dev_pasid domain ops. This refactors the IOMMU SVA in

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

2022-03-19 Thread Lu Baolu
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 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++

[PATCH RFC 04/11] iommu/vt-d: Add SVA domain support

2022-03-19 Thread Lu Baolu
Add support for SVA domain allocation and provide an SVA-specific iommu_domain_ops. Signed-off-by: Lu Baolu --- include/linux/intel-iommu.h | 1 + drivers/iommu/intel/iommu.c | 12 drivers/iommu/intel/svm.c | 34 ++ 3 files changed, 47 insertions(+

[PATCH RFC 03/11] iommu: Add attach/detach_dev_pasid domain ops

2022-03-19 Thread Lu Baolu
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 - kernel DMA with PASID - hardware-assist mediated device This adds a pair o

[PATCH RFC 02/11] iommu: Add iommu_domain type for SVA

2022-03-19 Thread Lu Baolu
Add a new iommu domain type IOMMU_DOMAIN_SVA to represent an I/O page table which is shared from CPU host VA. Add a sva_cookie field in the iommu_domain structure to save the mm_struct which represent the CPU memory page table. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ++ 1 file

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

2022-03-19 Thread Lu Baolu
Use this field to save the pasid/ssid bits that a device is able to support with its IOMMU hardware. It is a generic attribute of a device and lifting it into the per-device dev_iommu struct makes it possible to allocate a PASID for device without calls into the IOMMU drivers. Any iommu driver whic

[PATCH RFC 00/11] iommu: SVA and IOPF refactoring

2022-03-19 Thread Lu Baolu
Hi, The former part of this series refactors the IOMMU SVA code by assigning an SVA type of iommu_domain to a shared virtual address and replacing sva_bind/unbind iommu ops with attach/detach_dev_pasid domain ops. The latter part changes the existing I/O page fault handling framework from only se

[PATCH v4 2/2] PCI: ACPI: Support Microsoft's "DmaProperty"

2022-03-19 Thread Rajat Jain via iommu
The "DmaProperty" is supported and documented by Microsoft here: https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports They use this property for DMA protection: https://docs.microsoft.com/en-us/windows/security/information-protection/kernel-dma-protection-for-thunde

[PATCH v4 1/2] PCI: Rename "pci_dev->untrusted" to "pci_dev->poses_dma_risk"

2022-03-19 Thread Rajat Jain via iommu
Rename the field to make it more clear, that the device can execute DMA attacks on the system, and thus the system may need protection from such attacks from this device. No functional change intended. Signed-off-by: Rajat Jain --- v4: Initial version, created based on comments on other patch

RE: [PATCH v4 14/32] iommu: introduce iommu_domain_alloc_type and the KVM type

2022-03-19 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, March 18, 2022 10:13 PM > > On Fri, Mar 18, 2022 at 02:23:57AM +, Tian, Kevin wrote: > > > Yes, that is another major part work besides the iommufd work. And > > it is not compatible with KVM features which rely on the dynamic > > manner of EPT. Though

RE: [PATCH v4 15/32] vfio: introduce KVM-owned IOMMU type

2022-03-19 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, March 18, 2022 9:46 PM > > On Fri, Mar 18, 2022 at 07:01:19AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, March 15, 2022 10:55 PM > > > > > > The first level iommu_domain has the 'type1' map and unmap and pins > > > the pages