From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web10.7118.1622034275272507430 for ; Wed, 26 May 2021 06:04:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@9elements.com header.s=google header.b=JdjeXnPR; spf=pass (domain: 9elements.com, ip: 209.85.214.181, mailfrom: patrick.rudolph@9elements.com) Received: by mail-pl1-f181.google.com with SMTP id s4so570733plg.12 for ; Wed, 26 May 2021 06:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kv7hnKVyPrdaaMegMpkvTW2PrWeOFF7jjyQ6SiCo40g=; b=JdjeXnPREPbyo+AUP4aonvqKAv3H2xaB8sbDbjs7SuLtfjcmL+FvVBgy0B+sQpPb8f lF8I6yDiWZU3E4w1O/iOKEIjllUDa4czi3haGuDEn6VrkMCGn++QW+WPqCpS2VYElqgK COblMXZa3rj1m1+y0qKYG+CiOYU4U3eWIqrvsEK0znTJxiV1z8xgExQxmGTmfKOCQHeB Qmfw5B3ymuhfIePIckuoxhb7SrKPYrVQU34Laavw1kIOCjBp/Jj27+sW03DxYvkCX9d+ CksbpFsCLSJEUFO4lVMtApYwZBZX6udWia7yAi9VMJZrZEJ3tSu/ilPvo9waXH6Bz9YQ ixGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kv7hnKVyPrdaaMegMpkvTW2PrWeOFF7jjyQ6SiCo40g=; b=eBc3ESQxCTG8KRDgKBf7fb++Oeb6AJMkXEmnxYvPyo12Prn5eDfI6PhbUzz9H4rcPk oGlIv6dPjjlCgnQ0QmQel4F29BHNiJbHF57E+HojNL7J2PMEg0OcNFOz6fOZNeI8ItOC VVL2mZkik10LRWRo+B71XtIezGBgp0qSGdAfw/ahdO5yKRPHSQBfs0B8+b8kakJmE+Ks anDCeXjgVHcG502ZENelVYuKYOoRM3+GhRMOxVhNQc2krRLIqQkq/crkSguWS90NUxcv zh2Ozw9a93cZ4tr3tXzP9Zv8f8oQy6Uo4932HYd2YbPhVX32GO1S4GP+CtdA+DvfnU5C ALww== X-Gm-Message-State: AOAM532Mfri7gur1JcRLVi8Uy/FgfO/rMa24c5YY7Du4kT+vuzRSjZVg 80sX1n0kULDl5C4gfVRSodW+AkoT8iqnwIn18/NNCSVRYcKOeA== X-Google-Smtp-Source: ABdhPJw6DqcC74IgP8tjzeoBgTDjokeMnbyuQ6qdyRMPR6x+VBCzMjFAtYZRzNBUMssCyPaur8OIOMHWBxUSTe/m7XY= X-Received: by 2002:a17:90a:3005:: with SMTP id g5mr3777430pjb.14.1622034274664; Wed, 26 May 2021 06:04:34 -0700 (PDT) MIME-Version: 1.0 References: <20210524071234.1056-1-zhiguang.liu@intel.com> <20210524071234.1056-6-zhiguang.liu@intel.com> In-Reply-To: <20210524071234.1056-6-zhiguang.liu@intel.com> From: "Patrick Rudolph" Date: Wed, 26 May 2021 15:04:23 +0200 Message-ID: Subject: Re: [edk2-devel] [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables To: devel@edk2.groups.io, "Liu, Zhiguang" Cc: Jian J Wang , Hao A Wu , Dandan Bi , Star Zeng , Zhichao Gao Content-Type: multipart/alternative; boundary="000000000000c1565105c33b4861" --000000000000c1565105c33b4861 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 24, 2021 at 9:13 AM Zhiguang Liu wrote= : > V1: > The default EfiSmbiosProtocol operates on an empty SMBIOS table. > The SMBIOS tables are provided by the bootloader on UefiPayloadPkg. > Scan for existing tables in SmbiosDxe and load them if they seem valid. > > This fixes the settings menu not showing any hardware information, instea= d > only "0 MB RAM" was displayed. > > Tests showed that the OS can still see the SMBIOS tables. > > V2: > SmbiosDxe will get the SMBIOS from a guid Hob. > Aslo will keep the SmbiosHandle if it is available. > > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Dandan Bi > Cc: Star Zeng > Cc: Zhichao Gao > Signed-off-by: Patrick Rudolph > Signed-off-by: Zhiguang Liu > --- > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 299 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-= - > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h | 4 +++- > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 5 ++++- > 3 files changed, 304 insertions(+), 4 deletions(-) > > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > index 3cdb0b1ed7..d2aa15d43f 100644 > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > @@ -2,7 +2,7 @@ > This code produces the Smbios protocol. It also responsible for > constructing > SMBIOS table into system table. > > -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -1408,6 +1408,300 @@ SmbiosTableConstruction ( > } > } > > +/** > + Validates a SMBIOS 2.0 table entry point. > + > + @param SmbiosTable The SMBIOS_TABLE_ENTRY_POINT to validate. > + > + @retval TRUE SMBIOS table entry point is valid. > + @retval FALSE SMBIOS table entry point is malformed. > + > +**/ > +STATIC > +BOOLEAN > +IsValidSmbios20Table ( > + IN SMBIOS_TABLE_ENTRY_POINT *SmbiosTable > + ) > +{ > + UINT8 Checksum; > + > + if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) !=3D 0) { > + return FALSE; > + } > + > + // > + // The actual value of the EntryPointLength should be 1Fh. > + // However, it was incorrectly stated in version 2.1 of smbios > specification. > + // Therefore, 0x1F and 0x1E are both accepted. > + // > + if (SmbiosTable->EntryPointLength !=3D 0x1E || > SmbiosTable->EntryPointLength !=3D sizeof (SMBIOS_TABLE_ENTRY_POINT)) { > + return FALSE; > + } > + > This is not correct, it should be if (SmbiosTable->EntryPointLength !=3D 0x1E && SmbiosTable->EntryPointLengt= h !=3D sizeof (SMBIOS_TABLE_ENTRY_POINT)) { otherwise the table wouldn't be recognized as valid. + // > + // MajorVersion should be 2. > + // > + if (SmbiosTable->MajorVersion !=3D 2) { > + return FALSE; > + } > + > + // > + // The whole struct check sum should be zero > + // > + Checksum =3D CalculateSum8 ( > + (UINT8 *) SmbiosTable, > + SmbiosTable->EntryPointLength > + ); > + if (Checksum !=3D 0) { > + return FALSE; > + } > + > + // > + // The Intermediate Entry Point Structure check sum should be zero. > + // > + Checksum =3D CalculateSum8 ( > + (UINT8 *) SmbiosTable + OFFSET_OF > (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString), > + SmbiosTable->EntryPointLength - OFFSET_OF > (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString) > + ); > + return (BOOLEAN) (Checksum =3D=3D 0); > +} > + > +/** > + Validates a SMBIOS 3.0 table entry point. > + > + @param SmbiosTable The SMBIOS_TABLE_3_0_ENTRY_POINT to validate. > + > + @retval TRUE SMBIOS table entry point is valid. > + @retval FALSE SMBIOS table entry point is malformed. > + > +**/ > +STATIC > +BOOLEAN > +IsValidSmbios30Table ( > + IN SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable > + ) > +{ > + UINT8 Checksum; > + > + if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) !=3D 0) { > + return FALSE; > + } > + if (SmbiosTable->EntryPointLength < sizeof > (SMBIOS_TABLE_3_0_ENTRY_POINT)) { > + return FALSE; > + } > + if (SmbiosTable->MajorVersion < 3) { > + return FALSE; > + } > + > + // > + // The whole struct check sum should be zero > + // > + Checksum =3D CalculateSum8 ( > + (UINT8 *) SmbiosTable, > + SmbiosTable->EntryPointLength > + ); > + if (Checksum !=3D 0) { > + return FALSE; > + } > + return TRUE; > +} > + > +/** > + Parse an existing SMBIOS table and insert it using SmbiosAdd. > + > + @param ImageHandle The EFI_HANDLE to this driver. > + @param Smbios The SMBIOS table to parse. > + @param Length The length of the SMBIOS table. > + > + @retval EFI_SUCCESS SMBIOS table was parsed and installed. > + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of > system resources. > + @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table > + > +**/ > +STATIC > +EFI_STATUS > +ParseAndAddExistingSmbiosTable ( > + IN EFI_HANDLE ImageHandle, > + IN SMBIOS_STRUCTURE_POINTER Smbios, > + IN UINTN Length > + ) > +{ > + EFI_STATUS Status; > + CHAR8 *String; > + EFI_SMBIOS_HANDLE SmbiosHandle; > + SMBIOS_STRUCTURE_POINTER SmbiosEnd; > + > + SmbiosEnd.Raw =3D Smbios.Raw + Length; > + > + if (Smbios.Raw >=3D SmbiosEnd.Raw || Smbios.Raw =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + do { > + // > + // Make sure not to access memory beyond SmbiosEnd > + // > + if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw || > + Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) { > + return EFI_INVALID_PARAMETER; > + } > + // > + // Check for end marker > + // > + if (Smbios.Hdr->Type =3D=3D SMBIOS_TYPE_END_OF_TABLE) { > + break; > + } > + // > + // Make sure not to access memory beyond SmbiosEnd > + // Each structure shall be terminated by a double-null (0000h). > + // > + if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > > SmbiosEnd.Raw || > + Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw)= { > + return EFI_INVALID_PARAMETER; > + } > + // > + // Install the table > + // > + SmbiosHandle =3D Smbios.Hdr->Handle; > + Status =3D SmbiosAdd ( > + &mPrivateData.Smbios, > + ImageHandle, > + &SmbiosHandle, > + Smbios.Hdr > + ); > + > + ASSERT_EFI_ERROR (Status); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + // > + // Go to the next SMBIOS structure. Each SMBIOS structure may includ= e > 2 parts: > + // 1. Formatted section; 2. Unformatted string section. So, 2 steps > are needed > + // to skip one SMBIOS structure. > + // > + > + // > + // Step 1: Skip over formatted section. > + // > + String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length); > + > + // > + // Step 2: Skip over unformatted string section. > + // > + do { > + // > + // Each string is terminated with a NULL(00h) BYTE and the sets of > strings > + // is terminated with an additional NULL(00h) BYTE. > + // > + for ( ; *String !=3D 0; String++) { > + if ((UINTN) String >=3D (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) = { > + return EFI_INVALID_PARAMETER; > + } > + } > + > + if (*(UINT8 *) ++String =3D=3D 0) { > + // > + // Pointer to the next SMBIOS structure. > + // > + Smbios.Raw =3D (UINT8 *) ++String; > + break; > + } > + } while (TRUE); > + } while (Smbios.Raw < SmbiosEnd.Raw); > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Retrieve SMBIOS from Hob. > + @param ImageHandle Module's image handle > + > + @retval EFI_SUCCESS Smbios from Hob is installed. > + @return EFI_NOT_FOUND Not found Smbios from Hob. > + @retval Other No Smbios from Hob is installed. > + > +**/ > +EFI_STATUS > +EFIAPI > +RetrieveSmbiosFromHob ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable; > + SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30Table; > + SMBIOS_STRUCTURE_POINTER Smbios; > + EFI_HOB_GUID_TYPE *GuidHob; > + PLD_SMBIOS_TABLE *SmBiosTableAdress; > + PLD_GENERIC_HEADER *GenericHeader; > + > + Status =3D EFI_NOT_FOUND; > + // > + // Scan for existing SMBIOS tables from gPldSmbios3TableGuid Guid Hob > + // > + GuidHob =3D GetFirstGuidHob (&gPldSmbios3TableGuid); > + if (GuidHob !=3D NULL) { > + GenericHeader =3D (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob)= ; > + if ((sizeof (PLD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_SIZE (GuidHo= b)) > && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (GuidHob))) { > + if (GenericHeader->Revision =3D=3D PLD_SMBIOS_TABLE_REVISION) { > + // > + // PLD_SMBIOS_TABLE structure is used when Revision equals to > PLD_SMBIOS_TABLE_REVISION > + // > + SmBiosTableAdress =3D (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA > (GuidHob); > + if (GenericHeader->Length >=3D PLD_SIZEOF_THROUGH_FIELD > (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) { > + Smbios30Table =3D (SMBIOS_TABLE_3_0_ENTRY_POINT *) (UINTN) > SmBiosTableAdress->SmBiosEntryPoint; > + if (IsValidSmbios30Table (Smbios30Table)) { > + Smbios.Raw =3D (UINT8 *) (UINTN) Smbios30Table->TableAddress= ; > + Status =3D ParseAndAddExistingSmbiosTable (ImageHandle, Smbi= os, > Smbios30Table->TableMaximumSize); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to > parse preinstalled tables from gPldSmbios3TableGuid Guid Hob\n")); > + Status =3D EFI_UNSUPPORTED; > + } else { > + return EFI_SUCCESS; > + } > + } > + } > + } else { > + Status =3D EFI_UNSUPPORTED; > + } > + } > + } > + > + // > + // Scan for existing SMBIOS tables from gPldSmbiosTableGuid Guid Hob, > + // if gPldSmbios3TableGuid Hob doesn't exist or parsing > gPldSmbios3TableGuid failed > + // > + GuidHob =3D GetFirstGuidHob (&gPldSmbiosTableGuid); > + > + if (GuidHob !=3D NULL) { > + GenericHeader =3D (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob)= ; > + if ((sizeof (PLD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_SIZE (GuidHo= b)) > && (GenericHeader->Length <=3D GET_GUID_HOB_DATA_SIZE (GuidHob))) { > + if (GenericHeader->Revision =3D=3D PLD_SMBIOS_TABLE_REVISION) { > + // > + // PLD_SMBIOS_TABLE structure is used when Revision equals to > PLD_SMBIOS_TABLE_REVISION > + // > + SmBiosTableAdress =3D (PLD_SMBIOS_TABLE *) GET_GUID_HOB_DATA > (GuidHob); > + if (GenericHeader->Length >=3D PLD_SIZEOF_THROUGH_FIELD > (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) { > + SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) > SmBiosTableAdress->SmBiosEntryPoint; > + if (IsValidSmbios20Table (SmbiosTable)) { > + Smbios.Raw =3D (UINT8 *) (UINTN) SmbiosTable->TableAddress; > + Status =3D ParseAndAddExistingSmbiosTable (ImageHandle, Smbi= os, > SmbiosTable->TableLength); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to > parse preinstalled tables from gPldSmbiosTableGuid Guid Hob\n")); > + Status =3D EFI_UNSUPPORTED; > + } > + return EFI_SUCCESS; > + } > + } > + } else { > + Status =3D EFI_UNSUPPORTED; > + } > + } > + } > + return Status; > +} > + > /** > > Driver to produce Smbios protocol and pre-allocate 1 page for the fina= l > SMBIOS table. > @@ -1451,5 +1745,6 @@ SmbiosDriverEntryPoint ( > &mPrivateData.Smbios > ); > > - return Status; > + RetrieveSmbiosFromHob (ImageHandle); > + return EFI_SUCCESS; > } > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h > index f97c85ae40..a260cf695e 100644 > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h > @@ -1,7 +1,7 @@ > /** @file > This code supports the implementation of the Smbios protocol > > -Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include > #include > #include > +#include > +#include > > #define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B', 'i', 's') > typedef struct { > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf > index f6c036e1dc..3286575098 100644 > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf > @@ -1,7 +1,7 @@ > ## @file > # This driver initializes and installs the SMBIOS protocol, constructs > SMBIOS table into system configuration table. > # > -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -41,6 +41,7 @@ > UefiDriverEntryPoint > DebugLib > PcdLib > + HobLib > > [Protocols] > gEfiSmbiosProtocolGuid ## PRODUCES > @@ -48,6 +49,8 @@ > [Guids] > gEfiSmbiosTableGuid ## SOMETIMES_PRODUCE= S > ## SystemTable > gEfiSmbios3TableGuid ## SOMETIMES_PRODUCE= S > ## SystemTable > + gPldSmbios3TableGuid > + gPldSmbiosTableGuid > > [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES > -- > 2.30.0.windows.2 > > > > ------------ > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#75489): https://edk2.groups.io/g/devel/message/75489 > Mute This Topic: https://groups.io/mt/83045509/2917327 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ > patrick.rudolph@9elements.com] > ------------ > > > --000000000000c1565105c33b4861 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, May 24, 2021 at 9:13 AM Zhiguang = Liu <zhiguang.liu@intel.com> wrote:
V1:=
The default EfiSmbiosProtocol operates on an empty SMBIOS table.
The SMBIOS tables are provided by the bootloader on UefiPayloadPkg.
Scan for existing tables in SmbiosDxe and load them if they seem valid.

