From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.1353.1571129606997129310 for ; Tue, 15 Oct 2019 01:53:27 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0191c146fb=sunnywang@hpe.com) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9F8pMYN008824 for ; Tue, 15 Oct 2019 08:53:26 GMT Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0b-002e3701.pphosted.com with ESMTP id 2vmmtw2hkx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 15 Oct 2019 08:53:26 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5009.houston.hpe.com (Postfix) with ESMTPS id 674F26B for ; Tue, 15 Oct 2019 08:53:25 +0000 (UTC) Received: from G4W9335.americas.hpqcorp.net (16.208.33.85) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 08:53:18 +0000 Received: from G1W8106.americas.hpqcorp.net (16.193.72.61) by G4W9335.americas.hpqcorp.net (16.208.33.85) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 15 Oct 2019 08:53:17 +0000 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (15.241.52.12) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Tue, 15 Oct 2019 08:53:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZqAAcj7pl72KG5IJWtvCj2VrIc/zslgDV5ag8FJFQX/b11XYXWW+kBJVVYDodCfxW87BmcaBRX3zjr4rkXpRaaesVDL7gdLMF8CVDa0aebLvic7HYDPZ+uZmgDvo3sHgJvSfYUBrGXrBgyi9xmSb4EK7iKjUfdRSp8mHmfP91r5RFdXkEf4wzn96AOm0gHXntQ63ykCQO5xVq4Wgkmaj7nAH93dfrqRz8hRsRmC/LjF6DK6c46JbG0o0EIVlTawFQaadFa5P8MiMiY2f/4yJvWpbXyzXAc5TP8GRULei4UfxFxeoa046KqLiy20mObOE4aM/5CgW39R4ETHTj0bVQ== 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=a/BZMclVuoh1inykU5z0wYq46foDpJi68l4o0xE3C4E=; b=NfSXEJjKu3CH/WjlF3ox9vt6FAeWGAdPTzQil8Y8tiDNm+wv+AGWW4h3pmGaMFBlMhEmNCXNz/gs3hLKZc9TFuctJ62alpq/aPRh4uOUng4K57oXzMsKnB34L4ruu0J6PNVVTumHfNhs51K5u8C3d8uwaYqnvu9M0kbWZMB6thq37B61ESOt9+IaObnKVsz+M5ncgBcwFk32hv+rGdKRB7v/3nzuicY+U49+ygli5thKfceqszZi9ZChl5mhptQGoGctWbpcn1A+uJkps+4lHFRHmm9MkUtqy9uxfunwCJc9M2ih2dibWPskn+UjwOwmWjOcdzIKx6izv8yWEmIj7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from DF4PR8401MB0969.NAMPRD84.PROD.OUTLOOK.COM (10.169.87.143) by DF4PR8401MB0764.NAMPRD84.PROD.OUTLOOK.COM (10.169.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.18; Tue, 15 Oct 2019 08:53:15 +0000 Received: from DF4PR8401MB0969.NAMPRD84.PROD.OUTLOOK.COM ([fe80::d1ca:f8fb:45e:4c30]) by DF4PR8401MB0969.NAMPRD84.PROD.OUTLOOK.COM ([fe80::d1ca:f8fb:45e:4c30%12]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 08:53:15 +0000 From: "Wang, Sunny (HPS SW)" To: "devel@edk2.groups.io" , "zhichao.gao@intel.com" , Ray Ni CC: Jian J Wang , Hao Wu , "Star Zeng" , Liming Gao , Sean Brogan , Michael Turner , Bret Barkelew , "Li, Walon" , "Wei, Kent (HPS SW)" , "Wang, Sunny (HPS SW)" Subject: Use a pcd to control PlatformRecovery Thread-Topic: Use a pcd to control PlatformRecovery Thread-Index: AdWDK94yxgzpZjqYRC+1b6PvmRyefQ== Date: Tue, 15 Oct 2019 08:53:15 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.242.247.139] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8b07cc08-b0c1-44eb-1290-08d7514d1e08 x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: DF4PR8401MB0764: x-ms-exchange-purlcount: 4 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:37; x-forefront-prvs: 01917B1794 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(136003)(396003)(39860400002)(376002)(189003)(199004)(13464003)(51444003)(76116006)(33656002)(66476007)(66446008)(66556008)(14444005)(256004)(26005)(186003)(66946007)(64756008)(2906002)(6436002)(8676002)(81166006)(7696005)(53546011)(6506007)(102836004)(81156014)(316002)(99286004)(110136005)(54906003)(2501003)(86362001)(476003)(4326008)(74316002)(25786009)(305945005)(7736002)(486006)(66066001)(6306002)(9686003)(7416002)(55016002)(8936002)(71190400001)(71200400001)(52536014)(478600001)(5660300002)(30864003)(6116002)(14454004)(966005)(3846002);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR8401MB0764;H:DF4PR8401MB0969.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2e+00U2GJLnTZQd7u2kf9di5cXGJ0i0tT/dDXYXcuMuFkLwYEvWTndFnpC1hvusH3qFouOOL4hgailV1P9zD3P7jVo/Lf0vJiEHia0wlEJsjUV77b1op3C/GkFe81RP3WfrY2OVq2poL5iyvhwWhC700XvYwVGyxUAhYa91rTlr1tHWgHNoGM/9OujgvADeOgMAXZlFT6i0yvAABIV4laVKR3KRNVQJSn8L9cfce5eBIwYgcoxcqoQ6lwEltqTAqbD23esNRZfGicrAXCsSKdCIFJWURm5XiRicPbTCZPF9DGn/BP7hBKt5OKbrojj/jQiXQohQAx88rwUs2mnt8O2NR3fAnEWdBisvDjTEbEMEQrPKb7uSAjsPQBQeEr0uutkj0oEcvIn9/2XQqFDk85v0XItbKyFF9l3DLTFGGxSDNAxBRQgaeA3ECCnzkqSg17i1zg3QX7WfwANo+nPyy8w== X-MS-Exchange-CrossTenant-Network-Message-Id: 8b07cc08-b0c1-44eb-1290-08d7514d1e08 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Oct 2019 08:53:15.3751 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0qWKaJ3ewZ9hjvrNr5jk+cNOVm9HYnfR9aQMu0BsfVipjK4VXMtEAgAYTj/RXP+eNrHr2eK8A1dS2jXdfYTAMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0764 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 4 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-15_04:2019-10-15,2019-10-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 mlxscore=0 clxscore=1011 suspectscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910150083 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Zhichao and Ray,=20 I have some questions about this code change. Sorry for being late to brin= g my questions here. For now, the code block for iterating the PlatformRecovery#### variables i= s controlled by OsIndications variable. However, it looks to me like that t= he PlatformRecovery#### should still be attempted for the case of that proc= essing of BootOrder does NOT result in success (according to section 3.4 in= UEFI 2.8). In other words, I think we should check PCD "PcdPlatformRecover= ySupport" instead of Local variable "PlatformRecovery" (from OsIndications = variable) like the code below. What do you guys think? If you need a meetin= g or short talk to discuss this, feel free to let me know.=20 if (!BootSuccess) { - if (PlatformRecovery) { + if (PcdGetBool (PcdPlatformRecoverySupport)) { LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, Load= OptionTypePlatformRecovery); ProcessLoadOptions (LoadOptions, LoadOptionCount); EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); } else { // // When platform recovery is not enabled, still boot to platform def= ault file path. // EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption); } =20 In addition, it looks like EDK2 don't have code to process OsRecovery#### = variables. Do we need to create a Bug on TianoCore Bugzilla system?=20 Moreover, I saw that both of you had a discussion about "Default PlatformR= ecovery", but I can't figure out the connection between the discussion and = the final code change. Isn't the "Default PlatformRecovery" part of the Pla= tform Recovery feature? At this moment, we don't have OS recovery support, = so I think that NO platform recovery support can be identified as NO boot o= ption recovery support. For this case, shouldn't we use PCD "PcdPlatformRec= overySupport" to control "Default PlatformRecovery" as well? For the next s= tep, I think we need to get further clarification from USWG to either not t= ie "Default Boot Behavior" with PlatformRecovery or update the description = to the following:=20 - If system firmware supports Platform recovery as described in Sectio= n 3.4.2, system firmware must include a PlatformRecovery#### variable speci= fying a short-form File Path Media Device Path.... Regards, Sunny Wang -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Gao,= Zhichao Sent: Thursday, June 20, 2019 11:44 AM To: devel@edk2.groups.io Cc: Jian J Wang ; Hao Wu ; Ray = Ni ; Star Zeng ; Liming Gao ; Sean Brogan ; Michael Turner ; Bret Barkelew Subject: [edk2-devel] [PATCH v5 2/2] MdeModulePkg/BdsDxe: Use a pcd to con= trol PlatformRecovery REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1678=20 Use the PcdPlatformRecoverySupport to control the function of platform rec= overy in BDS. First, set the variable's ("OsIndicationsSupported") EFI_OS_INDICATIONS_ST= ART_PLATFORM_RECOVERY bit base on the pcd. It would affect the variable "OsIndications". While the platform does not support the platform recovery, it is inappropr= iate to set a PlatformRecovery#### variable. So skip setting the variable. = But it should remain the behavior of booting from a default file path (such= as \EFI\BOOT\BOOTX64.EFI) to be compatible with the previous version UEFI = spec. Add memory check before build platform default boot option. If fail to all= ocate memory for the defualt boot file path, put the system into dead loop = to indicate it is unable to boot. 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(-) diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Unive= rsal/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 wil= l 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=20 +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/Unive= rsal/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 will = 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 @@ BdsFor= malizeOSIndicationVariable ( // Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerMenu); if (Status !=3D EFI_NOT_FOUND) { - OsIndicationSupport =3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_IND= ICATIONS_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 specify= ing - // a short-form File Path Media Device Path containing the platform def= ault - // 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 p= ath. 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, LoadOpt= ionTypePlatformRecovery); - if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionC= ount) =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=20 + specifying // a short-form File Path Media Device Path containing the= =20 + platform default // file path for removable media if the platform suppo= rts Platform Recovery. + // + if (PcdGetBool (PcdPlatformRecoverySupport)) { + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadO= ptionTypePlatformRecovery); + if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, LoadOpt= ions, 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 (&PlatformDefaultBoot= Option); + 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 @@ -10= 43,10 +1054,18 @@ BdsEntry ( } =20 if (!BootSuccess) { - LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadO= ptionTypePlatformRecovery); - ProcessLoadOptions (LoadOptions, LoadOptionCount); - EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); + if (PlatformRecovery) { + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, Loa= dOptionTypePlatformRecovery); + ProcessLoadOptions (LoadOptions, LoadOptionCount); + EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); + } else { + // + // When platform recovery is not enabled, still boot to platform de= fault file path. + // + EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption); + } } + EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption); =20 DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n")); PlatformBootManagerUnableToBoot (); -- 2.21.0.windows.1