Re: [RFC v2 2/5] vfio/type1: Check reserve region conflict and update iova list

From: Alex Williamson
Date: Fri Jan 19 2018 - 10:45:50 EST


On Fri, 19 Jan 2018 09:48:22 +0000
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@xxxxxxxxxx> wrote:
> > > +static void vfio_iommu_iova_resv_refresh(struct vfio_iommu *iommu)
> > > +{
> > > + struct vfio_domain *d;
> > > + struct vfio_group *g;
> > > + struct vfio_iova *node, *tmp;
> > > + struct iommu_resv_region *resv, *resv_next;
> > > + struct list_head resv_regions;
> > > + phys_addr_t start, end;
> > > +
> > > + INIT_LIST_HEAD(&resv_regions);
> > > +
> > > + list_for_each_entry(d, &iommu->domain_list, next) {
> > > + list_for_each_entry(g, &d->group_list, next)
> > > + iommu_get_group_resv_regions(g->iommu_group,
> > > + &resv_regions);
> > > + }
> > > +
> > > + if (list_empty(&resv_regions))
> > > + return;
> > > +
> > > + list_sort(NULL, &resv_regions, vfio_resv_cmp);
> > > +
> > > + node = list_first_entry(&iommu->iova_list, struct vfio_iova, list);
> > > + start = node->start;
> > > + node = list_last_entry(&iommu->iova_list, struct vfio_iova, list);
> > > + end = node->end;
> >
> > list_sort() only sorts based on ->start, we added reserved regions for
> > all our groups to one list, we potentially have multiple entries with
> > the same ->start. How can we be sure that the last one in the list
> > actually has the largest ->end value?
>
> Hmm.. the sorting is done on the reserved list. The start and end entries
> are of the iova list which is kept updated on _attach(). So I don't think
> there is a problem here.

Oops, yes you're right. List confusion. Thanks,

Alex