xen/x86: iommu: Ignore IOMMU mapping requests when a domain is dying
authorJulien Grall <jgrall@amazon.com>
Fri, 26 Feb 2021 10:56:39 +0000 (10:56 +0000)
committerJulien Grall <jgrall@amazon.com>
Tue, 2 Mar 2021 09:52:30 +0000 (09:52 +0000)
commit1ef48c82e77692f63114cb6bdeee8a9261dbe493
tree8b50b6992840d7fc657acdac1b5b19ba40c88637
parentf4cf483e2a1aec2b359347f0a34abd6bf2f208c2
xen/x86: iommu: Ignore IOMMU mapping requests when a domain is dying

The new x86 IOMMU page-tables allocator will release the pages when
relinquishing the domain resources. However, this is not sufficient
when the domain is dying because nothing prevents page-table to be
allocated.

As the domain is dying, it is not necessary to continue to modify the
IOMMU page-tables as they are going to be destroyed soon.

At the moment, page-table allocates will only happen when iommu_map().
So after this change there will be no more page-table allocation
happening because we don't use superpage mappings yet when not sharing
page tables.

In order to observe d->is_dying correctly, we need to rely on per-arch
locking, so the check to ignore IOMMU mapping is added on the per-driver
map_page() callback.

Fixes: 15bc9a1ef51c ("x86/iommu: add common page-table allocator")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/x86/iommu.c