From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 C3F7120945BD7 for ; Wed, 27 Sep 2017 23:18:52 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 23:22:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="904644532" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2017 23:22:06 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:22:06 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:22:05 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 28 Sep 2017 14:22:03 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it Thread-Index: AQHTOB29SqtX3B6Bw0OHpH6yUGBn5aLJzTyQ//966ACAAIdwgP//fT8AgACGWaA= Date: Thu, 28 Sep 2017 06:22:03 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B97C2B5@shsmsx102.ccr.corp.intel.com> References: <20170928055021.111952-1-ruiyu.ni@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B97C214@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BA6E76C@SHSMSX103.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B97C285@shsmsx102.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5BA6E7B8@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BA6E7B8@SHSMSX103.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Sep 2017 06:18:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ok, got it, tks. The new comment is showing why cache "BootNext" logic is s= till kept there, the commit log is showing the reason of the patch change. = Make sense. :) Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 Sent: Thursday, September 28, 2017 2:18 PM To: Zeng, Star ; edk2-devel@lists.01.org Cc: Dong, Eric Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until boo= ting it I didn't change the position of code to cache "BootNext", because: This could avoid the "BootNext" (set by PlatformBootManagerLib) be consumed= in *this* boot. Maybe this time it's more clear. Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Thursday, September 28, 2017 2:13 PM > To: Ni, Ruiyu ; edk2-devel@lists.01.org > Cc: Dong, Eric ; Zeng, Star > Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext"=20 > until booting it >=20 > The commit log is saying the "BootNext" *DELETED* (before > PlatformBootManagerLib) may be *LOST* if there is reset during=20 > PlatformBootManagerLib. I realized it. >=20 > The comment is saying to avoid the "BootNext" "SET" by=20 > PlatformBootManagerLib. Sorry I am not getting the point. >=20 > Thanks, > Star > -----Original Message----- > From: Ni, Ruiyu > Sent: Thursday, September 28, 2017 2:02 PM > To: Zeng, Star ; edk2-devel@lists.01.org > Cc: Dong, Eric > Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext"=20 > until booting it >=20 > This could avoid the "BootNext" set by PlatformBootManagerLib be=20 > consumed in *this* boot. >=20 > If I add "*" around "this", is it more clear? >=20 > Thanks/Ray >=20 > > -----Original Message----- > > From: Zeng, Star > > Sent: Thursday, September 28, 2017 2:00 PM > > To: Ni, Ruiyu ; edk2-devel@lists.01.org > > Cc: Dong, Eric ; Zeng, Star=20 > > > > Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" > > until booting it > > > > I am ok with the code logic change, but a little confused by the new=20 > > comment. It seems not match with the commit log. > > > > " This could avoid the "BootNext" set by PlatformBootManagerLib be=20 > > consumed in this boot. " > > > > > > Thanks, > > Star > > -----Original Message----- > > From: Ni, Ruiyu > > Sent: Thursday, September 28, 2017 1:50 PM > > To: edk2-devel@lists.01.org > > Cc: Dong, Eric ; Zeng, Star=20 > > > > Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until=20 > > booting it > > > > Current implementation deletes the "BootNext" before calling any=20 > > PlatformBootManagerLib APIs, but if system resets in=20 > > PlatformBootManagerLib APIs, "BootNext" is not consumed but lost. > > > > The patch defers the deletion of "BootNext" to before booting it. > > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Ruiyu Ni > > Cc: Eric Dong > > Cc: Star Zeng > > --- > > MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35 > > ++++++++++++++++++-------- > > ------ > > 1 file changed, 20 insertions(+), 15 deletions(-) > > > > diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > > b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > > index ac5f9088dd..a6fe617b56 100644 > > --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > > +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c > > @@ -808,7 +808,8 @@ BdsEntry ( > > ASSERT_EFI_ERROR (Status); > > > > // > > - // Cache and remove the "BootNext" NV variable. > > + // Cache the "BootNext" NV variable before calling any=20 > > + PlatformBootManagerLib APIs // This could avoid the "BootNext"=20 > > + set by > > PlatformBootManagerLib be consumed in this boot. > > // > > GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)=20 > > &BootNext, &DataSize); > > if (DataSize !=3D sizeof (UINT16)) { @@ -817,17 +818,6 @@ BdsEntry=20 > > ( > > } > > BootNext =3D NULL; > > } > > - Status =3D gRT->SetVariable ( > > - EFI_BOOT_NEXT_VARIABLE_NAME, > > - &gEfiGlobalVariableGuid, > > - 0, > > - 0, > > - NULL > > - ); > > - // > > - // Deleting NV variable shouldn't fail unless it doesn't exist. > > - // > > - ASSERT (Status =3D=3D EFI_SUCCESS || Status =3D=3D EFI_NOT_FOUND); > > > > // > > // Initialize the platform language variables @@ -1052,10=20 > > +1042,25 @@ BdsEntry ( > > > > EfiBootManagerHotkeyBoot (); > > > > - // > > - // Boot to "BootNext" > > - // > > if (BootNext !=3D NULL) { > > + // > > + // Delete "BootNext" NV variable before transferring control=20 > > + to it to > > prevent loops. > > + // > > + Status =3D gRT->SetVariable ( > > + EFI_BOOT_NEXT_VARIABLE_NAME, > > + &gEfiGlobalVariableGuid, > > + 0, > > + 0, > > + NULL > > + ); > > + // > > + // Deleting NV variable shouldn't fail unless it doesn't exist. > > + // > > + ASSERT (Status =3D=3D EFI_SUCCESS || Status =3D=3D EFI_NOT_FOUND= ); > > + > > + // > > + // Boot to "BootNext" > > + // > > UnicodeSPrint (BootNextVariableName, sizeof=20 > > (BootNextVariableName), L"Boot%04x", *BootNext); > > Status =3D EfiBootManagerVariableToLoadOption > > (BootNextVariableName, &LoadOption); > > if (!EFI_ERROR (Status)) { > > -- > > 2.12.2.windows.2