Skip to content

Commit

Permalink
StandaloneMmPkg/MmIpl : Add EFI_HOB_HANDOFF_INFO_TABLE to MM HOB list
Browse files Browse the repository at this point in the history
GetBootModeHob function need to add EFI_HOB_HANDOFF_INFO_TABLE
in MM hob data base.

Signed-off-by: Hongbin1 Zhang <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Star Zeng <[email protected]>
Cc: Jiaxin Wu <[email protected]>
Cc: Wei6 Xu <[email protected]>
Cc: Sami Mujawar <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Supreeth Venkatesh <[email protected]>
  • Loading branch information
hongbin123 committed Jan 24, 2025
1 parent 54c1460 commit 4f432a0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
28 changes: 28 additions & 0 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/MmFoundationHob.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,31 @@ CreateMmFoundationHobList (
*FoundationHobSize = UsedSize;
return Status;
}

/**
Builds a Handoff Information Table HOB.
@param Hob - Pointer to handoff information table HOB.
@param HobEnd - End of the HOB list.
**/
VOID
CreateMmHobHandoffInfoTable (
IN EFI_HOB_HANDOFF_INFO_TABLE *Hob,
IN VOID *HobEnd
)
{
Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
Hob->Header.HobLength = (UINT16)sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
Hob->Header.Reserved = 0;

Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
Hob->BootMode = GetBootModeHob ();

Hob->EfiMemoryTop = 0;
Hob->EfiMemoryBottom = 0;
Hob->EfiFreeMemoryTop = 0;
Hob->EfiFreeMemoryBottom = 0;
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
}
19 changes: 14 additions & 5 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ CreatMmHobList (
UINTN BufferSize;
UINTN FoundationHobSize;
EFI_HOB_MEMORY_ALLOCATION *MmProfileDataHob;
UINTN PhitHobSize;
VOID *HobEnd;

//
// Get platform HOBs
Expand Down Expand Up @@ -336,28 +338,35 @@ CreatMmHobList (
ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
ASSERT (FoundationHobSize != 0);

PhitHobSize = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
//
// Final result includes platform HOBs, foundation HOBs and a END node.
// Final result includes: PHIT HOB, Platform HOBs, Foundation HOBs and an END node.
//
*HobSize = PlatformHobSize + FoundationHobSize + sizeof (EFI_HOB_GENERIC_HEADER);
*HobSize = PhitHobSize + PlatformHobSize + FoundationHobSize + sizeof (EFI_HOB_GENERIC_HEADER);
HobList = AllocatePages (EFI_SIZE_TO_PAGES (*HobSize));
ASSERT (HobList != NULL);
if (HobList == NULL) {
DEBUG ((DEBUG_ERROR, "Out of resource to create MM HOBs\n"));
CpuDeadLoop ();
}

HobEnd = (UINT8 *)(UINTN)HobList + PhitHobSize + PlatformHobSize + FoundationHobSize;
//
// Create MmHobHandoffInfoTable
//
CreateMmHobHandoffInfoTable (HobList, HobEnd);

Check failure

Code scanning / CodeQL

Returned pointer not checked High

Value may be null; it should be checked before dereferencing.

//
// Get platform HOBs
//
Status = CreateMmPlatformHob (HobList, &PlatformHobSize);
Status = CreateMmPlatformHob ((UINT8 *)HobList + PhitHobSize, &PlatformHobSize);
ASSERT_EFI_ERROR (Status);

//
// Get foundation HOBs
//
Status = CreateMmFoundationHobList (
(UINT8 *)HobList + PlatformHobSize,
(UINT8 *)HobList + PhitHobSize + PlatformHobSize,
&FoundationHobSize,
HobList,
PlatformHobSize,
Expand All @@ -375,7 +384,7 @@ CreatMmHobList (
//
// Create MM HOB list end.
//
MmIplCreateHob ((UINT8 *)HobList + PlatformHobSize + FoundationHobSize, EFI_HOB_TYPE_END_OF_HOB_LIST, sizeof (EFI_HOB_GENERIC_HEADER));
MmIplCreateHob (HobEnd, EFI_HOB_TYPE_END_OF_HOB_LIST, sizeof (EFI_HOB_GENERIC_HEADER));

return HobList;
}
Expand Down
14 changes: 14 additions & 0 deletions StandaloneMmPkg/Drivers/StandaloneMmIplPei/StandaloneMmIplPei.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,18 @@ BuildMmProfileDataHobInPeiHobList (
VOID
);

/**
Builds a Handoff Information Table HOB.
@param Hob - Pointer to handoff information table HOB.
@param HobEnd - End of the HOB list.
**/
VOID
CreateMmHobHandoffInfoTable (
IN EFI_HOB_HANDOFF_INFO_TABLE *Hob,
IN VOID *HobEnd
);

#endif

0 comments on commit 4f432a0

Please sign in to comment.