From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 6846881988 for ; Tue, 10 Jan 2017 02:09:00 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 10 Jan 2017 02:09:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211625254" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2017 02:09:00 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 10 Jan 2017 02:09:00 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 10 Jan 2017 02:08:59 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Tue, 10 Jan 2017 18:08:57 +0800 From: "Zeng, Star" To: Chris Phillips , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length Thread-Index: AQHSaw6OVKksEBnfJE2LZoEwUGUDqKExfIww Date: Tue, 10 Jan 2017 10:08:57 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B8156BE@shsmsx102.ccr.corp.intel.com> References: <07736531-4229-420c-9676-99c2a5e59e5f@AIA2PHNNRN.local> In-Reply-To: <07736531-4229-420c-9676-99c2a5e59e5f@AIA2PHNNRN.local> 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 Subject: Re: [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length 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: Tue, 10 Jan 2017 10:09:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Chris, Could you also correct the typo "Assert" to "Asset"? With the typo fixed, Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Chri= s Phillips Sent: Tuesday, January 10, 2017 2:55 PM To: edk2-devel@lists.01.org Cc: Ni, Ruiyu Subject: [edk2] [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Le= ngth When running Nt32Pkg, SMBIOS Type 2 had the wrong Length. Fixed the code to use the correct structure in sizeof, and properly account= for ContainedObjectHandles. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips --- .../MiscBaseBoardManufacturerFunction.c | 16 +++++++++++-= ---- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunct= ion.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c index 303726c3fd..26d5d11da6 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction. +++ c @@ -3,6 +3,7 @@ SMBIOS type 2. =20 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -101,11 +1= 02,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen += 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStr= Len + 1 + ChassisStrLen +1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + Pro= ductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 = + ChassisStrLen +1 + 1); + // Since we fill NumberOfContainedObjectHandles =3D 0, remove sizeof=20 + (UINT16) bytes for ContainedObjectHandles[1] // SmbiosRecord =3D=20 + AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) +=20 + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen +=20 + 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1); =20 + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) +=20 + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen +=20 + 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; - SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2); + // + // Since we fill NumberOfContainedObjectHandles =3D 0, remove sizeof=20 + (UINT16) bytes for ContainedObjectHandles[1] // =20 + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2) - sizeof=20 + (UINT16); // // Make handle chosen by smbios protocol.add automatically. // @@ -142,9 +148,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); // - // Since we fill NumberOfContainedObjectHandles =3D 0 for simple, just a= fter this filed to fill string + // Since we fill NumberOfContainedObjectHandles =3D 0, just after this=20 + field to fill string // - OptionalStrStart -=3D 2; + OptionalStrStart -=3D sizeof (UINT16); UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1); -- 2.11.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel