From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 DD6BD21B02822 for ; Fri, 22 Feb 2019 01:02:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6970B8762D; Fri, 22 Feb 2019 09:02:21 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-51.rdu2.redhat.com [10.10.120.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A4205D9D4; Fri, 22 Feb 2019 09:02:18 +0000 (UTC) To: "Bi, Dandan" , "edk2-devel@lists.01.org" Cc: "Wu, Hao A" , "Wang, Jian J" , "Ni, Ray" , Sean Brogan , "Zeng, Star" References: <20190221104112.14995-1-lersek@redhat.com> <20190221104112.14995-2-lersek@redhat.com> <3C0D5C461C9E904E8F62152F6274C0BB40B94EFD@SHSMSX104.ccr.corp.intel.com> From: Laszlo Ersek Message-ID: <2c196fe3-bd8f-44a6-9ca7-19f4dc193d8b@redhat.com> Date: Fri, 22 Feb 2019 10:02:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <3C0D5C461C9E904E8F62152F6274C0BB40B94EFD@SHSMSX104.ccr.corp.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 22 Feb 2019 09:02:21 +0000 (UTC) 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 09:02:23 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 02/22/19 02:05, Bi, Dandan wrote: > Hi Laszlo, > > Thanks for helping fix it. > Reviewed-by: Bi Dandan Thanks! I'll wait for Ray's review too. Cheers! Laszlo >> -----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. >> >> 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. >> >> 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. >> >> 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=1539 >> Fixes: c2cf8720a5aad74230767a1f11bade2d86de3745 >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> v3: >> >> - rename BmReportImageFailure() to BmReportLoadFailure() [Ray] >> >> - eliminate PaddingStart and PaddingSize; zero out the full ExtendedData >> struct [Ray] >> >> - don't pick up Ard's R-b due to the change above being functional in >> nature >> >> v2: >> - new in v2 >> >> MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h | 1 + >> MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 65 >> ++++++++++++++------ >> 2 files changed, 48 insertions(+), 18 deletions(-) >> >> 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 >> >> #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; >> } >> >> +/** >> + 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 Boot >> + Service Driver Subclass. ErrorCode will be used 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 service >> + that should be reported. >> +**/ >> +VOID >> +BmReportLoadFailure ( >> + IN UINT32 ErrorCode, >> + IN EFI_STATUS FailureStatus >> + ) >> +{ >> + EFI_RETURN_STATUS_EXTENDED_DATA ExtendedData; >> + >> + if (!ReportErrorCodeEnabled ()) { >> + return; >> + } >> + >> + ASSERT ( >> + (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) || >> + (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED) >> + ); >> + >> + ZeroMem (&ExtendedData, sizeof (ExtendedData)); >> + ExtendedData.ReturnStatus = 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" and >> also signals the EFI ready to boot event. If the device path for the option >> @@ -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 = 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); >> >> -- >> 2.19.1.3.g30247aa5d201 >> >