iommu/amd: Fix the configuration of GCR3 table root pointer
authorAdrian Huang <ahuang12@lenovo.com>
Fri, 14 Feb 2020 10:44:51 +0000 (18:44 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 28 Feb 2020 15:19:48 +0000 (16:19 +0100)
The SPA of the GCR3 table root pointer[51:31] masks 20 bits. However,
this requires 21 bits (Please see the AMD IOMMU specification).
This leads to the potential failure when the bit 51 of SPA of
the GCR3 table root pointer is 1'.

Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
Fixes: 52815b75682e2 ("iommu/amd: Add support for IOMMUv2 domain mode")
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu_types.h

index f8d01d6b00da7d9f1e94f7819888e7200019ad06..ca8c4522045b35d1c57c76711a2af9cf0f03a439 100644 (file)
 
 #define DTE_GCR3_VAL_A(x)      (((x) >> 12) & 0x00007ULL)
 #define DTE_GCR3_VAL_B(x)      (((x) >> 15) & 0x0ffffULL)
-#define DTE_GCR3_VAL_C(x)      (((x) >> 31) & 0xfffffULL)
+#define DTE_GCR3_VAL_C(x)      (((x) >> 31) & 0x1fffffULL)
 
 #define DTE_GCR3_INDEX_A       0
 #define DTE_GCR3_INDEX_B       1