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.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 9908221EC8D0B for ; Wed, 27 Sep 2017 23:15:11 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 23:18:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="1176566119" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 27 Sep 2017 23:18:25 -0700 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:18:24 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:18:24 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 28 Sep 2017 14:18:22 +0800 From: "Ni, Ruiyu" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it Thread-Index: AQHTOB8ANvzVxUuwyU+Dohamyi8vPqLJzfkg//99YICAAIauMA== Date: Thu, 28 Sep 2017 06:18:22 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA6E7B8@SHSMSX103.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> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B97C285@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: 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:15:11 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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" until > booting it >=20 > The commit log is saying the "BootNext" *DELETED* (before > PlatformBootManagerLib) may be *LOST* if there is reset during > PlatformBootManagerLib. I realized it. >=20 > The comment is saying to avoid the "BootNext" "SET" by > 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" until > booting it >=20 > This could avoid the "BootNext" set by PlatformBootManagerLib be 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 > > 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 > > comment. It seems not match with the commit log. > > > > " This could avoid the "BootNext" set by PlatformBootManagerLib be > > 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 > > Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until > > booting it > > > > Current implementation deletes the "BootNext" before calling any > > PlatformBootManagerLib APIs, but if system resets in > > 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 > > + PlatformBootManagerLib APIs // This could avoid the "BootNext" set > > + by > > PlatformBootManagerLib be consumed in this boot. > > // > > GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) > > &BootNext, &DataSize); > > if (DataSize !=3D sizeof (UINT16)) { > > @@ -817,17 +818,6 @@ BdsEntry ( > > } > > 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 +1042,25 > > @@ BdsEntry ( > > > > EfiBootManagerHotkeyBoot (); > > > > - // > > - // Boot to "BootNext" > > - // > > if (BootNext !=3D NULL) { > > + // > > + // Delete "BootNext" NV variable before transferring control 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 > > (BootNextVariableName), L"Boot%04x", *BootNext); > > Status =3D EfiBootManagerVariableToLoadOption > > (BootNextVariableName, &LoadOption); > > if (!EFI_ERROR (Status)) { > > -- > > 2.12.2.windows.2