]> xenbits.xensource.com Git - xen.git/commitdiff
AMD/IOMMU: abstract maximum number of page table levels
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2022 13:42:01 +0000 (15:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Apr 2022 13:42:01 +0000 (15:42 +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_map.c
xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h

index 0b619e235e4fe2a0a9d97a0e20614742265ba2db..62bcfc5af78a38658b143e36d7956a784a85237a 100644 (file)
@@ -477,7 +477,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
index d9ec20cc900365869fd379cd0ae159bd1b73384e..ee3380c131411daaac5edb86b0ceb517b96264d9 100644 (file)
 #define IOMMU_DEV_TABLE_PAGE_TABLE_PTR_LOW_MASK                0xFFFFF000
 #define IOMMU_DEV_TABLE_PAGE_TABLE_PTR_LOW_SHIFT       12
 
+#define IOMMU_MAX_PT_LEVELS 6
+
 /* DeviceTable Entry[63:32] */
 #define IOMMU_DEV_TABLE_GV_SHIFT                    23
 #define IOMMU_DEV_TABLE_GV_MASK                     0x800000
index a3211ccdfb0088449efff43883f4331cea030f21..35b7d9eb231d2798d434ef9b576a6a230d2c0c19 100644 (file)
@@ -185,7 +185,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;
     }