From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web12.7472.1612443967597476307 for ; Thu, 04 Feb 2021 05:06:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PcUYe3ZB; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612443966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tOsYYNJ2msjeT+yrTQTM5UQ84ZKFK2EpfJcekRClWOc=; b=PcUYe3ZBd+BBBz14naTzugz9ppmkDPZVBaCPJZZomuPfZwYq2nuDvFYr8DskcLKRTtMSMf HZlA2xpwK+qtvZkDuJx2nGAv+lYu00sZSdFQWDIJAfKcXZ7vW68FHWN1XvvBZtFbYU4v78 2BiLFL/IIJLAd1WoWlYOxlp5eTe3sM8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-Y2hfdbGlM12Mi7JeyOGJvQ-1; Thu, 04 Feb 2021 08:06:04 -0500 X-MC-Unique: Y2hfdbGlM12Mi7JeyOGJvQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DB9C18CAE03; Thu, 4 Feb 2021 13:06:03 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-169.ams2.redhat.com [10.36.114.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53BE35D9C9; Thu, 4 Feb 2021 13:06:02 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/1] ArmPkg/Library: prevent endless reboot loop with emulated NV varstore To: devel@edk2.groups.io, leif@nuviainc.com Cc: Ard Biesheuvel References: <20210204125427.1157-1-leif@nuviainc.com> From: "Laszlo Ersek" Message-ID: <96817af4-5196-064b-2d71-6ca685d0a573@redhat.com> Date: Thu, 4 Feb 2021 14:06:01 +0100 MIME-Version: 1.0 In-Reply-To: <20210204125427.1157-1-leif@nuviainc.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 02/04/21 13:54, Leif Lindholm wrote: > 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 > Signed-off-by: Leif Lindholm > --- > .../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..9564ab817f4c 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__)); Incorrect indentation :P Laszlo > + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); > + } > } > > Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); >