The input HobLength of PrintHandler should be data size instead of whole length of HOB
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: DunTan <dun.tan@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
index 5fb638d4a4..f93aeec472 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
@@ -317,9 +317,11 @@ PrintPciRootBridgeInfoGuidHob (
{
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
UINTN Index;
+ UINTN Length;
Index = 0;
PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);
- ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));
+ Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
+ ASSERT (HobLength >= Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
@@ -369,10 +371,12 @@ PrintExtraDataGuidHob (
{
UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
UINTN Index;
+ UINTN Length;
Index = 0;
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);
- ASSERT (HobLength >= ExtraData->Header.Length);
+ Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
+ ASSERT (HobLength >= Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
@@ -443,7 +447,7 @@ PrintGuidHob (
for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));
- Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
+ Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
return Status;
}
}
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79981): https://edk2.groups.io/g/devel/message/79981
Mute This Topic: https://groups.io/mt/85270356/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Thank Dun for the fix.
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
________________________________
From: Tan, Dun <dun.tan@intel.com>
Sent: Tuesday, August 31, 2021 13:38
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Ma, Maurice <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; Tan, Dun <dun.tan@intel.com>
Subject: [Patch V2 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions
The input HobLength of PrintHandler should be data size instead of whole length of HOB
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: DunTan <dun.tan@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
index 5fb638d4a4..f93aeec472 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
@@ -317,9 +317,11 @@ PrintPciRootBridgeInfoGuidHob (
{
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
UINTN Index;
+ UINTN Length;
Index = 0;
PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);
- ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));
+ Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
+ ASSERT (HobLength >= Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
@@ -369,10 +371,12 @@ PrintExtraDataGuidHob (
{
UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
UINTN Index;
+ UINTN Length;
Index = 0;
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);
- ASSERT (HobLength >= ExtraData->Header.Length);
+ Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
+ ASSERT (HobLength >= Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
@@ -443,7 +447,7 @@ PrintGuidHob (
for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));
- Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
+ Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
return Status;
}
}
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80392): https://edk2.groups.io/g/devel/message/80392
Mute This Topic: https://groups.io/mt/85270356/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Tan, Dun <dun.tan@intel.com>
> Sent: Tuesday, August 31, 2021 1:38 PM
> To: devel@edk2.groups.io
> Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Ma, Maurice <maurice.ma@intel.com>; You, Benjamin
> <benjamin.you@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; Tan, Dun <dun.tan@intel.com>
> Subject: [Patch V2 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions
>
> The input HobLength of PrintHandler should be data size instead of whole length of HOB
>
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Signed-off-by: DunTan <dun.tan@intel.com>
> ---
> UefiPayloadPkg/UefiPayloadEntry/PrintHob.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
> index 5fb638d4a4..f93aeec472 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
> @@ -317,9 +317,11 @@ PrintPciRootBridgeInfoGuidHob (
> {
> UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
> UINTN Index;
> + UINTN Length;
> Index = 0;
> PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (HobRaw);
> - ASSERT (HobLength >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES));
> + Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof
> (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
> + ASSERT (HobLength >= Length);
> DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
> DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));
> DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
> @@ -369,10 +371,12 @@ PrintExtraDataGuidHob (
> {
> UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
> UINTN Index;
> + UINTN Length;
>
> Index = 0;
> ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);
> - ASSERT (HobLength >= ExtraData->Header.Length);
> + Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof
> (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
> + ASSERT (HobLength >= Length);
> DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
> DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));
> DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
> @@ -443,7 +447,7 @@ PrintGuidHob (
> for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
> if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
> DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));
> - Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
> + Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
> return Status;
> }
> }
> --
> 2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80435): https://edk2.groups.io/g/devel/message/80435
Mute This Topic: https://groups.io/mt/85270356/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.