[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.15 2/4] xen/iommu: x86: Free the IOMMU page-tables with the pgtables.lock held
From: Julien Grall <jgrall@xxxxxxxxxx> The pgtables.lock is protecting access to the page list pgtables.list. However, iommu_free_pgtables() will not held it. I guess it was assumed that page-tables cannot be allocated while the domain is dying. Unfortunately, there is no guarantee that iommu_map() will not be called while a domain is dying (it looks like to be possible from XEN_DOMCTL_memory_mapping). So it would be possible to be concurrently allocate memory and free the page-tables. Therefore, we need to held the lock when freeing the page tables. There are more issues around the IOMMU page-allocator. They will be handled in follow-up patches. Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> --- xen/drivers/passthrough/x86/iommu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index cea1032b3d02..779dbb5b98ba 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -267,13 +267,18 @@ int iommu_free_pgtables(struct domain *d) struct page_info *pg; unsigned int done = 0; + spin_lock(&hd->arch.pgtables.lock); while ( (pg = page_list_remove_head(&hd->arch.pgtables.list)) ) { free_domheap_page(pg); if ( !(++done & 0xff) && general_preempt_check() ) + { + spin_unlock(&hd->arch.pgtables.lock); return -ERESTART; + } } + spin_unlock(&hd->arch.pgtables.lock); return 0; } -- 2.17.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |