From nobody Mon Feb 9 17:09:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61517+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61517+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1592571678; cv=none; d=zohomail.com; s=zohoarc; b=Q1phNpdXcbqPG/I42M93q8AW9WPXh9zKsWLv8w1jDxkzPAvKJNagBUUD9+5kKJcG9H4lsb34xW7dYq2JJiMb8ReSpMwACTBz27HJgBD5fTn4mHiON2T1z6yK7/TCJQe8pvWNLgJB/gw0Sll4gKjbhwmZNmSk4Mf7CLP9Jh/uMvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592571678; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ZjmwCevpE5lr7Uz2bn5VZkGRZ+NhtPgzG+yrzfms2A4=; b=Fz+yPqqFcRirQRd1SsiR+EWYNlMO3OfnrXtSEKNki5A9K+XPtIrGNoKvakdZsdj+X+9+sGQVeLm9d+VWo2Ajp6x4FKkoNZWvLHrRw6lSdBIbcB2ohuFSmaXSoffWKY+XqsLxGpKJ2elIFiJsn8Ja17eCC827mpK3aEjpzO/cv6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61517+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592571678804479.51551959430867; Fri, 19 Jun 2020 06:01:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fTRhYY1788612x2Fk60nebwt; Fri, 19 Jun 2020 06:01:15 -0700 X-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 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 X-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" X-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: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC. Date: Fri, 19 Jun 2020 08:10:26 +0530 Message-Id: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krishnadasx.veliyathuparambil.prakashan@intel.com X-Gm-Message-State: ThjR65tDEYakMEuGJKc9m5O4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592571675; bh=9BcQ7DEM1MWsX898gZn0PIGkBebfnuN6I8/TrnoeeJQ=; h=Cc:Date:From:Reply-To:Subject:To; b=JefyYM4vNp369vfW3uKiMsBAomLHn87jNGt+2YG8ktb3mOz/lD6esFuMCm2cll4gl+A /0eaxF7rzX6U9UldK6W1b05IgBK8One27OkQLIl8m+i3wjTNoffqAKB4NITINZMpnCh8d fDbV1Qpj+LsWCtcNTGzw5hzeGz5Q/Ov/lV0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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" Acked-by, not Ack-by, but yes, I completely agree. Restricting the Reviewed-by: Sunny Wang --- .../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. =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 f= ailure to load boot option - // - BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status= ); - 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 f= ailure to load boot option + // + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status= ); + BootOption->Status =3D Status; return; } } @@ -1982,13 +1982,6 @@ EfiBootManagerBoot ( Status =3D gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &Boo= tOption->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 fa= ilure - // - 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 fa= ilure + // + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status); + } + PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber); + + // // Clear the Watchdog Timer after the image returns // --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61517): https://edk2.groups.io/g/devel/message/61517 Mute This Topic: https://groups.io/mt/74978785/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-