The IVRS ACPI table specifies maximum address sizes for I/O virtual
addresses. When allocating new protection domains that perform
translation, propagate these limits as the domain's geometry / aperture.

Based on prior work by Marius Hillenbrand.

Signed-off-by: Sebastian Ott <seb...@amazon.de>
---
 drivers/iommu/amd_iommu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index fb4a44550c4a..d2e79e27778e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2460,6 +2460,7 @@ static struct protection_domain 
*protection_domain_alloc(void)
 
 static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
 {
+       dma_addr_t max_va = DMA_BIT_MASK(amd_iommu_ivrs_va_size);
        struct protection_domain *pdomain;
        u64 *pt_root, root;
 
@@ -2477,11 +2478,6 @@ static struct iommu_domain 
*amd_iommu_domain_alloc(unsigned type)
 
                root = amd_iommu_domain_encode_pgtable(pt_root, 
PAGE_MODE_3_LEVEL);
                atomic64_set(&pdomain->pt_root, root);
-
-               pdomain->domain.geometry.aperture_start = 0;
-               pdomain->domain.geometry.aperture_end   = ~0ULL;
-               pdomain->domain.geometry.force_aperture = true;
-
                break;
        case IOMMU_DOMAIN_DMA:
                pdomain = dma_ops_domain_alloc();
@@ -2501,6 +2497,10 @@ static struct iommu_domain 
*amd_iommu_domain_alloc(unsigned type)
                return NULL;
        }
 
+       pdomain->domain.geometry.aperture_start = 0;
+       pdomain->domain.geometry.aperture_end   = max_va;
+       pdomain->domain.geometry.force_aperture = true;
+
        return &pdomain->domain;
 }
 
-- 
2.17.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to