From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.2588.1592534504165071774 for ; Thu, 18 Jun 2020 19:41:44 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: krishnadasx.veliyathuparambil.prakashan@intel.com) IronPort-SDR: EziALanmxpNnQtXWXMkZq2lNf8SY57ZlV25LMB7PcbEzSQtJLhsGZ3nq3kPjUiDFZ0NybTeuRu /X+xYxPI1xzA== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="140348835" X-IronPort-AV: E=Sophos;i="5.75,253,1589266800"; d="scan'208";a="140348835" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2020 19:41:43 -0700 IronPort-SDR: mcXrEOXmfXixYXQu/2lWDfiusnJw5JpOEKJ2Rpv8YLhsfw6MyJXZDuRQTLHpcQ/+5tGqbl5Bqs nS1+k0rJBSvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,253,1589266800"; d="scan'208";a="277857643" Received: from rkumarg-mobl.gar.corp.intel.com (HELO kveliyax-MOBL.gar.corp.intel.com) ([10.252.154.209]) by orsmga006.jf.intel.com with ESMTP; 18 Jun 2020 19:41:41 -0700 From: KrishnadasX Veliyathuparambil Prakashan To: devel@edk2.groups.io Cc: "Gao, Zhichao" , "Ni, Ray" Subject: [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC. Date: Fri, 19 Jun 2020 08:10:26 +0530 Message-Id: X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2818 For better memory management, re-ordered the DestroyRamDisk and ReportStatusCode calls inside the EfiBootManagerBoot() function. This will help to clean the unused memory before reporting the failure status, so that OEMs can use RSC Listener to launch custom boot option or application 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/MdeModulePk= g/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.=0D =0D Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.=0D -Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
=0D (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -1903,17 +1903,17 @@ EfiBootManagerBoot ( gBS->UnloadImage (ImageHandle);=0D }=0D //=0D - // Report Status Code with the failure status to indicate that the f= ailure to load boot option=0D - //=0D - BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status= );=0D - BootOption->Status =3D Status;=0D - //=0D // Destroy the RAM disk=0D //=0D if (RamDiskDevicePath !=3D NULL) {=0D BmDestroyRamDisk (RamDiskDevicePath);=0D FreePool (RamDiskDevicePath);=0D }=0D + //=0D + // Report Status Code with the failure status to indicate that the f= ailure to load boot option=0D + //=0D + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status= );=0D + BootOption->Status =3D Status;=0D return;=0D }=0D }=0D @@ -1982,13 +1982,6 @@ EfiBootManagerBoot ( Status =3D gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &Boo= tOption->ExitData);=0D DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status =3D %r\n", Status)= );=0D BootOption->Status =3D Status;=0D - if (EFI_ERROR (Status)) {=0D - //=0D - // Report Status Code with the failure status to indicate that boot fa= ilure=0D - //=0D - BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status);=0D - }=0D - PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber)= ;=0D =0D //=0D // Destroy the RAM disk=0D @@ -1998,6 +1991,15 @@ EfiBootManagerBoot ( FreePool (RamDiskDevicePath);=0D }=0D =0D + if (EFI_ERROR (Status)) {=0D + //=0D + // Report Status Code with the failure status to indicate that boot fa= ilure=0D + //=0D + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status);=0D + }=0D + PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber)= ;=0D +=0D +=0D //=0D // Clear the Watchdog Timer after the image returns=0D //=0D --=20 2.27.0.windows.1