public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "duntan" <dun.tan@intel.com>
To: devel@edk2.groups.io
Cc: duntan <dun.tan@intel.com>, Guo Dong <guo.dong@intel.com>,
	Ray Ni <ray.ni@intel.com>, Maurice Ma <maurice.ma@intel.com>,
	Benjamin You <benjamin.you@intel.com>,
	Zhiguang Liu <zhiguang.liu@intel.com>
Subject: [Patch V3 1/2] UefiPayloadPkg: Fix the bug in dump guid HOB info functions
Date: Fri, 10 Sep 2021 16:01:10 +0800	[thread overview]
Message-ID: <20210910080111.113-2-dun.tan@intel.com> (raw)
In-Reply-To: <20210910080111.113-1-dun.tan@intel.com>

From: duntan <dun.tan@intel.com>

The input HobLength of PrintHandler should be data size instead of whole length of HOB

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Dun Tan <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


  reply	other threads:[~2021-09-10  8:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10  8:01 [Patch V3 0/2] Fix and enhancement in Payload Entry DumpHob funcs duntan
2021-09-10  8:01 ` duntan [this message]
2021-09-10  8:01 ` [Patch V3 2/2] UefiPayloadPkg: Dump hob info from gEdkiiBootManagerMenuFileGuid duntan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210910080111.113-2-dun.tan@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox