]> xenbits.xensource.com Git - xen.git/commit
AMD/IOMMU: re-arrange exclusion range and unity map recording
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:16:46 +0000 (14:16 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:16:46 +0000 (14:16 +0200)
commit8ea80530cd0dbb8ffa7ac92606a3ee29663fdc93
tree1509422f2dd37a3511ed45428dfcf8f403bc4341
parent899272539cbe1acda736a850015416fff653a1b6
AMD/IOMMU: re-arrange exclusion range and unity map recording

The spec makes no provisions for OS behavior here to depend on the
amount of RAM found on the system. While the spec may not sufficiently
clearly distinguish both kinds of regions, they are surely meant to be
separate things: Only regions with ACPI_IVMD_EXCLUSION_RANGE set should
be candidates for putting in the exclusion range registers. (As there's
only a single such pair of registers per IOMMU, secondary non-adjacent
regions with the flag set already get converted to unity mapped
regions.)

First of all, drop the dependency on max_page. With commit b4f042236ae0
("AMD/IOMMU: Cease using a dynamic height for the IOMMU pagetables") the
use of it here was stale anyway; it was bogus already before, as it
didn't account for max_page getting increased later on. Simply try an
exclusion range registration first, and if it fails (for being
unsuitable or non-mergeable), register a unity mapping range.

With this various local variables become unnecessary and hence get
dropped at the same time.

With the max_page boundary dropped for using unity maps, the minimum
page table tree height now needs both recording and enforcing in
amd_iommu_domain_init(). Since we can't predict which devices may get
assigned to a domain, our only option is to uniformly force at least
that height for all domains, now that the height isn't dynamic anymore.

Further don't make use of the exclusion range unless ACPI data says so.

Note that exclusion range registration in
register_range_for_all_devices() is on a best effort basis. Hence unity
map entries also registered are redundant when the former succeeded, but
they also do no harm. Improvements in this area can be done later imo.

Also adjust types where suitable without touching extra lines.

This is part of XSA-378.

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