On 23/09/2023 02:24, Joao Martins wrote: > +int iopt_read_and_clear_dirty_data(struct io_pagetable *iopt, > + struct iommu_domain *domain, > + unsigned long flags, > + struct iommufd_dirty_data *bitmap) > +{ > + unsigned long last_iova, iova = bitmap->iova; > + unsigned long length = bitmap->length; > + int ret = -EOPNOTSUPP; > + > + if ((iova & (iopt->iova_alignment - 1))) > + return -EINVAL; > + > + if (check_add_overflow(iova, length - 1, &last_iova)) > + return -EOVERFLOW; > + > + down_read(&iopt->iova_rwsem); > + ret = iommu_read_and_clear_dirty(domain, flags, bitmap); > + up_read(&iopt->iova_rwsem); > + return ret; > +} I need to call out that a mistake I made, noticed while submitting. I should be walk over iopt_areas here (or in iommu_read_and_clear_dirty()) to check area::pages. So this is a comment I have to fix for next version. I did that for clear_dirty but not for this function hence half-backed. There are a lot of other changes nonetheless, so didn't wanted to break what I had there. Apologies for the distraction. Joao