Skip to content

iommu: Prepare to deliver page faults to user space

Lu Baolu kvm linux-iommu lkml 20 versions – Applied

Status from this message: Applied, thanks Baolu.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 posting 2/210 patches 35 repliesIn review
  2. v7 posting 2/210 patches 18 repliesSuperseded
  3. v6 posting 2/210 patches 38 repliesSuperseded
Earlier versions · 17
VersionPostedPatchesRepliesStatus
v5 posting 2/29 patches53 repliesSuperseded
v4 posting 2/29 patches18 repliesSuperseded
v13 Latest16 patches1 replyApplied
v1216 patches7 repliesSuperseded
v1116 patches10 repliesSuperseded
v3 posting 2/28 patches34 repliesSuperseded
v1016 patches14 repliesSuperseded
v914 patches6 repliesSuperseded
v8 posting 1/212 patches12 repliesSuperseded
v7 posting 1/212 patches36 repliesSuperseded
v2 posting 2/26 patches39 repliesSuperseded
v6 posting 1/212 patches2 repliesSuperseded
v5 posting 1/212 patches12 repliesSuperseded
v4 posting 1/210 patches37 repliesSuperseded
v3 posting 1/211 patches8 repliesSuperseded
v2 posting 1/212 patches57 repliesSuperseded
v19 patches27 repliesSuperseded

Changes in v13 from the cover letter

- Refine the comments for iopf_queue_remove_device().

Patches in v13 Applied

#Subject and filesSizeRepliesApplied
1/16iommu: Move iommu fault data to linux/iommu.hMAINTAINERS include/linux/iommu.h include/uapi/linux/iommu.h+151 -1630 replies
2/16iommu/arm-smmu-v3: Remove unrecoverable faults reportingdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c+13 -330 replies
3/16iommu: Remove unrecoverable fault datainclude/linux/iommu.h+2 -700 replies
4/16iommu: Cleanup iopf data structure definitionsdrivers/iommu/io-pgfault.c drivers/iommu/iommu.c include/linux/iommu.h+11 -210 replies
5/16iommu: Merge iopf_device_param into iommu_fault_paramdrivers/iommu/io-pgfault.c drivers/iommu/iommu.c include/linux/iommu.h+72 -900 replies
6/16iommu: Remove iommu_[un]register_device_fault_handler()drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c drivers/iommu/intel/iommu.c drivers/iommu/io-pgfault.c +3 more+13 -1330 replies
7/16iommu: Merge iommu_fault_event and iopf_faultdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/intel/iommu.h drivers/iommu/intel/svm.c +3 more+17 -340 replies
8/16iommu: Prepare for separating SVA and IOPFdrivers/iommu/io-pgfault.c include/linux/iommu.h+32 -250 replies
9/16iommu: Make iommu_queue_iopf() more genericdrivers/iommu/io-pgfault.c drivers/iommu/iommu-sva.c drivers/iommu/iommu-sva.h +1 more+61 -200 replies
10/16iommu: Separate SVA and IOPFdrivers/iommu/Kconfig drivers/iommu/Makefile drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +9 more+277 -2910 replies
11/16iommu: Refine locking for per-device fault data managementdrivers/iommu/io-pgfault.c+30 -310 replies
12/16iommu: Use refcount for fault data accessdrivers/iommu/io-pgfault.c drivers/iommu/iommu-sva.c include/linux/iommu.h+88 -580 replies
13/16iommu: Improve iopf_queue_remove_device()drivers/iommu/intel/iommu.c drivers/iommu/io-pgfault.c include/linux/iommu.h+41 -300 replies
14/16iommu: Track iopf group instead of last faultdrivers/iommu/io-pgfault.c include/linux/iommu.h+86 -1620 replies
15/16iommu: Make iopf_group_response() return voiddrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/intel/iommu.h drivers/iommu/intel/svm.c +2 more+99 -1210 replies
16/16iommu: Make iommu_report_device_fault() return voiddrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/intel/svm.c drivers/iommu/io-pgfault.c +1 more+19 -340 replies

Reviews trailers per patch

All 16 patches have a Reviewed-by or Acked-by.

PatchJason GunthorpeKevin TianYi LiuYan ZhaoLongfang Liu
1/16R-b R-b R-b T-b T-b
2/16R-b R-b T-b
3/16R-b R-b T-b T-b
4/16R-b R-b R-b T-b T-b
5/16R-b R-b T-b T-b
6/16R-b R-b T-b T-b
7/16R-b R-b R-b T-b T-b
8/16R-b R-b R-b T-b T-b
9/16R-b R-b R-b T-b T-b
10/16R-b R-b T-b T-b
11/16R-b R-b T-b T-b
12/16R-b R-b T-b
13/16R-b T-b
14/16R-b R-b T-b
15/16R-b R-b
16/16R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v13 thread

Cover letter [PATCH v13 00/16] iommu: Prepare to deliver page faults to user space

When a user-managed page table is attached to an IOMMU, it is necessary to deliver IO page faults to user space so that they can be handled appropriately. One use case for this is nested translation, which is currently being discussed in the mailing list.

I have posted a RFC series [1] that describes the implementation of delivering page faults to user space through IOMMUFD. This series has received several comments on the IOMMU refactoring, which I am trying to address in this series.

The major refactoring includes:

- [PATCH 01 ~ 04] Move include/uapi/linux/iommu.h to include/linux/iommu.h. Remove the unrecoverable fault data definition.
- [PATCH 05 ~ 06] Remove iommu_[un]register_device_fault_handler().
- [PATCH 07 ~ 10] Separate SVA and IOPF. Make IOPF a generic page fault handling framework.
- [PATCH 11 ~ 16] Improve iopf framework.

