From nobody Fri Apr 26 21:21:25 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+104812+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+104812+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1683931450; cv=none; d=zohomail.com; s=zohoarc; b=HsPvjgPGfgPk81m+SS+LUiV8Wyo5Q4Z1bwn6WLam40+7vv2YhTXyrDxVjTO6sz6NngY80hNkNwvIQIONw8DWOCkgWJUvLpPHfvAAFoJ96sOnsUiq9OsPqcaHKFzOuXepjWGvzAXjGlszjcZGSTDsYeqbH3+5ue8WYg5bhUgmo4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683931450; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=vrfpz5ZjZzUAAeFpbbEUq6SSFHAm/A0J36nbjeB5Ovw=; b=OtQQXkK5W1ptlrvz2jbJgijwPo24TO/WRoiweHBcYyvvRxe9Sad1sNbtNV5Z3lqgZwLPpoWzfbkfrGxuP9ryK1AQ2K4WtIhcgfQF8K/10PqLCp5HifTJw1SwW+ne5Ex8KSvu1nyHJFtQ7u+nBB3soERM4AcYo6MBtguQhc5Vin4= 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+104812+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1683931450550827.553233787021; Fri, 12 May 2023 15:44:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id o8LAYY1788612x6G7owRhOuB; Fri, 12 May 2023 15:44:10 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.37620.1683931449482021138 for ; Fri, 12 May 2023 15:44:09 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349738224" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349738224" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 15:44:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="789980283" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="789980283" X-Received: from gdong1-mobl.amr.corp.intel.com ([10.213.179.211]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 15:44:08 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [edk2-devel][PATCH V2] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload Date: Fri, 12 May 2023 15:44:01 -0700 Message-Id: <20230512224401.793-1-guo.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,guo.dong@intel.com X-Gm-Message-State: LMgSZ7T3RI3ZpSwbDWDb2lD7x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1683931450; bh=piHfEsfARrG01GtKWfVNLMRLpTNhK4dV2YbM9lbQjmA=; h=Cc:Date:From:Reply-To:Subject:To; b=A6KNR2e3GQZJnJqE0mnJLw5Og68lkxr//bZlJsDudfspznGdUyfhYBx+5NRiKaiwM1Q RMLhfOaOB/7VFnErM6uiB1mhp7gBPlznNKXEs1x4L5FOFyRMnYUMN9OSmXW/lTUKLYklV QMrChRPVROvL5nkIVUEy/a2QBkk8IcJgBkI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1683931451873100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: James Lu Reviewed-by: Gua Guo --- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c |= 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++------- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |= 5 +++-- UefiPayloadPkg/UefiPayloadPkg.dec |= 3 --- 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= ger.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 62637ae6aa..1660d6c330 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. =20 -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 =20 **/ @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatformConsole.h" #include #include +#include =20 /** Signal EndOfDxe event and install SMM Ready to lock protocol. @@ -89,6 +90,77 @@ PlatformFindLoadOption ( return -1; } =20 +/** + Get the FV device path for the shell file. + + @return A pointer to device path structure. +**/ +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; + EFI_FV_FILETYPE FoundType; + EFI_FV_FILE_ATTRIBUTES FileAttributes; + + Status =3D EFI_SUCCESS; + gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiFirmwareVolume2ProtocolGuid, + NULL, + &FvHandleCount, + &FvHandleBuffer + ); + + for (Index =3D 0; Index < FvHandleCount; Index++) { + Size =3D 0; + gBS->HandleProtocol ( + FvHandleBuffer[Index], + &gEfiFirmwareVolume2ProtocolGuid, + (VOID **)&Fv + ); + Status =3D Fv->ReadFile ( + Fv, + &gUefiShellFileGuid, + NULL, + &Size, + &FoundType, + &FileAttributes, + &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. =20 @@ -109,15 +181,11 @@ 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; =20 - Status =3D gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGu= id, (VOID **)&LoadedImage); - ASSERT_EFI_ERROR (Status); - EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); DevicePath =3D AppendDevicePathNode ( - DevicePathFromHandle (LoadedImage->DeviceHandle), + BdsGetShellFvDevicePath (), (EFI_DEVICE_PATH_PROTOCOL *)&FileNode ); =20 @@ -248,7 +316,7 @@ PlatformBootManagerAfterConsole ( // // Register UEFI Shell // - PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", L= OAD_OPTION_ACTIVE); + PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_O= PTION_ACTIVE); =20 if (FixedPcdGetBool (PcdBootManagerEscape)) { Print ( diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index f9626175e2..a3951b7a7e 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= 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 =20 [LibraryClasses] BaseLib @@ -52,6 +53,7 @@ [Guids] gEfiEndOfDxeEventGroupGuid gEdkiiBootManagerMenuFileGuid + gUefiShellFileGuid =20 [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/UefiPayload= Pkg.dec index a23a7b5a78..8d111f3a90 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -67,9 +67,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize|0|UINT3= 2|0x10000002 ## Save bootloader parameter gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004 =20 -## FFS filename to find the shell application. -gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E,= 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }|VOID*|0= x10000005 - ## Used to help reduce fragmentation in the EFI memory map gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x19|UINT3= 2|0x10000012 gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x= 10000013 --=20 2.39.1.windows.1 -=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 (#104812): https://edk2.groups.io/g/devel/message/104812 Mute This Topic: https://groups.io/mt/98859456/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-