From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.2541.1608173814129963544 for ; Wed, 16 Dec 2020 18:56:54 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ming.tan@intel.com) IronPort-SDR: NBblZtC2IhpWgNbEQSKp1fi6tPPE7EbG6QV+mI1ZUc+lPdoGnnJs+WOk03KGk/wDrmfdI043Mv +HB31I6drRvA== X-IronPort-AV: E=McAfee;i="6000,8403,9837"; a="259902018" X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="259902018" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2020 18:56:53 -0800 IronPort-SDR: Fs/Q6pnLrVDWCzXe3EqLbPfbfalV+R3byudq7sIZ/YUKGYC3zTVRo8TvCgfsFckcFtZJhLBpyZ 5EmUw/fXqLjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="452576921" Received: from shwdejointlab96.ccr.corp.intel.com ([10.239.134.88]) by fmsmga001.fm.intel.com with ESMTP; 16 Dec 2020 18:56:51 -0800 From: "Tan, Ming" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao Subject: [PATCH] MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lost Date: Thu, 17 Dec 2020 10:56:23 +0800 Message-Id: <20201217025624.1072-1-ming.tan@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 a 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 a unregister function of gEfiEventExitBootServicesGuid, but unregister it after receive the status code of EFI_SW_BS_PC_EXIT_BOOT_SERVICES. Cc: Dandan Bi Cc: Liming Gao Signed-off-by: Ming Tan --- .../RuntimeDxe/SerialStatusCodeWorker.c | 16 ++++++++++++++++ .../RuntimeDxe/StatusCodeHandlerRuntimeDxe.c | 16 +--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStat= usCodeWorker.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/Serial= StatusCodeWorker.c index 0b98e7ec63..4ddeb273c1 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeW= orker.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeW= orker.c @@ -8,6 +8,12 @@ =0D #include "StatusCodeHandlerRuntimeDxe.h"=0D =0D +VOID=0D +EFIAPI=0D +UnregisterBootTimeHandlers (=0D + VOID=0D + );=0D +=0D /**=0D Convert status code value and extended data to readable ASCII string, se= nd string to serial I/O device.=0D =0D @@ -151,6 +157,16 @@ SerialStatusCodeReportWorker ( //=0D SerialPortWrite ((UINT8 *) Buffer, CharCount);=0D =0D + //=0D + // If register a unregister function of gEfiEventExitBootServicesGuid,=0D + // then some log called in ExitBootServices() will be lost,=0D + // so unregister the handler after receive the value of exit boot servic= e.=0D + //=0D + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CODE &&=0D + Value =3D=3D (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT= _SERVICES)) {=0D + UnregisterBootTimeHandlers();=0D + }=0D +=0D return EFI_SUCCESS;=0D }=0D =0D diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCode= HandlerRuntimeDxe.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/S= tatusCodeHandlerRuntimeDxe.c index a8c0fe5b71..011d03f01b 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.c @@ -17,16 +17,11 @@ EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = =3D NULL; Unregister status code callback functions only available at boot time fr= om=0D report status code router when exiting boot services.=0D =0D - @param Event Event whose notification function is being invoked= .=0D - @param Context Pointer to the notification function's context, wh= ich is=0D - always zero in current implementation.=0D -=0D **/=0D VOID=0D EFIAPI=0D UnregisterBootTimeHandlers (=0D - IN EFI_EVENT Event,=0D - IN VOID *Context=0D + VOID=0D )=0D {=0D if (PcdGetBool (PcdStatusCodeUseSerial)) {=0D @@ -178,15 +173,6 @@ StatusCodeHandlerRuntimeDxeEntry ( mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIG= H_LEVEL);=0D }=0D =0D - Status =3D gBS->CreateEventEx (=0D - EVT_NOTIFY_SIGNAL,=0D - TPL_NOTIFY,=0D - UnregisterBootTimeHandlers,=0D - NULL,=0D - &gEfiEventExitBootServicesGuid,=0D - &mExitBootServicesEvent=0D - );=0D -=0D Status =3D gBS->CreateEventEx (=0D EVT_NOTIFY_SIGNAL,=0D TPL_NOTIFY,=0D --=20 2.24.0.windows.2