]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuPageTable.c
ArmPkg/ArmGicDxe ARM: fix encoding for GICv3 interrupt acknowledge
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuPageTable.c
index 0a980b97534edfb27d956fe6d01cf5fdc137500f..4bee8c7772b9bf3ac6342c1a49e66f7dcb95983a 100644 (file)
 \r
 #include <Base.h>\r
 #include <Uefi.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/CpuLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/SerialPortLib.h>\r
 #include <Library/SynchronizationLib.h>\r
 #include <Library/PrintLib.h>\r
-#include <Protocol/MpService.h>\r
 #include <Protocol/SmmBase2.h>\r
 #include <Register/Cpuid.h>\r
 #include <Register/Msr.h>\r
@@ -107,6 +100,7 @@ PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] = {
 };\r
 \r
 PAGE_TABLE_POOL                   *mPageTablePool = NULL;\r
+BOOLEAN                           mPageTablePoolLock = FALSE;\r
 PAGE_TABLE_LIB_PAGING_CONTEXT     mPagingContext;\r
 EFI_SMM_BASE2_PROTOCOL            *mSmmBase2 = NULL;\r
 \r
@@ -1053,6 +1047,16 @@ InitializePageTablePool (
   VOID                      *Buffer;\r
   BOOLEAN                   IsModified;\r
 \r
+  //\r
+  // Do not allow re-entrance.\r
+  //\r
+  if (mPageTablePoolLock) {\r
+    return FALSE;\r
+  }\r
+\r
+  mPageTablePoolLock = TRUE;\r
+  IsModified = FALSE;\r
+\r
   //\r
   // Always reserve at least PAGE_TABLE_POOL_UNIT_PAGES, including one page for\r
   // header.\r
@@ -1063,9 +1067,15 @@ InitializePageTablePool (
   Buffer = AllocateAlignedPages (PoolPages, PAGE_TABLE_POOL_ALIGNMENT);\r
   if (Buffer == NULL) {\r
     DEBUG ((DEBUG_ERROR, "ERROR: Out of aligned pages\r\n"));\r
-    return FALSE;\r
+    goto Done;\r
   }\r
 \r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "Paging: added %lu pages to page table pool\r\n",\r
+    (UINT64)PoolPages\r
+    ));\r
+\r
   //\r
   // Link all pools into a list for easier track later.\r
   //\r
@@ -1099,7 +1109,9 @@ InitializePageTablePool (
     );\r
   ASSERT (IsModified == TRUE);\r
 \r
-  return TRUE;\r
+Done:\r
+  mPageTablePoolLock = FALSE;\r
+  return IsModified;\r
 }\r
 \r
 /**\r