Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cover-letter: iommufd support pasid attach/replace
PASID (Process Address Space ID) is a PCIe extension to tag the DMA transactions out of a physical device, and most modern IOMMU hardware have supported PASID granular address translation. So a PASID-capable device can be attached to multiple hwpts (a.k.a. domains), and each attachment is tagged with a pasid. This series is based on the preparation series [1] [2], it first adds a missing iommu API to replace the domain for a pasid. Based on the iommu pasid attach/ replace/detach APIs, this series adds iommufd APIs for device drivers to attach/replace/detach pasid to/from hwpt per userspace's request, and adds selftest to validate the iommufd APIs. The completed code can be found in the below link [3]. Heads up! The existing iommufd selftest was broken, there was a temp fix patch in the top of the branch [3]. If want to run the iommufd selftest, please apply that fix. Sorry for the inconvenience. [1] https://lore.kernel.org/linux-iommu/[email protected]/ # done [2] https://lore.kernel.org/linux-iommu/[email protected]/ [3] https://github.com/yiliu1765/iommufd/tree/iommufd_pasid [4] https://lore.kernel.org/linux-iommu/[email protected]/ Change log: v6: - Add kdoc to iommufd_device_get_attach_handle() to note the returned handle should be used with care. (Baolu) - Reworked the patch 07 and 08 of v5 to avoid domain allocation failure on VT-d after applying patch 07 of v5. 1) Split out the intel iommu driver IOMMU_HWPT_ALLOC_PASID support out of patch 08 2) Make the other parts of patch 07 and 08 into "Allow allocating PASID-compatible domain" and "iommufd: Enforce PASID-compatible domain for PASID-capable device" In this way, IOMMU_HWPT_ALLOC_PASID is enforced in iommufd pasid support on day1. - Enhanced the pasid selftest to have non-pasid-capable device and pasid-capable device. - Rebased on top of 6.13-rc2 and some already applied patches. v5: https://lore.kernel.org/linux-iommu/[email protected]/ - Fix a mistake in patch 02 of v4 (Kevin) - Move the iommufd_handle helpers to device.c - Add IOMMU_HWPT_ALLOC_PASID check to enforce pasid-compatible domain for pasid capable device in iommufd - Update the iommufd selftest to use IOMMU_HWPT_ALLOC_PASID v4: https://lore.kernel.org/linux-iommu/[email protected]/ - Replace remove_dev_pasid() by supporting set_dev_pasid() for blocking domain (Kevin) - This is done by the preparation series "Support attaching PASID to the blocked_domain" - Misc tweaks to foil the merging of the iommufd iopf series. Three new patches are added: - iommufd: Always pass iommu_attach_handle to iommu core - iommufd: Move the iommufd_handle helpers to iommufd_private.h - iommufd: Refactor __fault_domain_replace_dev() to be a wrapper of iommu_replace_group_handle() - Renmae patch 03 of v3 to be "iommufd: Support pasid attach/replace" - Add test case for attaching/replacing iopf-capable hwpt to pasid v3: https://lore.kernel.org/kvm/[email protected]/ - Split the set_dev_pasid op enhancements for domain replacement to be a separate series "Make set_dev_pasid op supportting domain replacement" [1]. The below changes are made in the separate series. *) set_dev_pasid() callback should keep the old config if failed to attach to a domain. This simplifies the caller a lot as caller does not need to attach it back to old domain explicitly. This also avoids some corner cases in which the core may do duplicated domain attachment as described in below link (Jason) https://lore.kernel.org/linux-iommu/BN9PR11MB52768C98314A95AFCD2FA6478C0F2@BN9PR11MB5276.namprd11.prod.outlook.com/ *) Drop patch 10 of v2 as it's a bug fix and can be submitted separately (Kevin) *) Rebase on top of Baolu's domain_alloc_paging refactor series (Jason) - Drop the attach_data which includes attach_fn and pasid, insteadly passing the pasid through the device attach path. (Jason) - Add a pasid-num-bits property to mock dev to make pasid selftest work (Kevin) v2: https://lore.kernel.org/linux-iommu/[email protected]/ - Domain replace for pasid should be handled in set_dev_pasid() callbacks instead of remove_dev_pasid and call set_dev_pasid afteward in iommu layer (Jason) - Make xarray operations more self-contained in iommufd pasid attach/replace/detach (Jason) - Tweak the dev_iommu_get_max_pasids() to allow iommu driver to populate the max_pasids. This makes the iommufd selftest simpler to meet the max_pasids check in iommu_attach_device_pasid() (Jason) v1: https://lore.kernel.org/kvm/[email protected]/#r - Implemnet iommu_replace_device_pasid() to fall back to the original domain if this replacement failed (Kevin) - Add check in do_attach() to check corressponding attach_fn per the pasid value. rfc: https://lore.kernel.org/linux-iommu/[email protected]/ Regards, Yi Liu Signed-off-by: Yi Liu <[email protected]>
- Loading branch information