From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.61]) by mx.groups.io with SMTP id smtpd.web10.476.1592410906839707489 for ; Wed, 17 Jun 2020 09:21:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=jUiWFTld; spf=pass (domain: vmware.com, ip: 40.107.244.61, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BC5XvfPaLTrc1IrXVrdEICKsUjfrQGN3fxRG3D5kp8LcY+UNDS0q8m2UqzgmBF7RJgfmfTTNTKqVyzxyX7OUg9gzXvphCgH1UnwOFE/aZAoJfyO8DK8UHSjyC3amnnR/+MoACtS7dP5oNL7dfsArDjRBoAsLHWgM+OSj/SBBbq5fJeleYuuUKploAsRS1hIs1BY2Wjmbk/RCoB5S0jDJJ1fg6kMwybwMre30uPIAUclBh53kbXLmHUsVnocWPZh+Kz1nlIAtPEYzAFJY/8Tl1gSJXs8IgFG3GVyNRyRvyoyZQdCtlMmiPKyZ1iZiiA+q4M+aaF7yqslIzUDH1Pjjrg== 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=lhLlYcwHcXPPn6VlT42kU4Xt8jkPrZ8+zrWRgePJfYw=; b=hC5ifDwC77RfQsGOAh8mIaQVCFOb2FDJHldAwLHa2NamnFk1MQ869ZWRMlKhRDB8qSGoRU4ImXB2ez/w9Xoo4lO3uYzGNRcxRAivDAgSSI/pJ3IiJSA1gnhdMXmd6W+soUlyMQBeqVA42X9r6CP9kHciPhelrCckTNTiHlGzgWq5CxcQV+G5P97RhoGFoREvffZmJmWa0QK1DDuMpcC/6I106aE55rNoxsbUhHWda2pSiTnACshQc+WgejY6ruKPiATh6KocYrU3peEzKdKUfyMfQmDb02kvtRRO3lj4foNnVx7X1ptMI+F8GKF74vH6Wg/7NmaUQblgKY9+Ol3wXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lhLlYcwHcXPPn6VlT42kU4Xt8jkPrZ8+zrWRgePJfYw=; b=jUiWFTldH+/1MxFt02521Hr+rAyVwesk4M+2xoi4Wjs9XPxgqtYUypV1NPjLDBuXaImJCcZw9GwvoEh3uthsYNdx0uRR4KdaGvj/ZZMsBiLRSQjmBuDD6KpY7b8ZE85ONVT92JLsJSthXLWcZXuw5AKph6lTQrmfXpKjgkuFTls= Received: from BN6PR05MB3411.namprd05.prod.outlook.com (2603:10b6:405:43::23) by BN7PR05MB4193.namprd05.prod.outlook.com (2603:10b6:406:86::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.10; Wed, 17 Jun 2020 16:21:44 +0000 Received: from BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::e1ef:31eb:c802:aef0]) by BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::e1ef:31eb:c802:aef0%3]) with mapi id 15.20.3109.018; Wed, 17 Jun 2020 16:21:44 +0000 From: "Andrei Warkentin" To: Ard Biesheuvel , "devel@edk2.groups.io" CC: "leif@nuviainc.com" , Pete Batard , Samer El-Haj-Mahmoud Subject: Re: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure Thread-Topic: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure Thread-Index: AQHWRAZ3SzRaX+G/eUytwcZOteMDHKjc/oQy Date: Wed, 17 Jun 2020 16:21:44 +0000 Message-ID: References: <20200616174834.1110310-1-ard.biesheuvel@arm.com> In-Reply-To: <20200616174834.1110310-1-ard.biesheuvel@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-originating-ip: [98.214.99.181] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 75162328-359c-467e-ebb0-08d812da868a x-ms-traffictypediagnostic: BN7PR05MB4193: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 04371797A5 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6y55rlMZgWH5dUJRYJrhNZV+F3Va/MjnY5s+4rCQKWWNKk51xbDscvfm863MTPGqw7AxdwT+3pOP2VPxUG8lBsE+XFygJhUBOWiCklZQFi+EiWH3dP7+5h+VU3+nhUBngiK4qFIVqiYvrmumc1jpBUc7WIR+q3CUnJMFDut18eVe2XAIQrQ56rtGC2gx4RfAGmv9/ZViWdUDcMKekFPL6nEdA8R/xl2HCj2JyitwKRNxzEjpKzEtan2IW7HpFHfS0XSdWfdYuSbB0+LwnTd//HOpECmwbaFgPe1RpuVnoiGlLjTqAvSDX++bRbeKubhNUONPtE3BgZNj8NdrLrT21g== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR05MB3411.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(366004)(346002)(39860400002)(136003)(396003)(19627405001)(5660300002)(316002)(86362001)(52536014)(55016002)(54906003)(9686003)(110136005)(33656002)(4326008)(186003)(71200400001)(26005)(76116006)(66446008)(66946007)(8676002)(8936002)(64756008)(478600001)(6506007)(53546011)(7696005)(66476007)(66556008)(83380400001)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: SQyA2bIsmxbWZVze4La7WpsO4Ibn1ERrmnvxMdtXgzrb2CbvM1IEQzoarUyZ9cQBtOvZKwdbM5YbdjJZFdetmIwcbPKmwe1d9e11g76V7pm+UcS1Q6L0O4ToEdAUks/06Rtsy6UyRHWNWhXyMpfhAjkFvx74Wotu/c6oBSefUXEL0OO98r5CZk816Ft5OCWx1gEb/KcRPolaAFFDfWwoxCDKxHl9c8JAHOG3BKV9SGZ8mQcWPO7U2au9kz8x2575w7G1N0FwuX3bLqODtDc8GIfWK61wF9ajMWuUVw3yhDN5CxDHi4EBIwwcwAIwhH9UzuGNaOeW7RsvM0P9MgQtQXRyvl0VNJ+1rxSKTSYWtX6roHcKwoROeZylxiMoelUWeRpHaP23/DqH9ynCNsrjc4VgZc5kRMPcGA3WEz4EQjyk/XUI6OKFvksq4ajK3huWfPm6kXTDhaZpOy3rne99R5w6ej8ZafyfaL1y9eB76YP54UvQVrDxBEH4BGxXCDWu x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN6PR05MB3411.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75162328-359c-467e-ebb0-08d812da868a X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2020 16:21:44.1737 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0rIYk4CvzNykCb02uEoIua8Q2PsVLC61w3kPrJ/KHZGp33s7icwWhANE2jSixB6LDJ68IBCvnjXoMTvbMnsjPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR05MB4193 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BN6PR05MB341182593343D1D0E7D62971B99A0BN6PR05MB3411namp_" --_000_BN6PR05MB341182593343D1D0E7D62971B99A0BN6PR05MB3411namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for working on this. Reviewed-by: Andrei Warkentin A non-blocking question: is a reboot necessary? Would it be possible to jus= t retry the boot sequence? A ________________________________ From: Ard Biesheuvel Sent: Tuesday, June 16, 2020 12:48 PM To: devel@edk2.groups.io Cc: leif@nuviainc.com ; Ard Biesheuvel ; Pete Batard ; Andrei Warkentin ; Samer El-Haj-Mahmoud Subject: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on = boot failure One of the side effects of the recent changes to PlatformBootManagerLib changes to avoid connecting all devices on every boot is that we no longer default to network boot on a virgin boot, but end up in the UiApp menu. At this point, the autogenerated boot options that we used to rely on will be instantiated too, but it does break the unattended boot case where devices are expected to attempt a network boot on the very first power on. Let's work around this by refreshing all boot options explicitly in the UnableToBoot() handler, and rebooting the system if doing so resulted in a change to the total number of configured boot options. This way, we ultimately end up in the UiApp as before if no boot options could be started, but only after all the autogenerated ones have been attempted as well. Cc: Pete Batard Cc: Andrei Warkentin (awarkentin@vmware.com) Cc: Samer El-Haj-Mahmoud Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 34 ++++++++++++++++++= ++ 1 file changed, 34 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index 15c5cac1bea0..9905cad22908 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -820,6 +820,40 @@ PlatformBootManagerUnableToBoot ( { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + UINTN OldBootOptionCount; + UINTN NewBootOptionCount; + + // + // Record the total number of boot configured boot options + // + BootOptions =3D EfiBootManagerGetLoadOptions (&OldBootOptionCount, + LoadOptionTypeBoot); + EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount); + + // + // Connect all devices, and regenerate all boot options + // + EfiBootManagerConnectAll (); + EfiBootManagerRefreshAllBootOption (); + + // + // Record the updated number of boot configured boot options + // + BootOptions =3D EfiBootManagerGetLoadOptions (&NewBootOptionCount, + LoadOptionTypeBoot); + EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount); + + // + // If the number of configured boot options has changed, reboot + // the system so the new boot options will be taken into account + // while executing the ordinary BDS bootflow sequence. + // + if (NewBootOptionCount !=3D OldBootOptionCount) { + DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n= ", + __FUNCTION__)); + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + } Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerMenu); if (EFI_ERROR (Status)) { -- 2.27.0 --_000_BN6PR05MB341182593343D1D0E7D62971B99A0BN6PR05MB3411namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Thanks for working on this.

