]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/Library: prevent endless reboot loop with emulated NV varstore
authorLeif Lindholm <leif@nuviainc.com>
Thu, 4 Feb 2021 12:36:59 +0000 (12:36 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 4 Feb 2021 16:11:23 +0000 (16:11 +0000)
If no valid boot options were found, PlatformBootManagerLib refreshes a
set of sane default options and then reboots. However, if there is in
fact no persistent varstore, the same thing happens again on next boot,
and we end up in an endlessly rebooting loop.

So when PcdEmuVariableNvModeEnable is TRUE, skip the reboot step and
enter the setup menu instead.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

index 9905cad22908fb5ee6507b5d12dd41bbd6d104b8..5ceb23d822e5d121158d87d437253559ef8d7eab 100644 (file)
@@ -848,11 +848,15 @@ PlatformBootManagerUnableToBoot (
   // 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
+  // *Unless* persistent varstore is being emulated, since we would\r
+  // then end up in an endless reboot loop.\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
+  if (!PcdGetBool (PcdEmuVariableNvModeEnable)) {\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
 \r
   Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);\r
index 2f726d117d7dfb90b0c6f1e71d6b31f4d1bd02dc..353d7a967b7687a1440fcb34f17b06bd4d71ffa8 100644 (file)
@@ -55,6 +55,7 @@
   gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
 \r
 [FixedPcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate\r
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits\r