iommu: add preemption support to iommu_{un,}map()
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 25 Jul 2022 13:31:41 +0000 (15:31 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:31:41 +0000 (15:31 +0200)
commitc519819ff5c61ae8b36509c9e8ed9d2a2fdac886
tree056c092c6539256f06a02c1f8e7b0fa06225f763
parentfcd27b3c759995775afb66be6bb7ba1e85da0506
iommu: add preemption support to iommu_{un,}map()

The loop in iommu_{,un}map() can be arbitrary large, and as such it
needs to handle preemption.  Introduce a new flag that signals whether
the function should do preemption checks, returning the number of pages
that have been processed in case a need for preemption was actually
found.

Note that the cleanup done in iommu_map() can now be incomplete if
preemption has happened, and hence callers would need to take care of
unmapping the whole range (ie: ranges already mapped by previously
preempted calls).  So far none of the callers care about having those
ranges unmapped, so error handling in arch_iommu_hwdom_init() can be
kept as-is.

Note that iommu_legacy_{un,}map() are left without preemption handling:
callers of those interfaces aren't going to modified to pass bigger
chunks, and hence the functions won't be modified as they are legacy and
uses should be replaced with iommu_{un,}map() instead if preemption is
required.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/drivers/passthrough/iommu.c
xen/include/xen/iommu.h