diff options
author | Dun Tan <dun.tan@intel.com> | 2024-10-21 17:45:56 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-11-05 08:30:16 +0000 |
commit | da8fd23dbba7088627e4420975088148076ad421 (patch) | |
tree | be0e2ee14bf2ae7ed7b716a65cb940c7da1bb450 | |
parent | 3adb5071751d634ce4116fc566f8a131ecc080af (diff) | |
download | edk2-da8fd23dbba7088627e4420975088148076ad421.tar.gz edk2-da8fd23dbba7088627e4420975088148076ad421.tar.bz2 edk2-da8fd23dbba7088627e4420975088148076ad421.zip |
StandaloneMmPkg/Core: Check Resource HOB and Mmram ranges
Check if the all the resource HOB in the input HOB list of
MmCore entry only covers non-Mmram ranges. The Resource HOB
is to describe the accessible non-Mmram range. All Resource
HOB should not overlap with any Mmram range.
Signed-off-by: Dun Tan <dun.tan@intel.com>
-rw-r--r-- | StandaloneMmPkg/Core/StandaloneMmCore.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 3a8842fc16..292e556b37 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -700,28 +700,60 @@ MigrateMemoryAllocationHobs ( }
/**
- This function is responsible for initializing a new HOB list in MMRAM based on
- the input HOB list.
+ This function is responsible for validating the input HOB list and
+ initializing a new HOB list in MMRAM based on the input HOB list.
@param [in] HobStart Pointer to the start of the HOB list.
+ @param [in] MmramRanges Pointer to the Mmram ranges.
+ @param [in] MmramRangeCount Count of Mmram ranges.
@retval Pointer to the new location of hob list in MMRAM.
**/
VOID *
InitializeMmHobList (
- IN VOID *HobStart
+ IN VOID *HobStart,
+ IN EFI_MMRAM_DESCRIPTOR *MmramRanges,
+ IN UINTN MmramRangeCount
)
{
VOID *MmHobStart;
UINTN HobSize;
EFI_STATUS Status;
EFI_PEI_HOB_POINTERS Hob;
+ UINTN Index;
+ EFI_PHYSICAL_ADDRESS MmramBase;
+ EFI_PHYSICAL_ADDRESS MmramEnd;
+ EFI_PHYSICAL_ADDRESS ResourceHobBase;
+ EFI_PHYSICAL_ADDRESS ResourceHobEnd;
ASSERT (HobStart != NULL);
Hob.Raw = (UINT8 *)HobStart;
while (!END_OF_HOB_LIST (Hob)) {
Hob.Raw = GET_NEXT_HOB (Hob);
+ if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+ ResourceHobBase = Hob.ResourceDescriptor->PhysicalStart;
+ ResourceHobEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength;
+
+ for (Index = 0; Index < MmramRangeCount; Index++) {
+ MmramBase = MmramRanges[Index].PhysicalStart;
+ MmramEnd = MmramRanges[Index].PhysicalStart + MmramRanges[Index].PhysicalSize;
+
+ if ((MmramBase < ResourceHobEnd) && (MmramEnd > ResourceHobBase)) {
+ //
+ // The Resource HOB is to describe the accessible non-Mmram range.
+ // All Resource HOB should not overlapp with any Mmram range.
+ //
+ DEBUG ((
+ DEBUG_ERROR,
+ "The resource HOB range [0x%lx, 0x%lx] overlaps with MMRAM range\n",
+ ResourceHobBase,
+ ResourceHobEnd
+ ));
+ CpuDeadLoop ();
+ }
+ }
+ }
}
//
@@ -821,7 +853,7 @@ StandaloneMmMain ( //
// Install HobList
//
- gHobList = InitializeMmHobList (HobStart);
+ gHobList = InitializeMmHobList (HobStart, MmramRanges, MmramRangeCount);
//
// Register notification for EFI_MM_CONFIGURATION_PROTOCOL registration and
|