]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
Add 2 APIs in SmmCpuFeaturesLib.
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / PiSmmCpuDxeSmm.c
index 670a5cf663f8c573a65aa061caaf7176743a9d7f..fb4655128fadaa3ee96c173b372439b17348fa58 100644 (file)
@@ -970,9 +970,9 @@ PiCpuSmmEntry (
   //\r
   BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1));\r
   if ((FamilyId == 4) || (FamilyId == 5)) {\r
-    Buffer = AllocateAlignedCodePages (BufferPages, SIZE_32KB);\r
+    Buffer = AllocateAlignedPages (BufferPages, SIZE_32KB);\r
   } else {\r
-    Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB);\r
+    Buffer = AllocateAlignedPages (BufferPages, SIZE_4KB);\r
   }\r
   ASSERT (Buffer != NULL);\r
   DEBUG ((EFI_D_INFO, "SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE(BufferPages)));\r
@@ -1415,6 +1415,35 @@ ConfigSmmCodeAccessCheck (
   }\r
 }\r
 \r
+/**\r
+  This API provides a way to allocate memory for page table.\r
+\r
+  This API can be called more once to allocate memory for page tables.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+AllocatePageTableMemory (\r
+  IN UINTN           Pages\r
+  )\r
+{\r
+  VOID  *Buffer;\r
+\r
+  Buffer = SmmCpuFeaturesAllocatePageTableMemory (Pages);\r
+  if (Buffer != NULL) {\r
+    return Buffer;\r
+  }\r
+  return AllocatePages (Pages);\r
+}\r
+\r
 /**\r
   Perform the remaining tasks.\r
 \r
@@ -1440,6 +1469,8 @@ PerformRemainingTasks (
     //\r
     ConfigSmmCodeAccessCheck ();\r
 \r
+    SmmCpuFeaturesCompleteSmmReadyToLock ();\r
+\r
     //\r
     // Clean SMM ready to lock flag\r
     //\r
@@ -1465,6 +1496,8 @@ PerformPreTasks (
     //\r
     ConfigSmmCodeAccessCheck ();\r
 \r
+    SmmCpuFeaturesCompleteSmmReadyToLock ();\r
+\r
     mRestoreSmmConfigurationInS3 = FALSE;\r
   }\r
 }\r