]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UefiBootManagerLib: fix LoadImage/StartImage status code rep.
authorLaszlo Ersek <lersek@redhat.com>
Wed, 20 Feb 2019 02:31:28 +0000 (03:31 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 25 Feb 2019 10:50:51 +0000 (11:50 +0100)
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 <dandan.bi@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1539
Fixes: c2cf8720a5aad74230767a1f11bade2d86de3745
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h

index d5957db610d93c7d49dbce89bec00ce29fd2d030..4ce83ce22d617620ceb98f90824525da9c2b358c 100644 (file)
@@ -1667,6 +1667,51 @@ BmIsBootManagerMenuFilePath (
   return FALSE;\r
 }\r
 \r
+/**\r
+  Report status code with EFI_RETURN_STATUS_EXTENDED_DATA about LoadImage() or\r
+  StartImage() failure.\r
+\r
+  @param[in] ErrorCode      An Error Code in the Software Class, DXE Boot\r
+                            Service Driver Subclass. ErrorCode will be used to\r
+                            compose the Value parameter for status code\r
+                            reporting. Must be one of\r
+                            EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and\r
+                            EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED.\r
+\r
+  @param[in] FailureStatus  The failure status returned by the boot service\r
+                            that should be reported.\r
+**/\r
+VOID\r
+BmReportLoadFailure (\r
+  IN UINT32     ErrorCode,\r
+  IN EFI_STATUS FailureStatus\r
+  )\r
+{\r
+  EFI_RETURN_STATUS_EXTENDED_DATA ExtendedData;\r
+\r
+  if (!ReportErrorCodeEnabled ()) {\r
+    return;\r
+  }\r
+\r
+  ASSERT (\r
+    (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) ||\r
+    (ErrorCode == EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)\r
+    );\r
+\r
+  ZeroMem (&ExtendedData, sizeof (ExtendedData));\r
+  ExtendedData.ReturnStatus = FailureStatus;\r
+\r
+  REPORT_STATUS_CODE_EX (\r
+    (EFI_ERROR_CODE | EFI_ERROR_MINOR),\r
+    (EFI_SOFTWARE_DXE_BS_DRIVER | ErrorCode),\r
+    0,\r
+    NULL,\r
+    NULL,\r
+    &ExtendedData.DataHeader + 1,\r
+    sizeof (ExtendedData) - sizeof (ExtendedData.DataHeader)\r
+    );\r
+}\r
+\r
 /**\r
   Attempt to boot the EFI boot option. This routine sets L"BootCurent" and\r
   also signals the EFI ready to boot event. If the device path for the option\r
@@ -1822,15 +1867,7 @@ EfiBootManagerBoot (
       //\r
       // Report Status Code with the failure status to indicate that the failure to load boot option\r
       //\r
-      REPORT_STATUS_CODE_EX (\r
-        EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR),\r
-        0,\r
-        NULL,\r
-        NULL,\r
-        &Status,\r
-        sizeof (EFI_STATUS)\r
-        );\r
+      BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);\r
       BootOption->Status = Status;\r
       //\r
       // Destroy the RAM disk\r
@@ -1911,15 +1948,7 @@ EfiBootManagerBoot (
     //\r
     // Report Status Code with the failure status to indicate that boot failure\r
     //\r
-    REPORT_STATUS_CODE_EX (\r
-      EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
-      (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED),\r
-      0,\r
-      NULL,\r
-      NULL,\r
-      &Status,\r
-      sizeof (EFI_STATUS)\r
-      );\r
+    BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status);\r
   }\r
   PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);\r
 \r
index 978fbff966f6eeba850ef3157039e6cf45414dbb..0fef63fceedf47a902a9a80203287cb451dd48af 100644 (file)
@@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/MemoryTypeInformation.h>\r
 #include <Guid/FileInfo.h>\r
 #include <Guid/GlobalVariable.h>\r
+#include <Guid/StatusCodeDataTypeId.h>\r
 #include <Guid/StatusCodeDataTypeVariable.h>\r
 \r
 #include <Library/PrintLib.h>\r