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.100; helo=mga07.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 D6512208D6126 for ; Thu, 21 Feb 2019 17:07:37 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2019 17:07:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,397,1544515200"; d="scan'208";a="321082210" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 21 Feb 2019 17:07:36 -0800 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 21 Feb 2019 17:07:36 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 21 Feb 2019 17:07:36 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.172]) with mapi id 14.03.0415.000; Fri, 22 Feb 2019 09:05:36 +0800 From: "Bi, Dandan" To: Laszlo Ersek , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Wang, Jian J" , "Ni, Ray" , Sean Brogan , "Zeng, Star" Thread-Topic: [PATCH v3 1/5] MdeModulePkg/UefiBootManagerLib: fix LoadImage/StartImage status code rep. Thread-Index: AQHUydIBCFQfotYbuUefd3XKF3cMT6XrAS3g Date: Fri, 22 Feb 2019 01:05:36 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB40B94EFD@SHSMSX104.ccr.corp.intel.com> References: <20190221104112.14995-1-lersek@redhat.com> <20190221104112.14995-2-lersek@redhat.com> In-Reply-To: <20190221104112.14995-2-lersek@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v3 1/5] MdeModulePkg/UefiBootManagerLib: fix LoadImage/StartImage status code rep. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2019 01:07:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Laszlo, Thanks for helping fix it. Reviewed-by: Bi Dandan Thanks, Dandan > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Thursday, February 21, 2019 6:41 PM > To: edk2-devel@lists.01.org > Cc: Bi, Dandan ; Wu, Hao A ; > Wang, Jian J ; Ni, Ray ; Sean > Brogan ; Zeng, Star > Subject: [PATCH v3 1/5] MdeModulePkg/UefiBootManagerLib: fix > LoadImage/StartImage status code rep. >=20 > In the EFI_RETURN_STATUS_EXTENDED_DATA structure from PI-1.7, there > may be padding between the DataHeader and ReturnStatus members. The > REPORT_STATUS_CODE_EX() macro starts populating the structure > immediately after DataHeader, therefore the source data must provide for > the padding. >=20 > Extract the BmReportLoadFailure() function from EfiBootManagerBoot(), > prepare a zero padding (if any) in a temporary > EFI_RETURN_STATUS_EXTENDED_DATA object, and fix the > REPORT_STATUS_CODE_EX() macro invocation. >=20 > Cc: Dandan Bi > Cc: Hao Wu > Cc: Jian J Wang > Cc: Ray Ni > Cc: Sean Brogan > Cc: Star Zeng > Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1539 > Fixes: c2cf8720a5aad74230767a1f11bade2d86de3745 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek > --- >=20 > Notes: > v3: >=20 > - rename BmReportImageFailure() to BmReportLoadFailure() [Ray] >=20 > - eliminate PaddingStart and PaddingSize; zero out the full ExtendedD= ata > struct [Ray] >=20 > - don't pick up Ard's R-b due to the change above being functional in > nature >=20 > v2: > - new in v2 >=20 > MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h | 1 + > MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 65 > ++++++++++++++------ > 2 files changed, 48 insertions(+), 18 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > index 978fbff966f6..0fef63fceedf 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > @@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #include #include > #include > +#include > #include >=20 > #include > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > index 9be1633b7480..02ff354ef6a3 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > @@ -1667,6 +1667,51 @@ BmIsBootManagerMenuFilePath ( > return FALSE; > } >=20 > +/** > + Report status code with EFI_RETURN_STATUS_EXTENDED_DATA about > +LoadImage() or > + StartImage() failure. > + > + @param[in] ErrorCode An Error Code in the Software Class, DXE Boo= t > + Service Driver Subclass. ErrorCode will be u= sed to > + compose the Value parameter for status code > + reporting. Must be one of > + EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and > + EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED. > + > + @param[in] FailureStatus The failure status returned by the boot serv= ice > + that should be reported. > +**/ > +VOID > +BmReportLoadFailure ( > + IN UINT32 ErrorCode, > + IN EFI_STATUS FailureStatus > + ) > +{ > + EFI_RETURN_STATUS_EXTENDED_DATA ExtendedData; > + > + if (!ReportErrorCodeEnabled ()) { > + return; > + } > + > + ASSERT ( > + (ErrorCode =3D=3D EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) || > + (ErrorCode =3D=3D EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED) > + ); > + > + ZeroMem (&ExtendedData, sizeof (ExtendedData)); > + ExtendedData.ReturnStatus =3D FailureStatus; > + > + REPORT_STATUS_CODE_EX ( > + (EFI_ERROR_CODE | EFI_ERROR_MINOR), > + (EFI_SOFTWARE_DXE_BS_DRIVER | ErrorCode), > + 0, > + NULL, > + NULL, > + &ExtendedData.DataHeader + 1, > + sizeof (ExtendedData) - sizeof (ExtendedData.DataHeader) > + ); > +} > + > /** > Attempt to boot the EFI boot option. This routine sets L"BootCurent" a= nd > also signals the EFI ready to boot event. If the device path for the o= ption > @@ -1822,15 +1867,7 @@ EfiBootManagerBoot ( > // > // Report Status Code with the failure status to indicate that the= failure to > load boot option > // > - REPORT_STATUS_CODE_EX ( > - EFI_ERROR_CODE | EFI_ERROR_MINOR, > - (EFI_SOFTWARE_DXE_BS_DRIVER | > EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR), > - 0, > - NULL, > - NULL, > - &Status, > - sizeof (EFI_STATUS) > - ); > + BmReportLoadFailure > (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, > + Status); > BootOption->Status =3D Status; > // > // Destroy the RAM disk > @@ -1911,15 +1948,7 @@ EfiBootManagerBoot ( > // > // Report Status Code with the failure status to indicate that boot = failure > // > - REPORT_STATUS_CODE_EX ( > - EFI_ERROR_CODE | EFI_ERROR_MINOR, > - (EFI_SOFTWARE_DXE_BS_DRIVER | > EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED), > - 0, > - NULL, > - NULL, > - &Status, > - sizeof (EFI_STATUS) > - ); > + BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, > Status); > } > PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) > OptionNumber); >=20 > -- > 2.19.1.3.g30247aa5d201 >=20