]> 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 89d9bea3fc0fdd5086ad6189e6ec87be36d39dd8..570b47cf73647a8b0e7e270a5f07847b2649c001 100644 (file)
 \r
 **/\r
 \r
 \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
 #include "DmaProtection.h"\r
 \r
 /**\r
@@ -306,18 +296,22 @@ IoMmuSetAttribute (
   EFI_STATUS            Status;\r
   EFI_PHYSICAL_ADDRESS  DeviceAddress;\r
   UINTN                 NumberOfPages;\r
   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
 \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
   }\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
 \r
   return Status;\r
 }\r