On Fri, 24 Sep 2021 14:48:52 -0300 Jason Gunthorpe <jgg@xxxxxxxx> wrote: > On Fri, Sep 24, 2021 at 05:57:03PM +0200, Christoph Hellwig wrote: > > Ensure pgsize_bitmap is always valid by initializing it to ULONG_MAX > > in vfio_iommu_type1_open and remove the now pointless update for > > the external domain case in vfio_iommu_type1_attach_group, which was > > just setting pgsize_bitmap to ULONG_MAX when only external domains > > were attached. > > > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > > drivers/vfio/vfio_iommu_type1.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > > index a48e9f597cb213..2c698e1a29a1d8 100644 > > +++ b/drivers/vfio/vfio_iommu_type1.c > > @@ -2196,7 +2196,6 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > > if (!iommu->external_domain) { > > INIT_LIST_HEAD(&domain->group_list); > > iommu->external_domain = domain; > > - vfio_update_pgsize_bitmap(iommu); > > } else { > > kfree(domain); > > } > > @@ -2582,6 +2581,7 @@ static void *vfio_iommu_type1_open(unsigned long arg) > > mutex_init(&iommu->lock); > > BLOCKING_INIT_NOTIFIER_HEAD(&iommu->notifier); > > init_waitqueue_head(&iommu->vaddr_wait); > > + iommu->pgsize_bitmap = ULONG_MAX; > > I wonder if this needs the PAGE_MASK/SIZE stuff? > > iommu->pgsize_bitmap = ULONG_MASK & PAGE_MASK; > > ? > > vfio_update_pgsize_bitmap() goes to some trouble to avoid setting bits > below the CPU page size here Yep, though PAGE_MASK should already be UL, so just PAGE_MASK itself should work. The ULONG_MAX in the update function just allows us to detect sub-page, ex. if the IOMMU supports 2K we can expose 4K minimum, but we can't if the min IOMMU page is 64K. Thanks, Alex