From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mx.groups.io with SMTP id smtpd.web12.7347.1612443272500595469 for ; Thu, 04 Feb 2021 04:54:32 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=IGeBNty0; spf=pass (domain: nuviainc.com, ip: 209.85.210.172, mailfrom: leif@nuviainc.com) Received: by mail-pf1-f172.google.com with SMTP id w14so2086263pfi.2 for ; Thu, 04 Feb 2021 04:54:32 -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=hU+FzoP16sa7F9hFx7JI05sn5F2L5YJGanxpuYiKqYw=; b=IGeBNty0526yJZZq0m+F7fXWfJAtloDnb0p6RhTweNWTueeDSmbvqizJUAO3ABaMmA xBxcpgah4/pITvXQDjoZ++BZDy9fJaxPoooID61UA8oH9DDfCgxHH/Q/hgrMDmjJVetq PamH6YfSkt+pcQnymWXPOkGKDQGQMepF0EPdjXxfu+sWBHfpqzWMynS8OZnSL9KbX4xO wwQK3DXbxAlk3vTBArFBfd5MUuAD6YEwNTMhDSurAf53uopva4DbqWc4IBNZ/VeMalXG QZh7md4tc9BGKSbVzukZ/MOte3eJzKF6AbCFqxGvvQWf4sCqP9b1ZKURK+dNp6WoJuxp fPjA== 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=hU+FzoP16sa7F9hFx7JI05sn5F2L5YJGanxpuYiKqYw=; b=G32EAlT+GgNpE6A62cnItB4RR+3qQdoNZXiTs1zYqczbmae8WYFJZwqbR7VSgVU5J/ 2T6TpIZERSNiOqO565DPQXhKDrjwknn5yRYjluENMrCTOLJKiRThSJvGXIAdpBTE5hC/ RUdOUW6zlPkcOC99/0Uu8CmecNXO/nXOPEP+DvliYhzmGJkspx7R2KjuRRtrhSGG/nCD nej8WFwpAUUrleu4gtTubXDvUNvkCjymxnARskN0C40jcXbPz39NyT/2H0/hq9dqoHi7 QP+jAWdRroKByeVgK5xa8grmoyiu+/FScd/ksucBvQPG9C39oVC5eS7H9NCaAiy1RfSH jYrw== X-Gm-Message-State: AOAM531y4SR1aJgJzWWtE+SVFN2QlypcfLGscw4lSvscl1w3vU8h6KaF 1t4opRc0/5LYaCqhcprlLbDxFANpRKlmqaor1jVbqfbh7ryOpX7EBEdt6m2MQnF46GWPgP7y33r yjS3Jw47+ol8E3cE3SZjo1c3Ga9HBOChgDxobvi9Y4tZ0v7PijJZru8+eM4xAOVlQzA== X-Google-Smtp-Source: ABdhPJwRoLbp0d2YBG6adRFv1BA7El+9dnMkILdGsbaHc/ERkNg9cjH57YvRsYMOAFJRz0h4++vfzA== X-Received: by 2002:a63:c44d:: with SMTP id m13mr8821191pgg.64.1612443271649; Thu, 04 Feb 2021 04:54:31 -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 l13sm5324673pjq.30.2021.02.04.04.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 04:54:31 -0800 (PST) From: "Leif Lindholm" To: devel@edk2.groups.io Cc: Ard Biesheuvel Subject: [PATCH 1/1] ArmPkg/Library: prevent endless reboot loop with emulated NV varstore Date: Thu, 4 Feb 2021 12:54:27 +0000 Message-Id: <20210204125427.1157-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 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__)); + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + } } Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); -- 2.20.1