]> xenbits.xensource.com Git - xen.git/commit
IOMMU: suppress "iommu_dont_flush_iotlb" when about to free a page
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 12:21:09 +0000 (14:21 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 12:21:09 +0000 (14:21 +0200)
commitdea460d86957bf1425a8a1572626099ac3f165a8
treee2e6b58f0955f1476a53f0bf285f261a26fc3e34
parent1ce75e99d75907aaffae05fcf658a833802bce49
IOMMU: suppress "iommu_dont_flush_iotlb" when about to free a page

Deferring flushes to a single, wide range one - as is done when
handling XENMAPSPACE_gmfn_range - is okay only as long as
pages don't get freed ahead of the eventual flush. While the only
function setting the flag (xenmem_add_to_physmap()) suggests by its name
that it's only mapping new entries, in reality the way
xenmem_add_to_physmap_one() works means an unmap would happen not only
for the page being moved (but not freed) but, if the destination GFN is
populated, also for the page being displaced from that GFN. Collapsing
the two flushes for this GFN into just one (end even more so deferring
it to a batched invocation) is not correct.

This is part of XSA-346.

Fixes: cf95b2a9fd5a ("iommu: Introduce per cpu flag (iommu_dont_flush_iotlb) to avoid unnecessary iotlb... ")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/common/memory.c