All page table allocation will use AllocatePageTableMemory(). Add SmmCpuFeaturesCompleteSmmReadyToLock() to PerformRemainingTasks() and PerformPreTasks().
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <jiewen....@intel.com> Cc: "Fan, Jeff" <jeff....@intel.com> Cc: "Kinney, Michael D" <michael.d.kin...@intel.com> --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 4 ++-- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 31 ++++++++++++++++++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 18 +++++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 2 +- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index 8a77280..b4ec36e 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -770,7 +770,7 @@ Gen4GPageTable ( // // Allocate the page table // - PageTable = AllocatePages (ExtraPages + 5 + PagesNeeded); + PageTable = AllocatePageTableMemory (ExtraPages + 5 + PagesNeeded); ASSERT (PageTable != NULL); PageTable = (VOID *)((UINTN)PageTable + EFI_PAGES_TO_SIZE (ExtraPages)); @@ -872,7 +872,7 @@ SetCacheability ( // // Allocate a page from SMRAM // - NewPageTableAddress = AllocatePages (1); + NewPageTableAddress = AllocatePageTableMemory (1); ASSERT (NewPageTableAddress != NULL); NewPageTable = (UINT64 *)NewPageTableAddress; diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 9ca3620..bc571ec 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1416,6 +1416,33 @@ ConfigSmmCodeAccessCheck ( } /** + This API provides a way to allocate memory for page table. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ) +{ + VOID *Buffer; + + Buffer = SmmCpuFeaturesAllocatePageTableMemory (Pages); + if (Buffer != NULL) { + return Buffer; + } + return AllocatePages (Pages); +} + +/** Perform the remaining tasks. **/ @@ -1440,6 +1467,8 @@ PerformRemainingTasks ( // ConfigSmmCodeAccessCheck (); + SmmCpuFeaturesCompleteSmmReadyToLock (); + // // Clean SMM ready to lock flag // @@ -1464,6 +1493,8 @@ PerformPreTasks ( // Configure SMM Code Access Check feature if available. // ConfigSmmCodeAccessCheck (); + + SmmCpuFeaturesCompleteSmmReadyToLock (); mRestoreSmmConfigurationInS3 = FALSE; } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 96d55c0..867bf2f 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -703,4 +703,22 @@ VOID DumpModuleInfoByIp ( IN UINTN CallerIpAddress ); + +/** + This API provides a way to allocate memory for page table. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ); #endif diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c index 8ddde9a..ff4e28e 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -552,7 +552,7 @@ InitPaging ( // ASSERT (Address == (*Pte & PHYSICAL_ADDRESS_MASK)); - Pt = AllocatePages (1); + Pt = AllocatePageTableMemory (1); ASSERT (Pt != NULL); // Split it -- 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel