From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web08.8013.1612446628867585562 for ; Thu, 04 Feb 2021 05:50:29 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=QcNZTU7L; spf=pass (domain: nuviainc.com, ip: 209.85.128.44, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f44.google.com with SMTP id t142so1009570wmt.1 for ; Thu, 04 Feb 2021 05:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1sndgpyPB8pBNtTvOkNSvrClxoXvCW9e9eDwpQuuvJk=; b=QcNZTU7LNMekPMiG9FeuSsjMQ6dh2GEvZpUzqJ+c/rmpjHjH+u+rOxDUM16ePKGYut OUISDBwnpLrDzOl7oebwjvPm6DYbXG+UB7S/9D6xxPrz4GK4n40Nb3ttMiBH+9SLFavM IhokykCbF/43UX+Af4XY7mxSm50sKwjMTMitLJWBPWL2hdf/sYlvttf8TW2e1o8CpBG5 UxNRGK6WLo5I46P/3jkkXNz1F24taY0iqtNYDASBhcZ9TSNMmGzgI4nj7Z4R9UClxX6e QjQ6oqbweoK11XDQeQXsvIzWDEj/eMj42NtEO7U5OV9U1ngvjZQzTGLLDVEUERHhWC7V WYMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1sndgpyPB8pBNtTvOkNSvrClxoXvCW9e9eDwpQuuvJk=; b=krYkuSeDk7drNM4sfuQ21YYsekgyGDK/9o2449CCrhF9GZegxNZGDBPxbK7zjBAMsC yPk+zlf58RlAu6TnFd8xqctrqd0YjQNU9ZwTt+TGUOvq441ici6hpJ8Avi4rekUGPiAy 8L5cvlkLvm3klOR5O631OQQb5Fr2X0rlY4uFqVPpeY1z0XZaQ+79b5MLQYGG4MfYoiRb GP6i7GW2eod/Pn0x2TOdjjjevRlLnRx7i8VOR8gYdMhNMejA2/eKDb4fNVWO9jMQx3k+ IiJ+uh7pA38OCnR/DrJ0tHFpmcNQ49lc8o0CL1mhPVCC83A3TzspGv7FIjZ6LvO2ZE3q ILhw== X-Gm-Message-State: AOAM530ZW0Df5mlKPjEioXR526AxDOrD6346MQUtUWl5y2/q4ZvVsM46 9XcBACp/FT8BHURZ/1F0+YqYdkRIsxYbxBtPfx/xu9P4YKOGQC7UCJ8kQDhHEDrrLe3ZiVqAX7t fHNRvM11AmZBlu4f1CXT3UurVQUjMtbCj7GlPguHJP8k5YefVAiovOFJVZKk6/Eit7Q== X-Google-Smtp-Source: ABdhPJxYMEt4joADuAgYSrivfhiqf9/L0c0M0MC2NkdOSa7eFlNfOt+CEFxt3sM1od0mFAFOB3SYoA== X-Received: by 2002:a1c:9851:: with SMTP id a78mr7381491wme.66.1612446626923; Thu, 04 Feb 2021 05:50:26 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id o18sm6123171wmh.20.2021.02.04.05.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 05:50:26 -0800 (PST) Date: Thu, 4 Feb 2021 13:50:24 +0000 From: "Leif Lindholm" To: devel@edk2.groups.io, lersek@redhat.com Cc: Ard Biesheuvel Subject: Re: [edk2-devel] [PATCH 1/1] ArmPkg/Library: prevent endless reboot loop with emulated NV varstore Message-ID: <20210204135024.GZ1664@vanye> References: <20210204125427.1157-1-leif@nuviainc.com> <96817af4-5196-064b-2d71-6ca685d0a573@redhat.com> MIME-Version: 1.0 In-Reply-To: <96817af4-5196-064b-2d71-6ca685d0a573@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 04, 2021 at 14:06:01 +0100, Laszlo Ersek wrote: > 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 Doh! Emacs, you have betrayed me! *Hangs head in shame* / Leif > Laszlo > > > + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); > > + } > > } > > > > Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); > > > > > > > >