From nobody Mon Nov 25 12:18:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69130+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69130+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1608213557; cv=none; d=zohomail.com; s=zohoarc; b=GaXHtU9ZMgXUSIoEI5/HnRsMaN0KW7bcTnwu6VB+B7spJFoitkOcv79fvO/AIpnFwGyDGxa7b8a4Re9YSuy2EFGRYe6IHXwbz7Tm5zM4aelU2H4R0jsLE930Oqr+hUXd63KwVN296GFTjZ9VPZAp0KAVavQB/IxCR4YJyqww9rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608213557; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=oFAnpDKQu7z95F2qHl6Bzk6o1fmmxejTAFB3pJzSBnM=; b=jkxQ+2vkrJuz19TrtndNwy4AmWKR9eVn8TfBKCTLlz/Skb/NktakMEZiN2cOHUvpyV72+OsmU0itdGlJI7KNEJcITdEPQrBo4v0AkM0jeu4JYI5yGXIsJ20pyIuFUN3ENaSQByGNNg4ocLMcCJlos6OE5+PoKIc+g29s+vLaTFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69130+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608213557198650.680971124535; Thu, 17 Dec 2020 05:59:17 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id teFpYY1788612xTCrkHLINB5; Thu, 17 Dec 2020 05:59:16 -0800 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web09.8394.1608213550948580482 for ; Thu, 17 Dec 2020 05:59:11 -0800 IronPort-SDR: Pt8q5WD9WI2YoLrqHtfmsjDHF/Z3znJYu5JHVJ+IogPp6P7G7KTh2+dDBMs0pSpe+KIu+4u8s4 ET8i0q5HDOhw== X-IronPort-AV: E=McAfee;i="6000,8403,9837"; a="175397358" X-IronPort-AV: E=Sophos;i="5.78,428,1599548400"; d="scan'208";a="175397358" X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2020 05:59:09 -0800 IronPort-SDR: 1NVQYSM6PzCa1ZVynPVA+ZK377sz2OjkpSmkxW6fSLoVqggd+6Yqosb57fe055lfq6nu3l6n2y N7JpIkIqJaXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,428,1599548400"; d="scan'208";a="413402604" X-Received: from shwdejointlab96.ccr.corp.intel.com ([10.239.134.88]) by orsmga001.jf.intel.com with ESMTP; 17 Dec 2020 05:59:08 -0800 From: "Tan, Ming" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao Subject: [edk2-devel] [PATCH v5] MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lost Date: Thu, 17 Dec 2020 21:58:59 +0800 Message-Id: <20201217135859.1677-1-ming.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ming.tan@intel.com X-Gm-Message-State: HsLRWOGxd1g9VaQIYp9YweXix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608213556; bh=2tYq0Zz0abSzTuBxiGX1KuVlWmurh3KXBURw+POCsx8=; h=Cc:Date:From:Reply-To:Subject:To; b=Ud84V5sNNMuihbrBuLNuIttt/lTw9wY6TcF7r2xWyVtdwyX+wPdwZUHeekQKCvIG2Io gg/qNRhO0yxTZ58BwL0lJgNHy9gsCcvpMLIINS+10BVgM3SITL2W6SLStAo581ZeF+QqX VRRR5YPfoZsIXNlxRzzoIm/cBMLolWF7mKU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3126 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 Cc: Liming Gao Signed-off-by: Ming Tan --- V5: Fix an unused var bug and compile error using GCC. V4: Fix a spell bug in code comment, change 'a' to 'an' before 'unregister'. V3: Fix a spell bug in commit message, change 'a' to 'an' before 'unregiste= r'. V2: Add the REF link in commit message. .../RuntimeDxe/SerialStatusCodeWorker.c | 10 ++++++++++ .../RuntimeDxe/StatusCodeHandlerRuntimeDxe.c | 17 +---------------- .../RuntimeDxe/StatusCodeHandlerRuntimeDxe.h | 11 +++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStat= usCodeWorker.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/Serial= StatusCodeWorker.c index 0b98e7ec63..f7ab71e32a 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeW= orker.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCodeW= orker.c @@ -151,6 +151,16 @@ SerialStatusCodeReportWorker ( // SerialPortWrite ((UINT8 *) Buffer, CharCount); =20 + // + // If register an unregister function of gEfiEventExitBootServicesGuid, + // then some log called in ExitBootServices() will be lost, + // so unregister the handler after receive the value of exit boot servic= e. + // + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CODE && + Value =3D=3D (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT= _SERVICES)) { + UnregisterBootTimeHandlers(); + } + return EFI_SUCCESS; } =20 diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCode= HandlerRuntimeDxe.c b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/S= tatusCodeHandlerRuntimeDxe.c index a8c0fe5b71..2e11c1f4d2 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.c @@ -10,23 +10,17 @@ #include "StatusCodeHandlerRuntimeDxe.h" =20 EFI_EVENT mVirtualAddressChangeEvent =3D NULL; -static EFI_EVENT mExitBootServicesEvent =3D NULL; EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol =3D NULL; =20 /** Unregister status code callback functions only available at boot time fr= om report status code router when exiting boot services. =20 - @param Event Event whose notification function is being invoked. - @param Context Pointer to the notification function's context, wh= ich is - always zero in current implementation. - **/ VOID EFIAPI UnregisterBootTimeHandlers ( - IN EFI_EVENT Event, - IN VOID *Context + VOID ) { if (PcdGetBool (PcdStatusCodeUseSerial)) { @@ -178,15 +172,6 @@ StatusCodeHandlerRuntimeDxeEntry ( mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, TPL_HIG= H_LEVEL); } =20 - Status =3D gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - UnregisterBootTimeHandlers, - NULL, - &gEfiEventExitBootServicesGuid, - &mExitBootServicesEvent - ); - Status =3D gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, diff --git a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCode= HandlerRuntimeDxe.h b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/S= tatusCodeHandlerRuntimeDxe.h index fd4689c2d7..f1789dc538 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.h +++ b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandler= RuntimeDxe.h @@ -118,4 +118,15 @@ RtMemoryStatusCodeReportWorker ( IN EFI_STATUS_CODE_DATA *Data OPTIONAL ); =20 +/** + Unregister status code callback functions only available at boot time fr= om + report status code router when exiting boot services. + +**/ +VOID +EFIAPI +UnregisterBootTimeHandlers ( + VOID + ); + #endif --=20 2.24.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69130): https://edk2.groups.io/g/devel/message/69130 Mute This Topic: https://groups.io/mt/79036460/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-