From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0726.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe41::726]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81DD081EF3 for ; Wed, 16 Nov 2016 01:08:05 -0800 (PST) Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.26) by CS1PR84MB0024.NAMPRD84.PROD.OUTLOOK.COM (10.162.189.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Wed, 16 Nov 2016 09:08:07 +0000 Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) by CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) with mapi id 15.01.0721.017; Wed, 16 Nov 2016 09:08:06 +0000 From: "Wang, Sunny (HPS SW)" To: Ruiyu Ni , "edk2-devel@lists.01.org" CC: Jie Lin , "Wang, Sunny (HPS SW)" , "Haskell, Darrell" , "Shifflett, Joseph" Thread-Topic: [edk2] [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery#### Thread-Index: AQHSPyfAWWosWWw1hUWDCn4/Qtlq1qDbO9vw Date: Wed, 16 Nov 2016 09:08:06 +0000 Message-ID: References: <20161115100425.299856-1-ruiyu.ni@intel.com> <20161115100425.299856-4-ruiyu.ni@intel.com> In-Reply-To: <20161115100425.299856-4-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sunnywang@hpe.com; x-originating-ip: [15.211.131.5] x-microsoft-exchange-diagnostics: 1; CS1PR84MB0024; 7:SnCQiXeuWy7iEs4f/dAA1ZdaUyJBdeNx+hvA1xhtBcfxeSOQ/MsoKGQ/TJvceJ0VIM4dOelIKruoYjSXVmU5xHPfitH4AMcHBAO7erTWezdoV5JTUNQuwR41mlVN01AKA7FlagtFbq9FC4W6imcOvFg2lA/RyJ9HDhDbf6F4B8Z9yFYeJ8vCJn3Lq1cb+kmw/8HEzas4hP8plPsZjuWn7npq7pTIfD80C8LvCDXzSuLTSF6Y4Vv4xvYfFmU4UH6nKW82ILeMfrUvER0qmt5Y76BltapJqDgS/tseESCWB3jfrChTKNDiqv3hxJ+3Vc9fHizZFL7X/yL7BEAv64tKj7u1bibwaDxYlnbMOsw+UOc= x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10019020)(6009001)(7916002)(199003)(189002)(13464003)(377454003)(229853002)(189998001)(8676002)(86362001)(2900100001)(77096005)(92566002)(7736002)(7846002)(74316002)(305945005)(50986999)(2950100002)(105586002)(106116001)(5001770100001)(99286002)(97736004)(101416001)(76176999)(54356999)(122556002)(3280700002)(7696004)(3660700001)(5660300001)(106356001)(4326007)(33656002)(66066001)(87936001)(9686002)(102836003)(3846002)(2501003)(6116002)(81156014)(68736007)(81166006)(2906002)(6506003)(8936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0024; H:CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: ffa360a5-1537-448c-685f-08d40e001444 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CS1PR84MB0024; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6060326)(6040281)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041223)(6061324); SRVR:CS1PR84MB0024; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0024; x-forefront-prvs: 01283822F8 received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Nov 2016 09:08:06.7407 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0024 Subject: Re: [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery#### X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2016 09:08:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, This patch looks good to me.=20 Reviewed-by: Sunny Wang Just a suggestion. If we can add the code block below into BmGetFreeOptionN= umber(), I think it would be better. + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount,=20 + LoadOptionTypePlatformRecovery); if (EfiBootManagerFindLoadOption (&Load= Option, LoadOptions, LoadOptionCount) =3D=3D -1) { + for (Index =3D 0; Index < LoadOptionCount; Index++) { + // + // The PlatformRecovery#### options are sorted by OptionNumber. + // Find the the smallest unused number as the new OptionNumber. + // + if (LoadOptions[Index].OptionNumber !=3D Index) { + break; + } + } + LoadOption.OptionNumber =3D Index; + Status =3D EfiBootManagerLoadOptionToVariable (&LoadOption); + ASSERT_EFI_ERROR (Status); + } -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Tuesday, November 15, 2016 6:04 PM To: edk2-devel@lists.01.org Cc: Jie Lin Subject: [edk2] [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting Platform= Recovery#### Current implementation always creates PlatformRecovery0000 pointing to \EFI= \BOOT\BOOT$(ARCH).efi but it may overwrite PlatformRecovery#### created bef= ore (maybe by a DXE driver). The patch only uses the smallest unused option number for the \EFI\BOOT\BOO= T$(ARCH).efi PlatformRecovery#### to avoid overwriting already-created Plat= formRecovery####. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Jie Lin --- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index 48e5351..56034f5 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -834,7 +834,7 @@ BdsEntry ( FilePath =3D FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME); Status =3D EfiBootManagerInitializeLoadOption ( &LoadOption, - 0, + LoadOptionNumberUnassigned, LoadOptionTypePlatformRecovery, LOAD_OPTION_ACTIVE, L"Default PlatformRecovery", @@ -843,9 +843,24 @@ BdsEntry ( 0 ); ASSERT_EFI_ERROR (Status); - EfiBootManagerLoadOptionToVariable (&LoadOption); + LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount,=20 + LoadOptionTypePlatformRecovery); if (EfiBootManagerFindLoadOption (&Load= Option, LoadOptions, LoadOptionCount) =3D=3D -1) { + for (Index =3D 0; Index < LoadOptionCount; Index++) { + // + // The PlatformRecovery#### options are sorted by OptionNumber. + // Find the the smallest unused number as the new OptionNumber. + // + if (LoadOptions[Index].OptionNumber !=3D Index) { + break; + } + } + LoadOption.OptionNumber =3D Index; + Status =3D EfiBootManagerLoadOptionToVariable (&LoadOption); + ASSERT_EFI_ERROR (Status); + } EfiBootManagerFreeLoadOption (&LoadOption); FreePool (FilePath); + EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); =20 // // Report Status Code to indicate connecting drivers will happen -- 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel