From nobody Tue Feb 10 19:14:43 2026 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+106048+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+106048+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1686636826; cv=none; d=zohomail.com; s=zohoarc; b=fqzrgzOCV6hxIYJsZwboDgrePQdtqz9AzBsoMjAC+HoAZZLy8Mpza+vuKVuOLI8U9P93ioWVHZ2VjxpcsD7Cqcj1K2xqAJ/fxbSW+/QYNxae3YckktcbB5k2rYRWYRL740kMOa8xFTncOVJETRYKaeJFRSFmfjUq9A8Q8Xyf8Yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686636826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=t6rXJ8BKNepA2h4ZFjRB5i0OJbTAYLKU5E5x+VzFLt4=; b=eeU5BKp+GulOAG3hMYQtMd1IfhL8NjQprITwznzFEgi3bofZOx4qIfkIRdXbt3j+0BAN2LWfICVd+ZNJ7P+zvVYpj9siHkzfcgPjUceOhNSROktbmd+28g0T3v8FKugnUc1yB+AOKc8JsM8cMTKyWRZ6sJcTdRjXtT+MKKdMJog= 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+106048+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168663682629912.620774677392319; Mon, 12 Jun 2023 23:13:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Pjv3YY1788612x5Ku8JopKuQ; Mon, 12 Jun 2023 23:13:45 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.7304.1686636811551339614 for ; Mon, 12 Jun 2023 23:13:45 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="358238285" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="358238285" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 23:13:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="741306390" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="741306390" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orsmga008.jf.intel.com with ESMTP; 12 Jun 2023 23:13:42 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Jiaxin Wu , Dandan Bi , Liming Gao , Jian J Wang , Eric Dong Subject: [edk2-devel] [PATCH V3 6/8] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Date: Tue, 13 Jun 2023 14:13:23 +0800 Message-Id: <20230613061325.1664-7-ray.ni@intel.com> In-Reply-To: <20230613061325.1664-1-ray.ni@intel.com> References: <20230613061325.1664-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ray.ni@intel.com X-Gm-Message-State: SUECIp3azE1CZ65Dg9P3Wukpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1686636825; bh=Tjg4juyS2VKL10i81f+EmUF89ISoKmKdUQdiawITdcM=; h=Cc:Date:From:Reply-To:Subject:To; b=CWxwqfrWFR3Fs20kC+9qtRTupb8rGslMTe9bTaot0zHahInRvEKcaG/YGgKl2ik56Vm IwbMLl2lIfRii05sck+MAFqB91CGEtssekedbPzXm2IQy0ZP+KrCsKccK+BAk6sJPTgtb vbuxLP0f+nNeVtIxVXig8TKbxTjHaAp7Ggg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686636828096100003 Content-Type: text/plain; charset="utf-8" Because SMM perf-logging is migrated to non-SMRAM at ReadyToBoot by DxeCorePerformanceLib, the perf-logging after ExitBS is useless and impact the SMI latency at runtime. Hence the SmmCorePerformanceLib is updated to disable perf-logging after ExitBS. Cc: Jiaxin Wu Cc: Dandan Bi Cc: Liming Gao Cc: Jian J Wang Reviewed-by: Jiaxin Wu Reviewed-by: Eric Dong Reviewed-by: Jian J Wang --- .../SmmCorePerformanceLib.c | 48 ++++++++++++++++++- .../SmmCorePerformanceLib.inf | 3 +- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 3efe56e056..c566a298dd 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -16,7 +16,7 @@ =20 SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted= input and do basic validation. =20 -Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -48,6 +48,7 @@ SPIN_LOCK mSmmFpdtLock; PERFORMANCE_PROPERTY mPerformanceProperty; UINT32 mCachedLength =3D 0; UINT32 mBootRecordSize =3D 0; +BOOLEAN mPerformanceMeasurementEnabled; =20 // // Interfaces for SMM PerformanceMeasurement Protocol. @@ -929,6 +930,36 @@ FpdtSmiHandler ( return EFI_SUCCESS; } =20 +/** + This is the Event call back function is triggered in SMM to notify the L= ibrary + the system is entering runtime phase. + + @param[in] Protocol Points to the protocol's unique identifier + @param[in] Interface Points to the interface instance + @param[in] Handle The handle on which the interface was installed + + @retval EFI_SUCCESS SmmAtRuntimeCallBack runs successfully + **/ +EFI_STATUS +EFIAPI +SmmCorePerformanceLibExitBootServicesCallback ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + // + // Disable performance measurement after ExitBootServices because + // 1. Performance measurement might impact SMI latency at runtime; + // 2. Performance log is copied to non SMRAM at ReadyToBoot so runtime p= erformance + // log is not useful. + // + mPerformanceMeasurementEnabled =3D FALSE; + + return EFI_SUCCESS; +} + + /** SmmBase2 protocol notify callback function, when SMST and SMM memory ser= vice get initialized this function is callbacked to initialize the Smm Performance Lib @@ -948,6 +979,7 @@ InitializeSmmCorePerformanceLib ( EFI_HANDLE SmiHandle; EFI_STATUS Status; PERFORMANCE_PROPERTY *PerformanceProperty; + VOID *Registration; =20 // // Initialize spin lock @@ -987,6 +1019,16 @@ InitializeSmmCorePerformanceLib ( Status =3D gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, = &mPerformanceProperty); ASSERT_EFI_ERROR (Status); } + + // + // Register callback function for ExitBootServices event. + // + Status =3D gSmst->SmmRegisterProtocolNotify ( + &gEdkiiSmmExitBootServicesProtocolGuid, + SmmCorePerformanceLibExitBootServicesCallback, + &Registration + ); + ASSERT_EFI_ERROR (Status); } =20 /** @@ -1011,6 +1053,8 @@ SmmCorePerformanceLibConstructor ( EFI_EVENT Event; VOID *Registration; =20 + mPerformanceMeasurementEnabled =3D (BOOLEAN)((PcdGet8 (PcdPerformanceLi= braryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D= 0); + if (!PerformanceMeasurementEnabled ()) { // // Do not initialize performance infrastructure if not required. @@ -1383,7 +1427,7 @@ PerformanceMeasurementEnabled ( VOID ) { - return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMA= NCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); + return mPerformanceMeasurementEnabled; } =20 /** diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ib.inf b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i= nf index 9eecc4b58c..9a7e14e80c 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf @@ -8,7 +8,7 @@ # This library is mainly used by SMM Core to start performance logging to= ensure that # SMM Performance and PerformanceEx Protocol are installed at the very be= ginning of SMM phase. # -# Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -58,6 +58,7 @@ =20 [Protocols] gEfiSmmBase2ProtocolGuid ## CONSUMES + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES =20 [Guids] ## PRODUCES ## SystemTable --=20 2.39.1.windows.1 -=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 (#106048): https://edk2.groups.io/g/devel/message/106048 Mute This Topic: https://groups.io/mt/99500188/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-