From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mx.groups.io with SMTP id smtpd.web12.8217.1612447568888733586 for ; Thu, 04 Feb 2021 06:06:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=oO5T+j3K; spf=pass (domain: nuviainc.com, ip: 209.85.216.42, mailfrom: leif@nuviainc.com) Received: by mail-pj1-f42.google.com with SMTP id z9so1851453pjl.5 for ; Thu, 04 Feb 2021 06:06:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z3avZnnTDCcAZ2vcium9yNIMiA92ETvdoIuarF6ghQw=; b=oO5T+j3KuCgS2Qk4Jylwatml2VXJa+nIUq9FwTc3tTXcVzEyEPPYSxDGxleMnk6GvG YFhwWYnVlwjngo2z0qo2uP3OvwMleIxu0ID7cMrlwtrpljnBr2BHC9+W/dRCaAe8CQOs 9V8RBTG8yUkiM83pnlkhmuVXGz3jCVvTgFGFp6A51EFtzwi7+Mw/AyOuxmVHfpvUd1Xz +3jzey6U90kySVYmPafOKbyuB5nwerUQSY4XDiHlunMhzXHRt3Py0a2eYDIl0pZi0P7W 4SIChqO5I264R+hDt8+7Usicyyx8bYGT4mysxmtmlzmwNQyWtuC0hf3HnqToUHKjbsK2 C8fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z3avZnnTDCcAZ2vcium9yNIMiA92ETvdoIuarF6ghQw=; b=nxnaE7zmMRoOTzWBC6a+j9pq+KlazInSqA7wtSXZuskw7AGUPh0p3wg8eE9xvZO7NC 5mBAr7BmPFrJVGas4wTD7Hkz7oZ1+LPzlch+Ja+8ML/pbvBO3tk7uBJBxq3yUzJjWPxh ZFEPHGdHyl/nQFTyiP4ikCWxHFAYQtWmKztVPU9cxCJVtGnvZbFyq7JzOStYmZpqYzhN RwE2MIy2loSci6rcEWbT+580yhw69MeiooIUvNi4MCsQycO7FHuPkrqUwVmNXqppIVif PxhbZ/2lYbm4h/EewPHEKmFxf/yQqaAo4G5NePeHOdLCC8y81b2Au/BBUAW3C+R1I2XO ZJ8Q== X-Gm-Message-State: AOAM530AEMrsahjh7wLnnIlG7eDImDMEyh9bYYje5Fd+j/B3P/E6nDVk noKHB3Qgzjbjm9/ArKPXLHhXhuEvA7QCnUSL33JG66HiPc9+MaiJ7QqXK3dDIVetjAl8I3ERQCF PPVUDx9GJw2MDRJn7RUKWnmZwVU0V3BftCp+iZCEXjPRzGw9s8mZ84lWN5pMfqqpijg== X-Google-Smtp-Source: ABdhPJyMwwP/NDmj6sz3nOFk0F5r0BpkZZ89A4R7Ga/UOJd5oSrSTZhRXHORyTtl9RqzNtk17Ndt9A== X-Received: by 2002:a17:90a:6288:: with SMTP id d8mr8699944pjj.49.1612447567985; Thu, 04 Feb 2021 06:06:07 -0800 (PST) Return-Path: Received: from leonardo.ba.nuviainc.com (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id c15sm815782pjc.9.2021.02.04.06.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:06:07 -0800 (PST) From: "Leif Lindholm" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Laszlo Ersek Subject: [PATCH v2 1/1] ArmPkg/Library: prevent endless reboot loop with emulated NV varstore Date: Thu, 4 Feb 2021 14:06:01 +0000 Message-Id: <20210204140601.9215-1-leif@nuviainc.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Laszlo Ersek Signed-off-by: Leif Lindholm --- Changes in v2: - Fix indentation. - Add missing space in commit message. ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 + ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 2f726d117d7d..353d7a967b76 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -55,6 +55,7 @@ [FeaturePcd] gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport [FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index 9905cad22908..5ceb23d822e5 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -848,11 +848,15 @@ PlatformBootManagerUnableToBoot ( // 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. + // *Unless* persistent varstore is being emulated, since we would + // then end up in an endless reboot loop. // - if (NewBootOptionCount != OldBootOptionCount) { - DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n", - __FUNCTION__)); - gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + if (!PcdGetBool (PcdEmuVariableNvModeEnable)) { + if (NewBootOptionCount != OldBootOptionCount) { + DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n", + __FUNCTION__)); + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + } } Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); -- 2.20.1