mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 06:02:05 +00:00
iommufd: Support allocating nested parent domain
Extend IOMMU_HWPT_ALLOC to allocate domains to be used as parent (stage-2) in nested translation. Add IOMMU_HWPT_ALLOC_NEST_PARENT to the uAPI. Link: https://lore.kernel.org/r/20230928071528.26258-5-yi.l.liu@intel.com Signed-off-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
89d63875d8
commit
4ff5421633
@ -83,6 +83,9 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
|
||||
|
||||
lockdep_assert_held(&ioas->mutex);
|
||||
|
||||
if (flags && !ops->domain_alloc_user)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
hwpt = iommufd_object_alloc(ictx, hwpt, IOMMUFD_OBJ_HW_PAGETABLE);
|
||||
if (IS_ERR(hwpt))
|
||||
return hwpt;
|
||||
@ -154,7 +157,7 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
|
||||
struct iommufd_ioas *ioas;
|
||||
int rc;
|
||||
|
||||
if (cmd->flags || cmd->__reserved)
|
||||
if ((cmd->flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT)) || cmd->__reserved)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
idev = iommufd_get_device(ucmd, cmd->dev_id);
|
||||
|
@ -347,10 +347,20 @@ struct iommu_vfio_ioas {
|
||||
};
|
||||
#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
|
||||
|
||||
/**
|
||||
* enum iommufd_hwpt_alloc_flags - Flags for HWPT allocation
|
||||
* @IOMMU_HWPT_ALLOC_NEST_PARENT: If set, allocate a domain which can serve
|
||||
* as the parent domain in the nesting
|
||||
* configuration.
|
||||
*/
|
||||
enum iommufd_hwpt_alloc_flags {
|
||||
IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct iommu_hwpt_alloc - ioctl(IOMMU_HWPT_ALLOC)
|
||||
* @size: sizeof(struct iommu_hwpt_alloc)
|
||||
* @flags: Must be 0
|
||||
* @flags: Combination of enum iommufd_hwpt_alloc_flags
|
||||
* @dev_id: The device to allocate this HWPT for
|
||||
* @pt_id: The IOAS to connect this HWPT to
|
||||
* @out_hwpt_id: The ID of the new HWPT
|
||||
|
Loading…
Reference in New Issue
Block a user