From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B4D1481EF5 for ; Wed, 16 Nov 2016 02:16:13 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP; 16 Nov 2016 02:16:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,647,1473145200"; d="scan'208";a="31936882" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 16 Nov 2016 02:16:18 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Nov 2016 02:16:17 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Nov 2016 02:16:17 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.142]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.138]) with mapi id 14.03.0248.002; Wed, 16 Nov 2016 18:16:15 +0800 From: "Ni, Ruiyu" To: "Wang, Sunny (HPS SW)" , "edk2-devel@lists.01.org" CC: "Haskell, Darrell" , "Lin, Jie" Thread-Topic: [edk2] [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting PlatformRecovery#### Thread-Index: AQHSPye82hCUb34/JkmFCL9weLRJ+6DazXYAgACWMrA= Date: Wed, 16 Nov 2016 10:16:15 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D58E7BB73@SHSMSX104.ccr.corp.intel.com> References: <20161115100425.299856-1-ruiyu.ni@intel.com> <20161115100425.299856-4-ruiyu.ni@intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGI0ZjEyMTUtMzQyMS00OWZmLTgzOGItY2U1OWFmZDcwN2RhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ikg5eFJ6aDM4U2xVY0JuMlpQNnU3TEpsNDFRcm5DeGdIeDRcL2VZNjlIZXpRPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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 10:16:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable BmGetFreeOptionNumber() is internal function. It cannot be used by BdsDxe d= river. If we found more usages for BmGetFreeOptionNumber() we can expose it public= ly and enhance the logic to support find free number for load option who doesn't h= ave associated *Order NV variable. Regards, Ray >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wan= g, Sunny (HPS SW) >Sent: Wednesday, November 16, 2016 5:08 PM >To: Ni, Ruiyu ; edk2-devel@lists.01.org >Cc: Haskell, Darrell ; Lin, Jie >Subject: Re: [edk2] [PATCH 3/3] MdeModulePkg/BdsDxe: Avoid overwriting Pla= tformRecovery#### > >Hi Ray, >This patch looks good to me. >Reviewed-by: Sunny Wang > >Just a suggestion. If we can add the code block below into BmGetFreeOption= Number(), I think it would be better. > >+ LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, >+ LoadOptionTypePlatformRecovery); if (EfiBootManagerFindLoadOption (&Loa= dOption, 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 Rui= yu 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 Platfor= mRecovery#### > >Current implementation always creates PlatformRecovery0000 pointing to \EF= I\BOOT\BOOT$(ARCH).efi but it may overwrite >PlatformRecovery#### created before (maybe by a DXE driver). > >The patch only uses the smallest unused option number for the \EFI\BOOT\BO= OT$(ARCH).efi PlatformRecovery#### to avoid >overwriting already-created PlatformRecovery####. > >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/Unive= rsal/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, >+ LoadOptionTypePlatformRecovery); if (EfiBootManagerFindLoadOption (&Loa= dOption, 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); > > // > // 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 >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel