]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Tue, 16 Jun 2020 17:35:24 +0000 (19:35 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 17 Jun 2020 18:28:29 +0000 (18:28 +0000)
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 UiApp will instantiate the autogenerated
boot options that we used to rely on as before, but since we are already
sitting idle in the root UiApp menu at that point, 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.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c

index 15c5cac1bea05feb7a5c44cbe948cc94e73f3dfa..9905cad22908fb5ee6507b5d12dd41bbd6d104b8 100644 (file)
@@ -820,6 +820,40 @@ PlatformBootManagerUnableToBoot (
 {\r
   EFI_STATUS                   Status;\r
   EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
+  UINTN                        OldBootOptionCount;\r
+  UINTN                        NewBootOptionCount;\r
+\r
+  //\r
+  // Record the total number of boot configured boot options\r
+  //\r
+  BootOptions = EfiBootManagerGetLoadOptions (&OldBootOptionCount,\r
+                  LoadOptionTypeBoot);\r
+  EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount);\r
+\r
+  //\r
+  // Connect all devices, and regenerate all boot options\r
+  //\r
+  EfiBootManagerConnectAll ();\r
+  EfiBootManagerRefreshAllBootOption ();\r
+\r
+  //\r
+  // Record the updated number of boot configured boot options\r
+  //\r
+  BootOptions = EfiBootManagerGetLoadOptions (&NewBootOptionCount,\r
+                  LoadOptionTypeBoot);\r
+  EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount);\r
+\r
+  //\r
+  // If the number of configured boot options has changed, reboot\r
+  // the system so the new boot options will be taken into account\r
+  // while executing the ordinary BDS bootflow sequence.\r
+  //\r
+  if (NewBootOptionCount != OldBootOptionCount) {\r
+    DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n",\r
+      __FUNCTION__));\r
+    gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+  }\r
 \r
   Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);\r
   if (EFI_ERROR (Status)) {\r