AMD/IOMMU: correct global exclusion range extending
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:12:13 +0000 (14:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:12:13 +0000 (14:12 +0200)
commitb02c5c88982411be11e3413159862f255f1f39dc
tree732aa000942852035ed981e5238f40a57e505f1b
parenta931e8e64af07bd333a31f3b71a3f8f3e7910857
AMD/IOMMU: correct global exclusion range extending

Besides unity mapping regions, the AMD IOMMU spec also provides for
exclusion ranges (areas of memory not to be subject to DMA translation)
to be specified by firmware in the ACPI tables. The spec does not put
any constraints on the number of such regions.

Blindly assuming all addresses between any two such ranges should also
be excluded can't be right. Since hardware has room for just a single
such range (comprised of the Exclusion Base Register and the Exclusion
Range Limit Register), combine only adjacent or overlapping regions (for
now; this may require further adjustment in case table entries aren't
sorted by address) with matching exclusion_allow_all settings. This
requires bubbling up error indicators, such that IOMMU init can be
failed when concatenation wasn't possible.

Furthermore, since the exclusion range specified in IOMMU registers
implies R/W access, reject requests asking for less permissions (this
will be brought closer to the spec by a subsequent change).

This is part of XSA-378 / CVE-2021-28695.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/drivers/passthrough/amd/iommu_acpi.c