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.556.1686886120507383057 for ; Thu, 15 Jun 2023 20:28:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=e4f9a5eM; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: jian.j.wang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686886120; x=1718422120; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Czx9SEGaTue0Q5eqJXNydhOldxXyEoZVDxXZkJWOhOg=; b=e4f9a5eMzlVrtGXyhW3JvujsxaDja2hXp1U9ebyeYBXvEJh40cmACdyi bCWI44S4Pxyz6IIB2i3DVrG1gGF8yJKKkqkblpqp/M0PBNEnJ26fNyl6c q07zG5iTXqfPPHe1MjMGPCZ0sCmkOVNEfTpEapQ6IdWFlqgtePciJZGNS PKX7kJhhQYaH+uvzYRUjNdAHds5pydDGuMC15C/S97VDkmtW5Y/yiKUI3 +Ny7qtLKm7ecEB9fl1hgFwpa0TByGj3QFYqMFJrYlSLhFYrjc9sQssJ+C 0/uHvNEAeMHLOUIcx8Xi36aA48dJy7l/Q9MFD8rZ4K0nt+/McysBoiK7a A==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="445486720" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="445486720" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 20:28:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="825561418" X-IronPort-AV: E=Sophos;i="6.00,246,1681196400"; d="scan'208";a="825561418" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga002.fm.intel.com with ESMTP; 15 Jun 2023 20:28:31 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 15 Jun 2023 20:28:30 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 15 Jun 2023 20:28:30 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Thu, 15 Jun 2023 20:28:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7kp/ILGan3xh2gEfGqZZKuq1KLkowt6c1BHXurDpAJHO5W7Lpl2U6jVRbOK61cSi70sIgXN408NGCUWM3SMZfMvWyB6qsqZ8gTAkrr+mXAE7hTR1wkcZ0zgCr4VGwBgFv75zKH5v/2LWKGIXb5fV9X4E2+SWawXCXSPQBpHj+04zB3mLHpOPR39+WkK5bETFTNKM4pJPGrKueQzi1gNTVBu5eRMnhqvFB8xQFnqNIbJs084AS3BZLks3L1naJp3uD/rIzCiSdleWA9cPYL31U7Pbvcki/Uw0lHIZWT5YHy+rl9SiEPGAcxJyBb5hKlbD4FnoO7bUAjkNKc1MM05fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2ZEMbnSZ9wL+J8CSpNWrTuO3U3sxOZJYS7NqCqOYwTE=; b=Szk6fV/5a9gRmqZJU7oCjasELEP3iz8a4OXX4esJURhsuPN4nmf4Fz9qK+WXffWaMwk00kqWAuTZ31T/iqkPRU7/sEJZZ4dByr6XeB2zH5tznfYRSYW80Al5UpG9DeG9FTEDEl5auZsCUuOYhafpng7LNhvEIPnOHQVILRsFKDiL54pAYwCS5/rwDoQjza2bmX64j4Gt9Nr88lMaACM7Trf28kQWW8rHlHAcjw//3NBsr2iWkVrjGesaav9q05dTfthimLfylerCvGfXAYSHDOww162sO1JUZ8NnLH/TXtECzj8mN6QFNqPjmUNa+jTn8MjqLMVWOtO5e+K4tirdfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN7PR11MB6749.namprd11.prod.outlook.com (2603:10b6:806:267::22) by MN2PR11MB4631.namprd11.prod.outlook.com (2603:10b6:208:262::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.27; Fri, 16 Jun 2023 03:28:27 +0000 Received: from SN7PR11MB6749.namprd11.prod.outlook.com ([fe80::44ba:3af9:1e34:cf53]) by SN7PR11MB6749.namprd11.prod.outlook.com ([fe80::44ba:3af9:1e34:cf53%7]) with mapi id 15.20.6500.025; Fri, 16 Jun 2023 03:28:27 +0000 From: "Wang, Jian J" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Wu, Jiaxin" , "Bi, Dandan" , "Gao, Liming" , "Dong, Eric" Subject: Re: [PATCH V3 6/8] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Thread-Topic: [PATCH V3 6/8] MdeModulePkg/SmmCorePerformanceLib: Disable perf-logging at runtime Thread-Index: AQHZnb476FCFeIm3aUWuAq/BZoZD7a+MybOg Date: Fri, 16 Jun 2023 03:28:27 +0000 Message-ID: References: <20230613061325.1664-1-ray.ni@intel.com> <20230613061325.1664-7-ray.ni@intel.com> In-Reply-To: <20230613061325.1664-7-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN7PR11MB6749:EE_|MN2PR11MB4631:EE_ x-ms-office365-filtering-correlation-id: 776886b4-355e-4f60-ed38-08db6e19c008 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lA39qeqY/wS4T9uhJPRSxPypt3NRRPECubk2FbDGvgQn0+38CkGzu8zc9PNVDgo2cVW6oToI8JXrtE+HRhhPnXZBA6EtVSEjQWzWT9IB3XNbFa6Q9/TqUYpcrXWXSUpEDyLAX5sfQb/SxtPQsEiNT+FJ0B8IP+JZtYxsofyZSCe7CJmMbKlN8EEQ1tYsBV/P7ZE0qAU9JhelYXeABvi/spr2/ZbjxAF6HoBsuIAbPnMxLrS+E/gRtFI02/aGrD3yIlHdcif7sRXfRjA4+YurrWxWO83jVfmiU8eWUDk7tFLhSlHABSfHcYipGldTg381bWM0SRKZcElQFt6Qg8syV/dyvQB2L6EZbACorBNuxi7I77sLBddrhz0bvbCiv8jaYR/dBPxq07rhLaMYNcPEpZVPfoj57krDTcAAnzpXU5D2qN0XSIpFplFARqeuXgDwkkwzg7ppET2XhcSD0lvcVXBFrS+uJzwdU6hSumK2fX2i4wixQ9fcM069cBrUl97J6DwJxXitqYIgIKDAXAH4S8dqB3ZhpQ36Z5uDHOq3GJCJMCWIDkWlP8VoXcUxWMI7RxHpIuSydS8q6of3CR3DwFecVl8ePl3rmOKwek/uYN5aWkzsarojEEQ0I13DvQr/ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR11MB6749.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(376002)(136003)(39860400002)(346002)(451199021)(110136005)(54906003)(41300700001)(8676002)(86362001)(7696005)(64756008)(66946007)(66556008)(66476007)(66446008)(8936002)(316002)(33656002)(71200400001)(4326008)(76116006)(19627235002)(38070700005)(9686003)(478600001)(26005)(107886003)(55016003)(5660300002)(52536014)(83380400001)(6506007)(53546011)(2906002)(186003)(82960400001)(38100700002)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ItUBqcnBHnbjD0yZ4tJishW65dQPFPUSQ12MtRp1QTutJrXxpC+Sdxlf9p6f?= =?us-ascii?Q?nalxJ7tsstxQIw1LaIt2kRfWEh/UHrMngQizXKe2Jt2FRrIp4aHSzKP3f44q?= =?us-ascii?Q?iqnsC3lr15F0MqVJouvLSGSDp4QDk4FQ9Xuxp3E1W+0FlqT4u8cyRYfcuIgj?= =?us-ascii?Q?Emo7cRYPKDtpPxBFCqQjjxhzCQjqzyLg3aLJ6ka28SM2IQVJ8WsnAnteYSxJ?= =?us-ascii?Q?YFnNGj4/UREdxxZxuNm7v5Pzvdc8Mw4u116uCKDAJPvMNnZYfC/K63dAOIGP?= =?us-ascii?Q?FVM1qBmT3GG7HI1KNIYk9G87X/ub+F9zki8S75wp5KZ1OLJaf7pTBXjy8Viy?= =?us-ascii?Q?taMIS4wlgAZyYxevCt2XCmgshWEQyhbs1zhrzs9RziP2g0V0+esu78kZ3Wvs?= =?us-ascii?Q?jTtUp6IdXNK50D2exCpXp2M/AWASfMUTTjwKnDrmTkISxQ/MufkcXTyV+VDB?= =?us-ascii?Q?w+ghITEzKnLDsiq1TlXhuaHT01jmuGg3DHvbWBtJ41jMNo9O1+xYOjgm52hf?= =?us-ascii?Q?Ve6Mjg33y/L23tAY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ascii?Q?88LFX+WP0OXmfSoYvSr3i4WJwwc5giPhbzBdWcQETOcn6gvOENtm0aU3ot0g?= =?us-ascii?Q?syIhQjRBYD/Gcki6U4l3pF7hGAN/pYMk47FEVnP3vE4L2zG5KLyEj/wgjig0?= =?us-ascii?Q?JHXkcLNd5A60olE0J/wTHscnyE/HJF7Ogi+xZRj8?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN7PR11MB6749.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 776886b4-355e-4f60-ed38-08db6e19c008 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2023 03:28:27.7788 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mcrQ5z53KYgIPkQGiY3bOI6+zNHl7epbyLddaRikTwwVegS/thgjhdlt7ACsp6KNWZb4/kp8IK0mB9lK7MBriA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4631 Return-Path: jian.j.wang@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang Regards, Jian > -----Original Message----- > From: Ni, Ray > Sent: Tuesday, June 13, 2023 2:13 PM > To: devel@edk2.groups.io > Cc: Wu, Jiaxin ; Bi, Dandan ; G= ao, > Liming ; Wang, Jian J ; > Dong, Eric > Subject: [PATCH V3 6/8] MdeModulePkg/SmmCorePerformanceLib: Disable > perf-logging at runtime >=20 > 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. >=20 > Cc: Jiaxin Wu > Cc: Dandan Bi > Cc: Liming Gao > Cc: Jian J Wang > Reviewed-by: Jiaxin Wu > Reviewed-by: Eric Dong > --- > .../SmmCorePerformanceLib.c | 48 ++++++++++++++++++- > .../SmmCorePerformanceLib.inf | 3 +- > 2 files changed, 48 insertions(+), 3 deletions(-) >=20 > diff --git > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib. > 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 >=20 > SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive > untrusted input and do basic validation. >=20 >=20 >=20 > -Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
>=20 > +Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 >=20 >=20 > **/ >=20 > @@ -48,6 +48,7 @@ SPIN_LOCK mSmmFpdtLock; > PERFORMANCE_PROPERTY mPerformanceProperty; >=20 > UINT32 mCachedLength =3D 0; >=20 > UINT32 mBootRecordSize =3D 0; >=20 > +BOOLEAN mPerformanceMeasurementEnabled; >=20 >=20 >=20 > // >=20 > // Interfaces for SMM PerformanceMeasurement Protocol. >=20 > @@ -929,6 +930,36 @@ FpdtSmiHandler ( > return EFI_SUCCESS; >=20 > } >=20 >=20 >=20 > +/** >=20 > + This is the Event call back function is triggered in SMM to notify the= Library >=20 > + the system is entering runtime phase. >=20 > + >=20 > + @param[in] Protocol Points to the protocol's unique identifier >=20 > + @param[in] Interface Points to the interface instance >=20 > + @param[in] Handle The handle on which the interface was installed >=20 > + >=20 > + @retval EFI_SUCCESS SmmAtRuntimeCallBack runs successfully >=20 > + **/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +SmmCorePerformanceLibExitBootServicesCallback ( >=20 > + IN CONST EFI_GUID *Protocol, >=20 > + IN VOID *Interface, >=20 > + IN EFI_HANDLE Handle >=20 > + ) >=20 > +{ >=20 > + // >=20 > + // Disable performance measurement after ExitBootServices because >=20 > + // 1. Performance measurement might impact SMI latency at runtime; >=20 > + // 2. Performance log is copied to non SMRAM at ReadyToBoot so runtime > performance >=20 > + // log is not useful. >=20 > + // >=20 > + mPerformanceMeasurementEnabled =3D FALSE; >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > + >=20 > + >=20 > /** >=20 > SmmBase2 protocol notify callback function, when SMST and SMM memory > service get initialized >=20 > this function is callbacked to initialize the Smm Performance Lib >=20 > @@ -948,6 +979,7 @@ InitializeSmmCorePerformanceLib ( > EFI_HANDLE SmiHandle; >=20 > EFI_STATUS Status; >=20 > PERFORMANCE_PROPERTY *PerformanceProperty; >=20 > + VOID *Registration; >=20 >=20 >=20 > // >=20 > // Initialize spin lock >=20 > @@ -987,6 +1019,16 @@ InitializeSmmCorePerformanceLib ( > Status =3D gBS->InstallConfigurationTable (&gPerformanceProtocolGuid= , > &mPerformanceProperty); >=20 > ASSERT_EFI_ERROR (Status); >=20 > } >=20 > + >=20 > + // >=20 > + // Register callback function for ExitBootServices event. >=20 > + // >=20 > + Status =3D gSmst->SmmRegisterProtocolNotify ( >=20 > + &gEdkiiSmmExitBootServicesProtocolGuid, >=20 > + SmmCorePerformanceLibExitBootServicesCallback, >=20 > + &Registration >=20 > + ); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > } >=20 >=20 >=20 > /** >=20 > @@ -1011,6 +1053,8 @@ SmmCorePerformanceLibConstructor ( > EFI_EVENT Event; >=20 > VOID *Registration; >=20 >=20 >=20 > + mPerformanceMeasurementEnabled =3D (BOOLEAN)((PcdGet8 > (PcdPerformanceLibraryPropertyMask) & > PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); >=20 > + >=20 > if (!PerformanceMeasurementEnabled ()) { >=20 > // >=20 > // Do not initialize performance infrastructure if not required. >=20 > @@ -1383,7 +1427,7 @@ PerformanceMeasurementEnabled ( > VOID >=20 > ) >=20 > { >=20 > - return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & > PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) !=3D 0); >=20 > + return mPerformanceMeasurementEnabled; >=20 > } >=20 >=20 >=20 > /** >=20 > diff --git > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i > nf > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i > nf > index 9eecc4b58c..9a7e14e80c 100644 > --- > a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i > nf > +++ > b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i > nf > @@ -8,7 +8,7 @@ > # This library is mainly used by SMM Core to start performance logging = to > ensure that >=20 > # SMM Performance and PerformanceEx Protocol are installed at the very > beginning of SMM phase. >=20 > # >=20 > -# Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved. >=20 > +# Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved. >=20 > # SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > # >=20 > ## >=20 > @@ -58,6 +58,7 @@ >=20 >=20 > [Protocols] >=20 > gEfiSmmBase2ProtocolGuid ## CONSUMES >=20 > + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES >=20 >=20 >=20 > [Guids] >=20 > ## PRODUCES ## SystemTable >=20 > -- > 2.39.1.windows.1