This fixes the settings menu not showing any hardware information, instead<= br> only "0 MB RAM" was displayed.

Tests showed that the OS can still see the SMBIOS tables.

V2:
SmbiosDxe will get the SMBIOS from a guid Hob.
Aslo will keep the SmbiosHandle if it is available.

Cc: Jian J Wang <
jian.j.wang@intel.com>
Cc: Hao A Wu <ha= o.a.wu@intel.com>
Cc: Dandan Bi <= dandan.bi@intel.com>
Cc: Star Zeng <= star.zeng@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
=C2=A0MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c=C2=A0 =C2=A0| 299 ++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
=C2=A0MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h=C2=A0 =C2=A0|=C2=A0 =C2= =A04 +++-
=C2=A0MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf |=C2=A0 =C2=A05 ++++-<= br> =C2=A03 files changed, 304 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.c
index 3cdb0b1ed7..d2aa15d43f 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -2,7 +2,7 @@
=C2=A0 =C2=A0This code produces the Smbios protocol. It also responsible fo= r constructing
=C2=A0 =C2=A0SMBIOS table into system table.

-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR&g= t;
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR&g= t;
=C2=A0SPDX-License-Identifier: BSD-2-Clause-Patent

=C2=A0**/
@@ -1408,6 +1408,300 @@ SmbiosTableConstruction (
=C2=A0 =C2=A0}
=C2=A0}

+/**
+=C2=A0 Validates a SMBIOS 2.0 table entry point.
+
+=C2=A0 @param=C2=A0 SmbiosTable=C2=A0 =C2=A0The SMBIOS_TABLE_ENTRY_POINT t= o validate.
+
+=C2=A0 @retval TRUE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SMBIOS table e= ntry point is valid.
+=C2=A0 @retval FALSE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SMBIOS table entry = point is malformed.
+
+**/
+STATIC
+BOOLEAN
+IsValidSmbios20Table (
+=C2=A0 IN SMBIOS_TABLE_ENTRY_POINT=C2=A0 =C2=A0 =C2=A0 *SmbiosTable
+=C2=A0 )
+{
+=C2=A0 UINT8 Checksum;
+
+=C2=A0 if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) = !=3D 0) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // The actual value of the EntryPointLength should be 1Fh.
+=C2=A0 // However, it was incorrectly stated in version 2.1 of smbios spec= ification.
+=C2=A0 // Therefore, 0x1F and 0x1E are both accepted.
+=C2=A0 //
+=C2=A0 if (SmbiosTable->EntryPointLength !=3D 0x1E || SmbiosTable->E= ntryPointLength !=3D sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+

This is not correct, it should be

if (SmbiosTable->EntryPointLength !=3D 0x1E = && SmbiosTable->EntryPointLength !=3D sizeof (SMBIOS_TABLE_ENTRY= _POINT)) {

otherwise the table wouldn't be rec= ognized as valid.

+=C2=A0 //
+=C2=A0 // MajorVersion should be 2.
+=C2=A0 //
+=C2=A0 if (SmbiosTable->MajorVersion !=3D 2) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // The whole struct check sum should be zero
+=C2=A0 //
+=C2=A0 Checksum =3D CalculateSum8 (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(UINT8 *) SmbiosTab= le,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SmbiosTable->Ent= ryPointLength
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0);
+=C2=A0 if (Checksum !=3D 0) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // The Intermediate Entry Point Structure check sum should be zero.=
+=C2=A0 //
+=C2=A0 Checksum =3D CalculateSum8 (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(UINT8 *) SmbiosTab= le + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SmbiosTable->Ent= ryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorStri= ng)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0);
+=C2=A0 return (BOOLEAN) (Checksum =3D=3D 0);
+}
+
+/**
+=C2=A0 Validates a SMBIOS 3.0 table entry point.
+
+=C2=A0 @param=C2=A0 SmbiosTable=C2=A0 =C2=A0The SMBIOS_TABLE_3_0_ENTRY_POI= NT to validate.
+
+=C2=A0 @retval TRUE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SMBIOS table e= ntry point is valid.
+=C2=A0 @retval FALSE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SMBIOS table entry = point is malformed.
+
+**/
+STATIC
+BOOLEAN
+IsValidSmbios30Table (
+=C2=A0 IN SMBIOS_TABLE_3_0_ENTRY_POINT=C2=A0 *SmbiosTable
+=C2=A0 )
+{
+=C2=A0 UINT8 Checksum;
+
+=C2=A0 if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5)= !=3D 0) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+=C2=A0 if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_= ENTRY_POINT)) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+=C2=A0 if (SmbiosTable->MajorVersion < 3) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // The whole struct check sum should be zero
+=C2=A0 //
+=C2=A0 Checksum =3D CalculateSum8 (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(UINT8 *) SmbiosTab= le,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SmbiosTable->Ent= ryPointLength
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0);
+=C2=A0 if (Checksum !=3D 0) {
+=C2=A0 =C2=A0 return FALSE;
+=C2=A0 }
+=C2=A0 return TRUE;
+}
+
+/**
+=C2=A0 Parse an existing SMBIOS table and insert it using SmbiosAdd.
+
+=C2=A0 @param=C2=A0 ImageHandle=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Th= e EFI_HANDLE to this driver.
+=C2=A0 @param=C2=A0 Smbios=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 The SMBIOS table to parse.
+=C2=A0 @param=C2=A0 Length=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 The length of the SMBIOS table.
+
+=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SMBIOS = table was parsed and installed.
+=C2=A0 @retval EFI_OUT_OF_RESOURCES=C2=A0 Record was not added due to lack= of system resources.
+=C2=A0 @retval EFI_INVALID_PARAMETER Smbios is not a correct smbios table<= br> +
+**/
+STATIC
+EFI_STATUS
+ParseAndAddExistingSmbiosTable (
+=C2=A0 IN EFI_HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 ImageHandle,
+=C2=A0 IN SMBIOS_STRUCTURE_POINTER=C2=A0 =C2=A0 =C2=A0 Smbios,
+=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Length
+=C2=A0 )
+{
+=C2=A0 EFI_STATUS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 Status;
+=C2=A0 CHAR8=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0*String;
+=C2=A0 EFI_SMBIOS_HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sm= biosHandle;
+=C2=A0 SMBIOS_STRUCTURE_POINTER=C2=A0 =C2=A0 =C2=A0 SmbiosEnd;
+
+=C2=A0 SmbiosEnd.Raw =3D Smbios.Raw + Length;
+
+=C2=A0 if (Smbios.Raw >=3D SmbiosEnd.Raw || Smbios.Raw =3D=3D NULL) { +=C2=A0 =C2=A0 return EFI_INVALID_PARAMETER;
+=C2=A0 }
+
+=C2=A0 do {
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Make sure not to access memory beyond SmbiosEnd
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Ra= w ||
+=C2=A0 =C2=A0 =C2=A0 Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Ra= w) {
+=C2=A0 =C2=A0 =C2=A0 return EFI_INVALID_PARAMETER;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Check for end marker
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 if (Smbios.Hdr->Type =3D=3D SMBIOS_TYPE_END_OF_TABLE) { +=C2=A0 =C2=A0 =C2=A0 break;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Make sure not to access memory beyond SmbiosEnd
+=C2=A0 =C2=A0 // Each structure shall be terminated by a double-null (0000= h).
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) = > SmbiosEnd.Raw ||
+=C2=A0 =C2=A0 =C2=A0 Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT= 8) < Smbios.Raw) {
+=C2=A0 =C2=A0 =C2=A0 return EFI_INVALID_PARAMETER;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Install the table
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 SmbiosHandle =3D Smbios.Hdr->Handle;
+=C2=A0 =C2=A0 Status =3D SmbiosAdd (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&mPrivateData.S= mbios,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ImageHandle,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&SmbiosHandle,<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Smbios.Hdr
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0);
+
+=C2=A0 =C2=A0 ASSERT_EFI_ERROR (Status);
+=C2=A0 =C2=A0 if (EFI_ERROR (Status)) {
+=C2=A0 =C2=A0 =C2=A0 return Status;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Go to the next SMBIOS structure. Each SMBIOS structure ma= y include 2 parts:
+=C2=A0 =C2=A0 // 1. Formatted section; 2. Unformatted string section. So, = 2 steps are needed
+=C2=A0 =C2=A0 // to skip one SMBIOS structure.
+=C2=A0 =C2=A0 //
+
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Step 1: Skip over formatted section.
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length); +
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 // Step 2: Skip over unformatted string section.
+=C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 do {
+=C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 // Each string is terminated with a NULL(00h) BYTE an= d the sets of strings
+=C2=A0 =C2=A0 =C2=A0 // is terminated with an additional NULL(00h) BYTE. +=C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 for ( ; *String !=3D 0; String++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((UINTN) String >=3D (UINTN) SmbiosEnd.R= aw - sizeof (UINT8)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return EFI_INVALID_PARAMETER;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 =C2=A0 if (*(UINT8 *) ++String =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Pointer to the next SMBIOS structure.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Smbios.Raw =3D (UINT8 *) ++String;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
+=C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 } while (TRUE);
+=C2=A0 } while (Smbios.Raw < SmbiosEnd.Raw);
+
+=C2=A0 return EFI_SUCCESS;
+}
+
+
+/**
+=C2=A0 Retrieve SMBIOS from Hob.
+=C2=A0 @param ImageHandle=C2=A0 =C2=A0 =C2=A0Module's image handle
+
+=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 Smbios from Hob is installed.
+=C2=A0 @return EFI_NOT_FOUND=C2=A0 Not found Smbios from Hob.
+=C2=A0 @retval Other=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 No Smbios from Hob = is installed.
+
+**/
+EFI_STATUS
+EFIAPI
+RetrieveSmbiosFromHob (
+=C2=A0 IN EFI_HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ImageHandle +=C2=A0 )
+{
+=C2=A0 EFI_STATUS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 Status;
+=C2=A0 SMBIOS_TABLE_ENTRY_POINT=C2=A0 =C2=A0 =C2=A0 *SmbiosTable;
+=C2=A0 SMBIOS_TABLE_3_0_ENTRY_POINT=C2=A0 *Smbios30Table;
+=C2=A0 SMBIOS_STRUCTURE_POINTER=C2=A0 =C2=A0 =C2=A0 Smbios;
+=C2=A0 EFI_HOB_GUID_TYPE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*G= uidHob;
+=C2=A0 PLD_SMBIOS_TABLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *S= mBiosTableAdress;
+=C2=A0 PLD_GENERIC_HEADER=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *Generi= cHeader;
+
+=C2=A0 Status =3D EFI_NOT_FOUND;
+=C2=A0 //
+=C2=A0 // Scan for existing SMBIOS tables from gPldSmbios3TableGuid Guid H= ob
+=C2=A0 //
+=C2=A0 GuidHob =3D GetFirstGuidHob (&gPldSmbios3TableGuid);
+=C2=A0 if (GuidHob !=3D NULL) {
+=C2=A0 =C2=A0 GenericHeader =3D (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (= GuidHob);
+=C2=A0 =C2=A0 if ((sizeof (PLD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_S= IZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DA= TA_SIZE (GuidHob))) {
+=C2=A0 =C2=A0 =C2=A0 if (GenericHeader->Revision =3D=3D PLD_SMBIOS_TABL= E_REVISION) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 // PLD_SMBIOS_TABLE structure is used when Rev= ision equals to PLD_SMBIOS_TABLE_REVISION
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 SmBiosTableAdress =3D (PLD_SMBIOS_TABLE *) GET= _GUID_HOB_DATA (GuidHob);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (GenericHeader->Length >=3D PLD_SIZEO= F_THROUGH_FIELD (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Smbios30Table =3D (SMBIOS_TABLE_3_0_ENT= RY_POINT *) (UINTN) SmBiosTableAdress->SmBiosEntryPoint;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (IsValidSmbios30Table (Smbios30Table= )) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Smbios.Raw =3D (UINT8 *) (UINTN)= Smbios30Table->TableAddress;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D ParseAndAddExistingSm= biosTable (ImageHandle, Smbios, Smbios30Table->TableMaximumSize);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (EFI_ERROR (Status)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((DEBUG_ERROR, &quo= t;RetrieveSmbiosFromHob: Failed to parse preinstalled tables from gPldSmbio= s3TableGuid Guid Hob\n"));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D EFI_UNSUPPORTE= D;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return EFI_SUCCESS;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 } else {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D EFI_UNSUPPORTED;
+=C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+=C2=A0 }
+
+=C2=A0 //
+=C2=A0 // Scan for existing SMBIOS tables from gPldSmbiosTableGuid Guid Ho= b,
+=C2=A0 // if gPldSmbios3TableGuid Hob doesn't exist or parsing gPldSmb= ios3TableGuid failed
+=C2=A0 //
+=C2=A0 GuidHob =3D GetFirstGuidHob (&gPldSmbiosTableGuid);
+=C2=A0
+=C2=A0 if (GuidHob !=3D NULL) {
+=C2=A0 =C2=A0 GenericHeader =3D (PLD_GENERIC_HEADER *) GET_GUID_HOB_DATA (= GuidHob);
+=C2=A0 =C2=A0 if ((sizeof (PLD_GENERIC_HEADER) <=3D GET_GUID_HOB_DATA_S= IZE (GuidHob)) && (GenericHeader->Length <=3D GET_GUID_HOB_DA= TA_SIZE (GuidHob))) {
+=C2=A0 =C2=A0 =C2=A0 if (GenericHeader->Revision =3D=3D PLD_SMBIOS_TABL= E_REVISION) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 // PLD_SMBIOS_TABLE structure is used when Rev= ision equals to PLD_SMBIOS_TABLE_REVISION
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 //
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 SmBiosTableAdress =3D (PLD_SMBIOS_TABLE *) GET= _GUID_HOB_DATA (GuidHob);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (GenericHeader->Length >=3D PLD_SIZEO= F_THROUGH_FIELD (PLD_SMBIOS_TABLE, SmBiosEntryPoint)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POI= NT *) (UINTN) SmBiosTableAdress->SmBiosEntryPoint;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (IsValidSmbios20Table (SmbiosTable))= {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Smbios.Raw =3D (UINT8 *) (UINTN)= SmbiosTable->TableAddress;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D ParseAndAddExistingSm= biosTable (ImageHandle, Smbios, SmbiosTable->TableLength);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (EFI_ERROR (Status)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG ((DEBUG_ERROR, &quo= t;RetrieveSmbiosFromHob: Failed to parse preinstalled tables from gPldSmbio= sTableGuid Guid Hob\n"));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D EFI_UNSUPPORTE= D;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return EFI_SUCCESS;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 } else {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Status =3D EFI_UNSUPPORTED;
+=C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+=C2=A0 }
+=C2=A0 return Status;
+}
+
=C2=A0/**

=C2=A0 =C2=A0Driver to produce Smbios protocol and pre-allocate 1 page for = the final SMBIOS table.
@@ -1451,5 +1745,6 @@ SmbiosDriverEntryPoint (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&m= PrivateData.Smbios
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0);

-=C2=A0 return Status;
+=C2=A0 RetrieveSmbiosFromHob (ImageHandle);
+=C2=A0 return EFI_SUCCESS;
=C2=A0}
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.h
index f97c85ae40..a260cf695e 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.h
@@ -1,7 +1,7 @@
=C2=A0/** @file
=C2=A0 =C2=A0This code supports the implementation of the Smbios protocol
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR&g= t;
+Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR&g= t;
=C2=A0SPDX-License-Identifier: BSD-2-Clause-Patent

=C2=A0**/
@@ -24,6 +24,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#include <Library/MemoryAllocationLib.h>
=C2=A0#include <Library/UefiBootServicesTableLib.h>
=C2=A0#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <UniversalPayload/SmbiosTable.h>

=C2=A0#define SMBIOS_INSTANCE_SIGNATURE SIGNATURE_32 ('S', 'B&#= 39;, 'i', 's')
=C2=A0typedef struct {
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/= Universal/SmbiosDxe/SmbiosDxe.inf
index f6c036e1dc..3286575098 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
@@ -1,7 +1,7 @@
=C2=A0## @file
=C2=A0# This driver initializes and installs the SMBIOS protocol, construct= s SMBIOS table into system configuration table.
=C2=A0#
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR= >
+# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR= >
=C2=A0#
=C2=A0#=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent
=C2=A0#
@@ -41,6 +41,7 @@
=C2=A0 =C2=A0UefiDriverEntryPoint
=C2=A0 =C2=A0DebugLib
=C2=A0 =C2=A0PcdLib
+=C2=A0 HobLib

=C2=A0[Protocols]
=C2=A0 =C2=A0gEfiSmbiosProtocolGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## PRODUCES
@@ -48,6 +49,8 @@
=C2=A0[Guids]
=C2=A0 =C2=A0gEfiSmbiosTableGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0## SOM= ETIMES_PRODUCES ## SystemTable
=C2=A0 =C2=A0gEfiSmbios3TableGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## SOMETIMES= _PRODUCES ## SystemTable
+=C2=A0 gPldSmbios3TableGuid
+=C2=A0 gPldSmbiosTableGuid

=C2=A0[Pcd]
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion=C2=A0 =C2=A0##= CONSUMES
--
2.30.0.windows.2



------------
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#75489): https://edk2.groups.io/g/dev= el/message/75489
Mute This Topic: https://groups.io/mt/83045509/2917327
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [patrick.rudolph= @9elements.com]
------------


--000000000000c1565105c33b4861--