From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.99]) by mx.groups.io with SMTP id smtpd.web11.341.1623775940710344720 for ; Tue, 15 Jun 2021 09:52:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=FpoxzVKW; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.99, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HYkmJeAG87NZC536AsmSbANax8F+3hyMVFA12MUol6LfoRntHSXXB65UqGr5axphrzjgqRvt22NhYms7woZ0mEbmteLXmAivayEiKzPfLYefkcOCXk4fpW/l0umjHJLnBBm2rP435cxqN6NnxfrNCE53nItYIx60mjIH1/Bj4vHkBy/5EBfsLb6ve2dK7h7RHVo4pzBUhrW08j0jeJsMMxFi3mIE1pPHS2ZTi5yt5NyepJFSKbk6/j98w/N0gySPtayhOY7b7QesiC20Tbktv8wdQplb7zFTpOVcCOGxsEirqHaWaK/VY4DYJbfl89I7fXRZy9ZXLahhGaC1EMXWmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d7ou7zYP+B556IpXDQaq1TVpibnzCqrE/ErTzTmasJM=; b=I7PQx2YOk/rdGv33DwWY+kMWQp7WrXWUOcEAus40G5XZjrsZkQSReCwAYIDc/qya35AhVc6V74gF+Lt4sOQKF4Xt4dXfvTgPNurp7KtxliVgpifXlOSH50V4THHICqPW1J10p5WDqzNanLlaTLw54PrEWf5OMpo4nUAkgUWO92Qfp+WwFH3+PhP1i4SBNvcNWPp6g0Z+LTjoVCuEdHfPzFjt0glkaLYwKRUkuxPF352ubpNHM/KjuFXtTV++45JnhjvLoi8XgnaK8EqA80EHLUzHXsRlNZUhJtxZT+AWRAlnhLlaQUCcYo4MI7PXdKVi5DMwIl7jwWPPTx2Ek+qkrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d7ou7zYP+B556IpXDQaq1TVpibnzCqrE/ErTzTmasJM=; b=FpoxzVKWOx38O0In7u2U7P7Vl+W1ux+dLVLr0WnAW4EY6IOpM+acbOfTTcFHk8tvrOd+hxAxAnD2VUaG355eUkUwdExXMrdIq9cfZ7jBmx3QThMIsE0SpGJI+A9evRmwK/J3hRZnpnVoDPP/JLrISlorZgJZLUCDCcLweKq6iBA= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM6PR01MB4841.prod.exchangelabs.com (2603:10b6:5:72::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.24; Tue, 15 Jun 2021 16:52:18 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::4d8d:74e3:6747:75a2]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::4d8d:74e3:6747:75a2%7]) with mapi id 15.20.4219.025; Tue, 15 Jun 2021 16:52:18 +0000 Subject: Re: [edk2-platforms][PATCH v2 29/32] JadePkg: Recover boot options when NVRAM cleared To: Leif Lindholm CC: devel@edk2.groups.io, Vu Nguyen , Thang Nguyen , Chuong Tran , Phong Vo , Michael D Kinney , Ard Biesheuvel , Nate DeSimone References: <20210526100724.5359-1-nhi@os.amperecomputing.com> <20210526100724.5359-31-nhi@os.amperecomputing.com> <20210607234627.7hrdr3xwtuw2m7w5@leviathan> From: "Nhi Pham" Message-ID: <46b2f2a6-b250-e4d5-4a42-471c073344a6@os.amperecomputing.com> Date: Tue, 15 Jun 2021 23:52:09 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <20210607234627.7hrdr3xwtuw2m7w5@leviathan> X-Originating-IP: [116.110.40.240] X-ClientProxiedBy: HKAPR03CA0013.apcprd03.prod.outlook.com (2603:1096:203:c8::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.7] (116.110.40.240) by HKAPR03CA0013.apcprd03.prod.outlook.com (2603:1096:203:c8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Tue, 15 Jun 2021 16:52:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5cffb1b1-eba6-458e-b030-08d9301defd5 X-MS-TrafficTypeDiagnostic: DM6PR01MB4841: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H6sLJApwn4PE7adU8kX5jG7hTis0oxWZdC+MzIUnPS678a6ZE4ubbzgAyICcUUee3v90Oo5X6RWpUEfEFrhVzSG3CgKtxKcUIiRRz06dRFrdgQ+vtFozpTJsVFy9K5rou4ooKRNFt5EAMQfkyEhQwG68YiADyCZD+/zmuJw5yEArviw1LZzvPuWFisAjwAnUrxRsNbnSmb2zza5NZxeiOCPrqV6XcyMAPuRw3Lk81KKLFoTdw9WBHfyAKD0K4IyxVZg4QHhfjUybaqJeTPInxwIm5UYqXMG5PoFVmelKBPdm/bWMsRod8bvoyLRqSaGAp4z3qg+CygobUigZPf6KRlIe0VP/U/b4DBay6FfMgRN3ECkyI6t9wivm0NJNta7780XNCP42TVMwx6pGRYiieVP1q4zLgZxsmBQQVp89VhksO7dHr/ENLXXX8M1IFTqEhus0HlgX6XE+UD3q9Zh7XYJnNmbHC4/4gC31fluEGENnjc5FCIEkJ6npsdu6vtVNBmGffAof7AdE+4yhs+8qLjSkFwfzPyAjlsLvsT9KHh/AYfua6x+Rcg6aluLBkZBZvChp+Gt4jz+7Gi8i+YJdokMZ8ISugcgMwCtyIeDro7Y/Pr7b0PQflUE/ecLkBCaajhlphi3P1BcozTRBWl8pFLSJ2rbHp/7D82voc26wDjBtpK4t5M2EHLHqaZeJjP0bR7P5s7zcESXaAt3TP61bLmgTKsD5srPY3k1COq2Y3UszO0XQL5w3+f3jVylWF/kgG2RKRjJJleXv6og7hWbDxWsohW1tFgRhgVU+nXwy5T1EHJ1vYXM6K8rS31L5bkoC+wjRqV0delyHFELQpY6ymw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(136003)(39850400004)(366004)(376002)(8936002)(38100700002)(38350700002)(966005)(86362001)(2906002)(83380400001)(31686004)(31696002)(6666004)(66946007)(6486002)(54906003)(26005)(66556008)(8676002)(53546011)(186003)(478600001)(6916009)(66476007)(16576012)(52116002)(4326008)(5660300002)(16526019)(956004)(2616005)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?l2/DJqZvxytH15ytKrxFCc5RP/SZ8CNe1PHk7WkMyJQA8IOsDqq8LF1m8QwM?= =?us-ascii?Q?fycADQYMrKXxC9bcyD87eL0/IcY4lsAQkvyBHqHVwnzIA9ZOuxW06VS/UXOP?= =?us-ascii?Q?itIxUcXxbVweZ/wlSR798vyKV0Uqf51yH97YtaoflqxGItWEQkndGEtkBcql?= =?us-ascii?Q?fItu7hKqllAvA6BO8+JqDjkkMyzRGooQIaKQ8VhZAuXtryVC3YIR5MePkTwK?= =?us-ascii?Q?3TO7QQxJ5ZG20VubVakqQKonmcnEUBXhg3xrx8TicPNa8RNxnSCl1texBRxv?= =?us-ascii?Q?M/ptOh/tBWGZlEoZOloeMP5CD+tvJlNz414VQxSf3xNb2tLmLwJRYa6GfbCe?= =?us-ascii?Q?NwU20Wb9zKRQlgXJ+p/PLKas5rtCFC/GrgkpIJzgYbE29xrH+eGAmz/uoNIl?= =?us-ascii?Q?CSxShlGFLrium77SxtnwhADyCYgkPWFo4mR8V4TYPlDDR7Jh/tw0JhHfo05x?= =?us-ascii?Q?+8IaZlvrc2PHdSThabPX7NFLQqOHF48lZaVgo2TRLBwQ/a56T4FG/RK2HdVn?= =?us-ascii?Q?rETn4cFViQHdhtnaIYBRdUUSsStvrbzRebDIvLwH+Jrte51u6x0IbGjJ3R41?= =?us-ascii?Q?mFDQDnZ15/+WbvgESL4l49iL+PS1wlf6d+2PnwHr/0YdYaTfWP2QU6cnk9A9?= =?us-ascii?Q?NoySBRGN111QMaYcp7mq414bORurxwCSeP5LLOC49BClAEI2A9M9wa6cVXqm?= =?us-ascii?Q?gl0zIPpVjEdocOIfcFAh1KOS7dtSi+f6B95G/6RJB/mVW+P5A53090HdQTKS?= =?us-ascii?Q?czcguAvmCIHSPRnQByTpd1jNRliihlFr/MXCF7p0iU9pvAzlgCSnkfaFkPHU?= =?us-ascii?Q?YE4HG8Arb/fO6XJuTdX7+Kt7cuaxzoec83bl4kJWNpfe7eTcNVjdipNUNwcA?= =?us-ascii?Q?ETVLI2HbaB0oP3YrIwwE+7RIuSrk5FnzMiEPQ+pRGA7+ly8S90H90o/lWt4x?= =?us-ascii?Q?xeIFIPxFw7L9goTTboWIyXgJkqeyDqqLGPOFBo3I98MDOYg1F87DGSe2TKPg?= =?us-ascii?Q?TKwXiTJSPQ7Z2SeZyvq5VKm2FIcwOdDoVwP6BX5oFs/P1/cYq/2XPqrvuSqJ?= =?us-ascii?Q?ZwzVMfwpnQZ0D2/mKJHJle727OHT17PSbkmEBaky6GHIFZmqM7EdqXANcgBC?= =?us-ascii?Q?9H4uvujpii83q3EY2YDZmlQkkFUKPiT24KxM8Zmjo6D6od1F1EeoG8lIrENn?= =?us-ascii?Q?aWzIIdwIpRXtx+K8koG5bsW7CDGE0sWvPdJ7qo/JB+djLhS2xrr2KlzaNA/t?= =?us-ascii?Q?ZHIiOzixdH7kNqy6TEFdo6RirYNoEVFst40i6UKWzuzebFIyGaw6ZjfO0M4r?= =?us-ascii?Q?rDqTHKCaLM6k/JXt0G3Q6YpJ?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cffb1b1-eba6-458e-b030-08d9301defd5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 16:52:18.7098 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2O2tWDgshWaOQ+HAxO36uxgNXg+xjXJQ1bnjLHAhFwWvK+4Uf1fR/Rdgfu/kIKrjq6jq5EtYnyCH2YQNVfUYEgPVAJtw/zq5bBHK93TXU4w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4841 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 6/8/21 06:46, Leif Lindholm wrote: > 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=3D2831 > > But could you let me know which specific edk2 change broke this for > you, since it is not obvious to me? Thanks Leif for the info. The issue happened since below change=C2=A0 037d86dd7a (20/06/06 14:49)=20 ArmPkg/PlatformBootManagerLib: don't connect all devices on each boot=20 From that commit, System with a NVRAM cleared might try to boot with=20 default boot option in Platform Recovery mode. As ReadyToBoot event is=20 not triggered in this mode, services like ACPI and PCIe can't complete=20 theirs finalizing configurations and cause the OS fails to boot. This=20 patch is to prevent the system from entering Platform Recovery mode by=20 recovering boot options list each time NVRAM cleared. Best regards, Nhi > > / > 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/BootOptionsReco= veryDxe.inf | 39 +++++++++++++ >> Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsReco= veryDxe.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/WatchdogConf= igDxe.inf >> Silicon/Ampere/AmpereAltraPkg/Drivers/PcieDeviceConfigDxe/PcieDevice= ConfigDxe.inf >> + >> + # >> + # Misc >> + # >> + Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptionsRec= overyDxe.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/Watchdog= ConfigDxe.inf >> INF Silicon/Ampere/AmpereAltraPkg/Drivers/PcieDeviceConfigDxe/PcieDe= viceConfigDxe.inf >> =20 >> + # >> + # Misc >> + # >> + INF Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOption= sRecoveryDxe.inf >> + >> !include Platform/Ampere/AmperePlatformPkg/FvRules.fdf.inc >> diff --git a/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/Boot= OptionsRecoveryDxe.inf b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecover= yDxe/BootOptionsRecoveryDxe.inf >> new file mode 100644 >> index 000000000000..624332339beb >> --- /dev/null >> +++ b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptions= RecoveryDxe.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 =3D 0x0001001B >> + BASE_NAME =3D BootOptionsRecoveryDxe >> + FILE_GUID =3D FDCDDC91-4F9E-400C-9BB4-1FE4BE9565= B3 >> + MODULE_TYPE =3D DXE_DRIVER >> + VERSION_STRING =3D 1.0 >> + ENTRY_POINT =3D 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/Boot= OptionsRecoveryDxe.c b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryD= xe/BootOptionsRecoveryDxe.c >> new file mode 100644 >> index 000000000000..cd9637ec704e >> --- /dev/null >> +++ b/Platform/Ampere/JadePkg/Drivers/BootOptionsRecoveryDxe/BootOptions= RecoveryDxe.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 (PcdNvramEr= ased), __FUNCTION__)); >> + >> + if (PcdGetBool (PcdNvramErased)) { >> + DEBUG ((DEBUG_INFO, "%a: Register event to recover boot options\n",= __FUNCTION__)); >> + Status =3D gBS->CreateEventEx ( >> + EVT_NOTIFY_SIGNAL, >> + TPL_CALLBACK, >> + RecoveryCallback, >> + NULL, >> + &gEfiEndOfDxeEventGroupGuid, >> + &EndOfDxeEvent >> + ); >> + ASSERT_EFI_ERROR (Status); >> + } >> + >> + return Status; >> +} >> --=20 >> 2.17.1 >>