amd iommu: Fix iommu page size encoding when page order > 0.
authorWei Wang <wei.wang2@amd.com>
Tue, 8 Nov 2011 10:25:19 +0000 (11:25 +0100)
committerWei Wang <wei.wang2@amd.com>
Tue, 8 Nov 2011 10:25:19 +0000 (11:25 +0100)
Fix io address in invalid all pages command.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/passthrough/amd/iommu_map.c
xen/include/asm-x86/hvm/svm/amd-iommu-defs.h

index 1402806c5fa6f4ba9be6567d5748651577dfc3aa..6c7f7a19b8b7a483c349a2dabdd6397f1e3df0c8 100644 (file)
@@ -77,25 +77,26 @@ static void invalidate_iommu_pages(struct amd_iommu *iommu,
 {
     u64 addr_lo, addr_hi;
     u32 cmd[4], entry;
-    u64 mask = 0;
     int sflag = 0, pde = 0;
 
-    /* If sflag == 1, the size of the invalidate command is determined
-     by the first zero bit in the address starting from Address[12] */
-    if ( order == 9 || order == 18 )
-    {
-        mask = ((1ULL << (order - 1)) - 1) << PAGE_SHIFT;
-        io_addr |= mask;
-        sflag = 1;
-    }
+    ASSERT ( order == 0 || order == 9 || order == 18 );
 
     /* All pages associated with the domainID are invalidated */
-    else if ( io_addr == 0x7FFFFFFFFFFFF000ULL )
+    if ( order || (io_addr == INV_IOMMU_ALL_PAGES_ADDRESS ) )
     {
         sflag = 1;
         pde = 1;
     }
 
+    /* If sflag == 1, the size of the invalidate command is determined
+     by the first zero bit in the address starting from Address[12] */
+    if ( order )
+    {
+        u64 mask = 1ULL << (order - 1 + PAGE_SHIFT);
+        io_addr &= ~mask;
+        io_addr |= mask - 1;
+    }
+
     addr_lo = io_addr & DMA_32BIT_MASK;
     addr_hi = io_addr >> 32;
 
@@ -917,7 +918,7 @@ static void _amd_iommu_flush_pages(struct domain *d,
 
 void amd_iommu_flush_all_pages(struct domain *d)
 {
-    _amd_iommu_flush_pages(d, 0x7FFFFFFFFFFFFULL, 0);
+    _amd_iommu_flush_pages(d, INV_IOMMU_ALL_PAGES_ADDRESS, 0);
 }
 
 void amd_iommu_flush_pages(struct domain *d,
index 5303bdde885efcc7aaca053a94861f016c3c4b10..a94303a39dc12596160ec89d1cd37dc70fc3bbf3 100644 (file)
 #define INT_REMAP_ENTRY_VECTOR_MASK     0x00FF0000
 #define INT_REMAP_ENTRY_VECTOR_SHIFT    16
 
+#define INV_IOMMU_ALL_PAGES_ADDRESS      ((1ULL << 63) - 1)
+
 #endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */