From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.3925.1622010762759364535 for ; Tue, 25 May 2021 23:32:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Pm2JupUz; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: hao.a.wu@intel.com) IronPort-SDR: Z3anwyxAR57LRSDYvBEAaGuwsQu1VWPL8AFhvYWzTQcUtLkwQsR46iYE+9s4i9UYnSr+zILO+Q xU2Q7m6Dfs0Q== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="287968108" X-IronPort-AV: E=Sophos;i="5.82,330,1613462400"; d="scan'208";a="287968108" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2021 23:32:41 -0700 IronPort-SDR: 75pCTO7HJBGHhyKekz4DDH89mEibM1hm33oPH0QOi0x0Y/9Kfsnz7Pe1oXNH88jDxM8cwmD8KA N0qXTlotLtOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,330,1613462400"; d="scan'208";a="409092451" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga007.fm.intel.com with ESMTP; 25 May 2021 23:32:40 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) 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; Tue, 25 May 2021 23:32:40 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 25 May 2021 23:32:39 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Tue, 25 May 2021 23:32:39 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.46) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Tue, 25 May 2021 23:32:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SgFMjAGC0fEVHh+FEODTgKqfI9+kn2q1uTM/wxi/0W/e9xJa+WPJ2NafAQu7hx3v+UVScMEnIm2OrOiNLsKFcGWGgLz2af6O/mThsMxkRPeYEmZRWufphl2BOxBhGNbtHttDMCgDh/q12k3IQmys+d3XrrBJN9/CHhVPOCYMU1gGCqr0Fhi4EYpRIRgzdUvxAfi3wJHNAcly7SjkVlH1IBuns5wpYpHESn/MNqdHTXCpCjUsZmV5+mUoXuVnABiCfkz9OEs6Mk+dNOXK+onadNJXhU/ZSpcALhsuXzTuy84bP+pLFF1fAuN2TU/3R/nYNTbxnE1zTMS/Zg2p+iBwkg== 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=haTtLbHfhCFhyUh98jUJ6X7NwPbQfphMtT69yxqV+6U=; b=CG3j7ygcG+LwjPszqeY4jlfppkib/AalTGyfcK4lF8zwvGuXlnhmuphv+Q3cSt9qSdrX8tAEqB+MohDqNHwF4AXP5qd4ubAaiG6mEKOW9sXAiq6NfS6nPJePib0mQHwKbFJm8wi4DRtKVyk04AKLpDWgSHIcAouLcI9NvKpODvfmALOYI8UIwVHEjwULyHmNJtKGEpdzLMy4HPvroMgZ8UipwZf6yvlr2TiuLLDsVMpDboc1zZPkoT+7ONHBBJgEp3d0qdXIVsJ8S65XtoLvmqd7/Zjz7Q4GrB3uy2fLXRt5XKyFaf/RyOmbuCvGCGmzGecwlmTDdX9dMtMlasOItw== 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=haTtLbHfhCFhyUh98jUJ6X7NwPbQfphMtT69yxqV+6U=; b=Pm2JupUzhqDRpAlTVI0kijOjSS8LI3jJlx4yJzpKXVy2vs2gKgiau19/BCfk/5F6ZsvuxqnxLhX56Z9cHJP+HSClbclOVLScP/g+NGT/1tkPVhLj0ePGClfOZp3DLrRqjrtqsKcIMrpL5WfNXAhUmZGlyuoLhIiBznwS00YW/3A= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN0PR11MB5728.namprd11.prod.outlook.com (2603:10b6:408:165::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20; Wed, 26 May 2021 06:32:38 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031%4]) with mapi id 15.20.4150.027; Wed, 26 May 2021 06:32:38 +0000 From: "Wu, Hao A" 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 Thread-Topic: [edk2-devel] [PATCH 5/9] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Thread-Index: AQHXUGxDy3aqNf5/2U+BRmKROR98DKr1PSPQgAATJ7A= Date: Wed, 26 May 2021 06:32:38 +0000 Message-ID: References: <20210524071234.1056-1-zhiguang.liu@intel.com> <20210524071234.1056-6-zhiguang.liu@intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.208] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 643bc590-4017-4165-cca1-08d920100e6e x-ms-traffictypediagnostic: BN0PR11MB5728: 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: RIh6E9cwzjKOjM6VU+na5uy/I4QUzf8LlhsxftuBd40uUU+/lAhzVx9HnXRGDrkhxd8f0zSTniucq8SNRf75Ezk0SzLwmsY7gbzIBrLpaG0f/giWsNFbAn2ZLu73Cr0fZXv55MGv3Df6nko6qJc6U+VL8FXg9ae6BVJQ1odCD57nnYUsLVIMWrmqS5JLdAe0gZ6u13mS7Q9I8TGb4x2pbdURbve2SI0yXdgAl7cLhNVscDPip34bGDmIGCJK7Mf6Q7kcnkDbCsiGwg8pEZUvs1F8aNvPEwvbsOccKoBdjgcqq/SFOmHTGIkasyMZSOlIDU5wJhPHjQ9rMkwgORGw9Zjo/qy6bR+7GwuK6AXriTIIesuz0Ur01gfrVS1DFTmpDZf9Qx66mA3wnGyLBGmWx97lPR3SzT5Z5ejiOmNjjXkQGcycIhzSZFw2GF+rKpyKNq7tZ2o0krGODVUgJIK8Bm7QjPF1aD5lYPV6rFPSz8B2FwKBYZJPrSSxbirVZ4dW/7IeN8dJTbLXz+1Aq7J8MW5ZYBNgLGl1muriwEu1UpoczlXCn68mGsHaDTTporLNuATjUWnA7eRv0zkKm+5xhLAuVvJIkZ29llE/FK7CQY4Om5h2tTCaRrOoVIGTRJnucOPUmHZH39ErxPftc3UaNdFFwoPE8Di7SeNRGdiMKEdphV4xKrJtM2EvJPcvjKJ/ZFd3pr02mw22iri0BwnL2/bHr/+t5/34kNDieEXVePg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(39860400002)(396003)(346002)(366004)(136003)(26005)(66476007)(64756008)(66446008)(76116006)(66946007)(66556008)(2906002)(110136005)(316002)(54906003)(186003)(4326008)(8936002)(38100700002)(8676002)(6636002)(83380400001)(2940100002)(478600001)(966005)(55016002)(6506007)(86362001)(52536014)(122000001)(71200400001)(53546011)(30864003)(9686003)(33656002)(19627235002)(5660300002)(7696005)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?65G3Buyj0F4LAg+kT3aJ/zyFKWDF9vMvtExdo3zq+RksmTCLaf6P6yne1f7F?= =?us-ascii?Q?CL5d2Wq4dpC26uF15dQkDWBinjSm0bo+5bleRbk/oYvzpGIBEF4VhN5AoQ1T?= =?us-ascii?Q?EcFCbgmVMVafvRUztfnTLV3K2/9MMru9lbAmUF2zlEJMrV/9jWrLKSalZb+J?= =?us-ascii?Q?F22VQCnyG0PbxCe9uUeNSfuSwc2KNj076SyyNZPTLjyIi2I2NNWwUXx7gtEG?= =?us-ascii?Q?FK6mplnHeYxkYK9MEWUH41btxBjWNG/7xT7D737JSiQSkg/3uITPMZig4C/j?= =?us-ascii?Q?EPtNpl3tSTJrGWKZCteLvEcL86Y33L2w+ld1xyxFIPsdI20naikB3whMtyzL?= =?us-ascii?Q?Y3HMcx/t9XeMWvCvEURTpXNNgOzKxO0lKRcFO6EO1pp+lIf1S/shvjf56GQQ?= =?us-ascii?Q?W/78lj04bOrQNluL2eFsteImI3kN8zJTMIc1ZM/uJOEdUJHsFVTvLo2w/fEB?= =?us-ascii?Q?6HxcBUnfWzymwo4d4ucENYkV4nfOeVWx9Z7hNZdzMylXBs0x6sI6TeVzlgzI?= =?us-ascii?Q?ItusR5pfW/McAascgw0XdMWTt8/yVwUZyVL3HywYLIWTkL+MMnrq8Xvfsmr8?= =?us-ascii?Q?9ALtYyfN7wKSmrD3yY4eH1WyLAVXfkyGBIczx/BpMrCwz7hLHifMB8+kJAvB?= =?us-ascii?Q?Gr6BBZsdntltUdT2r1Ips47f/ddC+pfN6raKEVAG46Iy1HQmqaYykCFn4dHS?= =?us-ascii?Q?QdOk2uv7TCnP34F9sO1yL4mlBDU2ZPkggDSIqN3Z8gThF6P9eD2Pi/bzaZk+?= =?us-ascii?Q?n8uwYQZzuat5l9VYK0N1HXI3z2nAvbDEMwAzdOxS9uFRuPR0S/B5k/FEpG39?= =?us-ascii?Q?8dUVNbnILdHT2nmql5F7FpRrdnE7zZDwjXrzGTWT7zqC9gclBDh6SNxqrM42?= =?us-ascii?Q?uqWyxs/7PsomN2xfeFi3Hzc6uMUd2ga88vo/Sw7eln553U7hkkaJcsuhsAVr?= =?us-ascii?Q?CHDTw2s1gHuSaBKsH6UdnUmxR/Czx+0X46ji9Ay5J8AimdcFYEwxf4CqiDdX?= =?us-ascii?Q?EKC2oat3mCV57DevTsBFaksVUnzWRM/lV2d48dJSTq2FULkoEop5SlQQTTxs?= =?us-ascii?Q?KrgN7Kpcg75swKnox2k+Adl3PDJAyKrOedDnPmzrUFfa+xAA6GFcZFYMb+nS?= =?us-ascii?Q?nYH3S1VT2REbEwJBXaFVThTuaCe49LVCKYxGJetSFBQQKEBl0oWpmfktNU+7?= =?us-ascii?Q?eQtAUyCssnI+ZOI+y0UIs/aBxt+sogU5ZfVpaAytu29kR8aHQE0rR4Mgusdo?= =?us-ascii?Q?WwoPSdRmrFA1Wwji0v8sjbWNxNIYUEycUSdmek9SS736ZNhJAQWLJuGcXZZ+?= =?us-ascii?Q?XxcOO3KfvAk2nxC/fRe1fzB0?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 643bc590-4017-4165-cca1-08d920100e6e X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2021 06:32:38.2044 (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: RS7M/vuTIUPU90FK2mnG+mAcLBqyuCY9no/XrF14xutN5j1HrDFV7r7HfRUoP3o+ZQbo0A07/RBkqFmHElGdcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR11MB5728 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sorry for missing one comment. I think we can add below information for GUID information in SmbiosDxe.inf= : gPldSmbios3TableGuid ## CONSUMES = ## HOB gPldSmbiosTableGuid ## SOMETIMES_CONSUMES = ## HOB Best Regards, Hao Wu > -----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 >=20 > Adding Ray. >=20 > 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 patch? > Thanks. >=20 > Some inline comments below: >=20 >=20 > > -----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 valid= . > > > > 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; > > > > + } >=20 >=20 > Should a check for the 'IntermediateAnchorString' be added here as well? >=20 >=20 > > > > + > > > > + // > > > > + // 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; >=20 >=20 > 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 form= at > (which is still true for version 3.0). >=20 > So I think I check like: > if (EntryPointStructure->MajorVersion < 2) {...} should be used here. >=20 >=20 > > > > + } > > > > + > > > > + // > > > > + // 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 > > + 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 >=20 >=20 > I think RetrieveSmbiosFromHob() is an internal function. > Please help to remove the 'EFIAPI' keyword here. >=20 >=20 > > > > +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->TableAddres= s; > > > > + 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; > > > > + } > > > > + } > > > > + } >=20 >=20 > Is it possible to abstract the codes that: > a) Search & parse of gPldSmbios3TableGuid > b) Search & parse of gPldSmbiosTableGuid into a function? >=20 > I found that most of the logic is identical. >=20 > Best Regards, > Hao Wu >=20 >=20 > > > > + 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_PROD= UCES ## > > SystemTable > > > > gEfiSmbios3TableGuid ## SOMETIMES_PROD= UCES ## > > SystemTable > > > > + gPldSmbios3TableGuid > > > > + gPldSmbiosTableGuid > > > > > > > > [Pcd] > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion ## CONSUMES > > > > -- > > 2.30.0.windows.2 >=20 >=20 >=20 >=20 >=20