AMD/IOMMU: correct global exclusion range extending
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:04:44 +0000 (15:04 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:04:44 +0000 (15:04 +0200)
commit8da14912d229eeef969f0738ec98c61a29946d07
tree3d2b0f142d057aeb05be5c89e56fcb600f488ae4
parentf7a973031675e0be4a31178bfae28ab4a305dbdf
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>
master commit: b02c5c88982411be11e3413159862f255f1f39dc
master date: 2021-08-25 14:12:13 +0200
xen/drivers/passthrough/amd/iommu_acpi.c