iommufd: Share iommufd_hwpt_alloc with IOMMUFD_OBJ_HWPT_NESTED
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 26 Oct 2023 04:39:33 +0000 (21:39 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 26 Oct 2023 14:15:57 +0000 (11:15 -0300)
commitb5021cb264e67baf051569a41debe277c279952b
tree7cd2efbe8aff5586a0c71f987f8338fe1ff90896
parent89db31635c87a7856e205c7ebf9f562e4bb206fe
iommufd: Share iommufd_hwpt_alloc with IOMMUFD_OBJ_HWPT_NESTED

Allow iommufd_hwpt_alloc() to have a common routine but jump to different
allocators corresponding to different user input pt_obj types, either an
IOMMUFD_OBJ_IOAS for a PAGING hwpt or an IOMMUFD_OBJ_HWPT_PAGING as the
parent for a NESTED hwpt.

Also, move the "flags" validation to the hwpt allocator (paging), so that
later the hwpt_nested allocator can do its own separate flags validation.

Link: https://lore.kernel.org/r/20231026043938.63898-6-yi.l.liu@intel.com
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/hw_pagetable.c