Reviewed-by: Andrei Warken= tin <awarkentin@vmware.com>

A non-blocking question: i= s a reboot necessary? Would it be possible to just retry the boot sequence?=

A

From: Ard Biesheuvel <ar= d.biesheuvel@arm.com>
Sent: Tuesday, June 16, 2020 12:48 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: leif@nuviainc.com <leif@nuviainc.com>; Ard Biesheuvel <= ard.biesheuvel@arm.com>; Pete Batard <pete@akeo.ie>; Andrei Warken= tin <awarkentin@vmware.com>; Samer El-Haj-Mahmoud <Samer.El-Haj-Ma= hmoud@arm.com>
Subject: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot opti= ons on boot failure
 
One of the side effects of the recent changes to P= latformBootManagerLib
changes to avoid connecting all devices on every boot is that we no
longer default to network boot on a virgin boot, but end up in the
UiApp menu. At this point, the autogenerated boot options that we used
to rely on will be instantiated too, but it does break the unattended
boot case where devices are expected to attempt a network boot on the
very first power on.

Let's work around this by refreshing all boot options explicitly in
the UnableToBoot() handler, and rebooting the system if doing so
resulted in a change to the total number of configured boot options.
This way, we ultimately end up in the UiApp as before if no boot
options could be started, but only after all the autogenerated ones
have been attempted as well.


