From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by mx.groups.io with SMTP id smtpd.web11.10610.1683702893420477504 for ; Wed, 10 May 2023 00:14:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@gmail.com header.s=20221208 header.b=CwbOScA2; spf=pass (domain: gmail.com, ip: 209.85.128.173, mailfrom: mike.maslenkin@gmail.com) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-55af4277904so105748867b3.1 for ; Wed, 10 May 2023 00:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683702892; x=1686294892; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lIXSfPqfQH7fyavAhf2H6ZQJ50/CNsz/81LREbiZVH4=; b=CwbOScA2Nuzw01mMuCRTGDgx34+f/of3XNvEKdzqHWZZfTtuBdbNv6Swl52C/72eLG SqUJW1C/YXOG6fO1Lyb0pqL61YG0xlzJ1C91l6ElkG4hPt+A3B39zxj3PMgcvKjlQV2U O6F1/GAc6SB/P1akkRuiHriU/QpqoAhB9cqy104dH/DLwcUXsodahXZjsRbbvBgqfOXM HBmAkWUVDp7fz1c42RdDvUNzpJL+ra0YByWazh926HtpbW91OsUUxqbpbwNCeW5y38Wa YTqRWx5HCQ3s4bhAZLkO5+UtOlEW8+az09FEzTskQQTh1pKZeAi5raHuIlum1vDooxeW 5o2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683702892; x=1686294892; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lIXSfPqfQH7fyavAhf2H6ZQJ50/CNsz/81LREbiZVH4=; b=UalbZFBHGxidvuXzuqdcw7OEr1WPyE6FfgiH+z7WGloWcHrNQxUidC7/hmsqpZnHN6 Tfu+LoMIlCmu3vUqQxOXJJ2GvWsi/CWDTXLUksJb0wKckWwBu+iCplL5NUE94tWs+LMJ gQrgtJHKYKpWSpksD79QUI7URNonfmd0lIWcLTAM3TVbwDDJfGpANiXARy1Nv9aVD/3X CsmALjHHUrboehRjxsdyp9hG1P99LyGku+onvWvKkOcoJz2Lt9o7JrSUMZ+0qhzBUuba 1XfqWPvPkv/qZUT+yaVvkcv7Jmc9TPquxVGhOB5TjY99gnnhrinnhDXQoGe+Q9mvo929 KWWg== X-Gm-Message-State: AC+VfDzpIglTrTgYoqqVzgA4eUMKiZ2S4io3nH2+jfJe71iBfGxsvi7K YF5JdVaSwwI7VZxMXr1BuXOzv0DEGQ6S3f1sPrmjbli0H6jIYw== X-Google-Smtp-Source: ACHHUZ7y++55z20uYBv19s7rDaD4hNpihMUWRv2KdTAQVEbJazaYhqqgeYxLIVoloiRr+D6W4ffpMND/ow3BFPJCMGc= X-Received: by 2002:a0d:cc97:0:b0:55a:8626:772a with SMTP id o145-20020a0dcc97000000b0055a8626772amr17804893ywd.27.1683702892429; Wed, 10 May 2023 00:14:52 -0700 (PDT) MIME-Version: 1.0 References: <20230510035817.1023-1-guo.dong@intel.com> In-Reply-To: <20230510035817.1023-1-guo.dong@intel.com> From: "Mike Maslenkin" Date: Wed, 10 May 2023 10:14:16 +0300 Message-ID: Subject: Re: [edk2-devel][PATCH] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload To: devel@edk2.groups.io, guo.dong@intel.com Cc: Ray Ni , Sean Rhodes , James Lu , Gua Guo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Guo Dong Don't you need to free "Buffer" after Fv->ReadSection() call ? Regards, Mike. On Wed, May 10, 2023 at 6:58=E2=80=AFAM Guo Dong wrote= : > > From: Guo Dong > > After moving BDS driver to a new FV for universal UEFI payload, > the shell boot option path is not correct since it used the BDS > FV instead of DXE FV in its device path. > This patch would find the correct FV by reading shell file. > It also removed PcdShellFile by using gUefiShellFileGuid. > > Signed-off-by: Guo Dong > Cc: Ray Ni > Cc: Sean Rhodes > Cc: James Lu > Cc: Gua Guo > --- > UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c = | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +------ > UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf= | 5 +++-- > UefiPayloadPkg/UefiPayloadPkg.dec = | 3 --- > 3 files changed, 73 insertions(+), 11 deletions(-) > > diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMa= nager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager= .c > index 62637ae6aa..cf72783af1 100644 > --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c > +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c > @@ -2,7 +2,7 @@ > This file include all platform action which can be customized > by IBV/OEM. > > -Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include "PlatformConsole.h" > #include > #include > +#include > > /** > Signal EndOfDxe event and install SMM Ready to lock protocol. > @@ -89,6 +90,72 @@ PlatformFindLoadOption ( > return -1; > } > > + > +EFI_DEVICE_PATH_PROTOCOL * > +BdsGetShellFvDevicePath ( > + VOID > + ) > +{ > + UINTN FvHandleCount; > + EFI_HANDLE *FvHandleBuffer; > + UINTN Index; > + EFI_STATUS Status; > + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; > + UINTN Size; > + UINT32 AuthenticationStatus; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + VOID *Buffer; > + > + Status =3D EFI_SUCCESS; > + gBS->LocateHandleBuffer ( > + ByProtocol, > + &gEfiFirmwareVolume2ProtocolGuid, > + NULL, > + &FvHandleCount, > + &FvHandleBuffer > + ); > + > + for (Index =3D 0; Index < FvHandleCount; Index++) { > + Buffer =3D NULL; > + Size =3D 0; > + gBS->HandleProtocol ( > + FvHandleBuffer[Index], > + &gEfiFirmwareVolume2ProtocolGuid, > + (VOID **) &Fv > + ); > + Status =3D Fv->ReadSection ( > + Fv, > + &gUefiShellFileGuid, > + EFI_SECTION_PE32, > + 0, > + &Buffer, > + &Size, > + &AuthenticationStatus > + ); > + if (!EFI_ERROR (Status)) { > + // > + // Found the shell file > + // > + break; > + } > + } > + > + if (EFI_ERROR (Status)) { > + if (FvHandleCount) { > + FreePool (FvHandleBuffer); > + } > + return NULL; > + } > + > + DevicePath =3D DevicePathFromHandle (FvHandleBuffer[Index]); > + > + if (FvHandleCount) { > + FreePool (FvHandleBuffer); > + } > + > + return DevicePath; > +} > + > /** > Register a boot option using a file GUID in the FV. > > @@ -109,15 +176,12 @@ PlatformRegisterFvBootOption ( > EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > UINTN BootOptionCount; > MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; > - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; > EFI_DEVICE_PATH_PROTOCOL *DevicePath; > > - Status =3D gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocol= Guid, (VOID **)&LoadedImage); > - ASSERT_EFI_ERROR (Status); > > EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); > DevicePath =3D AppendDevicePathNode ( > - DevicePathFromHandle (LoadedImage->DeviceHandle), > + BdsGetShellFvDevicePath(), > (EFI_DEVICE_PATH_PROTOCOL *)&FileNode > ); > > @@ -248,7 +312,7 @@ PlatformBootManagerAfterConsole ( > // > // Register UEFI Shell > // > - PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell",= LOAD_OPTION_ACTIVE); > + PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD= _OPTION_ACTIVE); > > if (FixedPcdGetBool (PcdBootManagerEscape)) { > Print ( > diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMa= nagerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMa= nagerLib.inf > index f9626175e2..a3951b7a7e 100644 > --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi= b.inf > +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi= b.inf > @@ -1,7 +1,7 @@ > ## @file > # Include all platform action which can be customized by IBV/OEM. > # > -# Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved. > +# Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > ## > @@ -32,6 +32,7 @@ > MdePkg/MdePkg.dec > MdeModulePkg/MdeModulePkg.dec > UefiPayloadPkg/UefiPayloadPkg.dec > + ShellPkg/ShellPkg.dec > > [LibraryClasses] > BaseLib > @@ -52,6 +53,7 @@ > [Guids] > gEfiEndOfDxeEventGroupGuid > gEdkiiBootManagerMenuFileGuid > + gUefiShellFileGuid > > [Protocols] > gEfiGenericMemTestProtocolGuid ## CONSUMES > @@ -69,7 +71,6 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn > gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand > - gUefiPayloadPkgTokenSpaceGuid.PcdShellFile > gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate > gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits > gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity > diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPaylo= adPkg.dec > index a23a7b5a78..8d111f3a90 100644 > --- a/UefiPayloadPkg/UefiPayloadPkg.dec > +++ b/UefiPayloadPkg/UefiPayloadPkg.dec > @@ -67,9 +67,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize|0|UIN= T32|0x10000002 > ## Save bootloader parameter > gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004 > > -## FFS filename to find the shell application. > -gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3= E, 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }|VOID*= |0x10000005 > - > ## Used to help reduce fragmentation in the EFI memory map > gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x19|UIN= T32|0x10000012 > gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|= 0x10000013 > -- > 2.39.1.windows.1 > > > > ------------ > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#104480): https://edk2.groups.io/g/devel/message/10448= 0 > Mute This Topic: https://groups.io/mt/98799622/1770412 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [mike.maslenkin@gmail.c= om] > ------------ > >