]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelSiliconPkg VTdDxe: Option to force no early access attr request
authorStar Zeng <star.zeng@intel.com>
Wed, 17 Oct 2018 09:43:28 +0000 (17:43 +0800)
committerStar Zeng <star.zeng@intel.com>
Thu, 25 Oct 2018 03:50:43 +0000 (11:50 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1272

To have high confidence in usage for platform, add option (BIT2 of
PcdVTdPolicyPropertyMask) to force no IOMMU access attribute request
recording before DMAR table is installed.

Check PcdVTdPolicyPropertyMask BIT2 before RequestAccessAttribute()
and ProcessRequestedAccessAttribute(), then RequestAccessAttribute(),
ProcessRequestedAccessAttribute() and mAccessRequestXXX variables
could be optimized by compiler when PcdVTdPolicyPropertyMask BIT2 = 1.

Test done:
1: Created case that has IOMMU access attribute request before DMAR
   table is installed, ASSERT was triggered after setting
   PcdVTdPolicyPropertyMask BIT2 to 1.

2. Confirmed RequestAccessAttribute(), ProcessRequestedAccessAttribute()
   and mAccessRequestXXX variables were optimized by compiler after
   setting PcdVTdPolicyPropertyMask BIT2 to 1.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.c
IntelSiliconPkg/IntelSiliconPkg.dec

index 86d50eb6f2882041ce9f5a63254552e5ae2baec6..7784545631b390b0aeb8c46c7988d518075af88a 100644 (file)
@@ -515,7 +515,13 @@ SetupVtd (
 \r
   ParseDmarAcpiTableRmrr ();\r
 \r
 \r
   ParseDmarAcpiTableRmrr ();\r
 \r
-  ProcessRequestedAccessAttribute ();\r
+  if ((PcdGet8 (PcdVTdPolicyPropertyMask) & BIT2) == 0) {\r
+    //\r
+    // Support IOMMU access attribute request recording before DMAR table is installed.\r
+    // Here is to process the requests.\r
+    //\r
+    ProcessRequestedAccessAttribute ();\r
+  }\r
 \r
   for (Index = 0; Index < mVtdUnitNumber; Index++) {\r
     DEBUG ((DEBUG_INFO,"VTD Unit %d (Segment: %04x)\n", Index, mVtdUnitInformation[Index].Segment));\r
 \r
   for (Index = 0; Index < mVtdUnitNumber; Index++) {\r
     DEBUG ((DEBUG_INFO,"VTD Unit %d (Segment: %04x)\n", Index, mVtdUnitInformation[Index].Segment));\r
index 25d7c80af1d421edb6e37daab50d72309aea7be5..09948ce50e940b4f408603465de9f8c33e6af20e 100644 (file)
@@ -254,6 +254,13 @@ VTdSetAttribute (
     // Record the entry to driver global variable.\r
     // As such once VTd is activated, the setting can be adopted.\r
     //\r
     // Record the entry to driver global variable.\r
     // As such once VTd is activated, the setting can be adopted.\r
     //\r
+    if ((PcdGet8 (PcdVTdPolicyPropertyMask) & BIT2) != 0) {\r
+      //\r
+      // Force no IOMMU access attribute request recording before DMAR table is installed.\r
+      //\r
+      ASSERT_EFI_ERROR (EFI_NOT_READY);\r
+      return EFI_NOT_READY;\r
+    }\r
     Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess);\r
   } else {\r
     PERF_CODE (\r
     Status = RequestAccessAttribute (Segment, SourceId, DeviceAddress, Length, IoMmuAccess);\r
   } else {\r
     PERF_CODE (\r
index c0cf58fa6cb59a56adae061001d3c9618f7f5f45..2f5bef6089f9baafa87153967f1429bd3e8eb48c 100644 (file)
@@ -58,6 +58,7 @@
   ## The mask is used to control VTd behavior.<BR><BR>\r
   #  BIT0: Enable IOMMU during boot (If DMAR table is installed in DXE. If VTD_INFO_PPI is installed in PEI.)\r
   #  BIT1: Enable IOMMU when transfer control to OS (ExitBootService in normal boot. EndOfPEI in S3)\r
   ## The mask is used to control VTd behavior.<BR><BR>\r
   #  BIT0: Enable IOMMU during boot (If DMAR table is installed in DXE. If VTD_INFO_PPI is installed in PEI.)\r
   #  BIT1: Enable IOMMU when transfer control to OS (ExitBootService in normal boot. EndOfPEI in S3)\r
+  #  BIT2: Force no IOMMU access attribute request recording before DMAR table is installed.\r
   # @Prompt The policy for VTd driver behavior.\r
   gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask|1|UINT8|0x00000002\r
 \r
   # @Prompt The policy for VTd driver behavior.\r
   gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask|1|UINT8|0x00000002\r
 \r