From 0de7882b46f31618f60bec65005af9a1d085b051 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Mon, 8 Jul 2024 13:24:55 +0800 Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Simplify SMM Profile Size Calculation The motivation of this change is to simplify the logic in StandaloneMmIpl when allocating the memory for SMM profile data. IPL does not need to detect the CPU feature regarding MSR DS Area. That change requires the PCD value contains the MSR DS Area. So, the size of SmmProfileData will be simplified to the PcdCpuSmmProfileSize directly. mMsrDsAreaSize will be within the PcdCpuSmmProfileSize if mBtsSupported is TRUE. 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/NonMmramMapDxeSmm.c | 6 +----- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h | 2 -- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 12 +++++++++--- UefiCpuPkg/UefiCpuPkg.dec | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c index 51f0edd296..a98013b7d0 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapDxeSmm.c @@ -495,11 +495,7 @@ GetSmmProfileData ( ASSERT (Size != NULL); - if (mBtsSupported) { - *Size = PcdGet32 (PcdCpuSmmProfileSize) + mMsrDsAreaSize; - } else { - *Size = PcdGet32 (PcdCpuSmmProfileSize); - } + *Size = PcdGet32 (PcdCpuSmmProfileSize); Base = 0xFFFFFFFF; Status = gBS->AllocatePages ( diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h index 0dccf7ca65..bc08f03640 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h @@ -270,8 +270,6 @@ extern UINTN mSmmShadowStackSize; /// extern UINT8 mSmmSaveStateRegisterLma; -extern BOOLEAN mBtsSupported; -extern UINTN mMsrDsAreaSize; extern BOOLEAN mAcpiS3Enable; #define PAGE_TABLE_POOL_ALIGNMENT BASE_128KB diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c index 164af20a4c..c152dccea4 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -748,9 +748,6 @@ InitSmmProfileInternal ( ); ASSERT (mLastPFEntryPointer != NULL); - mSmmProfileSize = FixedPcdGet32 (PcdCpuSmmProfileSize); - ASSERT ((mSmmProfileSize & 0xFFF) == 0); - // // Get Smm Profile Base // @@ -758,6 +755,15 @@ InitSmmProfileInternal ( DEBUG ((DEBUG_ERROR, "SmmProfileBase = 0x%016x.\n", (UINTN)mSmmProfileBase)); DEBUG ((DEBUG_ERROR, "SmmProfileSize = 0x%016x.\n", (UINTN)SmmProfileSize)); + if (mBtsSupported) { + ASSERT (SmmProfileSize > mMsrDsAreaSize); + mSmmProfileSize = (UINTN)SmmProfileSize - mMsrDsAreaSize; + } else { + mSmmProfileSize = (UINTN)SmmProfileSize; + } + + ASSERT ((mSmmProfileSize & 0xFFF) == 0); + // // Initialize SMM profile data header. // diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 2cabf5fc03..33ac8cf91c 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -281,7 +281,7 @@ ## Specifies buffer size in bytes to save SMM profile data. The value should be a multiple of 4KB. # @Prompt SMM profile data buffer size. - gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize|0x200000|UINT32|0x32132107 + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmProfileSize|0x600000|UINT32|0x32132107 ## Specifies stack size in bytes for each processor in SMM. # @Prompt Processor stack size in SMM.