AMD/IOMMU: correct device unity map handling
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:05:03 +0000 (15:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:05:03 +0000 (15:05 +0200)
commit100b2e2d5ee0ea5549113ad6b15f4b532c13bcd7
treee40f1a6db2410bb766d07a30de91d6e980ae65d3
parent8da14912d229eeef969f0738ec98c61a29946d07
AMD/IOMMU: correct device unity map handling

Blindly assuming all addresses between any two such ranges, specified by
firmware in the ACPI tables, should also be unity-mapped can't be right.
Nor can it be correct to merge ranges with differing permissions. Track
ranges individually; don't merge at all, but check for overlaps instead.
This requires bubbling up error indicators, such that IOMMU init can be
failed when allocation of a new tracking struct wasn't possible, or an
overlap was detected.

At this occasion also stop ignoring
amd_iommu_reserve_domain_unity_map()'s return value.

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

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
master commit: 34750a3eb022462cdd1c36e8ef9049d3d73c824c
master date: 2021-08-25 14:15:11 +0200
xen/drivers/passthrough/amd/iommu.h
xen/drivers/passthrough/amd/iommu_acpi.c
xen/drivers/passthrough/amd/pci_amd_iommu.c