From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.8187.1614785367289142390 for ; Wed, 03 Mar 2021 07:29:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Kijpj3dn; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: guo.dong@intel.com) IronPort-SDR: qVDPDaYZLmqZbE2pWm9vZ0d65nLizvC6undSZKQ8gm2kr2PueQ4Bg7pGuMSVGS3JgrfM30t+4L DdMpR8IZyzNw== X-IronPort-AV: E=McAfee;i="6000,8403,9912"; a="187333912" X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="187333912" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 07:29:26 -0800 IronPort-SDR: CEhnRUGR4xNDBdEbCG9vpj/h/cx1dDhGh/47FDwfpIvX1lofmn1jwYYiWeO1r4shIgWM9mEesA mV5h/tvlQaxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="428307129" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga004.fm.intel.com with ESMTP; 03 Mar 2021 07:29:26 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 3 Mar 2021 07:29:25 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 3 Mar 2021 07:29:25 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Wed, 3 Mar 2021 07:29:25 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Wed, 3 Mar 2021 07:29:24 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aC6EooMEpLYsqlEPaivNmZGrsdhvcMhq7B6Ob+8AscF3vKlwF9A0foTiS8PL/cE7bPXJOtW/uxwpVZyYcpWc6YWsUFLLkb7s+6EgGoIPCbf3NOyGkQtzd0BwbaB2c71WPy4HK3XGw3YtZ++3qITyXMxmEjSr/5O/K+s/uiJOGA5wxPUFzMFyWu3BPiklzfKdp7IhsR6HQh1YGBZDq4Zd4ug22fpIQPPynYXSrukvwPCgdDiDm6Yjml+lDS87inXoUqJXRYxNkyt5lG3RoPt+nbWscmq8nPL4zWRtl8EHBCYjeD/0NIyeHNtgKg7VZePifPykcVkBUaL17dpXmFBhyA== 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=3pyk+n++K+c7mhHgWHCK/vNF2X1vw1+dENJqyJte07k=; b=WdzDU+dpYRKT9W93X5e6i0Q3JDRbytOTa7SUL10ZePY5W86M6ib2vgCKZD0C4E4k10srjDEikx8Tz3PkQo05OpPgs7LO+xjNeM8sURpfV2PXzt9SuWW9F5NqValBio6MhfgCadpBQOCP0JuQS+NWZe1WyQmJD94hUZ4UOoGvdIQZ61NE3VrY+AkSjvb3bFjgeD3uOITj/AX0btLRlVQCUixMQVp4oD3IqsVR6UWKuUWPGYBHlmDzOsWNAAtyzLeq1/djQmrvca/zJDhsgLi8IZybeVhYgb/aV87KHRmugVMk69oTs6wPtcXyOKCnq7z3yXSicuzVjEnNVlhBtBvn1Q== 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=3pyk+n++K+c7mhHgWHCK/vNF2X1vw1+dENJqyJte07k=; b=Kijpj3dnUSgpP9hAJTT9qlLdiHfRT4n76Hxdkk2MVVMPmg9QG2KQ0VrEUkQhkKvLKenD2HrweDH/llb40vCBFOZqu2+g9nJXvbUNPqygIeufCA/CrDJ5KKO977FVhyDyeNeJO8uOjjKWnAkm8/EjwjMMVMEP0PFgeHdSTjF/Fuo= Received: from BYAPR11MB3622.namprd11.prod.outlook.com (2603:10b6:a03:fe::30) by BY5PR11MB4484.namprd11.prod.outlook.com (2603:10b6:a03:1c3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.28; Wed, 3 Mar 2021 15:29:22 +0000 Received: from BYAPR11MB3622.namprd11.prod.outlook.com ([fe80::9d0a:3b97:a353:663d]) by BYAPR11MB3622.namprd11.prod.outlook.com ([fe80::9d0a:3b97:a353:663d%3]) with mapi id 15.20.3890.029; Wed, 3 Mar 2021 15:29:22 +0000 From: "Guo Dong" To: Patrick Rudolph , "devel@edk2.groups.io" CC: "Bi, Dandan" , "Zeng, Star" , "Gao, Zhichao" , "You, Benjamin" , "philipp.deppenwiese@9elements.com" , "Ma, Maurice" Subject: Re: [PATCH - resend] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Thread-Topic: [PATCH - resend] MdeModulePkg/Universal/SmbiosDxe: Scan for existing tables Thread-Index: AQHXDqfBjQqQARoiZEuVJzQMavzNEKpyYiQw Date: Wed, 3 Mar 2021 15:29:21 +0000 Message-ID: References: <20210301143221.2775162-1-patrick.rudolph@9elements.com> In-Reply-To: <20210301143221.2775162-1-patrick.rudolph@9elements.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: 9elements.com; dkim=none (message not signed) header.d=none;9elements.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [68.2.51.172] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 39dcd0a7-99e2-41e2-533c-08d8de591eb0 x-ms-traffictypediagnostic: BY5PR11MB4484: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Z3bs95MBsknWQV1DoEvli7PpiECcwb6hGzqZ3EffkaPfNDGx7d4z+4AZ1zcDyBP3U1d1yy26m/hxe77P9X9fliKGsvXL2GloIHkd6g3KS3afoQwB87Gk3RSfrvepE1L51QZzeAJct2n4JNx47kI2iygczJq1xurqkLg+rjbbFxE7LthMTU3R4hE+lxe5U9BGP1tomcs0wg7T2xmFvmtWwL7ZcAoP/o/+NoUAaaNn9dSYlcVujIlcQmhYT5RMLS5ak09I/K520+l/6t6eyAKnLV7T3J3AYsXMgwXM4CkH/fe5QsZnT4C8V91e3RFh2p5X7f4300s3pJJ4St+5ANrNqeoX1/2cCBxBWQepjat/PkIGO1QsYRGhZzTmWcDRIjg7x2ZMpqgHzi9hPn+7BgFRwOympznVFXqCwL+AXtRuzC4sfBAeW8IGaPIDlI7RsE0v+btOsHmYQn8MxrtPqXR96oLImkHQIW2HQAxSdBql/Ar+hjN62JI5em871knVHiKAZ9OleKFMmads/9ooLQa4Kw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3622.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(366004)(396003)(346002)(376002)(39860400002)(33656002)(316002)(110136005)(52536014)(54906003)(5660300002)(478600001)(26005)(19627235002)(66556008)(66476007)(66946007)(7696005)(66446008)(4326008)(64756008)(76116006)(186003)(8676002)(2906002)(86362001)(55016002)(8936002)(9686003)(6506007)(107886003)(71200400001)(53546011)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?fxcxkMC+oMueaVHEuz6RP94g1zgkYQrZMtpKUpQQtxpOxyNkaOXhCgPWEdUJ?= =?us-ascii?Q?x+Iz7/B6VmfDDV/axmbzXcRUFwMvLhGodsQNgRKY0ZP2dSPSqqjv4WocXJ9G?= =?us-ascii?Q?2yatHxjspToHfbJP6Lh6pnwg5wopWSDcUwpE5hNQTZ5NMNcAe70dTjl/FZ/z?= =?us-ascii?Q?1HZ43GLdCRCemnfAfRnymkfIQ6euh+g+JAbq3dAivLsUl0jNQnC6xnd0fnVt?= =?us-ascii?Q?Z2W6kE1xEmytss2KuLfEwOgvCXIq5aW0xm9BtjwuLGBV/m2VGbDghb4O9WRp?= =?us-ascii?Q?nzAiVglc7gOxr3ttvRhJjS95vTZYCZ8zMR7LD7Hjiyxov9mKSaVxySZvYcRS?= =?us-ascii?Q?ekZmd/n2l/Xec2q5WVyu927DGgyl6ruhXAAkcOyaAzuDgXT10l8rrLWc9LKD?= =?us-ascii?Q?ynCoa7qNY5KnpCnMFeDRX4zlYiPvknwpWnTuuOppDCGwKSFOxW72YdRIT+NG?= =?us-ascii?Q?jjfF9KcuElfdFmsp6Y0kB1LHmP+mGFrN6MSwhEquJznUNKkbvQGY1gaGyQaE?= =?us-ascii?Q?K9z7qYaaiP9F76kCMY9KV9fmRj/86yj/vDdUPRUJrhYMqnryU+dnFyDQenyd?= =?us-ascii?Q?HWUZTH2CtKJbnjD28pc7I95Xtc56wkCVqykuGYBVVrIjiCivpAI/7dudrH5Z?= =?us-ascii?Q?6R2OMWMDgZfGu2vbEEbz2NFeunB7yTrhQTD8MRXwpaab9pxFasXbt7Vj4I5y?= =?us-ascii?Q?I1feAfNaQoHvgfDebw+GTiuGSqG6IILR6oqF0wHtBRwi2MsfI7vA4GofFSCC?= =?us-ascii?Q?D/huFXXeuKeOGQFgdQn2cnq8zHIjyGHjEZ0gm4IbsOp1RVWI7bQHgpokg0mM?= =?us-ascii?Q?+a5+S3RTeK83pNG/fDkfmZ/zQvx0I2QikrsuPFGVh4JVRxP16gwZHYnbElel?= =?us-ascii?Q?Ns5nRCLyyUA7Wuqo5zLqz3UwVjUUfkMsHbOE32ZXZB+9sgcvnCCi9pwOJuLU?= =?us-ascii?Q?Ou3WCnSa9tUyGqJt6gKpAxUDDbOLS2oVjHFqrwbYBvDVw6SqZWWd+Oh7PbG3?= =?us-ascii?Q?qfV2xXYCkByyBjtH/9bJJ1X21O6VmAsbYTeLgmkFCRHOnzCBjiRxrLviDLqN?= =?us-ascii?Q?Gc+1as0PpyJtEf7Mi+jJnhOQg5qleDzQh5vU3PWoMUdOgPh0NqoQbdABzKTi?= =?us-ascii?Q?U4Da+7JAo09aNYEXloAsiJNJSi/dERruFv2o8pxZG2rLaF0TprYTn08YN6Gy?= =?us-ascii?Q?JhJrYMks21WNy4VlJoJGz5gous39+3s2VguOFN0iXLywWtr2v1UPZJEfGapH?= =?us-ascii?Q?qBg+fZEjG9+hxiU/nfJdlnQQTwSTob2HG+U3TiU2aelv2sndT2U6veFXmaq/?= =?us-ascii?Q?gBc=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3622.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39dcd0a7-99e2-41e2-533c-08d8de591eb0 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2021 15:29:21.9353 (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: i2/O1Hwyp4gC7998SHQdEZErWZS+PnG5d3SlEyFPR5AijE2jE67mRlfRjXcIHGmr94dy3yL/2evWnb5+QTTpJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4484 Return-Path: guo.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi SmbiosDxe maintainers, Do you have any comments on this patch? Maybe it is a more clean way to check if SMBIOS table HOB exists in its ent= ry point instead of checking GetSystemConfigurationTable. If the HOB exists, just add the SMBIOS records. And maybe we could skip so = many sanity checks. We could define a SMBIOS table HOB as below. /// /// SMBIOS table hob /// typedef struct { EFI_HOB_GUID_TYPE Header; UINT64 TableAddress; } SMBIOS_TABLE_HOB; The HOB guid could be gEfiSmbiosTableGuid or gEfiSmbios3TableGuid based on = the records. UEFI payload (or bootloader) could produce this HOB based on information fr= om bootloader. Thanks, Guo > -----Original Message----- > From: Patrick Rudolph > Sent: Monday, March 1, 2021 7:32 AM > To: devel@edk2.groups.io > Cc: Bi, Dandan ; Zeng, Star ; > Gao, Zhichao ; You, Benjamin > ; philipp.deppenwiese@9elements.com; Ma, > Maurice ; Dong, Guo > Subject: [PATCH - resend] MdeModulePkg/Universal/SmbiosDxe: Scan for > existing tables >=20 > 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. >=20 > This fixes the settings menu not showing any hardware information, instea= d > only "0 MB RAM" was displayed. >=20 > Tests showed that the OS can still see the SMBIOS tables. >=20 > Signed-off-by: Patrick Rudolph > --- > MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 223 > +++++++++++++++++++- > 1 file changed, 221 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > index 3cdb0b1ed7..958a249cf9 100644 > --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c > @@ -1408,6 +1408,177 @@ SmbiosTableConstruction ( > } >=20 > } >=20 >=20 >=20 > +/** >=20 > + Validates a SMBIOS 2.0 table entry point. >=20 > + >=20 > + @param EntryPointStructure The SMBIOS_TABLE_ENTRY_POINT to > validate. >=20 > + >=20 > + @retval TRUE SMBIOS table entry point is valid. >=20 > + @retval FALSE SMBIOS table entry point is malformed. >=20 > + >=20 > +**/ >=20 > +STATIC >=20 > +BOOLEAN >=20 > +ValidateSmbios20Table( >=20 > + IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure >=20 > +) { >=20 > + UINT8 Checksum; >=20 > + >=20 > + if (CompareMem (EntryPointStructure->AnchorString, "_SM_", 4) !=3D 0) = { >=20 > + return FALSE; >=20 > + } >=20 > + if (EntryPointStructure->EntryPointLength < 0x1E) { >=20 > + return FALSE; >=20 > + } >=20 > + if (EntryPointStructure->MajorVersion < 2) { >=20 > + return FALSE; >=20 > + } >=20 > + if (EntryPointStructure->SmbiosBcdRevision > 0 && >=20 > + (EntryPointStructure->SmbiosBcdRevision >> 4) < 2) { >=20 > + return FALSE; >=20 > + } >=20 > + if (EntryPointStructure->TableLength =3D=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + if (EntryPointStructure->TableAddress =3D=3D 0 || >=20 > + EntryPointStructure->TableAddress =3D=3D ~0) { >=20 > + return FALSE; >=20 > + } >=20 > + >=20 > + Checksum =3D CalculateSum8((UINT8 *) EntryPointStructure, >=20 > + EntryPointStructure->EntryPointLength); >=20 > + if (Checksum !=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + >=20 > + Checksum =3D CalculateSum8((UINT8 *) EntryPointStructure + 0x10, >=20 > + EntryPointStructure->EntryPointLength - 0x10); >=20 > + if (Checksum !=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + return TRUE; >=20 > +} >=20 > + >=20 > +/** >=20 > + Validates a SMBIOS 3.0 table entry point. >=20 > + >=20 > + @param Smbios30EntryPointStructure The > SMBIOS_TABLE_3_0_ENTRY_POINT to validate. >=20 > + >=20 > + @retval TRUE SMBIOS table entry point is valid. >=20 > + @retval FALSE SMBIOS table entry point is malformed. >=20 > + >=20 > +**/ >=20 > +STATIC >=20 > +BOOLEAN >=20 > +ValidateSmbios30Table( >=20 > + IN SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30EntryPointStructure >=20 > +) { >=20 > + UINT8 Checksum; >=20 > + >=20 > + if (CompareMem (Smbios30EntryPointStructure->AnchorString, "_SM3_", > 5) !=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + if (Smbios30EntryPointStructure->EntryPointLength < 0x18) { >=20 > + return FALSE; >=20 > + } >=20 > + if (Smbios30EntryPointStructure->MajorVersion < 3) { >=20 > + return FALSE; >=20 > + } >=20 > + if (Smbios30EntryPointStructure->TableMaximumSize =3D=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + if (Smbios30EntryPointStructure->TableAddress =3D=3D 0 || >=20 > + Smbios30EntryPointStructure->TableAddress =3D=3D ~0) { >=20 > + return FALSE; >=20 > + } >=20 > + >=20 > + Checksum =3D CalculateSum8((UINT8 *) Smbios30EntryPointStructure, >=20 > + Smbios30EntryPointStructure->EntryPointLength); >=20 > + if (Checksum !=3D 0) { >=20 > + return FALSE; >=20 > + } >=20 > + return TRUE; >=20 > +} >=20 > + >=20 > +/** >=20 > + Parse an existing SMBIOS table and insert it using SmbiosAdd. >=20 > + >=20 > + @param ImageHandle The EFI_HANDLE to this driver. >=20 > + @param Smbios The SMBIOS table to parse. >=20 > + @param Length The length of the SMBIOS table. >=20 > + >=20 > + @retval EFI_SUCCESS SMBIOS table was parsed and installed. >=20 > + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of > system resources. >=20 > + >=20 > +**/ >=20 > +STATIC >=20 > +EFI_STATUS >=20 > +ParseAndAddExistingSmbiosTable( >=20 > + IN EFI_HANDLE ImageHandle, >=20 > + IN SMBIOS_STRUCTURE_POINTER Smbios, >=20 > + IN UINTN Length >=20 > +) { >=20 > + EFI_STATUS Status; >=20 > + CHAR8 *String; >=20 > + EFI_SMBIOS_HANDLE SmbiosHandle; >=20 > + SMBIOS_STRUCTURE_POINTER SmbiosEnd; >=20 > + >=20 > + SmbiosEnd.Raw =3D Smbios.Raw + Length; >=20 > + >=20 > + do { >=20 > + // Check for end marker >=20 > + if (Smbios.Hdr->Type =3D=3D 127) { >=20 > + break; >=20 > + } >=20 > + >=20 > + // Install the table >=20 > + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; >=20 > + Status =3D SmbiosAdd ( >=20 > + &mPrivateData.Smbios, >=20 > + ImageHandle, >=20 > + &SmbiosHandle, >=20 > + Smbios.Hdr >=20 > + ); >=20 > + >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + if (EFI_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + // >=20 > + // Go to the next SMBIOS structure. Each SMBIOS structure may includ= e 2 > parts: >=20 > + // 1. Formatted section; 2. Unformatted string section. So, 2 steps = are > needed >=20 > + // to skip one SMBIOS structure. >=20 > + // >=20 > + >=20 > + // >=20 > + // Step 1: Skip over formatted section. >=20 > + // >=20 > + String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length); >=20 > + >=20 > + // >=20 > + // Step 2: Skip over unformatted string section. >=20 > + // >=20 > + do { >=20 > + // >=20 > + // Each string is terminated with a NULL(00h) BYTE and the sets of= strings >=20 > + // is terminated with an additional NULL(00h) BYTE. >=20 > + // >=20 > + for ( ; *String !=3D 0; String++) { >=20 > + } >=20 > + >=20 > + if (*(UINT8*)++String =3D=3D 0) { >=20 > + // >=20 > + // Pointer to the next SMBIOS structure. >=20 > + // >=20 > + Smbios.Raw =3D (UINT8 *)++String; >=20 > + break; >=20 > + } >=20 > + } while (TRUE); >=20 > + } while (Smbios.Raw < SmbiosEnd.Raw); >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > + >=20 > /** >=20 >=20 >=20 > Driver to produce Smbios protocol and pre-allocate 1 page for the fina= l > SMBIOS table. >=20 > @@ -1426,7 +1597,10 @@ SmbiosDriverEntryPoint ( > IN EFI_SYSTEM_TABLE *SystemTable >=20 > ) >=20 > { >=20 > - EFI_STATUS Status; >=20 > + EFI_STATUS Status; >=20 > + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable; >=20 > + SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30Table; >=20 > + SMBIOS_STRUCTURE_POINTER Smbios; >=20 >=20 >=20 > mPrivateData.Signature =3D SMBIOS_INSTANCE_SIGNATURE; >=20 > mPrivateData.Smbios.Add =3D SmbiosAdd; >=20 > @@ -1450,6 +1624,51 @@ SmbiosDriverEntryPoint ( > EFI_NATIVE_INTERFACE, >=20 > &mPrivateData.Smbios >=20 > ); >=20 > + // >=20 > + // Scan for existing SMBIOS tables installed by bootloader >=20 > + // >=20 > + Status =3D EfiGetSystemConfigurationTable ( >=20 > + &gEfiSmbios3TableGuid, >=20 > + (VOID **) &Smbios30Table >=20 > + ); >=20 > + if (!EFI_ERROR (Status) && ValidateSmbios30Table(Smbios30Table)) { >=20 > + Smbios.Raw =3D AllocatePool(Smbios30Table->TableMaximumSize); >=20 > + if (!Smbios.Raw) { >=20 > + return EFI_OUT_OF_RESOURCES; >=20 > + } >=20 > + // >=20 > + // Backup old table in case it gets overwritten while parsing it >=20 > + // >=20 > + CopyMem (Smbios.Raw, (VOID *)Smbios30Table, Smbios30Table- > >TableMaximumSize); >=20 > + Status =3D ParseAndAddExistingSmbiosTable(ImageHandle, Smbios, > Smbios30Table->TableMaximumSize); >=20 > + FreePool(Smbios.Raw); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "SmbiosDriverEntryPoint: Failed to parse > preinstalled tables\n")); >=20 > + Status =3D EFI_SUCCESS; >=20 > + } >=20 > + } >=20 > + >=20 > + Status =3D EfiGetSystemConfigurationTable ( >=20 > + &gEfiSmbiosTableGuid, >=20 > + (VOID **) &SmbiosTable >=20 > + ); >=20 > + if (!EFI_ERROR (Status) && ValidateSmbios20Table(SmbiosTable)) { >=20 > + Smbios.Raw =3D AllocatePool(SmbiosTable->TableLength); >=20 > + if (!Smbios.Raw) { >=20 > + return EFI_OUT_OF_RESOURCES; >=20 > + } >=20 > + // >=20 > + // Backup old table in case it gets overwritten while parsing it >=20 > + // >=20 > + CopyMem (Smbios.Raw, (VOID *)(UINTN)SmbiosTable->TableAddress, > SmbiosTable->TableLength); >=20 >=20 >=20 > - return Status; >=20 > + Status =3D ParseAndAddExistingSmbiosTable(ImageHandle, Smbios, > SmbiosTable->TableLength); >=20 > + FreePool(Smbios.Raw); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "SmbiosDriverEntryPoint: Failed to parse > preinstalled tables\n")); >=20 > + Status =3D EFI_SUCCESS; >=20 > + } >=20 > + } >=20 > + >=20 > + return EFI_SUCCESS; >=20 > } >=20 > -- > 2.26.2