VT-d: undo device mappings upon error
authorJan Beulich <jbeulich@suse.com>
Thu, 24 Jun 2021 14:28:25 +0000 (16:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 24 Jun 2021 14:28:25 +0000 (16:28 +0200)
commitf3401d65d9f0dce508c3d7da55de4a093d748ae1
tree6ebacc6875d01f64037c3877c6db297ad84f64cb
parent90bafdba8ebf41c9af31b5c725a938da2a75d292
VT-d: undo device mappings upon error

When
 - flushes (supposedly not possible anymore after XSA-373),
 - secondary mappings for legacy PCI devices behind bridges,
 - secondary mappings for chipset quirks, or
 - find_upstream_bridge() invocations
fail, the successfully established device mappings should not be left
around.

Further, when (parts of) unmapping fail, simply returning an error is
typically not enough. Crash the domain instead in such cases, arranging
for domain cleanup to continue in a best effort manner despite such
failures.

Finally make domain_context_unmap()'s error behavior consistent in the
legacy PCI device case: Don't bail from the function in one special
case, but always just exit the switch statement.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
xen/drivers/passthrough/vtd/iommu.c