This is also available at github [2].

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://github.com/LuBaolu/intel-iommu/commits/preparatory-io-pgfault-delivery-v13

Change log:
v13:
- Refine the comments for iopf_queue_remove_device().

v12: https://lore.kernel.org/linux-iommu/[email protected]/
- Add Jason and Kevin's Reviewed-by tags.
- Fix some minor comments.
- No code change.

v11: https://lore.kernel.org/linux-iommu/[email protected]/
- Cleanup IOMMU_PAGE_RESP_PASID_VALID flag bit.
- Cleanup code comments.

v10: https://lore.kernel.org/linux-iommu/[email protected]/
- Make iopf_group_response() return void, as nobody can do anything
with the failure.
- Make iommu_report_device_fault() automatically respond to
unhandleable faults and change its return type to void.
- PATCH 01 ~ 14 are in good shapes now.

v9: https://lore.kernel.org/linux-iommu/[email protected]/
- Protecting the assignment of dev->iommu->fault_param with RCU.
- Extending the fault parameter's lifetime to the entire path of iopf handling.
- Since iopf_queue_flush_dev() can only be called before iopf_queue_remove_device(), there's no need to hold a reference
count.
- Improve iopf_queue_remove_device() as per Jason's comments on the device removal sequence from the iopf queue. This will likely
require changes to the iommu drivers, which are supposed to be addressed in separate series.
- Track the iopf_group as a whole instead of the last fault within the group to simplify the fault report and response paths.
- PATCH 01 ~ 11 are in good shapes now.

v8: https://lore.kernel.org/linux-iommu/[email protected]/
- Drop PATCH 12/12 as it is no longer necessary to drain page requests page requests during PASID translation changes.
- Separate PATCH 11/12 into two distinct patches. The first patch
refines locking scheme for protecting per-device fault data, while
the second patch replaces mutex with RCU to enhance locking
efficiency.
- PATCH 01 ~ 10 are in good shapes now.

v7: https://lore.kernel.org/linux-iommu/[email protected]/
- Rebase to v6.7-rc1.
- Export iopf_group_response() for global use.
- Release lock when calling iopf handler.
- The whole series has been verified to work for SVA case on Intel platforms by Zhao Yan. Add her Tested-by to affected patches.

v6: https://lore.kernel.org/linux-iommu/[email protected]/
- [PATCH 09/12] Check IS_ERR() against the iommu domain. [Jingqi/Jason]
- [PATCH 12/12] Rename the comments and name of iopf_queue_flush_dev(), no functionality changes. [Kevin]
- All patches rebased on the latest iommu/core branch.

v5: https://lore.kernel.org/linux-iommu/[email protected]/
- Consolidate per-device fault data management. (New patch 11)
- Improve iopf_queue_flush_dev(). (New patch 12)

v4: https://lore.kernel.org/linux-iommu/[email protected]/
- Merge iommu_fault_event and iopf_fault. They are duplicate.
- Move iommu_report_device_fault() and iommu_page_response() to io-pgfault.c.
- Move iommu_sva_domain_alloc() to iommu-sva.c.
- Add group->domain and use it directly in sva fault handler.
- Misc code refactoring and refining.

v3: https://lore.kernel.org/linux-iommu/[email protected]/
- Convert the fault data structures from uAPI to kAPI.
- Merge iopf_device_param into iommu_fault_param.
- Add debugging on domain lifetime for iopf.
- Remove patch "iommu: Change the return value of dev_iommu_get()".
- Remove patch "iommu: Add helper to set iopf handler for domain".
- Misc code refactoring and refining.

v2: https://lore.kernel.org/linux-iommu/[email protected]/
- Remove unrecoverable fault data definition as suggested by Kevin.
- Drop the per-device fault cookie code considering that doesn't make
much sense for SVA.
- Make the IOMMU page fault handling framework generic. So that it can available for use cases other than SVA.

v1: https://lore.kernel.org/linux-iommu/[email protected]/

Lu Baolu (16):
iommu: Move iommu fault data to linux/iommu.h iommu/arm-smmu-v3: Remove unrecoverable faults reporting
iommu: Remove unrecoverable fault data
iommu: Cleanup iopf data structure definitions
iommu: Merge iopf_device_param into iommu_fault_param
iommu: Remove iommu_[un]register_device_fault_handler()
iommu: Merge iommu_fault_event and iopf_fault
iommu: Prepare for separating SVA and IOPF
iommu: Make iommu_queue_iopf() more generic
iommu: Separate SVA and IOPF
iommu: Refine locking for per-device fault data management
iommu: Use refcount for fault data access
iommu: Improve iopf_queue_remove_device()
iommu: Track iopf group instead of last fault
iommu: Make iopf_group_response() return void
iommu: Make iommu_report_device_fault() return void

 include/linux/iommu.h                         | 262 +++++++---
 drivers/iommu/intel/iommu.h                   |   4 +-
 drivers/iommu/iommu-sva.h                     |  71 ---
 include/uapi/linux/iommu.h                    | 161 ------
 .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |  14 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 103 ++--
 drivers/iommu/intel/iommu.c                   |  28 +-
 drivers/iommu/intel/svm.c                     |  41 +-
 drivers/iommu/io-pgfault.c                    | 473 ++++++++++--------
 drivers/iommu/iommu-sva.c                     |  71 ++-
 drivers/iommu/iommu.c                         | 233 ---------
 MAINTAINERS                                   |   1 -
 drivers/iommu/Kconfig                         |   4 +
 drivers/iommu/Makefile                        |   3 +-
 drivers/iommu/intel/Kconfig                   |   1 +
 15 files changed, 583 insertions(+), 887 deletions(-)
 delete mode 100644 drivers/iommu/iommu-sva.h
 delete mode 100644 include/uapi/linux/iommu.h
Signature · 1 line
2.34.1