IntelSiliconPkg: Fix VS2015 NOOPT IA32 build failure in IntelVTdDxe
authorStar Zeng <star.zeng@intel.com>
Thu, 10 Aug 2017 05:11:14 +0000 (13:11 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 11 Aug 2017 01:30:19 +0000 (09:30 +0800)
There are VS2015 NOOPT IA32 build failure like below in IntelVTdDxe.
XXX.lib(XXX.obj) : error LNK2001: unresolved external symbol __allshl
XXX.lib(XXX.obj) : error LNK2001: unresolved external symbol __aullshr

This patch is to update Vtd.h to use UINT32 instead of UINT64 for
bitfields in structure definition, and also update IntelVTdDxe code
accordingly.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
IntelSiliconPkg/Include/IndustryStandard/Vtd.h
IntelSiliconPkg/IntelVTdDxe/DmaProtection.h
IntelSiliconPkg/IntelVTdDxe/PciInfo.c
IntelSiliconPkg/IntelVTdDxe/TranslationTable.c
IntelSiliconPkg/IntelVTdDxe/TranslationTableEx.c
IntelSiliconPkg/IntelVTdDxe/VtdReg.c

index 5c6a494..3b7012c 100644 (file)
 \r
 typedef union {\r
   struct {\r
-    UINT64  Present:1;\r
-    UINT64  Reserved_1:11;\r
-    UINT64  ContextTablePointer:52;\r
+    UINT32  Present:1;\r
+    UINT32  Reserved_1:11;\r
+    UINT32  ContextTablePointerLo:20;\r
+    UINT32  ContextTablePointerHi:32;\r
 \r
     UINT64  Reserved_64;\r
   } Bits;\r
@@ -40,13 +41,15 @@ typedef union {
 \r
 typedef union {\r
   struct {\r
-    UINT64  LowerPresent:1;\r
-    UINT64  Reserved_1:11;\r
-    UINT64  LowerContextTablePointer:52;\r
-\r
-    UINT64  UpperPresent:1;\r
-    UINT64  Reserved_65:11;\r
-    UINT64  UpperContextTablePointer:52;\r
+    UINT32  LowerPresent:1;\r
+    UINT32  Reserved_1:11;\r
+    UINT32  LowerContextTablePointerLo:20;\r
+    UINT32  LowerContextTablePointerHi:32;\r
+\r
+    UINT32  UpperPresent:1;\r
+    UINT32  Reserved_65:11;\r
+    UINT32  UpperContextTablePointerLo:20;\r
+    UINT32  UpperContextTablePointerHi:32;\r
   } Bits;\r
   struct {\r
     UINT64  Uint64Lo;\r
@@ -56,17 +59,19 @@ typedef union {
 \r
 typedef union {\r
   struct {\r
-    UINT64  Present:1;\r
-    UINT64  FaultProcessingDisable:1;\r
-    UINT64  TranslationType:2;\r
-    UINT64  Reserved_4:8;\r
-    UINT64  SecondLevelPageTranslationPointer:52;\r
-\r
-    UINT64  AddressWidth:3;\r
-    UINT64  Ignored_67:4;\r
-    UINT64  Reserved_71:1;\r
-    UINT64  DomainIdentifier:16;\r
-    UINT64  Reserved_88:40;\r
+    UINT32  Present:1;\r
+    UINT32  FaultProcessingDisable:1;\r
+    UINT32  TranslationType:2;\r
+    UINT32  Reserved_4:8;\r
+    UINT32  SecondLevelPageTranslationPointerLo:20;\r
+    UINT32  SecondLevelPageTranslationPointerHi:32;\r
+\r
+    UINT32  AddressWidth:3;\r
+    UINT32  Ignored_67:4;\r
+    UINT32  Reserved_71:1;\r
+    UINT32  DomainIdentifier:16;\r
+    UINT32  Reserved_88:8;\r
+    UINT32  Reserved_96:32;\r
   } Bits;\r
   struct {\r
     UINT64  Uint64Lo;\r
@@ -76,51 +81,54 @@ typedef union {
 \r
 typedef union {\r
   struct {\r
-    UINT64  Present:1;\r
-    UINT64  FaultProcessingDisable:1;\r
-    UINT64  TranslationType:3;\r
-    UINT64  ExtendedMemoryType:3;\r
-    UINT64  DeferredInvalidateEnable:1;\r
-    UINT64  PageRequestEnable:1;\r
-    UINT64  NestedTranslationEnable:1;\r
-    UINT64  PASIDEnable:1;\r
-    UINT64  SecondLevelPageTranslationPointer:52;\r
-\r
-    UINT64  AddressWidth:3;\r
-    UINT64  PageGlobalEnable:1;\r
-    UINT64  NoExecuteEnable:1;\r
-    UINT64  WriteProtectEnable:1;\r
-    UINT64  CacheDisable:1;\r
-    UINT64  ExtendedMemoryTypeEnable:1;\r
-    UINT64  DomainIdentifier:16;\r
-    UINT64  SupervisorModeExecuteProtection:1;\r
-    UINT64  ExtendedAccessedFlagEnable:1;\r
-    UINT64  ExecuteRequestsEnable:1;\r
-    UINT64  SecondLevelExecuteEnable:1;\r
-    UINT64  Reserved_92:4;\r
-    UINT64  PageAttributeTable0:3;\r
-    UINT64  Reserved_Pat0:1;\r
-    UINT64  PageAttributeTable1:3;\r
-    UINT64  Reserved_Pat1:1;\r
-    UINT64  PageAttributeTable2:3;\r
-    UINT64  Reserved_Pat2:1;\r
-    UINT64  PageAttributeTable3:3;\r
-    UINT64  Reserved_Pat3:1;\r
-    UINT64  PageAttributeTable4:3;\r
-    UINT64  Reserved_Pat4:1;\r
-    UINT64  PageAttributeTable5:3;\r
-    UINT64  Reserved_Pat5:1;\r
-    UINT64  PageAttributeTable6:3;\r
-    UINT64  Reserved_Pat6:1;\r
-    UINT64  PageAttributeTable7:3;\r
-    UINT64  Reserved_Pat7:1;\r
-\r
-    UINT64  PASIDTableSize:4;\r
-    UINT64  Reserved_132:8;\r
-    UINT64  PASIDTablePointer:52;\r
-\r
-    UINT64  Reserved_192:12;\r
-    UINT64  PASIDStateTablePointer:52;\r
+    UINT32  Present:1;\r
+    UINT32  FaultProcessingDisable:1;\r
+    UINT32  TranslationType:3;\r
+    UINT32  ExtendedMemoryType:3;\r
+    UINT32  DeferredInvalidateEnable:1;\r
+    UINT32  PageRequestEnable:1;\r
+    UINT32  NestedTranslationEnable:1;\r
+    UINT32  PASIDEnable:1;\r
+    UINT32  SecondLevelPageTranslationPointerLo:20;\r
+    UINT32  SecondLevelPageTranslationPointerHi:32;\r
+\r
+    UINT32  AddressWidth:3;\r
+    UINT32  PageGlobalEnable:1;\r
+    UINT32  NoExecuteEnable:1;\r
+    UINT32  WriteProtectEnable:1;\r
+    UINT32  CacheDisable:1;\r
+    UINT32  ExtendedMemoryTypeEnable:1;\r
+    UINT32  DomainIdentifier:16;\r
+    UINT32  SupervisorModeExecuteProtection:1;\r
+    UINT32  ExtendedAccessedFlagEnable:1;\r
+    UINT32  ExecuteRequestsEnable:1;\r
+    UINT32  SecondLevelExecuteEnable:1;\r
+    UINT32  Reserved_92:4;\r
+    UINT32  PageAttributeTable0:3;\r
+    UINT32  Reserved_Pat0:1;\r
+    UINT32  PageAttributeTable1:3;\r
+    UINT32  Reserved_Pat1:1;\r
+    UINT32  PageAttributeTable2:3;\r
+    UINT32  Reserved_Pat2:1;\r
+    UINT32  PageAttributeTable3:3;\r
+    UINT32  Reserved_Pat3:1;\r
+    UINT32  PageAttributeTable4:3;\r
+    UINT32  Reserved_Pat4:1;\r
+    UINT32  PageAttributeTable5:3;\r
+    UINT32  Reserved_Pat5:1;\r
+    UINT32  PageAttributeTable6:3;\r
+    UINT32  Reserved_Pat6:1;\r
+    UINT32  PageAttributeTable7:3;\r
+    UINT32  Reserved_Pat7:1;\r
+\r
+    UINT32  PASIDTableSize:4;\r
+    UINT32  Reserved_132:8;\r
+    UINT32  PASIDTablePointerLo:20;\r
+    UINT32  PASIDTablePointerHi:32;\r
+\r
+    UINT32  Reserved_192:12;\r
+    UINT32  PASIDStateTablePointerLo:20;\r
+    UINT32  PASIDStateTablePointerHi:32;\r
   } Bits;\r
   struct {\r
     UINT64  Uint64_1;\r
@@ -132,63 +140,66 @@ typedef union {
 \r
 typedef union {\r
   struct {\r
-    UINT64  Present:1;\r
-    UINT64  Reserved_1:2;\r
-    UINT64  PageLevelCacheDisable:1;\r
-    UINT64  PageLevelWriteThrough:1;\r
-    UINT64  Reserved_5:6;\r
-    UINT64  SupervisorRequestsEnable:1;\r
-    UINT64  FirstLevelPageTranslationPointer:52;\r
+    UINT32  Present:1;\r
+    UINT32  Reserved_1:2;\r
+    UINT32  PageLevelCacheDisable:1;\r
+    UINT32  PageLevelWriteThrough:1;\r
+    UINT32  Reserved_5:6;\r
+    UINT32  SupervisorRequestsEnable:1;\r
+    UINT32  FirstLevelPageTranslationPointerLo:20;\r
+    UINT32  FirstLevelPageTranslationPointerHi:32;\r
   } Bits;\r
   UINT64    Uint64;\r
 } VTD_PASID_ENTRY;\r
 \r
 typedef union {\r
   struct {\r
-    UINT64  Reserved_0:32;\r
-    UINT64  ActiveReferenceCount:16;\r
-    UINT64  Reserved_48:15;\r
-    UINT64  DeferredInvalidate:1;\r
+    UINT32  Reserved_0:32;\r
+    UINT32  ActiveReferenceCount:16;\r
+    UINT32  Reserved_48:15;\r
+    UINT32  DeferredInvalidate:1;\r
   } Bits;\r
   UINT64    Uint64;\r
 } VTD_PASID_STATE_ENTRY;\r
 \r
 typedef union {\r
   struct {\r
-    UINT64  Present:1;\r
-    UINT64  ReadWrite:1;\r
-    UINT64  UserSupervisor:1;\r
-    UINT64  PageLevelWriteThrough:1;\r
-    UINT64  PageLevelCacheDisable:1;\r
-    UINT64  Accessed:1;\r
-    UINT64  Dirty:1;\r
-    UINT64  PageSize:1; // It is PageAttribute:1 for 4K page entry\r
-    UINT64  Global:1;\r
-    UINT64  Ignored_9:1;\r
-    UINT64  ExtendedAccessed:1;\r
-    UINT64  Ignored_11:1;\r
+    UINT32  Present:1;\r
+    UINT32  ReadWrite:1;\r
+    UINT32  UserSupervisor:1;\r
+    UINT32  PageLevelWriteThrough:1;\r
+    UINT32  PageLevelCacheDisable:1;\r
+    UINT32  Accessed:1;\r
+    UINT32  Dirty:1;\r
+    UINT32  PageSize:1; // It is PageAttribute:1 for 4K page entry\r
+    UINT32  Global:1;\r
+    UINT32  Ignored_9:1;\r
+    UINT32  ExtendedAccessed:1;\r
+    UINT32  Ignored_11:1;\r
     // NOTE: There is PageAttribute:1 as bit12 for 1G page entry and 2M page entry\r
-    UINT64  Address:40;\r
-    UINT64  Ignored_52:11;\r
-    UINT64  ExecuteDisable:1;\r
+    UINT32  AddressLo:20;\r
+    UINT32  AddressHi:20;\r
+    UINT32  Ignored_52:11;\r
+    UINT32  ExecuteDisable:1;\r
   } Bits;\r
   UINT64    Uint64;\r
 } VTD_FIRST_LEVEL_PAGING_ENTRY;\r
 \r
 typedef union {\r
   struct {\r
-    UINT64  Read:1;\r
-    UINT64  Write:1;\r
-    UINT64  Execute:1;\r
-    UINT64  ExtendedMemoryType:3;\r
-    UINT64  IgnorePAT:1;\r
-    UINT64  PageSize:1;\r
-    UINT64  Ignored_8:3;\r
-    UINT64  Snoop:1;\r
-    UINT64  Address:40;\r
-    UINT64  Ignored_52:10;\r
-    UINT64  TransientMapping:1;\r
-    UINT64  Ignored_63:1;\r
+    UINT32  Read:1;\r
+    UINT32  Write:1;\r
+    UINT32  Execute:1;\r
+    UINT32  ExtendedMemoryType:3;\r
+    UINT32  IgnorePAT:1;\r
+    UINT32  PageSize:1;\r
+    UINT32  Ignored_8:3;\r
+    UINT32  Snoop:1;\r
+    UINT32  AddressLo:20;\r
+    UINT32  AddressHi:20;\r
+    UINT32  Ignored_52:10;\r
+    UINT32  TransientMapping:1;\r
+    UINT32  Ignored_63:1;\r
   } Bits;\r
   UINT64    Uint64;\r
 } VTD_SECOND_LEVEL_PAGING_ENTRY;\r
@@ -299,7 +310,6 @@ typedef union {
     UINT32        NWFS:1; // No Write Flag Support\r
     UINT32        EAFS:1; // Extended Accessed Flag Support\r
     UINT32        PSS:5; // PASID Size Supported\r
-\r
     UINT32        Rsvd_40:24;\r
   } Bits;\r
   UINT64     Uint64;\r
@@ -307,8 +317,9 @@ typedef union {
 \r
 typedef union {\r
   struct {\r
-    UINT64   Rsvd_0:12;\r
-    UINT64   FI:52;        // FaultInfo\r
+    UINT32   Rsvd_0:12;\r
+    UINT32   FILo:20;      // FaultInfo\r
+    UINT32   FIHi:32;      // FaultInfo\r
 \r
     UINT32   SID:16;       // Source Identifier\r
     UINT32   Rsvd_80:13;\r
index 6efed6e..8cfa69c 100644 (file)
@@ -41,6 +41,8 @@
 #include <IndustryStandard/DmaRemappingReportingTable.h>\r
 #include <IndustryStandard/Vtd.h>\r
 \r
+#define VTD_64BITS_ADDRESS(Lo, Hi) (LShiftU64 (Lo, 12) | LShiftU64 (Hi, 32))\r
+\r
 #define ALIGN_VALUE_UP(Value, Alignment)  (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))\r
 #define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))\r
 \r
index ea84317..d5f096f 100644 (file)
@@ -289,7 +289,7 @@ FindVtdIndexByPciDevice (
 \r
     if (mVtdUnitInformation[VtdIndex].ExtRootEntryTable != 0) {\r
       ExtRootEntry = &mVtdUnitInformation[VtdIndex].ExtRootEntryTable[SourceId.Index.RootIndex];\r
-      ExtContextEntryTable = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)LShiftU64 (ExtRootEntry->Bits.LowerContextTablePointer, 12) ;\r
+      ExtContextEntryTable = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(ExtRootEntry->Bits.LowerContextTablePointerLo, ExtRootEntry->Bits.LowerContextTablePointerHi) ;\r
       ThisExtContextEntry  = &ExtContextEntryTable[SourceId.Index.ContextIndex];\r
       if (ThisExtContextEntry->Bits.AddressWidth == 0) {\r
         continue;\r
@@ -298,7 +298,7 @@ FindVtdIndexByPciDevice (
       *ContextEntry    = NULL;\r
     } else {\r
       RootEntry = &mVtdUnitInformation[VtdIndex].RootEntryTable[SourceId.Index.RootIndex];\r
-      ContextEntryTable = (VTD_CONTEXT_ENTRY *)(UINTN)LShiftU64 (RootEntry->Bits.ContextTablePointer, 12) ;\r
+      ContextEntryTable = (VTD_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(RootEntry->Bits.ContextTablePointerLo, RootEntry->Bits.ContextTablePointerHi) ;\r
       ThisContextEntry  = &ContextEntryTable[SourceId.Index.ContextIndex];\r
       if (ThisContextEntry->Bits.AddressWidth == 0) {\r
         continue;\r
index 5af4a46..961d7ca 100644 (file)
@@ -120,12 +120,13 @@ CreateContextEntry (
 \r
     RootEntry = &mVtdUnitInformation[VtdIndex].RootEntryTable[SourceId.Index.RootIndex];\r
     if (RootEntry->Bits.Present == 0) {\r
-      RootEntry->Bits.ContextTablePointer  = RShiftU64 ((UINT64)(UINTN)Buffer, 12);\r
+      RootEntry->Bits.ContextTablePointerLo  = (UINT32) RShiftU64 ((UINT64)(UINTN)Buffer, 12);\r
+      RootEntry->Bits.ContextTablePointerHi  = (UINT32) RShiftU64 ((UINT64)(UINTN)Buffer, 32);\r
       RootEntry->Bits.Present = 1;\r
       Buffer = (UINT8 *)Buffer + EFI_PAGES_TO_SIZE (ContextPages);\r
     }\r
 \r
-    ContextEntryTable = (VTD_CONTEXT_ENTRY *)(UINTN)LShiftU64(RootEntry->Bits.ContextTablePointer, 12) ;\r
+    ContextEntryTable = (VTD_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(RootEntry->Bits.ContextTablePointerLo, RootEntry->Bits.ContextTablePointerHi) ;\r
     ContextEntry = &ContextEntryTable[SourceId.Index.ContextIndex];\r
     ContextEntry->Bits.TranslationType = 0;\r
     ContextEntry->Bits.FaultProcessingDisable = 0;\r
@@ -227,7 +228,7 @@ CreateSecondLevelPagingEntryTable (
     }\r
     DEBUG ((DEBUG_INFO,"  Lvl4(0x%x): Lvl3Start - 0x%x, Lvl3End - 0x%x\n", Index4, Lvl3Start, Lvl3End));\r
 \r
-    Lvl3PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)LShiftU64 (Lvl4PtEntry[Index4].Bits.Address, 12);\r
+    Lvl3PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(Lvl4PtEntry[Index4].Bits.AddressLo, Lvl4PtEntry[Index4].Bits.AddressHi);\r
     for (Index3 = Lvl3Start; Index3 <= Lvl3End; Index3++) {\r
       if (Lvl3PtEntry[Index3].Uint64 == 0) {\r
         Lvl3PtEntry[Index3].Uint64 = (UINT64)(UINTN)AllocateZeroPages (1);\r
@@ -239,7 +240,7 @@ CreateSecondLevelPagingEntryTable (
         SetSecondLevelPagingEntryAttribute (&Lvl3PtEntry[Index3], EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE);\r
       }\r
 \r
-      Lvl2PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)LShiftU64 (Lvl3PtEntry[Index3].Bits.Address, 12);\r
+      Lvl2PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(Lvl3PtEntry[Index3].Bits.AddressLo, Lvl3PtEntry[Index3].Bits.AddressHi);\r
       for (Index2 = 0; Index2 < SIZE_4KB/sizeof(VTD_SECOND_LEVEL_PAGING_ENTRY); Index2++) {\r
         Lvl2PtEntry[Index2].Uint64 = BaseAddress;\r
         SetSecondLevelPagingEntryAttribute (&Lvl2PtEntry[Index2], IoMmuAccess);\r
@@ -341,7 +342,7 @@ DumpDmarContextEntryTable (
     if (RootEntry[Index].Bits.Present == 0) {\r
       continue;\r
     }\r
-    ContextEntry = (VTD_CONTEXT_ENTRY *)(UINTN)LShiftU64 (RootEntry[Index].Bits.ContextTablePointer, 12);\r
+    ContextEntry = (VTD_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(RootEntry[Index].Bits.ContextTablePointerLo, RootEntry[Index].Bits.ContextTablePointerHi);\r
     for (Index2 = 0; Index2 < VTD_CONTEXT_ENTRY_NUMBER; Index2++) {\r
       if ((ContextEntry[Index2].Uint128.Uint64Lo != 0) || (ContextEntry[Index2].Uint128.Uint64Hi != 0)) {\r
         DEBUG ((DEBUG_INFO,"    ContextEntry(0x%02x) D%02xF%02x - 0x%016lx %016lx\n",\r
@@ -350,7 +351,7 @@ DumpDmarContextEntryTable (
       if (ContextEntry[Index2].Bits.Present == 0) {\r
         continue;\r
       }\r
-      DumpSecondLevelPagingEntry ((VOID *)(UINTN)LShiftU64 (ContextEntry[Index2].Bits.SecondLevelPageTranslationPointer, 12));\r
+      DumpSecondLevelPagingEntry ((VOID *)(UINTN)VTD_64BITS_ADDRESS(ContextEntry[Index2].Bits.SecondLevelPageTranslationPointerLo, ContextEntry[Index2].Bits.SecondLevelPageTranslationPointerHi));\r
     }\r
   }\r
   DEBUG ((DEBUG_INFO,"=========================\n"));\r
@@ -387,7 +388,7 @@ DumpSecondLevelPagingEntry (
     if (Lvl4PtEntry[Index4].Uint64 == 0) {\r
       continue;\r
     }\r
-    Lvl3PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)LShiftU64 (Lvl4PtEntry[Index4].Bits.Address, 12);\r
+    Lvl3PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(Lvl4PtEntry[Index4].Bits.AddressLo, Lvl4PtEntry[Index4].Bits.AddressHi);\r
     for (Index3 = 0; Index3 < SIZE_4KB/sizeof(VTD_SECOND_LEVEL_PAGING_ENTRY); Index3++) {\r
       if (Lvl3PtEntry[Index3].Uint64 != 0) {\r
         DEBUG ((DEBUG_VERBOSE,"    Lvl3Pt Entry(0x%03x) - 0x%016lx\n", Index3, Lvl3PtEntry[Index3].Uint64));\r
@@ -396,7 +397,7 @@ DumpSecondLevelPagingEntry (
         continue;\r
       }\r
 \r
-      Lvl2PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)LShiftU64 (Lvl3PtEntry[Index3].Bits.Address, 12);\r
+      Lvl2PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(Lvl3PtEntry[Index3].Bits.AddressLo, Lvl3PtEntry[Index3].Bits.AddressHi);\r
       for (Index2 = 0; Index2 < SIZE_4KB/sizeof(VTD_SECOND_LEVEL_PAGING_ENTRY); Index2++) {\r
         if (Lvl2PtEntry[Index2].Uint64 != 0) {\r
           DEBUG ((DEBUG_VERBOSE,"      Lvl2Pt Entry(0x%03x) - 0x%016lx\n", Index2, Lvl2PtEntry[Index2].Uint64));\r
@@ -405,7 +406,7 @@ DumpSecondLevelPagingEntry (
           continue;\r
         }\r
         if (Lvl2PtEntry[Index2].Bits.PageSize == 0) {\r
-          Lvl1PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)LShiftU64 (Lvl2PtEntry[Index2].Bits.Address, 12);\r
+          Lvl1PtEntry = (VTD_SECOND_LEVEL_PAGING_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(Lvl2PtEntry[Index2].Bits.AddressLo, Lvl2PtEntry[Index2].Bits.AddressHi);\r
           for (Index1 = 0; Index1 < SIZE_4KB/sizeof(VTD_SECOND_LEVEL_PAGING_ENTRY); Index1++) {\r
             if (Lvl1PtEntry[Index1].Uint64 != 0) {\r
               DEBUG ((DEBUG_VERBOSE,"        Lvl1Pt Entry(0x%03x) - 0x%016lx\n", Index1, Lvl1PtEntry[Index1].Uint64));\r
@@ -878,12 +879,13 @@ SetAccessAttribute (
       DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x) New\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
       Pt = (UINT64)RShiftU64 ((UINT64)(UINTN)SecondLevelPagingEntry, 12);\r
 \r
-      ExtContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;\r
-      ExtContextEntry->Bits.DomainIdentifier = GetPciDescriptor (VtdIndex, Segment, SourceId);\r
+      ExtContextEntry->Bits.SecondLevelPageTranslationPointerLo = (UINT32) Pt;\r
+      ExtContextEntry->Bits.SecondLevelPageTranslationPointerHi = (UINT32) RShiftU64(Pt, 20);\r
+      ExtContextEntry->Bits.DomainIdentifier = (UINT16) GetPciDescriptor (VtdIndex, Segment, SourceId);\r
       ExtContextEntry->Bits.Present = 1;\r
       DumpDmarExtContextEntryTable (mVtdUnitInformation[VtdIndex].ExtRootEntryTable);\r
     } else {\r
-      SecondLevelPagingEntry = (VOID *)(UINTN)LShiftU64 (ExtContextEntry->Bits.SecondLevelPageTranslationPointer, 12);\r
+      SecondLevelPagingEntry = (VOID *)(UINTN)VTD_64BITS_ADDRESS(ExtContextEntry->Bits.SecondLevelPageTranslationPointerLo, ExtContextEntry->Bits.SecondLevelPageTranslationPointerHi);\r
       DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x)\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
     }\r
   } else if (ContextEntry != NULL) {\r
@@ -892,12 +894,13 @@ SetAccessAttribute (
       DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x) New\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
       Pt = (UINT64)RShiftU64 ((UINT64)(UINTN)SecondLevelPagingEntry, 12);\r
 \r
-      ContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;\r
-      ContextEntry->Bits.DomainIdentifier = GetPciDescriptor (VtdIndex, Segment, SourceId);\r
+      ContextEntry->Bits.SecondLevelPageTranslationPointerLo = (UINT32) Pt;\r
+      ContextEntry->Bits.SecondLevelPageTranslationPointerHi = (UINT32) RShiftU64(Pt, 20);\r
+      ContextEntry->Bits.DomainIdentifier = (UINT16) GetPciDescriptor (VtdIndex, Segment, SourceId);\r
       ContextEntry->Bits.Present = 1;\r
       DumpDmarContextEntryTable (mVtdUnitInformation[VtdIndex].RootEntryTable);\r
     } else {\r
-      SecondLevelPagingEntry = (VOID *)(UINTN)LShiftU64 (ContextEntry->Bits.SecondLevelPageTranslationPointer, 12);\r
+      SecondLevelPagingEntry = (VOID *)(UINTN)VTD_64BITS_ADDRESS(ContextEntry->Bits.SecondLevelPageTranslationPointerLo, ContextEntry->Bits.SecondLevelPageTranslationPointerHi);\r
       DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x B%02x D%02x F%02x)\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
     }\r
   }\r
@@ -958,11 +961,13 @@ AlwaysEnablePageAttribute (
   SecondLevelPagingEntry = mVtdUnitInformation[VtdIndex].FixedSecondLevelPagingEntry;\r
   Pt = (UINT64)RShiftU64 ((UINT64)(UINTN)SecondLevelPagingEntry, 12);\r
   if (ExtContextEntry != NULL) {\r
-    ExtContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;\r
+    ExtContextEntry->Bits.SecondLevelPageTranslationPointerLo = (UINT32) Pt;\r
+    ExtContextEntry->Bits.SecondLevelPageTranslationPointerHi = (UINT32) RShiftU64(Pt, 20);\r
     ExtContextEntry->Bits.DomainIdentifier = ((1 << (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1);\r
     ExtContextEntry->Bits.Present = 1;\r
   } else if (ContextEntry != NULL) {\r
-    ContextEntry->Bits.SecondLevelPageTranslationPointer = Pt;\r
+    ContextEntry->Bits.SecondLevelPageTranslationPointerLo = (UINT32) Pt;\r
+    ContextEntry->Bits.SecondLevelPageTranslationPointerHi = (UINT32) RShiftU64(Pt, 20);\r
     ContextEntry->Bits.DomainIdentifier = ((1 << (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1);\r
     ContextEntry->Bits.Present = 1;\r
   }\r
index 0f54b97..65ed16e 100644 (file)
@@ -67,14 +67,16 @@ CreateExtContextEntry (
 \r
     ExtRootEntry = &mVtdUnitInformation[VtdIndex].ExtRootEntryTable[SourceId.Index.RootIndex];\r
     if (ExtRootEntry->Bits.LowerPresent == 0) {\r
-      ExtRootEntry->Bits.LowerContextTablePointer  = RShiftU64 ((UINT64)(UINTN)Buffer, 12);\r
+      ExtRootEntry->Bits.LowerContextTablePointerLo  = (UINT32) RShiftU64 ((UINT64)(UINTN)Buffer, 12);\r
+      ExtRootEntry->Bits.LowerContextTablePointerHi  = (UINT32) RShiftU64 ((UINT64)(UINTN)Buffer, 32);\r
       ExtRootEntry->Bits.LowerPresent = 1;\r
-      ExtRootEntry->Bits.UpperContextTablePointer  = RShiftU64 ((UINT64)(UINTN)Buffer, 12) + 1;\r
+      ExtRootEntry->Bits.UpperContextTablePointerLo  = (UINT32) RShiftU64 ((UINT64)(UINTN)Buffer, 12) + 1;\r
+      ExtRootEntry->Bits.UpperContextTablePointerHi  = (UINT32) RShiftU64 (RShiftU64 ((UINT64)(UINTN)Buffer, 12) + 1, 20);\r
       ExtRootEntry->Bits.UpperPresent = 1;\r
       Buffer = (UINT8 *)Buffer + EFI_PAGES_TO_SIZE (ContextPages);\r
     }\r
 \r
-    ExtContextEntryTable = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)LShiftU64(ExtRootEntry->Bits.LowerContextTablePointer, 12) ;\r
+    ExtContextEntryTable = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(ExtRootEntry->Bits.LowerContextTablePointerLo, ExtRootEntry->Bits.LowerContextTablePointerHi) ;\r
     ExtContextEntry = &ExtContextEntryTable[SourceId.Index.ContextIndex];\r
     ExtContextEntry->Bits.TranslationType = 0;\r
     ExtContextEntry->Bits.FaultProcessingDisable = 0;\r
@@ -122,7 +124,7 @@ DumpDmarExtContextEntryTable (
     if (ExtRootEntry[Index].Bits.LowerPresent == 0) {\r
       continue;\r
     }\r
-    ExtContextEntry = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)LShiftU64 (ExtRootEntry[Index].Bits.LowerContextTablePointer, 12);\r
+    ExtContextEntry = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(ExtRootEntry[Index].Bits.LowerContextTablePointerLo, ExtRootEntry[Index].Bits.LowerContextTablePointerHi);\r
     for (Index2 = 0; Index2 < VTD_CONTEXT_ENTRY_NUMBER/2; Index2++) {\r
       if ((ExtContextEntry[Index2].Uint256.Uint64_1 != 0) || (ExtContextEntry[Index2].Uint256.Uint64_2 != 0) ||\r
           (ExtContextEntry[Index2].Uint256.Uint64_3 != 0) || (ExtContextEntry[Index2].Uint256.Uint64_4 != 0)) {\r
@@ -137,7 +139,7 @@ DumpDmarExtContextEntryTable (
     if (ExtRootEntry[Index].Bits.UpperPresent == 0) {\r
       continue;\r
     }\r
-    ExtContextEntry = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)LShiftU64 (ExtRootEntry[Index].Bits.UpperContextTablePointer, 12);\r
+    ExtContextEntry = (VTD_EXT_CONTEXT_ENTRY *)(UINTN)VTD_64BITS_ADDRESS(ExtRootEntry[Index].Bits.UpperContextTablePointerLo, ExtRootEntry[Index].Bits.UpperContextTablePointerHi);\r
     for (Index2 = 0; Index2 < VTD_CONTEXT_ENTRY_NUMBER/2; Index2++) {\r
       if ((ExtContextEntry[Index2].Uint256.Uint64_1 != 0) || (ExtContextEntry[Index2].Uint256.Uint64_2 != 0) ||\r
           (ExtContextEntry[Index2].Uint256.Uint64_3 != 0) || (ExtContextEntry[Index2].Uint256.Uint64_4 != 0)) {\r
index d19aea2..f36e3de 100644 (file)
@@ -526,7 +526,7 @@ DumpVtdRegs (
     FrcdReg.Uint64[1] = MmioRead64 (mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16) + (Index * 16) + R_FRCD_REG + sizeof(UINT64)));\r
     DEBUG((DEBUG_INFO, "  FRCD_REG[%d] - 0x%016lx %016lx\n", Index, FrcdReg.Uint64[1], FrcdReg.Uint64[0]));\r
     if (FrcdReg.Uint64[1] != 0 || FrcdReg.Uint64[0] != 0) {\r
-      DEBUG((DEBUG_INFO, "    Fault Info - 0x%016lx\n", LShiftU64(FrcdReg.Bits.FI, 12)));\r
+      DEBUG((DEBUG_INFO, "    Fault Info - 0x%016lx\n", VTD_64BITS_ADDRESS(FrcdReg.Bits.FILo, FrcdReg.Bits.FIHi)));\r
       SourceId.Uint16 = (UINT16)FrcdReg.Bits.SID;\r
       DEBUG((DEBUG_INFO, "    Source - B%02x D%02x F%02x\n", SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function));\r
       DEBUG((DEBUG_INFO, "    Type - %x (%a)\n", FrcdReg.Bits.T, FrcdReg.Bits.T ? "read" : "write"));\r