From nobody Sun May 5 15:25:48 2024 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+62014+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+62014+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1593771796; cv=none; d=zohomail.com; s=zohoarc; b=SqW8GRk9or4WHiLPGXc2T7uNrwZ5kVSuzGYyz4vCeBKGYNpOqwmJqkamWX6KCA4CFvHglyrl+6ppLACyJIT6kqxAuE/JHShWAMYIt5Do8itRaSL6gl2jLSupl3LidvWDj5rBisJ3WISp6wHDGV78w994fU4SDZiHiV+N9PCYYE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593771796; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=kxAgq8vYgqaISjmGfpCDg5WhAJuphlwLfYV7iY23xd8=; b=Bk2+h044uR5BjcQlNxjf5j7YlzBC6BtR0tBcMhDCeFhhOLy74yyZZIa7aj3d8qy73GdUhyC9/xNxMF4ghPeEdSLGZzu+WdIMOwdqiLTEmHeg1z6C36sTQRi45JB0vyburMW7jBMKpXYgb/kTeLDW8PZd4rAx2H2gtEgx3nzViZc= 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+62014+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 1593771796488221.23966509383354; Fri, 3 Jul 2020 03:23:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id cbdbYY1788612xAeowuL0aLL; Fri, 03 Jul 2020 03:23:16 -0700 X-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 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 X-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" X-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: [edk2-devel] [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> 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: JAxj6L7GKSsDYXC3nwEe9aE1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1593771796; bh=809oguMCavyR0zXgPM/KZL8xx1lDO97pRc/z4TFB2to=; h=Cc:Date:From:Reply-To:Subject:To; b=uA3mcJNkZ7cnYmPEVNzWQmxanGM1onl4UVgb6hjAqDU4bY4fSTnhiecG8VEtOg6r32k QlHkNdLpw5qySEmi5dXXEB3cp38dVwlR1kWsrTo7IHtOPgfkPhnKweCR2aUe7K2rDsahR yGZ7sCYRoKhwbK8XQYDOSc0mJp36FO3gAlA= 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" --- .../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 (#62014): https://edk2.groups.io/g/devel/message/62014 Mute This Topic: https://groups.io/mt/75276603/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-