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.web09.8404.1612448240252887173 for ; Thu, 04 Feb 2021 06:17:21 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gvONvio0; 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=1612448239; 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=VJgeOKowumr3koFu1p9e1P4S2in8v15xXqB8B17BPxg=; b=gvONvio0YbJU1TfoRE78OwFTNvblZ3NSUXZCg/v+U8xUwGlFj++0ouoJOwzPYXBe/Jj4PU xcW39IAQzNj274DJ3dtsmqoKJUNW3xBW2AGMa7QNMWdSdCUNYIpA7Ty5ZWl1VlEU6Jdgbq 6rq6d+8j6Wc0pMHFOQTiQ5yPoR28HG8= 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-500-a5L_3xWiOW2bGHLDP3Wgxw-1; Thu, 04 Feb 2021 09:17:15 -0500 X-MC-Unique: a5L_3xWiOW2bGHLDP3Wgxw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45506107ACF9; Thu, 4 Feb 2021 14:17:14 +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 6A4245B69C; Thu, 4 Feb 2021 14:17:13 +0000 (UTC) Subject: Re: [PATCH v2 1/1] ArmPkg/Library: prevent endless reboot loop with emulated NV varstore To: Leif Lindholm , devel@edk2.groups.io Cc: Ard Biesheuvel References: <20210204140601.9215-1-leif@nuviainc.com> From: "Laszlo Ersek" Message-ID: <2f86afc5-eecb-8c63-2c40-01e380ab301f@redhat.com> Date: Thu, 4 Feb 2021 15:17:12 +0100 MIME-Version: 1.0 In-Reply-To: <20210204140601.9215-1-leif@nuviainc.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 15:06, 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 > 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); > At the level where I commented on v1 -- i.e., totally superficially --: Acked-by: Laszlo Ersek Ard should please review this patch for the logic change. Laszlo