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.88; helo=mga01.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 272B021EC8D19 for ; Wed, 27 Sep 2017 22:56:42 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2017 22:59:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,448,1500966000"; d="scan'208";a="154252388" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga005.jf.intel.com with ESMTP; 27 Sep 2017 22:59:54 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 27 Sep 2017 22:59:54 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Thu, 28 Sep 2017 13:59:52 +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 Date: Thu, 28 Sep 2017 05:59:52 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B97C214@shsmsx102.ccr.corp.intel.com> References: <20170928055021.111952-1-ruiyu.ni@intel.com> In-Reply-To: <20170928055021.111952-1-ruiyu.ni@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 05:56:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am ok with the code logic change, but a little confused by the new commen= t. 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=20 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 PlatformBo= otManagerLib APIs, but if system resets in PlatformBootManagerLib APIs, "Bo= otNext" 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/Univer= sal/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 by Pl= atformBootManagerLib 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 @@ Bd= sEntry ( =20 EfiBootManagerHotkeyBoot (); =20 - // - // Boot to "BootNext" - // if (BootNext !=3D NULL) { + // + // Delete "BootNext" NV variable before transferring control to it t= o 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