\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
};\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
ASSERT (SplitAttribute == Page4K);\r
if (SplitAttribute == Page4K) {\r
NewPageEntry = AllocatePagesFunc (1);\r
- DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry));\r
+ DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry));\r
if (NewPageEntry == NULL) {\r
return RETURN_OUT_OF_RESOURCES;\r
}\r
ASSERT (SplitAttribute == Page2M || SplitAttribute == Page4K);\r
if ((SplitAttribute == Page2M || SplitAttribute == Page4K)) {\r
NewPageEntry = AllocatePagesFunc (1);\r
- DEBUG ((DEBUG_INFO, "Split - 0x%x\n", NewPageEntry));\r
+ DEBUG ((DEBUG_VERBOSE, "Split - 0x%x\n", NewPageEntry));\r
if (NewPageEntry == NULL) {\r
return RETURN_OUT_OF_RESOURCES;\r
}\r
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
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
);\r
ASSERT (IsModified == TRUE);\r
\r
- return TRUE;\r
+Done:\r
+ mPageTablePoolLock = FALSE;\r
+ return IsModified;\r
}\r
\r
/**\r
\r
for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {\r
if (mLastPFEntryPointer[CpuIndex][PFEntry] != NULL) {\r
- *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~IA32_PG_P;\r
+ *mLastPFEntryPointer[CpuIndex][PFEntry] &= ~(UINT64)IA32_PG_P;\r
}\r
}\r
\r