summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2024-06-24 20:49:23 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-28 15:25:27 +0000
commitc8a1295d3e98490b4e18522cb1752200ae73d324 (patch)
treeaea304dede80aebe78f627940523f939fcd389c4 /UefiCpuPkg
parent8ccf7f65e5e3276e2bad06419134759c02107e75 (diff)
downloadedk2-c8a1295d3e98490b4e18522cb1752200ae73d324.tar.gz
edk2-c8a1295d3e98490b4e18522cb1752200ae73d324.tar.bz2
edk2-c8a1295d3e98490b4e18522cb1752200ae73d324.zip
UefiCpuPkg/PiSmmCpuDxeSmm: Get SMRAM info from gEfiSmmSmramMemoryGuid
MM can not use the SMM Access Protocol, so get SMRAM info from gEfiSmmSmramMemoryGuid instead of via SMM Access Protocol for both SMM and MM. 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>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c40
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h2
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf2
3 files changed, 16 insertions, 28 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c
index 5d2b9eefd3..1ba5967fd6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c
@@ -1282,7 +1282,6 @@ CpuSmramRangeCompare (
}
/**
-
Find out SMRAM information including SMRR base and SMRR size.
@param SmrrBase SMRR base
@@ -1295,35 +1294,24 @@ FindSmramInfo (
OUT UINT32 *SmrrSize
)
{
- EFI_STATUS Status;
- UINTN Size;
- EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
- EFI_SMRAM_DESCRIPTOR *CurrentSmramRange;
- UINTN Index;
- UINT64 MaxSize;
- BOOLEAN Found;
- EFI_SMRAM_DESCRIPTOR SmramDescriptor;
+ VOID *GuidHob;
+ EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *DescriptorBlock;
+ EFI_SMRAM_DESCRIPTOR *CurrentSmramRange;
+ UINTN Index;
+ UINT64 MaxSize;
+ BOOLEAN Found;
+ EFI_SMRAM_DESCRIPTOR SmramDescriptor;
- //
- // Get SMM Access Protocol
- //
- Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (SmrrBase != NULL && SmrrSize != NULL);
//
// Get SMRAM information
//
- Size = 0;
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
-
- mSmmCpuSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
- ASSERT (mSmmCpuSmramRanges != NULL);
-
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmmCpuSmramRanges);
- ASSERT_EFI_ERROR (Status);
-
- mSmmCpuSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
+ GuidHob = GetFirstGuidHob (&gEfiSmmSmramMemoryGuid);
+ ASSERT (GuidHob != NULL);
+ DescriptorBlock = (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)GET_GUID_HOB_DATA (GuidHob);
+ mSmmCpuSmramRangeCount = DescriptorBlock->NumberOfSmmReservedRegions;
+ mSmmCpuSmramRanges = DescriptorBlock->Descriptor;
//
// Sort the mSmmCpuSmramRanges
@@ -1373,7 +1361,7 @@ FindSmramInfo (
}
} while (Found);
- DEBUG ((DEBUG_INFO, "SMRR Base: 0x%x, SMRR Size: 0x%x\n", *SmrrBase, *SmrrSize));
+ DEBUG ((DEBUG_INFO, "%a: SMRR Base = 0x%x, SMRR Size = 0x%x\n", __func__, *SmrrBase, *SmrrSize));
}
/**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
index 87fd7d9ba1..c75f0ea9d6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/SmmConfiguration.h>
#include <Protocol/SmmCpu.h>
-#include <Protocol/SmmAccess2.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCpuService.h>
#include <Protocol/SmmMemoryAttribute.h>
@@ -25,6 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/AcpiS3Context.h>
#include <Guid/MemoryAttributesTable.h>
#include <Guid/PiSmmMemoryAttributesTable.h>
+#include <Guid/SmramMemoryReserve.h>
#include <Guid/SmmBaseHob.h>
#include <Guid/MpInformation2.h>
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index d18e9e85f8..2705ca69ea 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -102,7 +102,6 @@
SmmCpuSyncLib
[Protocols]
- gEfiSmmAccess2ProtocolGuid ## CONSUMES
gEfiSmmConfigurationProtocolGuid ## PRODUCES
gEfiSmmCpuProtocolGuid ## PRODUCES
gEfiSmmReadyToLockProtocolGuid ## NOTIFY
@@ -118,6 +117,7 @@
gEfiMemoryAttributesTableGuid ## CONSUMES ## SystemTable
gSmmBaseHobGuid ## CONSUMES
gMpInformation2HobGuid ## CONSUMES # Assume the HOB must has been created
+ gEfiSmmSmramMemoryGuid
[FeaturePcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmDebug ## CONSUMES