Skip to content

Commit 5f9bdbf

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd: Add a flag to enforce dirty tracking on attach
Throughout IOMMU domain lifetime that wants to use dirty tracking, some guarantees are needed such that any device attached to the iommu_domain supports dirty tracking. The idea is to handle a case where IOMMU in the system are assymetric feature-wise and thus the capability may not be supported for all devices. The enforcement is done by adding a flag into HWPT_ALLOC namely: IOMMU_HWPT_ALLOC_DIRTY_TRACKING .. Passed in HWPT_ALLOC ioctl() flags. The enforcement is done by creating a iommu_domain via domain_alloc_user() and validating the requested flags with what the device IOMMU supports (and failing accordingly) advertised). Advertising the new IOMMU domain feature flag requires that the individual iommu driver capability is supported when a future device attachment happens. Link: https://lore.kernel.org/r/20231024135109.73787-6-joao.m.martins@oracle.com Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 750e2e9 commit 5f9bdbf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/iommu/iommufd/hw_pagetable.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
157157
struct iommufd_ioas *ioas;
158158
int rc;
159159

160-
if ((cmd->flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT)) || cmd->__reserved)
160+
if ((cmd->flags & ~(IOMMU_HWPT_ALLOC_NEST_PARENT |
161+
IOMMU_HWPT_ALLOC_DIRTY_TRACKING)) ||
162+
cmd->__reserved)
161163
return -EOPNOTSUPP;
162164

163165
idev = iommufd_get_device(ucmd, cmd->dev_id);

include/uapi/linux/iommufd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,12 @@ struct iommu_vfio_ioas {
351351
* enum iommufd_hwpt_alloc_flags - Flags for HWPT allocation
352352
* @IOMMU_HWPT_ALLOC_NEST_PARENT: If set, allocate a HWPT that can serve as
353353
* the parent HWPT in a nesting configuration.
354+
* @IOMMU_HWPT_ALLOC_DIRTY_TRACKING: Dirty tracking support for device IOMMU is
355+
* enforced on device attachment
354356
*/
355357
enum iommufd_hwpt_alloc_flags {
356358
IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0,
359+
IOMMU_HWPT_ALLOC_DIRTY_TRACKING = 1 << 1,
357360
};
358361

359362
/**

0 commit comments

Comments
 (0)