Skip to content

IOMMU user API enhancement

Jacob Pan linux-api linux-doc linux-iommu lkml 5 versions – Applied

Status from this message: Queued for v5.10 now, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v12 Latest6 patches 4 repliesApplied
  2. v116 patches 2 repliesSuperseded
  3. v107 patches 0 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v97 patches9 repliesSuperseded
v87 patches5 repliesSuperseded

Changelog from the cover letter · 32 lines

v12
- Removed a redundant check in cache invalidate API
v11
- Use #define instead of enum in PASID data format, squashed change into "iommu/uapi: Handle data and argsz filled by users"
- Remove alloc/free from documentation per Yi's comment. IOMMU UAPI does not perform IOASID alloc/free.
v10
- Documentation grammar fixes based on Randy's review
v9
- Directly pass PASID value to iommu_sva_unbind_gpasid() without the superfluous data in struct iommu_gpasid_bind_data.
v8
- Rebased to v5.9-rc2
- Addressed review comments from Eric Auger
1. added a check for the unused vendor flags
2. commit message improvements
v7
- Added PASID data format enum for range checking
- Tidy up based on reviews from Alex W.
- Removed doc section for vIOMMU fault handling
v6
- Renamed all UAPI functions with iommu_uapi_ prefix
- Replaced argsz maxsz checking with flag specific size checks
- Documentation improvements based on suggestions by Eric Auger Replaced example code with a pointer to the actual code
- Added more checks for illegal flags combinations
- Added doc file to MAINTAINERS
v5
- Addjusted paddings in UAPI data to be 8 byte aligned
- Do not clobber argsz in IOMMU core before passing on to vendor driver
- Removed pr_warn_ for invalid UAPI data check, just return -EINVAL
- Clarified VFIO responsibility in UAPI data handling
- Use iommu_uapi prefix to differentiate APIs has in-kernel caller
- Added comment for unchecked flags of invalidation granularity
- Added example in doc to show vendor data checking

Patches in v12 Applied

#Subject and filesSizeRepliesApplied
1/6docs: IOMMU user APIDocumentation/userspace-api/iommu.rst MAINTAINERS+210 -00 replies
2/6iommu/uapi: Add argsz for user filled datainclude/uapi/linux/iommu.h+9 -30 replies
3/6iommu/uapi: Use named union for user datadrivers/iommu/intel/iommu.c drivers/iommu/intel/svm.c include/uapi/linux/iommu.h+14 -140 replies
4/6iommu/uapi: Rename uapi functionsdrivers/iommu/iommu.c include/linux/iommu.h+25 -240 replies
5/6iommu/uapi: Handle data and argsz filled by usersdrivers/iommu/iommu.c include/linux/iommu.h include/uapi/linux/iommu.h+207 -161 reply
6/6iommu/vt-d: Check UAPI data processed by IOMMU coredrivers/iommu/intel/iommu.c drivers/iommu/intel/svm.c include/uapi/linux/iommu.h+11 -41 reply

Reviews trailers per patch

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

PatchEric AugerLu BaoluJean-Philippe Brucker
1/6R-b
2/6R-b
3/6R-b R-b
4/6R-b
5/6R-b R-b
6/6R-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 3 reviewers.

Read the v12 thread

Cover letter [PATCH v12 0/6] IOMMU user API enhancement

IOMMU user API header was introduced to support nested DMA translation and related fault handling. The current UAPI data structures consist of three areas that cover the interactions between host kernel and guest:
- fault handling
- cache invalidation
- bind guest page tables, i.e. guest PASID

Future extensions are likely to support more architectures and vIOMMU features.

In the previous discussion, using user-filled data size and feature flags is made a preferred approach over a unified version number.
https://lkml.org/lkml/2020/1/29/45

In addition to introduce argsz field to data structures, this patchset is also trying to document the UAPI design, usage, and extension rules. VT-d driver changes to utilize the new argsz field is included, VFIO usage is to follow.

This set is available at:
https://github.com/jacobpan/linux.git vsva_v5.9_uapi_v12

Thanks,

Jacob

Changelog:
v12
- Removed a redundant check in cache invalidate API
v11
- Use #define instead of enum in PASID data format, squashed change into "iommu/uapi: Handle data and argsz filled by users"
- Remove alloc/free from documentation per Yi's comment. IOMMU UAPI does not perform IOASID alloc/free.
v10
- Documentation grammar fixes based on Randy's review
v9
- Directly pass PASID value to iommu_sva_unbind_gpasid() without the superfluous data in struct iommu_gpasid_bind_data.
v8
- Rebased to v5.9-rc2
- Addressed review comments from Eric Auger
1. added a check for the unused vendor flags
2. commit message improvements
v7
- Added PASID data format enum for range checking
- Tidy up based on reviews from Alex W.
- Removed doc section for vIOMMU fault handling
v6
- Renamed all UAPI functions with iommu_uapi_ prefix
- Replaced argsz maxsz checking with flag specific size checks
- Documentation improvements based on suggestions by Eric Auger Replaced example code with a pointer to the actual code
- Added more checks for illegal flags combinations
- Added doc file to MAINTAINERS
v5
- Addjusted paddings in UAPI data to be 8 byte aligned
- Do not clobber argsz in IOMMU core before passing on to vendor driver
- Removed pr_warn_ for invalid UAPI data check, just return -EINVAL
- Clarified VFIO responsibility in UAPI data handling
- Use iommu_uapi prefix to differentiate APIs has in-kernel caller
- Added comment for unchecked flags of invalidation granularity
- Added example in doc to show vendor data checking

v4
- Added checks of UAPI data for reserved fields, version, and flags.
- Removed version check from vendor driver (vt-d)
- Relaxed argsz check to match the UAPI struct size instead of variable union size
- Updated documentation

v3:
- Rewrote backward compatibility rule to support existing code re-compiled with newer kernel UAPI header that runs on older kernel. Based on review comment from Alex W.
https://lore.kernel.org/linux-iommu/[email protected]/
- Take user pointer directly in UAPI functions. Perform argsz check and copy_from_user() in IOMMU driver. Eliminate the need for VFIO or other upper layer to parse IOMMU data.
- Create wrapper function for in-kernel users of UAPI functions
v2:
- Removed unified API version and helper
- Introduced argsz for each UAPI data
- Introduced UAPI doc

Jacob Pan (6):
docs: IOMMU user API
iommu/uapi: Add argsz for user filled data iommu/uapi: Use named union for user data iommu/uapi: Rename uapi functions iommu/uapi: Handle data and argsz filled by users iommu/vt-d: Check UAPI data processed by IOMMU core

 Documentation/userspace-api/iommu.rst | 209 ++++++++++++++++++++++++++++++++++
 MAINTAINERS                           |   1 +
 drivers/iommu/intel/iommu.c           |  25 ++--
 drivers/iommu/intel/svm.c             |  13 ++-
 drivers/iommu/iommu.c                 | 196 +++++++++++++++++++++++++++++--
 include/linux/iommu.h                 |  35 ++++--
 include/uapi/linux/iommu.h            |  18 ++-
 7 files changed, 456 insertions(+), 41 deletions(-)
 create mode 100644 Documentation/userspace-api/iommu.rst
Signature · 1 line
2.7.4