From abc2f595235d0b87f1d15f1a75a345b22ff86c75 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Tue, 25 Jun 2024 00:40:32 +0800 Subject: UefiCpuPkg/PiSmmCpuDxeSmm: Move GetUefiMemoryMap into DxeSmm code MM can not call GetUefiMemoryMap() function, so, move it into DxeSmm code. Define a SmmReadyToLockEventNotify to handler the logic. This will make PiSmmCpuEntryCommon to be common function for SMM and MM. Signed-off-by: Jiaxin Wu Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Cc: Dun Tan Cc: Hongbin1 Zhang Cc: Wei6 Xu Cc: Yuanhao Xie --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c | 43 ------------------------------ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h | 1 + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 43 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 43 deletions(-) (limited to 'UefiCpuPkg/PiSmmCpuDxeSmm') diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c index 1ba5967fd6..78bfc8a3e7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c @@ -432,38 +432,6 @@ ExecuteFirstSmiInit ( PERF_FUNCTION_END (); } -/** - SMM Ready To Lock event notification handler. - - mSmmReadyToLock is set to perform additional lock actions that must be - performed from SMM on the next SMI. - - @param[in] Protocol Points to the protocol's unique identifier. - @param[in] Interface Points to the interface instance. - @param[in] Handle The handle on which the interface was installed. - - @retval EFI_SUCCESS Notification handler runs successfully. - **/ -EFI_STATUS -EFIAPI -SmmReadyToLockEventNotify ( - IN CONST EFI_GUID *Protocol, - IN VOID *Interface, - IN EFI_HANDLE Handle - ) -{ - // - // Cache a copy of UEFI memory map before we start profiling feature. - // - GetUefiMemoryMap (); - - // - // Set SMM ready to lock flag and return - // - mSmmReadyToLock = TRUE; - return EFI_SUCCESS; -} - /** Function to compare 2 SMM_BASE_HOB_DATA pointer based on ProcessorIndex. @@ -759,7 +727,6 @@ PiSmmCpuEntryCommon ( UINTN TileDataSize; UINTN TileSize; UINT8 *Stacks; - VOID *Registration; UINT32 RegEax; UINT32 RegEbx; UINT32 RegEcx; @@ -1231,16 +1198,6 @@ PiSmmCpuEntryCommon ( Status = InitializeSmmCpuServices (mSmmCpuHandle); ASSERT_EFI_ERROR (Status); - // - // register SMM Ready To Lock Protocol notification - // - Status = gMmst->MmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, - SmmReadyToLockEventNotify, - &Registration - ); - ASSERT_EFI_ERROR (Status); - // // Initialize SMM Profile feature // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h index ed0badf431..e662f2dc45 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h @@ -270,6 +270,7 @@ extern UINT8 mSmmSaveStateRegisterLma; extern BOOLEAN mBtsSupported; extern UINTN mMsrDsAreaSize; extern BOOLEAN mAcpiS3Enable; +extern BOOLEAN mSmmReadyToLock; #define PAGE_TABLE_POOL_ALIGNMENT BASE_128KB #define PAGE_TABLE_POOL_UNIT_SIZE BASE_128KB diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 5f126a5f23..22b0de13c7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -11,6 +11,38 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PiSmmCpuCommon.h" +/** + SMM Ready To Lock event notification handler. + + mSmmReadyToLock is set to perform additional lock actions that must be + performed from SMM on the next SMI. + + @param[in] Protocol Points to the protocol's unique identifier. + @param[in] Interface Points to the interface instance. + @param[in] Handle The handle on which the interface was installed. + + @retval EFI_SUCCESS Notification handler runs successfully. + **/ +EFI_STATUS +EFIAPI +SmmReadyToLockEventNotify ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + // + // Cache a copy of UEFI memory map before we start profiling feature. + // + GetUefiMemoryMap (); + + // + // Set SMM ready to lock flag and return + // + mSmmReadyToLock = TRUE; + return EFI_SUCCESS; +} + /** Get SmmCpuSyncConfig data: RelaxedMode, SyncTimeout, SyncTimeout2. @@ -149,6 +181,7 @@ PiCpuSmmEntry ( ) { EFI_STATUS Status; + VOID *Registration; // // Save the PcdPteMemoryEncryptionAddressOrMask value into a global variable. @@ -182,5 +215,15 @@ PiCpuSmmEntry ( ASSERT_EFI_ERROR (Status); } + // + // Register SMM Ready To Lock Protocol notification + // + Status = gMmst->MmRegisterProtocolNotify ( + &gEfiSmmReadyToLockProtocolGuid, + SmmReadyToLockEventNotify, + &Registration + ); + ASSERT_EFI_ERROR (Status); + return Status; } -- cgit