From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 56E2021EC8D0E for ; Wed, 27 Sep 2017 23:11:06 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 23:14:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="133092324" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 27 Sep 2017 23:14:20 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:14:19 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) 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:14:19 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Thu, 28 Sep 2017 14:13:07 +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//966ACAAIdwgA== Date: Thu, 28 Sep 2017 06:13:07 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B97C285@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> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BA6E76C@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:11:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The commit log is saying the "BootNext" *DELETED* (before PlatformBootManag= erLib) may be *LOST* if there is reset during PlatformBootManagerLib. I rea= lized it. The comment is saying to avoid the "BootNext" "SET" by PlatformBootManagerL= ib. Sorry I am not getting the point. Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 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 boo= ting it This could avoid the "BootNext" set by PlatformBootManagerLib be consumed i= n *this* boot. If I add "*" around "this", is it more clear? Thanks/Ray > -----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"=20 > until booting it >=20 > 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. >=20 > " This could avoid the "BootNext" set by PlatformBootManagerLib be=20 > consumed in this boot. " >=20 >=20 > 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=20 > booting it >=20 > 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. >=20 > The patch defers the deletion of "BootNext" to before booting it. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Eric Dong > Cc: Star Zeng > --- > MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35=20 > ++++++++++++++++++-------- > ------ > 1 file changed, 20 insertions(+), 15 deletions(-) >=20 > 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); >=20 > // > - // Cache and remove the "BootNext" NV variable. > + // Cache the "BootNext" NV variable before calling any=20 > + PlatformBootManagerLib APIs // This could avoid the "BootNext" set=20 > + 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 ( > } > 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); >=20 > // > // Initialize the platform language variables @@ -1052,10 +1042,25=20 > @@ BdsEntry ( >=20 > EfiBootManagerHotkeyBoot (); >=20 > - // > - // Boot to "BootNext" > - // > if (BootNext !=3D NULL) { > + // > + // Delete "BootNext" NV variable before transferring control to=20 > + 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=20 > (BootNextVariableName, &LoadOption); > if (!EFI_ERROR (Status)) { > -- > 2.12.2.windows.2