]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lost
authorTan, Ming <ming.tan@intel.com>
Fri, 18 Dec 2020 04:50:46 +0000 (12:50 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 22 Dec 2020 08:23:51 +0000 (08:23 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3126

1. If use PeiDxeDebugLibReportStatusCode as DebugLib, then some logs
after ExitBootService() will be lost.
2. The root cause:
2.1 The original code will register an unregister function
of gEfiEventExitBootServicesGuid, this unregister function will call
EFI_RSC_HANDLER_PROTOCOL->Unregister and does not support log through
serial port.
2.2 And some other drivers also register call back funtions of
gEfiEventExitBootServicesGuid.
2.3 Then after the unregister function is called, other call back
functions can't out log if them use RSC as DebugLib.
3. The DxeMain will report status code EFI_SW_BS_PC_EXIT_BOOT_SERVICES
after notify all the call back functions of
gEfiEventExitBootServicesGuid.
4. Solution: the StatusCodeHandlerRuntimeDxe.c will not register an
unregister function of gEfiEventExitBootServicesGuid, but unregister it
after receive the status code of EFI_SW_BS_PC_EXIT_BOOT_SERVICES.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Ming Tan <ming.tan@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeWorker.c
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.c
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.h

index 0b98e7ec6315f81f10a344ba3ec5f2614f0dc8b9..348f55edba544c44ca18dd04c5e99f3e925a3f1c 100644 (file)
@@ -151,6 +151,16 @@ SerialStatusCodeReportWorker (
   //\r
   SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
 \r
+  //\r
+  // If register an unregister function of gEfiEventExitBootServicesGuid,\r
+  // then some log called in ExitBootServices() will be lost,\r
+  // so unregister the handler after receive the value of exit boot service.\r
+  //\r
+  if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE &&\r
+      Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {\r
+    UnregisterSerialBootTimeHandlers();\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
index a8c0fe5b7149b5a71e2dc988f6cdacdf7f12c88a..d50335af8a19551b7210a516929e2a2ef1f61cd5 100644 (file)
 #include "StatusCodeHandlerRuntimeDxe.h"\r
 \r
 EFI_EVENT                 mVirtualAddressChangeEvent = NULL;\r
-static EFI_EVENT          mExitBootServicesEvent     = NULL;\r
 EFI_RSC_HANDLER_PROTOCOL  *mRscHandlerProtocol       = NULL;\r
 \r
 /**\r
   Unregister status code callback functions only available at boot time from\r
   report status code router when exiting boot services.\r
 \r
-  @param  Event         Event whose notification function is being invoked.\r
-  @param  Context       Pointer to the notification function's context, which is\r
-                        always zero in current implementation.\r
-\r
 **/\r
 VOID\r
 EFIAPI\r
-UnregisterBootTimeHandlers (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
+UnregisterSerialBootTimeHandlers (\r
+  VOID\r
   )\r
 {\r
   if (PcdGetBool (PcdStatusCodeUseSerial)) {\r
@@ -178,15 +172,6 @@ StatusCodeHandlerRuntimeDxeEntry (
     mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIGH_LEVEL);\r
   }\r
 \r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  UnregisterBootTimeHandlers,\r
-                  NULL,\r
-                  &gEfiEventExitBootServicesGuid,\r
-                  &mExitBootServicesEvent\r
-                  );\r
-\r
   Status = gBS->CreateEventEx (\r
                   EVT_NOTIFY_SIGNAL,\r
                   TPL_NOTIFY,\r
index fd4689c2d745ddd455af80a642077856c017b7b1..a2cf2ae0b7efc228f8704ce1ac45d6a5aa2fe06a 100644 (file)
@@ -118,4 +118,15 @@ RtMemoryStatusCodeReportWorker (
   IN EFI_STATUS_CODE_DATA               *Data OPTIONAL\r
   );\r
 \r
+/**\r
+  Unregister status code callback functions only available at boot time from\r
+  report status code router when exiting boot services.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+UnregisterSerialBootTimeHandlers (\r
+  VOID\r
+  );\r
+\r
 #endif\r