AMD/IOMMU: wait for command slot to be available
authorJan Beulich <jbeulich@suse.com>
Tue, 8 Jun 2021 17:16:15 +0000 (18:16 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 8 Jun 2021 17:36:03 +0000 (18:36 +0100)
commit766b1f447314dd5e8f14c540440cbfc080f3b998
treefe151715d003711181ff1ae5f24008217bb73b87
parente5bce3a74bacfe570233d61e57d31438d21fafd5
AMD/IOMMU: wait for command slot to be available

No caller cared about send_iommu_command() indicating unavailability of
a slot. Hence if a sufficient number prior commands timed out, we did
blindly assume that the requested command was submitted to the IOMMU
when really it wasn't. This could mean both a hanging system (waiting
for a command to complete that was never seen by the IOMMU) or blindly
propagating success back to callers, making them believe they're fine
to e.g. free previously unmapped pages.

Fold the three involved functions into one, add spin waiting for an
available slot along the lines of VT-d's qinval_next_index(), and as a
consequence drop all error indicator return types/values.

This is part of XSA-373 / CVE-2021-28692.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
(cherry picked from commit c4e44343579e2c3304d676404d81b2b9bd893c5b)
xen/drivers/passthrough/amd/iommu_cmd.c