On Wed, Feb 08, 2023 at 08:31:45PM -0800, Yi Liu wrote: > Today iommufd allocates the kernel-managed hw_pagetabe implicitly when > device is attached to an IOAS. This links the hw_pagetable to IOPT within > IOAS. > > However, this is not the perfect way. It makes much sense to let userspace > explicitly request hw_pagtable allocation via iommufd. The reason is even > though the hw_pagetable is kernel-managed, the mappings are feed by > userspace. Also, this makes the lifecircle of kernel-managed hw_pagetable > more clear during usage. This is very important in the usage of nested > translation, in which the kernel-managed hw_pagetable would be used as the > stage-2 hw_pagetable. In such case, both stage-1 and stage-2 hw_pagetable > should be allocated by userspace to ensure the life-circle. > > This adds an ioctl IOMMU_HWPT_ALLOC for the hw_pagetable allocation. For > kernel-managed hw_pagetable, userspace should provide an IOAS ID in the > allocation request. > > Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx> > Signed-off-by: Yi Liu <yi.l.liu@xxxxxxxxx> > --- > drivers/iommu/iommufd/device.c | 11 ++- > drivers/iommu/iommufd/hw_pagetable.c | 116 ++++++++++++++++++++++++ > drivers/iommu/iommufd/iommufd_private.h | 15 +++ > drivers/iommu/iommufd/main.c | 3 + > include/uapi/linux/iommufd.h | 48 ++++++++++ > 5 files changed, 191 insertions(+), 2 deletions(-) This patch and its requirements should all be first in the series. A mini series who's only job is to add IOMMU_HWPT_ALLOC Then patches to add IOMMU_HWPT_INVALIDATE Then the vt-d implementation of all this, including the vt-d specific changes to the uapi/etc. Jason