From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1974.1592417930247497195 for ; Wed, 17 Jun 2020 11:18:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 042311042; Wed, 17 Jun 2020 11:18:49 -0700 (PDT) Received: from [192.168.1.69] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 172453F71F; Wed, 17 Jun 2020 11:18:47 -0700 (PDT) Subject: Re: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure To: Andrei Warkentin , "devel@edk2.groups.io" Cc: "leif@nuviainc.com" , Pete Batard , Samer El-Haj-Mahmoud References: <20200616174834.1110310-1-ard.biesheuvel@arm.com> From: "Ard Biesheuvel" Message-ID: <3f95a537-f312-e1fa-7bb7-cdf1e40c0e13@arm.com> Date: Wed, 17 Jun 2020 20:18:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/17/20 6:21 PM, Andrei Warkentin wrote: > Thanks for working on this. >=20 > Reviewed-by: Andrei Warkentin >=20 Thanks. > A non-blocking question: is a reboot necessary? Would it be possible to= =20 > just retry the boot sequence? >=20 Not sure how we'd do that. > A > -----------------------------------------------------------------------= - > *From:* Ard Biesheuvel > *Sent:* Tuesday, June 16, 2020 12:48 PM > *To:* devel@edk2.groups.io > *Cc:* leif@nuviainc.com ; Ard Biesheuvel=20 > ; Pete Batard ; Andrei Warkentin=20 > ; Samer El-Haj-Mahmoud > *Subject:* [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot=20 > 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. >=20 > 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. >=20 >=20 > Cc: Pete Batard >=20 > Cc: Andrei Warkentin (awarkentin@vmware.com) >=20 > Cc: Samer El-Haj-Mahmoud >=20 > Signed-off-by: Ard Biesheuvel > --- > =A0ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 34=20 > ++++++++++++++++++++ > =A01 file changed, 34 insertions(+) >=20 > diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c=20 > b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c > index 15c5cac1bea0..9905cad22908 100644 > --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c > +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c > @@ -820,6 +820,40 @@ PlatformBootManagerUnableToBoot ( > =A0{ >=20 > =A0=A0 EFI_STATUS=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= Status; >=20 > =A0=A0 EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; >=20 > +=A0 EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; >=20 > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 OldBootOptionCount; >=20 > +=A0 UINTN=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 NewBootOptionCount; >=20 > + >=20 > +=A0 // >=20 > +=A0 // Record the total number of boot configured boot options >=20 > +=A0 // >=20 > +=A0 BootOptions =3D EfiBootManagerGetLoadOptions (&OldBootOptionCount, >=20 > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 LoadOptionTypeBoot= ); >=20 > +=A0 EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount); >=20 > + >=20 > +=A0 // >=20 > +=A0 // Connect all devices, and regenerate all boot options >=20 > +=A0 // >=20 > +=A0 EfiBootManagerConnectAll (); >=20 > +=A0 EfiBootManagerRefreshAllBootOption (); >=20 > + >=20 > +=A0 // >=20 > +=A0 // Record the updated number of boot configured boot options >=20 > +=A0 // >=20 > +=A0 BootOptions =3D EfiBootManagerGetLoadOptions (&NewBootOptionCount, >=20 > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 LoadOptionTypeBoot= ); >=20 > +=A0 EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount); >=20 > + >=20 > +=A0 // >=20 > +=A0 // If the number of configured boot options has changed, reboot >=20 > +=A0 // the system so the new boot options will be taken into account >=20 > +=A0 // while executing the ordinary BDS bootflow sequence. >=20 > +=A0 // >=20 > +=A0 if (NewBootOptionCount !=3D OldBootOptionCount) { >=20 > +=A0=A0=A0 DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot= =20 > options\n", >=20 > +=A0=A0=A0=A0=A0 __FUNCTION__)); >=20 > +=A0=A0=A0 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); >=20 > +=A0 } >=20 >=20 >=20 > =A0=A0 Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerMenu); >=20 > =A0=A0 if (EFI_ERROR (Status)) { >=20 > --=20 > 2.27.0 >=20