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=ruiyu.ni@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 B76B521EC8CEB for ; Wed, 27 Sep 2017 22:58:25 -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:01:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="904639114" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2017 23:01:39 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) 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:01:39 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 23:01:38 -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:01:36 +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 Date: Thu, 28 Sep 2017 06:01:36 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA6E76C@SHSMSX103.ccr.corp.intel.com> References: <20170928055021.111952-1-ruiyu.ni@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B97C214@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B97C214@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 05:58:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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" until > booting it >=20 > I am ok with the code logic change, but a little confused by the new comm= ent. It > seems not match with the commit log. >=20 > " This could avoid the "BootNext" set by PlatformBootManagerLib be consum= ed > 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 booti= ng > it >=20 > Current implementation deletes the "BootNext" before calling any > PlatformBootManagerLib APIs, but if system resets in PlatformBootManagerL= ib > 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 ++++++++++++++++++-------- > ------ > 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 > + 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); >=20 > // > // Initialize the platform language variables @@ -1052,10 +1042,25 @@ > BdsEntry ( >=20 > EfiBootManagerHotkeyBoot (); >=20 > - // > - // 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 (BootNextVariableNam= e, > &LoadOption); > if (!EFI_ERROR (Status)) { > -- > 2.12.2.windows.2