From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3602F8204F for ; Thu, 15 Dec 2016 23:12:49 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 15 Dec 2016 23:12:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,356,1477983600"; d="scan'208,217";a="1072703185" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 15 Dec 2016 23:12:48 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 15 Dec 2016 23:12:48 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 15 Dec 2016 23:12:47 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.54]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.11]) with mapi id 14.03.0248.002; Fri, 16 Dec 2016 15:12:45 +0800 From: "Yao, Jiewen" To: "Chan, Amy" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Chiu, Chasel" , "Chiu, Chasel" , "Abhishek, Chandan" Thread-Topic: [PATCH V2] IntelSiliconPkg: 0468303 caused to breaking the SMBIOS tables generation code Thread-Index: AQHSV2ugFoDsoYLK5kagl+/0Aeh8lqEKKI4Q Date: Fri, 16 Dec 2016 07:12:44 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A8C5867@shsmsx102.ccr.corp.intel.com> References: <20161216071045.11024-1-amy.chan@intel.com> In-Reply-To: <20161216071045.11024-1-amy.chan@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [PATCH V2] IntelSiliconPkg: 0468303 caused to breaking the SMBIOS tables generation code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 07:12:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Chan, Amy > Sent: Friday, December 16, 2016 3:11 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen ; Zeng, Star ;= Chiu; > Chiu, Chasel ; Chan; Chan, Amy > Subject: [PATCH V2] IntelSiliconPkg: 0468303 caused to breaking the SMBIO= S > tables generation code > > Cc: Jiewen Yao > Cc: Star Zeng > Cc: Chiu, Chasel > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Chan, Amy > > System test: > Smbios tables are correctly published on an intel internal platform. > > .../DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c | 134 > +++------------------ > 1 file changed, 14 insertions(+), 120 deletions(-) > > diff --git > a/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c > b/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c > index 8d513e0..968d372 100644 > --- a/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c > +++ b/IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c > @@ -27,95 +27,6 @@ > #include > #include > > -/** > - > - Get the full size of SMBIOS structure including optional strings that = follow the > formatted structure. > - @note: This function is copy from SmbiosDxe in MdeModulePkg. > - > - @param[in] This The EFI_SMBIOS_PROTOCOL instance. > - @param[in] Head Pointer to the beginning of SMBIOS > structure. > - @param[out] Size The returned size. > - @param[out] NumberOfStrings The returned number of optional string= s > that follow the formatted structure. > - > - @retval EFI_SUCCESS Size returned in Size. > - @retval EFI_INVALID_PARAMETER Input SMBIOS structure mal-formed or Siz= e > is NULL. > - > -**/ > -EFI_STATUS > -EFIAPI > -GetSmbiosStructureSize ( > - IN CONST EFI_SMBIOS_PROTOCOL *This, > - IN EFI_SMBIOS_TABLE_HEADER *Head, > - OUT UINTN *Size, > - OUT UINTN *NumberOfStrings > - ) > -{ > - UINTN FullSize; > - UINTN StrLen; > - UINTN MaxLen; > - INT8* CharInStr; > - > - if (Size =3D=3D NULL || NumberOfStrings =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - FullSize =3D Head->Length; > - CharInStr =3D (INT8*)Head + Head->Length; > - *Size =3D FullSize; > - *NumberOfStrings =3D 0; > - StrLen =3D 0; > - > - // > - // look for the two consecutive zeros, check the string limit by the w= ay. > - // > - while (*CharInStr !=3D 0 || *(CharInStr+1) !=3D 0) { > - if (*CharInStr =3D=3D 0) { > - *Size +=3D 1; > - CharInStr++; > - } > - > - if (This->MajorVersion < 2 || (This->MajorVersion =3D=3D 2 && > This->MinorVersion < 7)) { > - MaxLen =3D SMBIOS_STRING_MAX_LENGTH; > - } else if (This->MajorVersion < 3) { > - // > - // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on t= he length > of each individual text string. > - // However, the length of the entire structure table (including al= l strings) > must be reported > - // in the Structure Table Length field of the SMBIOS Structure Tab= le Entry > Point, > - // which is a WORD field limited to 65,535 bytes. > - // > - MaxLen =3D SMBIOS_TABLE_MAX_LENGTH; > - } else { > - // > - // SMBIOS 3.0 defines the Structure table maximum size as DWORD fi= eld > limited to 0xFFFFFFFF bytes. > - // Locate the end of string as long as possible. > - // > - MaxLen =3D SMBIOS_3_0_TABLE_MAX_LENGTH; > - } > - > - for (StrLen =3D 0 ; StrLen < MaxLen; StrLen++) { > - if (*(CharInStr+StrLen) =3D=3D 0) { > - break; > - } > - } > - > - if (StrLen =3D=3D MaxLen) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // forward the pointer > - // > - CharInStr +=3D StrLen; > - *Size +=3D StrLen; > - *NumberOfStrings +=3D 1; > - } > - > - // > - // count ending two zeros. > - // > - *Size +=3D 2; > - return EFI_SUCCESS; > -} > > /** > Adds SMBIOS records to tables > @@ -138,12 +49,8 @@ DxeSmbiosDataHobLibConstructor ( > EFI_SMBIOS_HANDLE SmbiosHandle; > EFI_SMBIOS_PROTOCOL *Smbios; > EFI_STATUS Status; > - UINTN InstalledPayloadSize; > - UINTN MaxPayloadSize; > UINT8 *RecordPtr; > UINT16 RecordCount; > - UINTN StructureSize; > - UINTN NumberOfStrings; > > RecordCount =3D 0; > > @@ -151,42 +58,29 @@ DxeSmbiosDataHobLibConstructor ( > > Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID > **)&Smbios); > if (Smbios =3D=3D NULL) { > - DEBUG ((DEBUG_WARN, " Can't locate SMBIOS protocol\n")); > + DEBUG ((DEBUG_WARN, "Can't locate SMBIOS protocol\n")); > return EFI_UNSUPPORTED; > } > > /// > - /// Get SMBIOS HOB data > + /// Get SMBIOS HOB data (each hob contains one SMBIOS record) > /// > for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw =3D > GET_NEXT_HOB (Hob)) { > if ((GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_GUID_EXTENSION) && > (CompareGuid (&Hob.Guid->Name, &gIntelSmbiosDataHobGuid))) { > - RecordPtr =3D (UINT8 *)Hob.Raw + sizeof (EFI_HOB_GUID_TYPE); > - MaxPayloadSize =3D Hob.Guid->Header.HobLength - sizeof > (EFI_HOB_GUID_TYPE); > - > - InstalledPayloadSize =3D 0; > - do { > - StructureSize =3D 0; > - Status =3D GetSmbiosStructureSize (Smbios, > (EFI_SMBIOS_TABLE_HEADER *)RecordPtr, &StructureSize, &NumberOfStrings); > - if ((Status =3D=3D EFI_SUCCESS) && (InstalledPayloadSize + Struc= tureSize > <=3D MaxPayloadSize)) { > - InstalledPayloadSize +=3D StructureSize; > - > - /// > - /// Add generic SMBIOS HOB to SMBIOS table > - /// > - DEBUG ((DEBUG_VERBOSE, " Add SMBIOS record type: %x\n", > ((EFI_SMBIOS_TABLE_HEADER *) RecordPtr)->Type)); > - SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; > - Status =3D Smbios->Add (Smbios, NULL, &SmbiosHandle, > (EFI_SMBIOS_TABLE_HEADER *) RecordPtr); > - if (!EFI_ERROR (Status)) { > - RecordPtr +=3D StructureSize; > - RecordCount++; > - } > - } else { > - break; > - } > - } while (TRUE); > + RecordPtr =3D GET_GUID_HOB_DATA (Hob.Raw); > + > + /// > + /// Add generic SMBIOS HOB to SMBIOS table > + /// > + DEBUG ((DEBUG_VERBOSE, "Add SMBIOS record type: %x\n", > ((EFI_SMBIOS_TABLE_HEADER *) RecordPtr)->Type)); > + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; > + Status =3D Smbios->Add (Smbios, NULL, &SmbiosHandle, > (EFI_SMBIOS_TABLE_HEADER *) RecordPtr); > + if (!EFI_ERROR (Status)) { > + RecordCount++; > + } > } > } > - DEBUG ((DEBUG_INFO, " Found %d Records and added to SMBIOS table.\n", > RecordCount)); > + DEBUG ((DEBUG_INFO, "Found %d Records and added to SMBIOS table.\n", > RecordCount)); > > return EFI_SUCCESS; > }