From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) (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 8248C81B39 for ; Mon, 9 Jan 2017 22:55:07 -0800 (PST) Received: from AIA2PHNNRN.local (unknown [16.214.90.9]) by g2t2354.austin.hpe.com (Postfix) with SMTP id 1754E4E; Tue, 10 Jan 2017 06:55:07 +0000 (UTC) Date: Tue, 10 Jan 2017 00:55:07 -0600 From: Chris Phillips CC: ruiyu.ni@intel.com Sender: Chris Phillips To: edk2-devel@lists.01.org; Message-ID: <07736531-4229-420c-9676-99c2a5e59e5f@AIA2PHNNRN.local> X-Mailer: TortoiseGit MIME-Version: 1.0 Subject: [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 06:55:07 -0000 Content-Type: text/plain; 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/MiscBaseBoardManufacturerFunction.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. 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 available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) // // Two zeros following the last string. // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1); + // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1] + // + SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1); SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2); + // + // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1] + // + SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16); // // Make handle chosen by smbios protocol.add automatically. // @@ -142,9 +148,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); // - // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string + // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string // - OptionalStrStart -= 2; + OptionalStrStart -= sizeof (UINT16); UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1); -- 2.11.0.windows.1