Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\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
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
// Display ExceptionType, CPU information and Image information\r
//\r
DumpCpuContext (ExceptionType, SystemContext);\r
- if (!NonStopMode) {\r
+ if (NonStopMode) {\r
+ //\r
+ // Set TF in EFLAGS\r
+ //\r
+ if (mPagingContext.MachineType == IMAGE_FILE_MACHINE_I386) {\r
+ SystemContext.SystemContextIa32->Eflags |= (UINT32)BIT8;\r
+ } else {\r
+ SystemContext.SystemContextX64->Rflags |= (UINT64)BIT8;\r
+ }\r
+ } else {\r
CpuDeadLoop ();\r
}\r
}\r