UefiCpuPkg/PiSmmCpuDxeSmm: Impl GetSmmProfileData for MM

MM CPU can not use the dynamic PCD (PcdCpuSmmProfileSize), so it
consumes the gMmProfileDataHobGuid memory allocation hob for
SmmProfile base address & size.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
This commit is contained in:
Jiaxin Wu 2024-06-26 12:10:38 +08:00 committed by mergify[bot]
parent cc996831bd
commit 502a9122a4
2 changed files with 40 additions and 0 deletions

View File

@ -6,3 +6,42 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "PiSmmCpuCommon.h"
/**
Get SmmProfileData.
@param[in, out] Size Return Size of SmmProfileData.
@return Address of SmmProfileData
**/
EFI_PHYSICAL_ADDRESS
GetSmmProfileData (
IN OUT UINT64 *Size
)
{
EFI_PEI_HOB_POINTERS SmmProfileDataHob;
ASSERT (Size != NULL);
//
// Get Smm Profile Base from Memory Allocation HOB
//
SmmProfileDataHob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (SmmProfileDataHob.Raw != NULL) {
//
// Find gMmProfileDataHobGuid
//
if (CompareGuid (&SmmProfileDataHob.MemoryAllocation->AllocDescriptor.Name, &gMmProfileDataHobGuid)) {
break;
}
SmmProfileDataHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (SmmProfileDataHob));
}
ASSERT (SmmProfileDataHob.Raw != NULL);
*Size = SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryLength;
return SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress;
}

View File

@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/SmramMemoryReserve.h>
#include <Guid/SmmBaseHob.h>
#include <Guid/MpInformation2.h>
#include <Guid/MmProfileData.h>
#include <Library/BaseLib.h>
#include <Library/IoLib.h>