From nobody Mon Apr 29 13:32:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70587+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70587+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=9elements.com ARC-Seal: i=1; a=rsa-sha256; t=1611158526; cv=none; d=zohomail.com; s=zohoarc; b=egLS0LiArG5oJhQNSW/T6Ta3xe/AeoBIVInv/gs5IMXUBu2CFSnNlTOT0dS5Y+1Hmnlq9HpGI/t3nrxab6diHSf8PQf2QbOaZiZikcLmWEbWe9w5kKsNP9uWe03gADzpqAFcb8CcGHAimZB7U6yjFKtMmgH/eWKgzAxDl0UwcPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611158526; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=WemlIpxHcizn6m7h5841exSpXh+MwCIuLURmfVnqn1o=; b=VPBO++2deld7lxbMCPCXXAxV5T9rOviREQvHiII1A3X16hDrVsKxVP0VL4se1EGolmnULl1xKZGYm8ZMV1Ofqshmzr7HdnN0kjSDTlXWvExD9QmPkYYSiIfRLUY57g9+YsS0cwuYcVC0TiTcxE4P6waVbWkkgQZ9XJfflNBUoxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70587+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611158526730230.63174448486382; Wed, 20 Jan 2021 08:02:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id nEZxYY1788612xTkM2gyQd7M; Wed, 20 Jan 2021 08:02:06 -0800 X-Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by mx.groups.io with SMTP id smtpd.web11.29803.1611158520709621639 for ; Wed, 20 Jan 2021 08:02:01 -0800 X-Received: by mail-ed1-f53.google.com with SMTP id j13so2083510edp.2 for ; Wed, 20 Jan 2021 08:02:00 -0800 (PST) X-Gm-Message-State: Faff3MOXjDor5phziud8tQkqx1787277AA= X-Google-Smtp-Source: ABdhPJwOw62R2zESlR9Cr96i+0bcFOz0xoqQFT3sLRWfZlV323HzzXDkdSfEpyBZlMp3zN9vQS8+zw== X-Received: by 2002:a05:6402:c9c:: with SMTP id cm28mr8148899edb.281.1611158519233; Wed, 20 Jan 2021 08:01:59 -0800 (PST) X-Received: from rudolphp-notebook.9e.network (ip-95-222-8-167.hsi15.unitymediagroup.de. [95.222.8.167]) by smtp.gmail.com with ESMTPSA id i6sm1063422ejd.110.2021.01.20.08.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 08:01:58 -0800 (PST) From: "Patrick Rudolph" To: devel@edk2.groups.io Cc: maurice.ma@intel.com, guo.dong@intel.com, benjamin.you@intel.com Subject: [edk2-devel] [PATCH] UefiPayloadPkg/BlSupportDxe: Use EfiSmbiosProtocol to install tables Date: Wed, 20 Jan 2021 17:01:57 +0100 Message-Id: <20210120160157.3343911-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,patrick.rudolph@9elements.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611158526; bh=vRkl59hNMMNgM8WIXlMJXt2ib3PHsR2jT+/nZnyT8bI=; h=Cc:Date:From:Reply-To:Subject:To; b=YswDYtU+DUBP1JnqaEhRImyuzmrHRLNxjQjC2B7ZCsVuA7bX3hPOGas/W/qLveNdzcq dryeGn8QelQQ9se1GZnDUt+s40RQASf6G+HSD/lNw/smtemNr4h6y8L3fhjnDtw3stRc8 7f7ekWfZ8CpIuW60Ma2C/IvDmrsLQcjskrM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The default EfiSmbiosProtocol operates on an empty SMBIOS table. As the SMBIOS tables are provided by the bootloader, install the SMBIOS tables using the EfiSmbiosProtocol. 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. Signed-off-by: Patrick Rudolph --- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 111 +++++++++++++++++++- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 3 + UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 5 +- 3 files changed, 115 insertions(+), 4 deletions(-) diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.c index a746d0581e..db478c1abc 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c @@ -79,6 +79,107 @@ ReserveResourceInGcd ( return Status; } =20 +EFI_STATUS +EFIAPI +BlDxeInstallSMBIOStables( + IN UINT64 SmbiosTableBase, + IN UINT32 SmbiosTableSize +) +{ + EFI_STATUS Status; + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable; + SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30Table; + SMBIOS_STRUCTURE_POINTER Smbios; + SMBIOS_STRUCTURE_POINTER SmbiosEnd; + CHAR8 *String; + EFI_SMBIOS_HANDLE SmbiosHandle; + EFI_SMBIOS_PROTOCOL *SmbiosProto; + + // + // Locate Smbios protocol. + // + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)= &SmbiosProto); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to locate gEfiSmbiosProtocolGuid\n", + __FUNCTION__)); + return Status; + } + + Smbios30Table =3D (SMBIOS_TABLE_3_0_ENTRY_POINT *)(UINTN)(SmbiosTableBas= e); + SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)(SmbiosTableBase); + + if (CompareMem (Smbios30Table->AnchorString, "_SM3_", 5) =3D=3D 0) { + Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) Smbios30Table->TableAddres= s; + SmbiosEnd.Raw =3D (UINT8 *) (UINTN) (Smbios30Table->TableAddress + Smb= ios30Table->TableMaximumSize); + if (Smbios30Table->TableMaximumSize > SmbiosTableSize) { + DEBUG((DEBUG_INFO, "%a: SMBIOS table size greater than reported by b= ootloader\n", + __FUNCTION__)); + } + } else if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) =3D=3D 0) { + Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddre= ss; + SmbiosEnd.Raw =3D (UINT8 *) ((UINTN) SmbiosTable->TableAddress + Smbio= sTable->TableLength); + + if (SmbiosTable->TableLength > SmbiosTableSize) { + DEBUG((DEBUG_INFO, "%a: SMBIOS table size greater than reported by b= ootloader\n", + __FUNCTION__)); + } + } else { + DEBUG ((DEBUG_ERROR, "%a: No valid SMBIOS table found\n", __FUNCTION__= )); + return EFI_NOT_FOUND; + } + + do { + // Check for end marker + if (Smbios.Hdr->Type =3D=3D 127) { + break; + } + + // Install the table + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; + Status =3D SmbiosProto->Add ( + SmbiosProto, + gImageHandle, + &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 ar= e 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 s= trings + // is terminated with an additional NULL(00h) BYTE. + // + for ( ; *String !=3D 0; String++) { + } + + 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; +} =20 /** Main entry for the bootloader support DXE module. @@ -133,9 +234,13 @@ BlDxeEntryPoint ( // Install Smbios Table // if (SystemTableInfo->SmbiosTableBase !=3D 0 && SystemTableInfo->SmbiosTa= bleSize !=3D 0) { - DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", S= ystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize)); - Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID= *)(UINTN)SystemTableInfo->SmbiosTableBase); - ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", + SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize)); + + if (BlDxeInstallSMBIOStables(SystemTableInfo->SmbiosTableBase, SystemT= ableInfo->SmbiosTableSize) !=3D EFI_SUCCESS) { + Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VO= ID *)(UINTN)SystemTableInfo->SmbiosTableBase); + ASSERT_EFI_ERROR (Status); + } } =20 // diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.h index 512105fafd..a5216cd2e9 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include =20 +#include + #include #include #include @@ -26,5 +28,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =20 #include +#include =20 #endif diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/= BlSupportDxe/BlSupportDxe.inf index cebc811355..d26a75248b 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf @@ -56,5 +56,8 @@ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize =20 +[Protocols] + gEfiSmbiosProtocolGuid + [Depex] - TRUE + gEfiSmbiosProtocolGuid --=20 2.26.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70587): https://edk2.groups.io/g/devel/message/70587 Mute This Topic: https://groups.io/mt/79981721/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-