|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [for-4.15][PATCH v2 4/5] xen/iommu: x86: Don't leak the IOMMU page-tables
On 09.02.2021 16:28, Julien Grall wrote:
> @@ -303,9 +317,29 @@ struct page_info *iommu_alloc_pgtable(struct domain *d)
> unmap_domain_page(p);
>
> spin_lock(&hd->arch.pgtables.lock);
> - page_list_add(pg, &hd->arch.pgtables.list);
> + /*
> + * The IOMMU page-tables are freed when relinquishing the domain, but
> + * nothing prevent allocation to happen afterwards. There is no valid
> + * reasons to continue to update the IOMMU page-tables while the
> + * domain is dying.
> + *
> + * So prevent page-table allocation when the domain is dying.
> + *
> + * We relying on &hd->arch.pgtables.lock to synchronize d->is_dying.
> + */
> + if ( likely(!d->is_dying) )
> + {
> + alive = true;
> + page_list_add(pg, &hd->arch.pgtables.list);
> + }
> spin_unlock(&hd->arch.pgtables.lock);
>
> + if ( unlikely(!alive) )
> + {
> + free_domheap_page(pg);
> + pg = NULL;
> + }
> +
> return pg;
> }
There's a pretty clear downside to this approach compared to that
of ignoring maps (and perhaps also unmaps) for dying domains: The
caller here will (hopefully) recognize and propagate an error.
Additionally (considering the situation patch 5 fixes) ignoring
unmaps may provide quite a bit of a performance gain for domain
destruction - we don't need every individual page unmapped from
the page tables.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |