mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
StandaloneMmPkg/Core: Migrate Memory Allocation Hob into MMRAM
If a Memory Allocation Hob with EfiBootServicesData memory type is reported into MM Hob List and it also has a non-zero GUID name, then the HOB is used by MM driver and needs to migrate the memory into MMRAM. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
This commit is contained in:
parent
6b69f564a9
commit
cfaccc89a2
@ -643,6 +643,66 @@ MmConfigurationMmNotify (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Migrate MemoryBaseAddress in memory allocation HOBs with BootServiceData
|
||||||
|
type and non-zero GUID name from Boot Service memory to MMRAM.
|
||||||
|
|
||||||
|
@param[in] HobStart Pointer to the start of the HOB list.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
MigrateMemoryAllocationHobs (
|
||||||
|
IN VOID *HobStart
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_PEI_HOB_POINTERS Hob;
|
||||||
|
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
|
||||||
|
VOID *MemoryInMmram;
|
||||||
|
|
||||||
|
MemoryAllocationHob = NULL;
|
||||||
|
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, HobStart);
|
||||||
|
while (Hob.Raw != NULL) {
|
||||||
|
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
|
||||||
|
if ((MemoryAllocationHob->AllocDescriptor.MemoryType == EfiBootServicesData) &&
|
||||||
|
(MmIsBufferOutsideMmValid (
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryLength
|
||||||
|
))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!IsZeroGuid (&MemoryAllocationHob->AllocDescriptor.Name)) {
|
||||||
|
MemoryInMmram = AllocatePages (EFI_SIZE_TO_PAGES (MemoryAllocationHob->AllocDescriptor.MemoryLength));
|
||||||
|
if (MemoryInMmram != NULL) {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"Migrate Memory Allocation Hob (%g) from %08x to %08p\n",
|
||||||
|
&MemoryAllocationHob->AllocDescriptor.Name,
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
|
||||||
|
MemoryInMmram
|
||||||
|
));
|
||||||
|
CopyMem (
|
||||||
|
MemoryInMmram,
|
||||||
|
(VOID *)(UINTN)MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryLength
|
||||||
|
);
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryInMmram;
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryType = EfiRuntimeServicesData;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
|
"Error - Memory Allocation Hob [%08x, %08x] doesn't have a GUID name specified\n",
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress,
|
||||||
|
MemoryAllocationHob->AllocDescriptor.MemoryLength
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
|
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the HOB list size.
|
/** Returns the HOB list size.
|
||||||
|
|
||||||
@param [in] HobStart Pointer to the start of the HOB list.
|
@param [in] HobStart Pointer to the start of the HOB list.
|
||||||
@ -757,6 +817,7 @@ StandaloneMmMain (
|
|||||||
CopyMem (MmHobStart, HobStart, HobSize);
|
CopyMem (MmHobStart, HobStart, HobSize);
|
||||||
Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
|
Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
MigrateMemoryAllocationHobs (MmHobStart);
|
||||||
gHobList = MmHobStart;
|
gHobList = MmHobStart;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user