From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.13153.1592814761357153831 for ; Mon, 22 Jun 2020 01:32:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0442533ea7=sunnywang@hpe.com) Received: from pps.filterd (m0134422.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05M8WHxO002367 for ; Mon, 22 Jun 2020 08:32:41 GMT Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 31svkrpj1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 22 Jun 2020 08:32:40 +0000 Received: from G9W8454.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.216.161.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3425.houston.hpe.com (Postfix) with ESMTPS id 0F2A9BA for ; Mon, 22 Jun 2020 08:32:40 +0000 (UTC) Received: from G4W9121.americas.hpqcorp.net (2002:10d2:1510::10d2:1510) by G9W8454.americas.hpqcorp.net (2002:10d8:a104::10d8:a104) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 22 Jun 2020 08:32:39 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (15.241.52.10) by G4W9121.americas.hpqcorp.net (16.210.21.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Mon, 22 Jun 2020 08:32:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNWUuc6hxWM2cOKSobIs6v2yvMV1LFgppTvtCvbaPkCIHizau4pfMnMtpaOj4evTuFGg1qovtTxOR028xr9PUslrQX8BdNO3F2X1hKrDTP3+E+1Ja88JKGxoS3V+YLvqffLLTgUZjlMBbWcQw4VWO84pKPzpT2fCU3JxRgIsf94p+n/dx8i0vHs9j+LEcB74bxRg9urj2u+Vo9xKf6P+l1sbE9OhSWMbnokOc+lm1tgtR5OMUn21/PW06PUDsLt2B8xrTOpQDU3lXIleFozvsK18MWbtFZ+JjfHOY1ghjRgO7lXYL0ZXmo1FTIpng+mQ4wojIzWb4hydiT66mrQQ/A== 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=OrTZvaZFdnwoN55vuwUGt79/X2q+XPXCg6H9jfKIuN0=; b=mN+dL+FEGdTVU3DSCnYXnBgCjy/prvH2+pDLoTY+EXTE19vtRAx5r5nqX8c9uXy8yS2w2r7wKJbI13klr3otNb9ZYN7/iEy8ApM92M7KCsO/mvMu0n3436WzCFizvSB5lCZGTlwCjAeK761nQyExEzKRpmJwkjLFQ7agrJORKfzSSVzfZqo8XsCbtL5KIr4eaIcI7t4mKj1C2ohAnohxPkyWNhAZxMVP10BfuSLeazBdis4dG1U0u6PwooU4n0QtU20E8NE0+iumARjqUc5P6Aw+CS0kAbEbvkX8vNBTun6GRfuZqcLoR+P4Yw0+a/tewX220XGhA5RiRnCPZP+TDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7609::21) by DF4PR8401MB0969.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 08:32:38 +0000 Received: from DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM ([fe80::69d6:52d6:4ce6:c317]) by DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM ([fe80::69d6:52d6:4ce6:c317%7]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 08:32:38 +0000 From: "Wang, Sunny (HPS SW)" To: "devel@edk2.groups.io" , "krishnadasx.veliyathuparambil.prakashan@intel.com" CC: "Gao, Zhichao" , "Ni, Ray" , "Wang, Sunny (HPS SW)" Subject: Re: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC. Thread-Topic: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC. Thread-Index: AQHWRjnNHoSAIn4pTkW2aS/loNcAKajkFz+A Date: Mon, 22 Jun 2020 08:32:38 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-originating-ip: [220.129.193.218] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 4efff07c-b1e6-4add-de1b-08d81686d25e x-ms-traffictypediagnostic: DF4PR8401MB0969: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:483; x-forefront-prvs: 0442E569BC x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1nAw2FNUvK5+6KNINEfdu4wR56AyywaJMg4YE5I87MpCgUPo6eKtnh/l1rtmVzcxNht7yjPZ0NE9ADgobVDjWt3l3skig403nrG9u9HQavwMM71ZxJ/U+Fzgn57s8hZZzI8lp+3BrvKJnjisHpvdIYhIADs/TkwKoUn54qr6sEfH48KYr0xDmVntLrHMuopfBesRe8iZ7M3dQrmOAramdrzFKnZQAtdGGJDo0oYQZtfTVc6pXb99L/saMlO7Av2Azc1bsUh1FXeltpDu1Q+6knlyr8WbU4Sk6EPSIQsTPt/Fs49M65sgFzGqCE72jDPI0N2auIcPncfzK5SryfvEJXvaNaL7PebyEsI06Ipi3FYG16K8/78tfhkutEAu9bMicqridBHz1VLjYlhbMTdPwg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFTY:;SFS:(376002)(39860400002)(346002)(136003)(366004)(396003)(966005)(478600001)(54906003)(76116006)(110136005)(2906002)(8936002)(8676002)(83380400001)(316002)(6506007)(7696005)(9686003)(55016002)(53546011)(4326008)(52536014)(5660300002)(86362001)(33656002)(26005)(71200400001)(66946007)(66476007)(66556008)(64756008)(186003)(66446008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: KKt74lqQXgagfGlS2aVjdzpDZ92inC7efmiAi6RxcNImeFfPdGV9LaqHN7uyofAimWyhJJy/ja4zXctuf2yg+DprltyC1Uto4mwiNgszHCRM8Y/aOs0FPb9x4ZSqKLalah3DZvVRmVRVFdAzPuN31jeCn7eymtz5RCr41rw+KGyjSd7XbY9mJkekzsKlHEWBM7DUaqxYneGuE3i9f82/V/eUZUv89Ib8khqIMbbYZb4IshWZ/TKACn+SnO43g5abLkGg27X3K9DYcDWIxy+Lc9wzRk7AiYCUSWGKYx+a5VD9rRvF9j4alecC2issZ3K+9dD3ekQOBV3y39d1AvVQ5E0RVF8VbG3+QDAbluqEBDlpoVnnfbeG8mVLusWYiZl4WDqeFQJTeUGG5EpjciGNPI7bGvD7NXuBbujDdcJTBNznrQdX1XZCScbhnkzOMr5NEv6I1Ku2LkG4wdQ6sWuy7CtwEDrOHJe/m0+aL53PJgOAIMIKoxxvZC7h2YKuBGRY X-MS-Exchange-CrossTenant-Network-Message-Id: 4efff07c-b1e6-4add-de1b-08d81686d25e X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2020 08:32:38.1647 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qXhAEE/NoE9m02xdUgsYYfCTA/HrirGrhqFwSMNw9VYaltF6e0qa/xR5jNv5PFYJ4kaAGwvlDue3LY8JGCyb6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0969 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 4 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-22_02:2020-06-22,2020-06-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006220064 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Looks good to me. Not sure if there was a reason to call BmDestroyRamDisk b= efore ReportStatusCode.=20 By the way, it is an interesting case that there is a custom boot option o= r application that needs the memory that was occupied by the RAM disk. It l= ooks to me like the custom boot option or application would like to create = the other RAM disk with allocating large memory for recovering the failed b= oot option.=20 Reviewed-by: Sunny Wang -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Kris= hnadasX Veliyathuparambil Prakashan Sent: Friday, June 19, 2020 10:40 AM To: devel@edk2.groups.io Cc: Gao, Zhichao ; Ni, Ray Subject: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destr= oy RamDisk memory before RSC. REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2818=20 For better memory management, re-ordered the DestroyRamDisk and ReportStat= usCode calls inside the EfiBootManagerBoot() function. This will help to clean the unused memory before reporting the failure sta= tus, so that OEMs can use RSC Listener to launch custom boot option or appl= ication for recovering the failed hard drive. This change will help to ensure that the allocated pool of memory for the = failed boot option is freed before executing OEM's RSC listener callback to= handle every boot option failure. Signed-off-by: KrishnadasX Veliyathuparambil Prakashan Cc: "Gao, Zhichao" Cc: "Ni, Ray" --- .../Library/UefiBootManagerLib/BmBoot.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModuleP= kg/Library/UefiBootManagerLib/BmBoot.c index 540d169ec1..aff620ad52 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -2,7 +2,7 @@ Library functions which relates with booting. =20 Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. -Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -1903,17 +1903,17 @@ EfiBootManagerBoot ( gBS->UnloadImage (ImageHandle); } // - // Report Status Code with the failure status to indicate that the = failure to load boot option - // - BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Statu= s); - BootOption->Status =3D Status; - // // Destroy the RAM disk // if (RamDiskDevicePath !=3D NULL) { BmDestroyRamDisk (RamDiskDevicePath); FreePool (RamDiskDevicePath); } + // + // Report Status Code with the failure status to indicate that the = failure to load boot option + // + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Statu= s); + BootOption->Status =3D Status; return; } } @@ -1982,13 +1982,6 @@ EfiBootManagerBoot ( Status =3D gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &Bo= otOption->ExitData); DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status =3D %r\n", Status= )); BootOption->Status =3D Status; - if (EFI_ERROR (Status)) { - // - // Report Status Code with the failure status to indicate that boot f= ailure - // - BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status); - } - PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber= ); =20 // // Destroy the RAM disk @@ -1998,6 +1991,15 @@ EfiBootManagerBoot ( FreePool (RamDiskDevicePath); } =20 + if (EFI_ERROR (Status)) { + // + // Report Status Code with the failure status to indicate that boot f= ailure + // + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status); + } PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)=20 + OptionNumber); + + // // Clear the Watchdog Timer after the image returns // -- 2.27.0.windows.1