From 502a9122a427f3f54def77c046c23214ba3c34b6 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Wed, 26 Jun 2024 12:10:38 +0800 Subject: [PATCH] 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 Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Cc: Dun Tan Cc: Hongbin1 Zhang Cc: Wei6 Xu Cc: Yuanhao Xie --- .../PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c | 39 +++++++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h | 1 + 2 files changed, 40 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c index 68f63f3c64..1dc610d697 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c @@ -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; +} diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h index 4b0d5fb08b..7f11429e50 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include