Cc: Pete Batard <pete@akeo.ie>

Cc: Andrei Warkentin (awarkentin@vmware.com) <awarkentin@vmware.com><= br>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 34 ++= 3;++++++++++++++= 3;++
 1 file changed, 34 insertions(+)

diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c
index 15c5cac1bea0..9905cad22908 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -820,6 +820,40 @@ PlatformBootManagerUnableToBoot (
 {

   EFI_STATUS        &nbs= p;          Status;

   EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;

+  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;

+  UINTN         &nbs= p;            &= nbsp; OldBootOptionCount;

+  UINTN         &nbs= p;            &= nbsp; NewBootOptionCount;

+

+  //

+  // Record the total number of boot configured boot options

+  //

+  BootOptions =3D EfiBootManagerGetLoadOptions (&OldBootOptio= nCount,

+           &nbs= p;      LoadOptionTypeBoot);

+  EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount)= ;

+

+  //

+  // Connect all devices, and regenerate all boot options

+  //

+  EfiBootManagerConnectAll ();

+  EfiBootManagerRefreshAllBootOption ();

+

+  //

+  // Record the updated number of boot configured boot options
+  //

+  BootOptions =3D EfiBootManagerGetLoadOptions (&NewBootOptio= nCount,

+           &nbs= p;      LoadOptionTypeBoot);

+  EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount)= ;

+

+  //

+  // If the number of configured boot options has changed, reboot=

+  // the system so the new boot options will be taken into accoun= t

+  // while executing the ordinary BDS bootflow sequence.

+  //

+  if (NewBootOptionCount !=3D OldBootOptionCount) {

+    DEBUG ((DEBUG_WARN, "%a: rebooting after refre= shing all boot options\n",

+      __FUNCTION__));

+    gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, = NULL);

+  }

 

   Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerM= enu);

   if (EFI_ERROR (Status)) {

--
2.27.0

--_000_BN6PR05MB341182593343D1D0E7D62971B99A0BN6PR05MB3411namp_--