From nobody Sat May 4 17:59:44 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+69083+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+69083+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1608174376; cv=none; d=zohomail.com; s=zohoarc; b=S213xsh6KA48EiVglMx+DArVduCz9JDctsa6guWc/VE57vCsxlIFLN3HG96NKuqyaZOTmeLquqOAsaAVHoM0+AvZG2UpWHXPVO/zbCJQOmRawVnS3Uz873oM7JOZ3BEUv9WP9sEO7CSWhF9TLFv4QOcUijnPsLgARZzUhTw6vEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608174376; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=7M8iESfCnldWh7siOPpC/Qz/tfkPWr+87M0LMpRXx5w=; b=dfPUzugyJ0AloyCoKD2ViWJH/8hXu55anIC4YlrnvHFORlaxE6MCWatnnkK1t9xtlLTHzWUeIBRQqIF1H4w0u3A393IIOps3DbzxV4PaOg+ZgfFc0plvn7ppokcrxCWokzbMk/ai7pTJlBjIazAvZJe0wuO1X0abKugZEw+5F84= 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+69083+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 1608174376255885.691142623504; Wed, 16 Dec 2020 19:06:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SLYUYY1788612xylwjFkxQOH; Wed, 16 Dec 2020 19:06:15 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.2617.1608174375353229970 for ; Wed, 16 Dec 2020 19:06:15 -0800 IronPort-SDR: Zj/P2P8VOpBG/6mYeUFAMck9W98hM3pgW1ZqhCUPHnTqXfaXaJaciA19v58EYq3/V1GbNNg5OH shd2xNj89KHg== X-IronPort-AV: E=McAfee;i="6000,8403,9837"; a="259903101" X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="259903101" X-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 19:06:15 -0800 IronPort-SDR: OBtgFXjbIicMN4smCK1BQIa6R/lhb7G5H5NRFxDON/1Svq7ZWLecjimY9CeBKkjHo0IKoT27w0 yyyjJxDfK+KA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="452578816" X-Received: from shwdejointlab96.ccr.corp.intel.com ([10.239.134.88]) by fmsmga001.fm.intel.com with ESMTP; 16 Dec 2020 19:06:14 -0800 From: "Tan, Ming" To: devel@edk2.groups.io Cc: Dandan Bi , Liming Gao Subject: [edk2-devel] [PATCH v2] MdeModulePkg/Universal/StatusCodeHandler: Fix a bug about log lost Date: Thu, 17 Dec 2020 11:06:07 +0800 Message-Id: <20201217030607.1177-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: YythytntQC7rGd7mIdiSsN17x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608174375; bh=lIAOK63ItTrUkwiSEAyQVDiAP4aR0VGWS8bPSVF3juk=; h=Cc:Date:From:Reply-To:Subject:To; b=nyyzAxdBHXLuG2auAOVDC/+oi0zcSMzZl1BZUCWyO70fLCQyJ8fWuZNU626cNG+uu/7 J/x4cwdA2Ja5NVq+ovyUFSPFjlx+FzlwTcCpLFxzd2G1pA2GniwmvhVqW9r5hW2OBmvek hqv3nywLZHrjHbCZe/MzR/vTx+QnSYGtW8E= 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 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 --- V2: Add the REF link in commit message. .../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 @@ =20 #include "StatusCodeHandlerRuntimeDxe.h" =20 +VOID +EFIAPI +UnregisterBootTimeHandlers ( + VOID + ); + /** Convert status code value and extended data to readable ASCII string, se= nd string to serial I/O device. =20 @@ -151,6 +157,16 @@ SerialStatusCodeReportWorker ( // SerialPortWrite ((UINT8 *) Buffer, CharCount); =20 + // + // If register a 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..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 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 +173,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, --=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 (#69083): https://edk2.groups.io/g/devel/message/69083 Mute This Topic: https://groups.io/mt/79029143/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-