From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.4871.1622019415549226082 for ; Wed, 26 May 2021 01:56:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=QHremriB; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: mmROK2LR7uDBBEu/8MMatNqqLk7LrruJuunbx4ZTIljKFMxgqHEcib/H3Z4G5cHN7dszAMy7By PZl/rUBU4A3w== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="199365366" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="199365366" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 01:56:54 -0700 IronPort-SDR: 3MpT9av9Nzc4liZ1wW1zFzowY8xps1DKZeQfnZH++Cuk78lRGmWcOrY1J9gaMTfneNkUQJLLd2 AsAFi5pOGo1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="547121599" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga001.fm.intel.com with ESMTP; 26 May 2021 01:56:54 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 26 May 2021 01:56:53 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Wed, 26 May 2021 01:56:53 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Wed, 26 May 2021 01:56:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EoA0mHXmRbqgp/4Jzdh0VECGSFefATW+Z3eAilHbgfrRPj1i5OnKF0qUirT2C3as+pImPTXaZm599Z19h3ISuDWVrZPubgx2n6kvFfyr5LO8M9qO1UK3546SsjlmAYFHXGLhSVzeEfN7cMlqubvqJFSAbWOAZFqX+lzScV72VpmDPRMfxae311rIIoF2XAssmMz7b9xl5HE8/c7j8DO8ai7tdUW7PV/bY7u+ikVU5n4RiI0q2p/wpn6fvUX2yNImROTphDyvX+tmHCgrljlkoJDqQST34ADO7yRCragVS2W65hNvJLgh5b55DtefL98bii+rAPelnBSLPXXiPJ6G8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=keWh21UaX4f2Ds+YLnxlntk+9JNrE/jbwJuQNJ6eqf8=; b=kM+5vIjA35BgBn2H3Bch3BU4sM1vVIORNn7YXULG1x5tQoJ3W3028cPo4UD2LWTuOoLlB2LJiO+Dorthqh/E5fwLauqCPU91gb5qVH+P2YvqXUueQfafwPjGp0Iqn2JC1ifZVHbUAxvmmEnRA7ycQ2hoBxqcHFWvqpLEBF/ltNFZj9dGMVpumnDwoINqCz5e36Bj8/6WJet+WfgPDLWK2nLAIMJK0p1Tl1EirhswoFlprbHUH+No7FNeVFWre+49BlPA9bU1ev7k3HD62RHHT/U4XbkLpjRzTdqzamVJwfulFcMytc3JsPj9mpK6yroUFCroyGWpa2DaB82Jo436Cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=keWh21UaX4f2Ds+YLnxlntk+9JNrE/jbwJuQNJ6eqf8=; b=QHremriB87bGKFQIhuLKpp66+047SB9QTesTuQ9MqPe2gjSFI4i4/IWSD6vjyxHIbhBxBbevRldwxYLYCJhHfZ+/h8j2Q+4zfYm5vtOm7bnFIBXQq8U4Y21Jplpsux763wqmJ5U0NEz8tSTXskHmhCp6TMjjCmeWouszh6skN1A= Received: from PH0PR11MB5048.namprd11.prod.outlook.com (2603:10b6:510:3d::14) by PH0PR11MB4965.namprd11.prod.outlook.com (2603:10b6:510:34::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Wed, 26 May 2021 08:56:51 +0000 Received: from PH0PR11MB5048.namprd11.prod.outlook.com ([fe80::8c52:953e:b2c2:d4e1]) by PH0PR11MB5048.namprd11.prod.outlook.com ([fe80::8c52:953e:b2c2:d4e1%2]) with mapi id 15.20.4150.027; Wed, 26 May 2021 08:56:51 +0000 From: "Zhiguang Liu" To: "Wu, Hao A" , "devel@edk2.groups.io" , "Ni, Ray" CC: "Wang, Jian J" , "Bi, Dandan" , "Zeng, Star" , "Gao, Zhichao" , Patrick Rudolph Subject: Re: [edk2-devel] [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Thread-Topic: [edk2-devel] [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Thread-Index: AQHXUGxDy3aqNf5/2U+BRmKROR98DKr1PSPQgAATJ7CAACiwkA== Date: Wed, 26 May 2021 08:56:50 +0000 Message-ID: References: <20210524071234.1056-1-zhiguang.liu@intel.com> <20210524071234.1056-6-zhiguang.liu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.46.54] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ff8754cf-4e11-46f2-0300-08d9202433e7 x-ms-traffictypediagnostic: PH0PR11MB4965: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /bQL/hXniSmhgPlIqL/kwPosRCTCBPzkGdz/bSv1AuZdNFMJQrBS7prgZjOa9IsFpUEilp2QD9qXHsj6T8iMZginU6s/HUzudfRgvy49NIjrKqMNrbw/PlpftmdEwTJVmBRD9gE4p78nXmy+f8OZviTgYUCe7ZngF+xvV4zpThC4eF4homf/JCRUyxK21/ebpFLZj4+Zoz43pACbxZ41Gxm+Q8XLROM2TdKZ9JV6LurUxRz3jv37lh3XFPLjXruqZvgeBxdRqfZzU8QbJGQ9ykudM5l49vSnhCBpHR7yp0XUdivWbA/l32scNLhXU7qTzW6m4gSTYsEWprzNSnUUgoEE8G+L2IqKqnPUd573OjDEnbFZTvUaI7sZLEd/9mGYQv7RCXLygcT0dGwuAOMhHgu7B90TRJ8wovgvbtFELiKCIxCbZqPRS4j5pqf62mmOYNLOObJfZBXNNi7leRyrkwlA7LU7lu4Nh6PvPUS2G3NrP7sqNfTyJpQLpWxxGg40EtsqjLHgqKNKRfuWNyIlHDAK0Sl8jRUqLR4nblaLNh8t4+/i/QXYX+d6Jy0aG1ctvLNzHmoclqcqWlKj5VIEwA5O+VTcOE4DUF4jr34fN1TXvDB7cM+rAGYCkuKUJGK4juXbYflWVKio6LtvPrVjoWjwKC9OxA1tHKy8eDo2BFnVN+qR1N+AbCgc7u7iFufp4kGTk9y/LmPuGTcjjo9/70TSV16Rgvpq+tJREIgSp5s= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5048.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(346002)(396003)(39860400002)(376002)(38100700002)(19627235002)(316002)(478600001)(53546011)(6636002)(966005)(71200400001)(54906003)(4326008)(64756008)(8676002)(55016002)(110136005)(122000001)(30864003)(8936002)(5660300002)(2906002)(52536014)(186003)(9686003)(86362001)(26005)(66556008)(76116006)(6506007)(83380400001)(33656002)(66476007)(7696005)(66946007)(66446008)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?vMwR2H3aqr9V39mmWsktLc7Sjc8DqHCENIl1LAToIO1jGqa/Jr1gp5S9tna4?= =?us-ascii?Q?pwpBMP5IpRb3BgXYtIhbVULu+xg2qzU0i7i4SxqlcSvJINDXNXMPALVz9zpH?= =?us-ascii?Q?LkMuE9GO61inuB0V0fHK60dct/j3yqx1tSErrQQCBv0auCUfzH1fg6ihqsGM?= =?us-ascii?Q?BPUiNLpPkoMBM4eMMEk5uq5nO/rVe9Isz1pWlF7dvQ/kYNvHOGyO06ot6i1i?= =?us-ascii?Q?wlnKWlsdfmHwftb9tMK7+/lQ4W+ypUCo+5YmB0/4L4b1iMH+OhibUQkiKMAO?= =?us-ascii?Q?HXKmyigovpZ/wQhT/mc+7hwl9tgIbew1VWlUh9KDD48tC3XFhN8zoXGi1uo+?= =?us-ascii?Q?HOK1iNWzn0urBcBa9pzuzw7QZxGMDc6yYjaRah/kuhhWnE/VVPa1zxSeTY3g?= =?us-ascii?Q?mjEHpIbAgA9IoriKqR/nw1fAcnaKhnUdkTHw1mQJ+iYRWrrA+uWtzWTB5Qt0?= =?us-ascii?Q?jQNNhdyem1ZkH+qQRvCLhOyHxk1o0/hzTog/JHXJuTL311mpdVt/07c7qSw0?= =?us-ascii?Q?yAGoSn5SlLCZqSDtGwZPl0VL8egbeciJRHotnPw4oNRZy2Qd9rsvqVUWm70r?= =?us-ascii?Q?JKa3vQCrPrvtfEBOkG6q82mPxkHRhh3ZhulgLuHnAobWcFTk6JUO6tOpAWqt?= =?us-ascii?Q?j5o+2gS9dZ4cWkZ0NvQOuWZrkSdP/hpC4ZAQurD0C9O9Z1332SjzjMJzjW/i?= =?us-ascii?Q?MQBoU1MkoAY9Lvbasall73licJQ1H5/JL72hXM+bU3FTOsB3zThv8QQsJAWB?= =?us-ascii?Q?AqdOrUlPPkq4tiSlLoBtXIbQ+GvfBY/6dv49cZcF02EYsRkf0O3OR9LOH6Z3?= =?us-ascii?Q?R72K7UeI42Jcb1+0eJMjuAS2/ZbscIzyc1gbPiSabne5tTEqSfHP/h/id7AL?= =?us-ascii?Q?pVKxf/1nTU3YMhgXPwXX8gzFyl/p0BKrtjCJ4HHmcGI3SdJFCcaztr6M6/N1?= =?us-ascii?Q?i9CacnRkxxhAMO/u+sbq8wWk0URRY26c6aRVDaumPewInR6Xc0SzGjJ0Anq9?= =?us-ascii?Q?v20CCqpnffuPeWhcmifx1eFnB5u8UMmWHi52JVUBPA5xFhLw1Chw49g2felK?= =?us-ascii?Q?8GQ7A6L/457lxOfiKDUGOT4UtvJTrI/bBIA1JNAmfMQDkyLsOe70fuSBXsij?= =?us-ascii?Q?pQTObfsD245kDWd/Qd3BfjK24QVAYI3E1vOSB8VcDNYTTEbu3c8bNDcJeGED?= =?us-ascii?Q?/OtOr2ltUtaPE0YmL52RVZFC1pHXV/FQ/8EjJNKK/gebb8u05UnFjaZNUrYj?= =?us-ascii?Q?4mNUcAtLw8LhO53XAlQzq4/14lujaWZaNHHoXFy9L/JMZXmfkmgyw5x5h2yb?= =?us-ascii?Q?JPk=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5048.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff8754cf-4e11-46f2-0300-08d9202433e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2021 08:56:50.9542 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8ZjZOH6QCZCqYw+5jepGjuN4M11PM30UNkaCVUs0s/jSDnc1a7Yik/REz53vJl9fHWyp7O1Xd5ylhUZnzSi9qQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4965 Return-Path: zhiguang.liu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Hao, Thanks for the comments. I will send another version soon. Thanks Zhiguang > -----Original Message----- > From: Wu, Hao A > Sent: Wednesday, May 26, 2021 2:33 PM > To: devel@edk2.groups.io; Wu, Hao A ; Liu, Zhiguang > ; Ni, Ray > Cc: Wang, Jian J ; Bi, Dandan > ; Zeng, Star ; Gao, Zhichao > ; Patrick Rudolph > > Subject: RE: [edk2-devel] [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: > Scan for existing tables >=20 > Sorry for missing one comment. > I think we can add below information for GUID information in SmbiosDxe.i= nf: >=20 > gPldSmbios3TableGuid ## CONSUMES = ## HOB > gPldSmbiosTableGuid ## SOMETIMES_CONSUME= S ## HOB >=20 > Best Regards, > Hao Wu >=20 >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Wu, > Hao > > A > > Sent: Wednesday, May 26, 2021 2:15 PM > > To: Liu, Zhiguang ; Ni, Ray > > ; devel@edk2.groups.io > > Cc: Wang, Jian J ; Bi, Dandan > > ; Zeng, Star ; Gao, Zhichao > > ; Patrick Rudolph > > > > Subject: Re: [edk2-devel] [PATCH 5/9] > > MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables > > > > Adding Ray. > > > > Hello Ray, I saw most of your comments in previous patch: > > "[PATCH - resend] MdeModulePkg/Universal/SmbiosDxe: Scan for existing > > tables" > > have been addressed in this patch series. > > Could you help to check if there are additional comments for this patc= h? > > Thanks. > > > > Some inline comments below: > > > > > > > -----Original Message----- > > > From: Liu, Zhiguang > > > Sent: Monday, May 24, 2021 3:13 PM > > > To: devel@edk2.groups.io > > > Cc: Wang, Jian J ; Wu, Hao A > > > ; Bi, Dandan ; Zeng, Star > > > ; Gao, Zhichao ; Patrick > > > Rudolph > > > Subject: [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for > > > existing tables > > > > > > 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 val= id. > > > > > > This fixes the settings menu not showing any hardware information, > > > instead 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; > > > > > > + } > > > > > > Should a check for the 'IntermediateAnchorString' be added here as wel= l? > > > > > > > > > > + > > > > > > + // > > > > > > + // 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; > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // MajorVersion should be 2. > > > > > > + // > > > > > > + if (SmbiosTable->MajorVersion !=3D 2) { > > > > > > + return FALSE; > > > > > > I might be wrong on this. > > My take with the SMBIOS spec is that a 2.0 table is allowed to has > > this field greater than 2. > > As long as a specific version of the SMBIOS spec still support this > > format (which is still true for version 3.0). > > > > So I think I check like: > > if (EntryPointStructure->MajorVersion < 2) {...} should be used here= . > > > > > > > > > > + } > > > > > > + > > > > > > + // > > > > > > + // 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 zer= o. > > > > > > + // > > > > > > + 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 install= ed. > > > > > > + @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 > > > + include 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 > > > > > > I think RetrieveSmbiosFromHob() is an internal function. > > Please help to remove the 'EFIAPI' keyword here. > > > > > > > > > > +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 > > > + (GuidHob)) && (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, > > > + Smbios, 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 > > > + (GuidHob)) && (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, > > > + Smbios, 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; > > > > > > + } > > > > > > + } > > > > > > + } > > > > > > Is it possible to abstract the codes that: > > a) Search & parse of gPldSmbios3TableGuid > > b) Search & parse of gPldSmbiosTableGuid into a function? > > > > I found that most of the logic is identical. > > > > Best Regards, > > Hao Wu > > > > > > > > > > + return Status; > > > > > > +} > > > > > > + > > > > > > /** > > > > > > > > > > > > Driver to produce Smbios protocol and pre-allocate 1 page for the > > > final 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_PR= ODUCES ## > > > SystemTable > > > > > > gEfiSmbios3TableGuid ## SOMETIMES_PR= ODUCES ## > > > SystemTable > > > > > > + gPldSmbios3TableGuid > > > > > > + gPldSmbiosTableGuid > > > > > > > > > > > > [Pcd] > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## > CONSUMES > > > > > > -- > > > 2.30.0.windows.2 > > > > > > > >=20 > >