From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=15.233.44.25; helo=g2t2352.austin.hpe.com; envelope-from=sunnywang@hpe.com; receiver=edk2-devel@lists.01.org Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) (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 3CEFA21EC8D13 for ; Wed, 27 Sep 2017 23:44:25 -0700 (PDT) Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id 9057191 for ; Thu, 28 Sep 2017 06:47:39 +0000 (UTC) Received: from G9W8670.americas.hpqcorp.net (16.220.49.29) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 28 Sep 2017 06:47:17 +0000 Received: from G1W8106.americas.hpqcorp.net (16.193.72.61) by G9W8670.americas.hpqcorp.net (16.220.49.29) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 28 Sep 2017 06:47:16 +0000 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (15.241.52.12) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1178.4 via Frontend Transport; Thu, 28 Sep 2017 06:46:55 +0000 Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.26) by CS1PR84MB0296.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Thu, 28 Sep 2017 06:46:53 +0000 Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) by CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) with mapi id 15.20.0077.016; Thu, 28 Sep 2017 06:46:53 +0000 From: "Wang, Sunny (HPS SW)" To: Ruiyu Ni , "edk2-devel@lists.01.org" CC: Eric Dong , Star Zeng , "Wang, Sunny (HPS SW)" Thread-Topic: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it Thread-Index: AQHTOB23lNevkAazlUGC1e5nDu9LE6LJ10FQ Date: Thu, 28 Sep 2017 06:46:53 +0000 Message-ID: References: <20170928055021.111952-1-ruiyu.ni@intel.com> In-Reply-To: <20170928055021.111952-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sunnywang@hpe.com; x-originating-ip: [16.242.247.135] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CS1PR84MB0296; 6:dN2jhlJTjAX/zzQD70TRD1Ylb8LurdGECCrGWgwNF+Ofqw9MVfzPsJlsPo4QO41e/5BpeQryL2KxrnQrJ6gaCk9oU5WYkr0/QqlUZv0yTJ6lZZ+D4OoWkNc99wqlS7xkfzeFntYn65pMuhvPnnpADDlA+7LMwK5OcgNeU7DiLQoAe6+FsEoFSoL48/cISmOkdUL24+W3w1jLWdy4bEoXg/DilDubzWZozhZt/HquGCFMS/+xz1BeQlqTmDW/tRooSPSqYleZHHjkVR8XUQ2mATcbUsW0WqappV03Pc3Z5uOncNW51jGbF/dwAAKERzSQBKTo4oT0+pNtXiq0goXloA==; 5:yDC3gLM7VtcBywP1ooLe2OYeWIhP1Eg4BUoPemIpZR/OBx9yMVI2iQBk8P7vI1G3czwnKeljcXOzsG2FjyGIxzb+FafgrgTh7A5jTQEPa2rAkO3QAoTZjrvWezxqzxJiTJGwD7twgNIYo6Jse/NOaw==; 24:Bp694UVj+ZDEOmwIDc1rj5r7KEdfdz7KLk1SV6QvWjbBnYYmCv1QjN81DOabAXOLxCfg/BX0GipgdSiO9bSfOvhgBrbR6U7anPKme1WOxiw=; 7:MONApWJUocA9xQeo4HCLBN1K4VAngNw9jsj86MPYHrs1NYhcICFlnIIoO7eyy8zHcBwKFJ+B/hLUNblyqDNa+eaB0uDubK49yy+8jCLgvaMgl9VbmqIOluQ/V5WO01L+xenEfBjPJQSVn8SxIhdJyXRzYYsxDP4hPXPnvYyE/Wudm+Ek+osaj3uTxkR7a/Fzi63F74kvMWE8QRm9KiE3uCqOdvePaNa8P1cbqyV/kNs= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(376002)(346002)(199003)(189002)(377454003)(13464003)(25786009)(53546010)(54356999)(229853002)(6506006)(77096006)(101416001)(6436002)(2900100001)(2950100002)(33656002)(105586002)(81156014)(106356001)(81166006)(8936002)(76176999)(478600001)(74316002)(966005)(9686003)(2501003)(14454004)(305945005)(97736004)(7696004)(54906003)(8676002)(50986999)(3660700001)(7736002)(110136005)(66066001)(55016002)(53936002)(6306002)(6246003)(316002)(4326008)(3280700002)(189998001)(68736007)(86362001)(102836003)(2906002)(3846002)(5660300001)(6116002)(19627235001); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0296; H:CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: a382aba5-ca84-4d32-4a20-08d5063cb408 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:CS1PR84MB0296; x-ms-traffictypediagnostic: CS1PR84MB0296: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CS1PR84MB0296; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CS1PR84MB0296; x-forefront-prvs: 0444EB1997 received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2017 06:46:53.0258 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0296 X-OriginatorOrg: hpe.com 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:44:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The change Looks good to me.=20 Also, Good to see you adding the comment about why we need to cache BootNex= t before all the platform hook function calls. :) Reviewed-by: Sunny Wang Regards, Sunny Wang -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Thursday, September 28, 2017 1:50 PM To: edk2-devel@lists.01.org Cc: Eric Dong ; Star Zeng Subject: [edk2] [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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel