From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web09.5746.1623109591317816447 for ; Mon, 07 Jun 2021 16:46:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=F5h9taeZ; spf=pass (domain: nuviainc.com, ip: 209.85.128.47, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f47.google.com with SMTP id s70-20020a1ca9490000b02901a589651424so704544wme.0 for ; Mon, 07 Jun 2021 16:46:31 -0700 (PDT) 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; bh=6wTXAJL8JcYo0gEwjykq8kJF0ftyc6BBzYNzUFKNEQ0=; b=F5h9taeZ+PbGEk1GpoC/feovRjlbFPFRSjrTAQ+74zua4Y2WuVXUor4UXQjOxh50YS zWqJBsZJT+uUYZpL2WHAzSH3y/t9usj6saibuyPHuWTL8ZYVZ5IUHFff6P1dxn+HLB/b HBUfO8NoOSBWAJY+3d57u6MR3GSYzJ9uR+lM8VidP2VYqWpgBAzTHK+BSZMbrJ6+iFYh CJ4O4Dk/Qiddk+1suoi3gQd+GJkRfh+331MLFDPBkynaqFji0+qpc29Dd4eay8DCLMxg t9VZ6+5qPkYSISJF3wePd7Vc3lOt8rUtkqyKOnjqGHJGXY33oBEmW7LaToYpuDNDsEyA T+8A== 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; bh=6wTXAJL8JcYo0gEwjykq8kJF0ftyc6BBzYNzUFKNEQ0=; b=sUfQa72IXZ4jhBaaVh1QSvLgzjdWqoafoNdb3zarrgYfDMng+XIES5F86eQnpS5+fd q8RMIizmlF5g3ubyam2685vWWn5MTIl7Xf1/CFNKuA5H+L484ajtussKvyNPIGfRUuzd JMCKWxuGbjgTMFBVUiwlg1TXTNZCqtuyOjNaMclN2FzC9otEkxFDrmC+R++R718fYxMB r087Bwml15OaGb+gR9ob9fiv6CtVtHmVSos6m/MPltHHg+QaC92qy4n1OmW/u3UIPCVh u/rGDulaEr5jc7g/RvM5JRELUxk1uWUJr5pM7zhlF6ZPuIiNcgSzvANhi1WwI34PSajO 3aOw== X-Gm-Message-State: AOAM5321gkPF2EHB4qCkKEK0wsAO0aSoKJksz3HEEL3Gl0IG/TQZIS7W 4tk5POzx4g89G2U0ADbXrvHg9w== X-Google-Smtp-Source: ABdhPJyMzhFlkeYrzK9gaREmvtjP6GoXVfJ51rWPSzqM/UxzM8GB9VccDnmLi0v/f/MScDfZHjP0vg== X-Received: by 2002:a7b:c38f:: with SMTP id s15mr1395169wmj.16.1623109589573; Mon, 07 Jun 2021 16:46:29 -0700 (PDT) Return-Path: Received: from leviathan (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id q11sm17320512wrx.80.2021.06.07.16.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 16:46:29 -0700 (PDT) Date: Tue, 8 Jun 2021 00:46:27 +0100 From: "Leif Lindholm" To: Nhi Pham Cc: devel@edk2.groups.io, Vu Nguyen , Thang Nguyen , Chuong Tran , Phong Vo , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: Re: [edk2-platforms][PATCH v2 29/32] JadePkg: Recover boot options when NVRAM cleared Message-ID: <20210607234627.7hrdr3xwtuw2m7w5@leviathan> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> <20210526100724.5359-31-nhi@os.amperecomputing.com> MIME-Version: 1.0 In-Reply-To: <20210526100724.5359-31-nhi@os.amperecomputing.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 26, 2021 at 17:07:21 +0700, Nhi Pham wrote: > From: Vu Nguyen > > Due to recent changes in EDK2, system without a valid boot options list > in NVRAM will enter Platform Recovery mode. As ReadyToBoot event is not > triggered in this mode, services like ACPI and PCIe won't be able to do > some finalization settings and cause OS fails to boot. > This change is to prevent the issue by recovery boot options list each > time NVRAM is cleared. Urgh. Ultimately this is a bug in EDK2. And it should be fixed in edk2: https://bugzilla.tianocore.org/show_bug.cgi?id=2831 But could you let me know which specific edk2 change broke this for you, since it is not obvious to me? / Leif > Cc: Thang Nguyen > Cc: Chuong Tran > Cc: Phong Vo > Cc: Leif Lindholm > Cc: Michael D Kinney > Cc: Ard Biesheuvel > Cc: Nate DeSimone > > Signed-off-by: Vu Nguyen > --- > Platform/Ampere/JadePkg/Jade.dsc | 5 ++ > Platform/Ampere/JadePkg/Jade.fdf | 5 ++ > Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf | 39 +++++++++++++ > Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.c | 58 ++++++++++++++++++++ > 4 files changed, 107 insertions(+) > > diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jade.dsc > index 9d787113e3b5..023f2e898d7f 100755 > --- a/Platform/Ampere/JadePkg/Jade.dsc > +++ b/Platform/Ampere/JadePkg/Jade.dsc > @@ -185,3 +185,8 @@ [Components.common] > Silicon/Ampere/AmpereAltraPkg/Drivers/RasConfigDxe/RasConfigDxe.inf > Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.inf > Silicon/Ampere/AmpereAltraPkg/Drivers/PcieDeviceConfigDxe/PcieDeviceConfigDxe.inf > + > + # > + # Misc > + # > + Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf > diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jade.fdf > index b0c2894d00f8..edbead046572 100755 > --- a/Platform/Ampere/JadePkg/Jade.fdf > +++ b/Platform/Ampere/JadePkg/Jade.fdf > @@ -361,4 +361,9 @@ [FV.FvMain] > INF Silicon/Ampere/AmpereAltraPkg/Drivers/WatchdogConfigDxe/WatchdogConfigDxe.inf > INF Silicon/Ampere/AmpereAltraPkg/Drivers/PcieDeviceConfigDxe/PcieDeviceConfigDxe.inf > > + # > + # Misc > + # > + INF Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf > + > !include Platform/Ampere/AmperePlatformPkg/FvRules.fdf.inc > diff --git a/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf > new file mode 100644 > index 000000000000..624332339beb > --- /dev/null > +++ b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.inf > @@ -0,0 +1,39 @@ > +# > +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x0001001B > + BASE_NAME = BootOptionsRecoveryDxe > + FILE_GUID = FDCDDC91-4F9E-400C-9BB4-1FE4BE9565B3 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = BootOptionsRecoveryDxeEntry > + > +[Sources] > + BootOptionsRecoveryDxe.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec > + > +[LibraryClasses] > + DebugLib > + PcdLib > + PrintLib > + UefiBootManagerLib > + UefiDriverEntryPoint > + UefiLib > + > +[Guids] > + gEfiEndOfDxeEventGroupGuid > + > +[Pcd] > + gAmpereTokenSpaceGuid.PcdNvramErased > + > +[Depex] > + gEfiFaultTolerantWriteProtocolGuid > diff --git a/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.c b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.c > new file mode 100644 > index 000000000000..cd9637ec704e > --- /dev/null > +++ b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRecoveryDxe.c > @@ -0,0 +1,58 @@ > +/** @file > + > + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +VOID > +EFIAPI > +RecoveryCallback ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + DEBUG ((DEBUG_INFO, "%a: Do recover boot options\n", __FUNCTION__)); > + > + EfiBootManagerConnectAll (); > + EfiBootManagerRefreshAllBootOption (); > + > + gBS->CloseEvent (Event); > +} > + > +EFI_STATUS > +EFIAPI > +BootOptionsRecoveryDxeEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_EVENT EndOfDxeEvent; > + > + DEBUG ((DEBUG_INFO, "%a: NVRAM Clear is %d\n", PcdGetBool (PcdNvramErased), __FUNCTION__)); > + > + if (PcdGetBool (PcdNvramErased)) { > + DEBUG ((DEBUG_INFO, "%a: Register event to recover boot options\n", __FUNCTION__)); > + Status = gBS->CreateEventEx ( > + EVT_NOTIFY_SIGNAL, > + TPL_CALLBACK, > + RecoveryCallback, > + NULL, > + &gEfiEndOfDxeEventGroupGuid, > + &EndOfDxeEvent > + ); > + ASSERT_EFI_ERROR (Status); > + } > + > + return Status; > +} > -- > 2.17.1 >