From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.3433.1593747551773653288 for ; Thu, 02 Jul 2020 20:39:12 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: krishnadasx.veliyathuparambil.prakashan@intel.com) IronPort-SDR: Blt3n/jQ81pUL8OSdCB0Acma+FNlbGoM7ABNxFWISAe+r19xkJJoZlemCxS7mkR+7DnjUIayQw Ntlme34u5LhQ== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="147093708" X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="147093708" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 20:39:10 -0700 IronPort-SDR: OMAgIc/HRdip995fWn+dmel75ZzGzb3kkbGjPF1iyKptCch0YvqcwTdJVEKND44lIcvqcYJ3kG zzanwAkT8usQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="282163164" Received: from kveliyax-mobl.gar.corp.intel.com ([10.213.95.72]) by orsmga006.jf.intel.com with ESMTP; 02 Jul 2020 20:39:08 -0700 From: KrishnadasX Veliyathuparambil Prakashan To: devel@edk2.groups.io Cc: KrishnadasX Veliyathuparambil Prakashan , "Gao, Zhichao" , "Ni, Ray" Subject: [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC Date: Fri, 3 Jul 2020 09:08:48 +0530 Message-Id: <67fbf576ab9f16e360e46710be21f0e85167cf6d.1593747388.git.krishnadasx.veliyathuparambil.prakashan@intel.com> 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