public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"krishnadasx.veliyathuparambil.prakashan@intel.com"
	<krishnadasx.veliyathuparambil.prakashan@intel.com>
Cc: "Gao, Zhichao" <zhichao.gao@intel.com>,
	"Ni, Ray" <ray.ni@intel.com>,
	"Wang, Sunny (HPS SW)" <sunnywang@hpe.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC.
Date: Mon, 22 Jun 2020 08:32:38 +0000	[thread overview]
Message-ID: <DF4PR8401MB0585D40B39BB1C12CC0164D2A8970@DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <ddae3ea5f61290774cdb19280200ae529fbc437c.1592534360.git.krishnadasx.veliyathuparambil.prakashan@intel.com>

Looks good to me. Not sure if there was a reason to call BmDestroyRamDisk before ReportStatusCode. 
By the way, it is an interesting case that there is a custom boot option or application that needs the memory that was occupied by the RAM disk. It looks 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 boot option. 

Reviewed-by: Sunny Wang <sunnywang@hpe.com>

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of KrishnadasX Veliyathuparambil Prakashan
Sent: Friday, June 19, 2020 10:40 AM
To: devel@edk2.groups.io
Cc: Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [edk2-devel] [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC.

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2818 

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 <krishnadasx.veliyathuparambil.prakashan@intel.com>
Cc: "Gao, Zhichao" <zhichao.gao@intel.com>
Cc: "Ni, Ray" <ray.ni@intel.com>
---
 .../Library/UefiBootManagerLib/BmBoot.c       | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/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.
 
 Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
-Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -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, Status);
-      BootOption->Status = Status;
-      //
       // Destroy the RAM disk
       //
       if (RamDiskDevicePath != 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, Status);
+      BootOption->Status = Status;
       return;
     }
   }
@@ -1982,13 +1982,6 @@ EfiBootManagerBoot (
   Status = gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &BootOption->ExitData);
   DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n", Status));
   BootOption->Status = Status;
-  if (EFI_ERROR (Status)) {
-    //
-    // Report Status Code with the failure status to indicate that boot failure
-    //
-    BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status);
-  }
-  PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
 
   //
   // Destroy the RAM disk
@@ -1998,6 +1991,15 @@ EfiBootManagerBoot (
     FreePool (RamDiskDevicePath);
   }
 
+  if (EFI_ERROR (Status)) {
+    //
+    // Report Status Code with the failure status to indicate that boot failure
+    //
+    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
   //
--
2.27.0.windows.1





  reply	other threads:[~2020-06-22  8:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19  2:40 [PATCH] MdeModulePkg: Upon BootOption failure, Destroy RamDisk memory before RSC KrishnadasX Veliyathuparambil Prakashan
2020-06-22  8:32 ` Wang, Sunny (HPS SW) [this message]
2020-07-03  6:02 ` [edk2-devel] " Liming Gao
2020-07-03  9:30   ` Veliyathuparambil Prakashan, KrishnadasX
2020-07-17  4:09     ` Veliyathuparambil Prakashan, KrishnadasX
2020-07-17  4:54       ` Gao, Zhichao
2020-07-17 15:06       ` Liming Gao
     [not found]       ` <162292995B2D9EDC.3435@groups.io>
2020-07-21  0:46         ` Liming Gao
2020-07-03 10:43   ` Leif Lindholm
2020-07-03 15:02     ` Liming Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DF4PR8401MB0585D40B39BB1C12CC0164D2A8970@DF4PR8401MB0585.NAMPRD84.PROD.OUTLOOK.COM \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox