]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
AMD/IOMMU: abstract maximum number of page table levels
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2022 13:14:33 +0000 (15:14 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2022 13:14:33 +0000 (15:14 +0200)
We will want to use the constant elsewhere.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
master commit: a038b514c1e970a8dc32229cbd31f6769ee61ad5
master date: 2022-04-05 14:20:04 +0200

xen/drivers/passthrough/amd/iommu-defs.h
xen/drivers/passthrough/amd/iommu.h
xen/drivers/passthrough/amd/iommu_map.c

index 0c97db2a3297acd8575bf19fe769cc5e20a0a3b9..8810e497b9b5989eb44ce550ed3aedafc0117f08 100644 (file)
@@ -106,6 +106,7 @@ struct amd_iommu_dte {
     bool tv:1;
     unsigned int :5;
     unsigned int had:2;
+#define IOMMU_MAX_PT_LEVELS 6
     unsigned int paging_mode:3;
     uint64_t pt_root:40;
     bool ppr:1;
index 79c6a5b5b0c89caf0aff1275a22c9079e9f11c5e..1cddbb9f94dbbefde4b3651366377654229f672d 100644 (file)
@@ -362,7 +362,7 @@ static inline int amd_iommu_get_paging_mode(unsigned long max_frames)
     while ( max_frames > PTE_PER_TABLE_SIZE )
     {
         max_frames = PTE_PER_TABLE_ALIGN(max_frames) >> PTE_PER_TABLE_SHIFT;
-        if ( ++level > 6 )
+        if ( ++level > IOMMU_MAX_PT_LEVELS )
             return -ENOMEM;
     }
 
index eb38c9a0bf269b6e2ae432e2deab475d4b7c58f6..544c5bc2e44be7c03e20b47b1c015bb88095ea5d 100644 (file)
@@ -256,7 +256,7 @@ static int iommu_pde_from_dfn(struct domain *d, unsigned long dfn,
     table = hd->arch.root_table;
     level = hd->arch.paging_mode;
 
-    BUG_ON( table == NULL || level < 1 || level > 6 );
+    BUG_ON( table == NULL || level < 1 || level > IOMMU_MAX_PT_LEVELS );
 
     /*
      * A frame number past what the current page tables can represent can't