From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Tue, 18 Jun 2019 22:06:12 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2019 22:06:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,391,1557212400"; d="scan'208";a="164921595" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 18 Jun 2019 22:06:11 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Jun 2019 22:06:11 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Jun 2019 22:06:10 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.225]) with mapi id 14.03.0439.000; Wed, 19 Jun 2019 13:06:09 +0800 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Gao, Zhichao" CC: "Wang, Jian J" , "Wu, Hao A" , "Zeng, Star" , "Gao, Liming" , Sean Brogan , Michael Turner , Bret Barkelew Subject: Re: [edk2-devel] [PATCH V4 2/2] MdeModulePkg/BdsDxe: Use a pcd to control PlatformRecovery Thread-Topic: [edk2-devel] [PATCH V4 2/2] MdeModulePkg/BdsDxe: Use a pcd to control PlatformRecovery Thread-Index: AQHVJkyVVIH/IwqPU0CwALOFLse7EqaibL5A Date: Wed, 19 Jun 2019 05:06:08 +0000 Deferred-Delivery: Wed, 19 Jun 2019 05:06:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C1D948E@SHSMSX104.ccr.corp.intel.com> References: <20190619031023.10820-1-zhichao.gao@intel.com> <20190619031023.10820-3-zhichao.gao@intel.com> In-Reply-To: <20190619031023.10820-3-zhichao.gao@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZmZmNDI0NjctZGFjYy00YmIxLWI4MDMtOWU4M2EyNDM3YzA4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicEw4R2hFcStaSDhHMVg0V3VleUQ4cU12ZUdqWDI2eDRlc25Ka0xEaXJramJJTjd1d2d0c0hyaytncld4ZHdmVCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Gao, Zhichao > Sent: Wednesday, June 19, 2019 11:10 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A = ; > Ni, Ray ; Zeng, Star ; Gao, Limin= g > ; Sean Brogan ; > Michael Turner ; Bret Barkelew > > Subject: [edk2-devel] [PATCH V4 2/2] MdeModulePkg/BdsDxe: Use a pcd to > control PlatformRecovery >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1678 >=20 > Use the PcdPlatformRecoverySupport to control the function of platform > recovery in BDS. > First, set the variable's ("OsIndicationsSupported") > EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY bit base on the pcd. > It would affect the variable "OsIndications". > While the platform does not support the platform recovery, it is > inappropriate to set a PlatformRecovery#### variable. So skip setting th= e > variable. But it should remain the behavior of booting from a default fi= le > path (such as \EFI\BOOT\BOOTX64.EFI) to be compatible with the previous > version UEFI spec. >=20 > Add memory check before build platform default boot option. If fail to > allocate memory for the defualt boot file path, put the system into dead > loop to indicate it is unable to boot. >=20 > Cc: Jian J Wang > Cc: Hao Wu > Cc: Ray Ni > Cc: Star Zeng > Cc: Liming Gao > Cc: Sean Brogan > Cc: Michael Turner > Cc: Bret Barkelew > Signed-off-by: Zhichao Gao > --- > MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +- > MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 71 +++++++++++++++--------- > 2 files changed, 47 insertions(+), 27 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf > b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf > index 6913389d34..7f94ca17df 100644 > --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf > +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf > @@ -5,7 +5,7 @@ > # gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore w= ill > invoke Entry # interface of protocol gEfiBdsArchProtocolGuid, then BDS > phase is entered. > # > -# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2008 - 2019, Intel Corporation. All rights > +reserved.
> # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -95,6 +95,7 @= @ > gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand > ## CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable #= # > SOMETIMES_CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed #= # > CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport > ## CONSUMES >=20 > [Depex] > TRUE > diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > index 9d312bd982..4f3168b62a 100644 > --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > @@ -5,7 +5,7 @@ > After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry wil= l be > invoked > to enter BDS phase. >=20 > -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -546,10 +546,14 @@ > BdsFormalizeOSIndicationVariable ( > // > Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerMenu); > if (Status !=3D EFI_NOT_FOUND) { > - OsIndicationSupport =3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI | > EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; > + OsIndicationSupport =3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI; > EfiBootManagerFreeLoadOption (&BootManagerMenu); > } else { > - OsIndicationSupport =3D > EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; > + OsIndicationSupport =3D 0; > + } > + > + if (PcdGetBool (PcdPlatformRecoverySupport)) { > + OsIndicationSupport |=3D > EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; > } >=20 > Status =3D gRT->SetVariable ( > @@ -662,6 +666,7 @@ BdsEntry ( > BOOLEAN BootSuccess; > EFI_DEVICE_PATH_PROTOCOL *FilePath; > EFI_STATUS BootManagerMenuStatus; > + EFI_BOOT_MANAGER_LOAD_OPTION PlatformDefaultBootOption; >=20 > HotkeyTriggered =3D NULL; > Status =3D EFI_SUCCESS; > @@ -763,14 +768,13 @@ BdsEntry ( > // > InitializeLanguage (TRUE); >=20 > - // > - // System firmware must include a PlatformRecovery#### variable > specifying > - // a short-form File Path Media Device Path containing the platform d= efault > - // file path for removable media > - // > FilePath =3D FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME); > + if (FilePath =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "Fail to allocate memory for defualt boot file > path. Unable to boot.\n")); > + CpuDeadLoop (); > + } > Status =3D EfiBootManagerInitializeLoadOption ( > - &LoadOption, > + &PlatformDefaultBootOption, > LoadOptionNumberUnassigned, > LoadOptionTypePlatformRecovery, > LOAD_OPTION_ACTIVE, > @@ -780,24 +784,31 @@ BdsEntry ( > 0 > ); > ASSERT_EFI_ERROR (Status); > - LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, > LoadOptionTypePlatformRecovery); > - if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, > LoadOptionCount) =3D=3D -1) { > - for (Index =3D 0; Index < LoadOptionCount; Index++) { > - // > - // The PlatformRecovery#### options are sorted by OptionNumber. > - // Find the the smallest unused number as the new OptionNumber. > - // > - if (LoadOptions[Index].OptionNumber !=3D Index) { > - break; > + > + // > + // System firmware must include a PlatformRecovery#### variable > + specifying // a short-form File Path Media Device Path containing the > + platform default // file path for removable media if the platform sup= ports > Platform Recovery. > + // > + if (PcdGetBool (PcdPlatformRecoverySupport)) { > + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, > LoadOptionTypePlatformRecovery); > + if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, > LoadOptions, LoadOptionCount) =3D=3D -1) { > + for (Index =3D 0; Index < LoadOptionCount; Index++) { > + // > + // The PlatformRecovery#### options are sorted by OptionNumber. > + // Find the the smallest unused number as the new OptionNumber. > + // > + if (LoadOptions[Index].OptionNumber !=3D Index) { > + break; > + } > } > + PlatformDefaultBootOption.OptionNumber =3D Index; > + Status =3D EfiBootManagerLoadOptionToVariable > (&PlatformDefaultBootOption); > + ASSERT_EFI_ERROR (Status); > } > - LoadOption.OptionNumber =3D Index; > - Status =3D EfiBootManagerLoadOptionToVariable (&LoadOption); > - ASSERT_EFI_ERROR (Status); > + EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); > } > - EfiBootManagerFreeLoadOption (&LoadOption); > FreePool (FilePath); > - EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); >=20 > // > // Report Status Code to indicate connecting drivers will happen @@ - > 1043,10 +1054,18 @@ BdsEntry ( > } >=20 > if (!BootSuccess) { > - LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, > LoadOptionTypePlatformRecovery); > - ProcessLoadOptions (LoadOptions, LoadOptionCount); > - EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); > + if (PlatformRecovery) { > + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, > LoadOptionTypePlatformRecovery); > + ProcessLoadOptions (LoadOptions, LoadOptionCount); > + EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); > + } else { > + // > + // When platform recovery is not enabled, still boot to platform = default > file path. > + // > + EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption); > + } > } > + EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption); >=20 > DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n")); > PlatformBootManagerUnableToBoot (); > -- > 2.21.0.windows.1 >=20 >=20 >=20