From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=15.241.140.75; helo=g4t3426.houston.hpe.com; envelope-from=sunnywang@hpe.com; receiver=edk2-devel@lists.01.org Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) (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 A1F8B202E5351 for ; Thu, 28 Jun 2018 02:02:31 -0700 (PDT) Received: from G4W9121.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.210.21.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3426.houston.hpe.com (Postfix) with ESMTPS id 63D5967; Thu, 28 Jun 2018 09:02:30 +0000 (UTC) Received: from G2W6309.americas.hpqcorp.net (2002:10c5:4033::10c5:4033) by G4W9121.americas.hpqcorp.net (2002:10d2:1510::10d2:1510) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Jun 2018 09:02:30 +0000 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (15.241.52.11) by G2W6309.americas.hpqcorp.net (16.197.64.51) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 28 Jun 2018 09:02:30 +0000 Received: from CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.COM (10.169.24.135) by CS1PR8401MB0518.NAMPRD84.PROD.OUTLOOK.COM (10.169.13.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.23; Thu, 28 Jun 2018 09:02:27 +0000 Received: from CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c567:d0e5:c732:9a66]) by CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c567:d0e5:c732:9a66%12]) with mapi id 15.20.0906.023; Thu, 28 Jun 2018 09:02:26 +0000 From: "Wang, Sunny (HPS SW)" To: Ruiyu Ni , "edk2-devel@lists.01.org" CC: Laszlo Ersek , Michael Turner , "Wang, Sunny (HPS SW)" Thread-Topic: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate boot failure Thread-Index: AQHUDrNZHJnPWSGfyUmir/5Ci+1idqR1V78g Date: Thu, 28 Jun 2018 09:02:26 +0000 Message-ID: References: <20180628074020.53444-1-ruiyu.ni@intel.com> In-Reply-To: <20180628074020.53444-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.133] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CS1PR8401MB0518; 7:duxcUJlzrFeNcpGcGM8GHMzdhGZSCg+HkeOFHT97mRGLugE3iDOro0wLRccBfxXC7Y0OSwu+MYiwP5bOtsM4zoeFPJUtw1pSXaG9uJL/SzxGxyXcyohUpAcZo0c2o2tgOXDd7QtVSNdMt5KwDWbG0ISL/tNhi3bs/4JIYcI6PZLenslmqS76t7UeerMRBX6Z+QQ1R5nAgT0uhWaOfz+Nci+lPXpuPmUQo4D+kA7ETPi8A4tmzDBP70a2GXg2cdaq x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10019020)(396003)(366004)(39860400002)(376002)(136003)(346002)(189003)(199004)(13464003)(2906002)(2501003)(81156014)(81166006)(5250100002)(99286004)(53936002)(106356001)(105586002)(7736002)(4326008)(476003)(3846002)(446003)(6116002)(575784001)(486006)(86362001)(97736004)(966005)(14444005)(14454004)(2900100001)(8936002)(11346002)(25786009)(8676002)(256004)(5660300001)(478600001)(229853002)(68736007)(316002)(6246003)(305945005)(6436002)(53546011)(55016002)(6306002)(33656002)(9686003)(6506007)(26005)(102836004)(74316002)(186003)(110136005)(54906003)(7696005)(76176011)(66066001); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR8401MB0518; H:CS1PR8401MB0933.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-office365-filtering-correlation-id: 58544f79-dfea-47c0-8f2f-08d5dcd5ded9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652034)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:CS1PR8401MB0518; x-ms-traffictypediagnostic: CS1PR8401MB0518: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(278428928389397)(89211679590171)(162533806227266)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231254)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:CS1PR8401MB0518; BCL:0; PCL:0; RULEID:; SRVR:CS1PR8401MB0518; x-forefront-prvs: 0717E25089 received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: beNC2Mg3vJePRvCtor+lXd13S6H6Jv7tVKAh8WWc5By+wXzizxsbTYGmhYjLWUi+U/qbqH09nHQd3Okf+/wjqJDbKKt4HZuwOBFOtNTAehFVPYn+hAtMRfpB9p7wNZ8QjGVbTHxwsoS58Tekbkb6AS0XivwgJjX3yAuhvQfldO7Di3oNaeQ0XinV4dVhoYbP3knNXtNnAWLCWvtoCjFekC1RqqAJJIBuCIkA7zaPZe0+cARDHfL8F/HaXa/8J6eP/jJR6MoTw8ZmSWq2bQpXDLZXR1OAzJ+nB9csLCi0cPczlLBbH0o8y02IW8KrGrJmO7yqZfMR8ZBdEZux6qb5xa+dyVHByLNBMDrUinCpOzo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 58544f79-dfea-47c0-8f2f-08d5dcd5ded9 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2018 09:02:26.6266 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0518 X-OriginatorOrg: hpe.com Subject: Re: [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate boot failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 09:02:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, Does the ultimate boot failure include the case where the system doesn't ha= ve "BootManagerMenu" application? If so, I think we should move EfiBootMan= agerUnableBoot() call out of BdsBootManagerMenuLoop(). The BdsBootManagerMe= nuLoop() is only called when system has BootManagerMenu application. Theref= ore, if the system doesn't have BootManagerMenu application, the EfiBootMan= agerUnableBoot() will have no chance to be called for handling the ultimate= boot failure case. =20 =09 Regards, Sunny Wang -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Thursday, June 28, 2018 3:40 PM To: edk2-devel@lists.01.org Cc: Laszlo Ersek ; Michael Turner Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: handle ultimate bo= ot failure When no boot option could be launched including platform recovery options a= nd options pointing to applications built into firmware volumes, a platform= callback registered through EfiBootManagerRegisterUnableBootHandler() is called. If there is no platform callback registered, default behavior is to print a= n error message to the screen and wait for user input. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Sean Brogan Cc: Michael Turner Cc: Laszlo Ersek --- MdeModulePkg/Include/Library/UefiBootManagerLib.h | 48 +++++++++++++++++++= ++++ MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 41 ++++++++++++++= +++++ MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 44 +++++++++++--------= -- 3 files changed, 113 insertions(+), 20 deletions(-) diff --git a/MdeModulePkg/Include/Library/UefiBootManagerLib.h b/MdeModuleP= kg/Include/Library/UefiBootManagerLib.h index bfc0cb86f8..0035c41082 100644 --- a/MdeModulePkg/Include/Library/UefiBootManagerLib.h +++ b/MdeModulePkg/Include/Library/UefiBootManagerLib.h @@ -800,4 +800,52 @@ EFIAPI EfiBootManagerDispatchDeferredImages ( VOID ); + +/** + The function is called when no boot option could be launched, + including platform recovery options and options pointing to=20 +applications + built into firmware volumes. + + The platform may register this function to inform the user about the abo= ve fact. + If this function returns, BDS core attempts to enter an infinite loop=20 +of pulling + up the Boot Manager Menu (if the platform includes the Boot Manager Menu= ). + If the Boot Manager Menu is unavailable, BDS will hang. +**/ +typedef +VOID +(EFIAPI *EFI_BOOT_MANAGER_UNABLE_BOOT) ( + VOID + ); + +/** + Register the callback function when no boot option could be launched, + including platform recovery options and options pointing to=20 +applications + built into firmware volumes. + + @param Handler The callback function. +**/ +VOID +EFIAPI +EfiBootManagerRegisterUnableBootHandler ( + EFI_BOOT_MANAGER_UNABLE_BOOT Handler + ); + +/** + The function is called when no boot option could be launched, + including platform recovery options and options pointing to=20 +applications + built into firmware volumes. + + If this function returns, BDS core attempts to enter an infinite loop=20 + of pulling up the Boot Manager Menu (if the platform includes the Boot M= anager Menu). + If the Boot Manager Menu is unavailable, BDS will hang. + + @retval EFI_SUCCESS The unable-boot callback is called successfully. + @retval EFI_UNSUPPORTED There is no unable-boot callback registered. +**/ +EFI_STATUS +EFIAPI +EfiBootManagerUnableBoot ( + VOID + ); + #endif diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/Library/UefiBootManagerLib/BmBoot.c index 6a23477eb8..122068267d 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -19,6 +19,7 @@ EFI_RAM_DISK_PROTOCOL *mRamDisk = =3D NULL; =20 EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION mBmRefreshLegacyBootOption = =3D NULL; EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = =3D NULL; +EFI_BOOT_MANAGER_UNABLE_BOOT mBmUnableBoot = =3D NULL; =20 /// /// This GUID is used for an EFI Variable that stores the front device pat= hes @@ -2461,3 +2462,43 @@ EfiBootManagerGetBootManagerMenu ( } } =20 +/** + Register the callback function when no boot option could be launched, + including platform recovery options and options pointing to=20 +applications + built into firmware volumes. + + @param Handler The callback function. +**/ +VOID +EFIAPI +EfiBootManagerRegisterUnableBootHandler ( + EFI_BOOT_MANAGER_UNABLE_BOOT Handler + ) +{ + mBmUnableBoot =3D Handler; +} + +/** + The function is called when no boot option could be launched, + including platform recovery options and options pointing to=20 +applications + built into firmware volumes. + + If this function returns, BDS core attempts to enter an infinite loop=20 + of pulling up the Boot Manager Menu (if the platform includes the Boot M= anager Menu). + If the Boot Manager Menu is unavailable, BDS will hang. + + @retval EFI_SUCCESS The unable-boot callback is called successfully. + @retval EFI_UNSUPPORTED There is no unable-boot callback registered. +**/ +EFI_STATUS +EFIAPI +EfiBootManagerUnableBoot ( + VOID + ) +{ + if (mBmUnableBoot !=3D NULL) { + mBmUnableBoot (); + return EFI_SUCCESS; + } + return EFI_UNSUPPORTED; +} diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index 49e403e181..0cb9b04dfb 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -649,32 +649,36 @@ BdsBootManagerMenuLoop ( IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu ) { + EFI_STATUS Status; EFI_INPUT_KEY Key; =20 - // - // Normally BdsDxe does not print anything to the system console, but th= is is - // a last resort -- the end-user will likely not see any DEBUG messages - // logged in this situation. - // - // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->Co= nIn - // here to see if it makes sense to request and wait for a keypress. - // - if (gST->ConIn !=3D NULL) { - AsciiPrint ( - "%a: No bootable option or device was found.\n" - "%a: Press any key to enter the Boot Manager Menu.\n", - gEfiCallerBaseName, - gEfiCallerBaseName - ); - BdsWaitForSingleEvent (gST->ConIn->WaitForKey, 0); - + Status =3D EfiBootManagerUnableBoot (); if (EFI_ERROR (Status)) { + // + // If platform doesn't register any unable-boot callback, this is + // a last resort -- the end-user will likely not see any DEBUG message= s + // logged in this situation. // - // Drain any queued keys. + // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->= ConIn + // here to see if it makes sense to request and wait for a keypress. // - while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) { + if (gST->ConIn !=3D NULL) { + AsciiPrint ( + "%a: No bootable option or device was found.\n" + "%a: Press any key to enter the Boot Manager Menu.\n", + gEfiCallerBaseName, + gEfiCallerBaseName + ); + BdsWaitForSingleEvent (gST->ConIn->WaitForKey, 0); + // - // just throw away Key + // Drain any queued keys. // + while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) { + // + // just throw away Key + // + } } } =20 -- 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel