[PATCH v6 10/10] iommufd/selftest: Add coverage for IOPF test

2024-05-26 Thread Lu Baolu
on the mock device. - Retrieving and responding to the IOPF through the file interface. Signed-off-by: Lu Baolu --- tools/testing/selftests/iommu/iommufd_utils.h | 84 +-- tools/testing/selftests/iommu/iommufd.c | 18 .../selftests/iommu/iommufd_fail_nth.c| 2

[PATCH v6 09/10] iommufd/selftest: Add IOPF support for mock device

2024-05-26 Thread Lu Baolu
. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_test.h | 8 drivers/iommu/iommufd/selftest.c | 64 2 files changed, 72 insertions(+) diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index e854d3f67205

[PATCH v6 08/10] iommufd: Associate fault object with iommufd_hw_pgtable

2024-05-26 Thread Lu Baolu
SID will differ from those that are not iopf-capable. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 9 ++ include/uapi/linux/iommufd.h| 8 + drivers/iommu/iommufd/fault.c | 17 ++ drivers/iommu/iommufd/hw_pagetable.c|

[PATCH v6 07/10] iommufd: Fault-capable hwpt attach/detach/replace

2024-05-26 Thread Lu Baolu
and non-iopf-capable hw page tables. This matches the nested translation use case, where a parent domain is attached by default and can then be replaced with a nested user domain with iopf support. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 12 ++ drivers/iommu/iommufd

[PATCH v6 05/10] iommufd: Add fault and response message definitions

2024-05-26 Thread Lu Baolu
the pending message. Signed-off-by: Lu Baolu --- include/uapi/linux/iommufd.h | 96 1 file changed, 96 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 1dfeaa2e649e..2f34d66436fb 100644 --- a/include/uapi/linux

[PATCH v6 06/10] iommufd: Add iommufd fault object

2024-05-26 Thread Lu Baolu
of an iommufd_hw_pgtable are routed through the fault object to user space. Similarly, user space's responses to these page faults are routed back to the iommu device driver through the same fault object. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 4 + drivers/iommu/iommufd

[PATCH v6 04/10] iommu: Extend domain attach group with handle support

2024-05-26 Thread Lu Baolu
that they could support the attach handle and export them for use in IOMMUFD. Signed-off-by: Lu Baolu --- drivers/iommu/iommu-priv.h | 8 +++ drivers/iommu/iommu.c | 99 ++ 2 files changed, 107 insertions(+) diff --git a/drivers/iommu/iommu-priv.h b/drivers

[PATCH v6 03/10] iommu: Add attach handle to struct iopf_group

2024-05-26 Thread Lu Baolu
deliver path, if no attach handle found for the iopf PASID, roll back to RID domain when the IOMMU driver supports this capability. iommu_get_domain_for_dev_pasid() is no longer used and can be removed. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 18 +--- drivers/iommu/io

[PATCH v6 02/10] iommu: Remove sva handle list

2024-05-26 Thread Lu Baolu
The struct sva_iommu represents an association between an SVA domain and a PASID of a device. It's stored in the iommu group's pasid array and also tracked by a list in the per-mm data structure. Removes duplicate tracking of sva_iommu by eliminating the list. Signed-off-by: Lu Baolu

[PATCH v6 00/10] IOMMUFD: Deliver IO page faults to user space

2024-05-26 Thread Lu Baolu
. https://lore.kernel.org/linux-iommu/zjwjd1ajeem6p...@ziepe.ca/ v1: https://lore.kernel.org/linux-iommu/20230530053724.232765-1-baolu...@linux.intel.com/ Lu Baolu (10): iommu: Introduce domain attachment handle iommu: Remove sva handle list iommu: Add attach handle to struct iopf_group iommu

[PATCH v6 01/10] iommu: Introduce domain attachment handle

2024-05-26 Thread Lu Baolu
-off-by: Lu Baolu --- include/linux/iommu.h | 18 +++--- drivers/dma/idxd/init.c | 2 +- drivers/iommu/iommu-sva.c | 13 - drivers/iommu/iommu.c | 23 +-- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/include/linux/iommu.h b

[PATCH v5 7/9] iommufd: Associate fault object with iommufd_hw_pgtable

2024-04-30 Thread Lu Baolu
will differ from those that are not iopf-capable. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 9 +++ include/uapi/linux/iommufd.h| 8 ++ drivers/iommu/iommufd/fault.c | 17 drivers/iommu/iommufd/hw_pagetable.c| 35

[PATCH v5 9/9] iommufd/selftest: Add coverage for IOPF test

2024-04-30 Thread Lu Baolu
on the mock device. - Retrieving and responding to the IOPF through the file interface. Signed-off-by: Lu Baolu --- tools/testing/selftests/iommu/iommufd_utils.h | 84 +-- tools/testing/selftests/iommu/iommufd.c | 18 .../selftests/iommu/iommufd_fail_nth.c| 2

[PATCH v5 8/9] iommufd/selftest: Add IOPF support for mock device

2024-04-30 Thread Lu Baolu
. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_test.h | 8 drivers/iommu/iommufd/selftest.c | 63 2 files changed, 71 insertions(+) diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index e854d3f67205

[PATCH v5 6/9] iommufd: Fault-capable hwpt attach/detach/replace

2024-04-30 Thread Lu Baolu
and non-iopf-capable hw page tables. This matches the nested translation use case, where a parent domain is attached by default and can then be replaced with a nested user domain with iopf support. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 10 ++ drivers/iommu/iommufd

[PATCH v5 5/9] iommufd: Add iommufd fault object

2024-04-30 Thread Lu Baolu
of an iommufd_hw_pgtable are routed through the fault object to user space. Similarly, user space's responses to these page faults are routed back to the iommu device driver through the same fault object. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 3 + drivers/iommu/iommu-priv.h

[PATCH v5 4/9] iommufd: Add fault and response message definitions

2024-04-30 Thread Lu Baolu
the pending message. Signed-off-by: Lu Baolu --- include/uapi/linux/iommufd.h | 96 1 file changed, 96 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 1dfeaa2e649e..83b45dce94a4 100644 --- a/include/uapi/linux

[PATCH v5 3/9] iommu: Add attachment handle to struct iopf_group

2024-04-30 Thread Lu Baolu
is wholly managed by user space, there is no domain attached to the PASID of the device. Improve this code to try fetching the attachment handle on a PASID if possible, otherwise try it on the RID. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 1 + drivers/iommu/io-pgfault.c | 34

[PATCH v5 2/9] iommu: Replace sva_iommu with iommu_attach_handle

2024-04-30 Thread Lu Baolu
The struct sva_iommu represents a bond of an SVA domain and a device. It is functionally equivalent to the iommu_attach_handle. To avoid code duplication, replace sva_iommu with the iommu_attach_handle and remove the code that manages sva_iommu. Signed-off-by: Lu Baolu --- include/linux/iommu.h

[PATCH v5 1/9] iommu: Introduce domain attachment handle

2024-04-30 Thread Lu Baolu
information beyond a domain pointer, depending on its specific use case. Co-developed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/iommu/iommu-priv.h | 6 ++ drivers/iommu/iommu.c | 156 - 2 files changed, 142

[PATCH v5 0/9] IOMMUFD: Deliver IO page faults to user space

2024-04-30 Thread Lu Baolu
...@ziepe.ca/ v1: https://lore.kernel.org/linux-iommu/20230530053724.232765-1-baolu...@linux.intel.com/ Lu Baolu (9): iommu: Introduce domain attachment handle iommu: Replace sva_iommu with iommu_attach_handle iommu: Add attachment handle to struct iopf_group iommufd: Add fault

[PATCH v4 9/9] iommufd/selftest: Add coverage for IOPF test

2024-04-02 Thread Lu Baolu
on the mock device. - Retrieving and responding to the IOPF through the file interface. Signed-off-by: Lu Baolu --- tools/testing/selftests/iommu/iommufd_utils.h | 84 +-- tools/testing/selftests/iommu/iommufd.c | 18 .../selftests/iommu/iommufd_fail_nth.c| 2

[PATCH v4 8/9] iommufd/selftest: Add IOPF support for mock device

2024-04-02 Thread Lu Baolu
. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_test.h | 8 drivers/iommu/iommufd/selftest.c | 63 2 files changed, 71 insertions(+) diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index e854d3f67205

[PATCH v4 7/9] iommufd: Associate fault object with iommufd_hw_pgtable

2024-04-02 Thread Lu Baolu
will differ from those that are not iopf-capable. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 10 +++ include/uapi/linux/iommufd.h| 8 ++ drivers/iommu/iommufd/fault.c | 20 ++ drivers/iommu/iommufd/hw_pagetable.c| 36

[PATCH v4 6/9] iommufd: Add iommufd fault object

2024-04-02 Thread Lu Baolu
of an iommufd_hw_pgtable are routed through the fault object to user space. Similarly, user space's responses to these page faults are routed back to the iommu device driver through the same fault object. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 3 + drivers/iommu/iommufd

[PATCH v4 5/9] iommufd: Add fault and response message definitions

2024-04-02 Thread Lu Baolu
the pending message. Signed-off-by: Lu Baolu --- include/uapi/linux/iommufd.h | 96 1 file changed, 96 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 1dfeaa2e649e..83b45dce94a4 100644 --- a/include/uapi/linux

[PATCH v4 4/9] iommufd: Fault-capable hw page table attach/detach/replace

2024-04-02 Thread Lu Baolu
and non-iopf-capable hw page tables. This matches the nested translation use case, where a parent domain is attached by default and can then be replaced with a nested user domain with iopf support. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 9 ++ drivers/iommu/iommufd

[PATCH v4 3/9] iommu: Add attachment handle to struct iopf_group

2024-04-02 Thread Lu Baolu
is wholly managed by user space, there is no domain attached to the PASID of the device. Improve this code to try fetching the attachment handle on a PASID if possible, otherwise try it on the RID. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 +- drivers/iommu/io-pgfault.c | 37

[PATCH v4 2/9] iommu: Replace sva_iommu with iommu_attach_handle

2024-04-02 Thread Lu Baolu
The struct sva_iommu represents a bond of an SVA domain and a device. It is functionally equivalent to the iommu_attach_handle. To avoid code duplication, replace sva_iommu with the iommu_attach_handle and remove the code that manages sva_iommu. Signed-off-by: Lu Baolu --- include/linux/iommu.h

[PATCH v4 1/9] iommu: Introduce domain attachment handle

2024-04-02 Thread Lu Baolu
information beyond a domain pointer, depending on its specific use case. Co-developed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Lu Baolu --- drivers/iommu/iommu-priv.h | 9 +++ drivers/iommu/iommu.c | 158 + 2 files changed

[PATCH v4 0/9] IOMMUFD: Deliver IO page faults to user space

2024-04-02 Thread Lu Baolu
to I/O page requests, so that user space applications can improve performance using io_uring. https://lore.kernel.org/linux-iommu/zjwjd1ajeem6p...@ziepe.ca/ v1: https://lore.kernel.org/linux-iommu/20230530053724.232765-1-baolu...@linux.intel.com/ Lu Baolu (9): iommu: Introduce domain

[PATCH v3 8/8] iommufd/selftest: Add coverage for IOPF test

2024-01-21 Thread Lu Baolu
on the mock device. - Retrieving and responding to the IOPF through the file interface. Signed-off-by: Lu Baolu --- tools/testing/selftests/iommu/iommufd_utils.h | 83 +-- tools/testing/selftests/iommu/iommufd.c | 17 .../selftests/iommu/iommufd_fail_nth.c| 2

[PATCH v3 7/8] iommufd/selftest: Add IOPF support for mock device

2024-01-21 Thread Lu Baolu
. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_test.h | 8 drivers/iommu/iommufd/selftest.c | 63 2 files changed, 71 insertions(+) diff --git a/drivers/iommu/iommufd/iommufd_test.h b/drivers/iommu/iommufd/iommufd_test.h index 482d4059f5db

[PATCH v3 6/8] iommufd: IOPF-capable hw page table attach/detach/replace

2024-01-21 Thread Lu Baolu
support. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 7 ++ drivers/iommu/iommufd/device.c | 15 ++- drivers/iommu/iommufd/fault.c | 122 3 files changed, 141 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommufd

[PATCH v3 5/8] iommufd: Associate fault object with iommufd_hw_pgtable

2024-01-21 Thread Lu Baolu
will differ from those that are not iopf-capable. The implementation of these will be introduced in the next patch. Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 11 include/uapi/linux/iommufd.h| 6 + drivers/iommu/iommufd/fault.c | 14

[PATCH v3 4/8] iommufd: Add iommufd fault object

2024-01-21 Thread Lu Baolu
of an iommufd_hw_pgtable are routed through the fault object to user space. Similarly, user space's responses to these page faults are routed back to the iommu device driver through the same fault object. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 + drivers/iommu/iommufd

[PATCH v3 3/8] iommufd: Add fault and response message definitions

2024-01-21 Thread Lu Baolu
check. Signed-off-by: Lu Baolu --- include/uapi/linux/iommufd.h | 67 1 file changed, 67 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 1dfeaa2e649e..d59e839ae49e 100644 --- a/include/uapi/linux/iommufd.h +++ b

[PATCH v3 2/8] iommu/sva: Use iopf domain attach/detach interface

2024-01-21 Thread Lu Baolu
of the domain. This ensures that the page fault is forwarded only if an iopf-capable domain is attached, and the domain will only be released after all outstanding faults are handled. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 2 +- drivers/iommu/io-pgfault.c | 59

[PATCH v3 1/8] iommu: Add iopf domain attach/detach/replace interface

2024-01-21 Thread Lu Baolu
uses. For example, the IOMMUFD could use it to store the iommufd_device pointer, so that it could easily retrieve the dev_id of the device that triggered the fault. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 36 + drivers/iommu/io-pgfault.c | 158

[PATCH v3 0/8] IOMMUFD: Deliver IO page faults to user space

2024-01-21 Thread Lu Baolu
and responding to I/O page requests, so that user space applications can improve performance using io_uring. https://lore.kernel.org/linux-iommu/zjwjd1ajeem6p...@ziepe.ca/ v1: https://lore.kernel.org/linux-iommu/20230530053724.232765-1-baolu...@linux.intel.com/ Lu Baolu (8): iommu: Add iopf