]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.c
IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdDxe / IntelVTdDxe.c
index 64693a8c6ec3520d5e467facb6749f4ae52b8aad..570b47cf73647a8b0e7e270a5f07847b2649c001 100644 (file)
 \r
 **/\r
 \r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/IoMmu.h>\r
-#include <Protocol/PciIo.h>\r
-\r
-#include <Library/IoLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
 #include "DmaProtection.h"\r
 \r
 /**\r
@@ -87,7 +77,7 @@ IoMmuUnmap (
 \r
   @retval EFI_SUCCESS           The requested memory pages were allocated.\r
   @retval EFI_UNSUPPORTED       Attributes is unsupported. The only legal attribute bits are\r
-                                MEMORY_WRITE_COMBINE and MEMORY_CACHED.\r
+                                MEMORY_WRITE_COMBINE, MEMORY_CACHED and DUAL_ADDRESS_CYCLE.\r
   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
   @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.\r
 \r
@@ -306,18 +296,22 @@ IoMmuSetAttribute (
   EFI_STATUS            Status;\r
   EFI_PHYSICAL_ADDRESS  DeviceAddress;\r
   UINTN                 NumberOfPages;\r
+  EFI_TPL               OriginalTpl;\r
+\r
+  OriginalTpl = gBS->RaiseTPL (VTD_TPL_LEVEL);\r
 \r
   Status = GetDeviceInfoFromMapping (Mapping, &DeviceAddress, &NumberOfPages);\r
-  if (EFI_ERROR(Status)) {\r
-    return Status;\r
+  if (!EFI_ERROR(Status)) {\r
+    Status = VTdSetAttribute (\r
+               This,\r
+               DeviceHandle,\r
+               DeviceAddress,\r
+               EFI_PAGES_TO_SIZE(NumberOfPages),\r
+               IoMmuAccess\r
+               );\r
   }\r
-  Status = VTdSetAttribute (\r
-             This,\r
-             DeviceHandle,\r
-             DeviceAddress,\r
-             EFI_PAGES_TO_SIZE(NumberOfPages),\r
-             IoMmuAccess\r
-             );\r
+\r
+  gBS->RestoreTPL (OriginalTpl);\r
 \r
   return Status;\r
 }\r