From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C3001941579 for ; Thu, 24 Aug 2023 08:43:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=yxfPCMOC8+pMIwa0I4qXTCNsx6/56zDTzzxFnVZ0m5U=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1692866606; v=1; b=HMKqanCVWMronhpi8XcWSPfznX+qIN4hSVErKWdgA0Nzf5oEU57mjDflGnCC7KuMkAqxRl5h UgdXdjOp5VBxsoKvXbBuhTPzOMU+ahQ4qQcUdkPoFzmMGG+DTR2/8fXOFKAdHvKh+6O/NEN6rgF MlhZWMu5uxkbyC8uUWwX/vYg= X-Received: by 127.0.0.2 with SMTP id udGzYY7687511xc5mQrMj7PS; Thu, 24 Aug 2023 01:43:26 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.6676.1692866605425606282 for ; Thu, 24 Aug 2023 01:43:25 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10811"; a="405386079" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="405386079" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 01:43:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10811"; a="713883339" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="713883339" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.43]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 01:43:22 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH] MdeModulePkg/DxeCorePerformanceLib:fix smm perf issue Date: Thu, 24 Aug 2023 16:42:15 +0800 Message-Id: <20230824084215.876-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk 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,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9Nx9MfhVbC4mwfvX9uMZF6lAx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=HMKqanCV; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Fix smm perf issue in DxeCorePerformanceLib. In current code logic, total SMM perf record is copied multiple times to FPDT table if multiple ReadyToBoot events are signaled. This patch changes the function InternalGetSmmPerfData() to only get newly generated Smm perf data. Then previous generated Smm perf data won't be copied to FPDT again. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4470 Signed-off-by: Dun Tan Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni --- MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index ef14bc0738..2c7b960c30 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -10,7 +10,7 @@ This library is mainly used by DxeCore to start performance logging to ensure that Performance Protocol is installed at the very beginning of DXE phase. -Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -73,6 +73,7 @@ UINT8 *mPerformancePointer = NULL; UINT8 *mBootRecordBuffer = NULL; BOOLEAN mLockInsertRecord = FALSE; CHAR8 *mDevicePathString = NULL; +UINTN mBootRecordOffset = 0; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; @@ -236,6 +237,7 @@ InternalGetSmmPerfData ( VOID *SmmBootRecordData; UINTN SmmBootRecordDataSize; UINTN ReservedMemSize; + UINTN CurrentRecordOffset; // // Collect boot records from SMM drivers. @@ -297,28 +299,32 @@ InternalGetSmmPerfData ( } // - // Get all boot records + // Get boot records starting from mBootRecordOffset // - SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET; - SmmBootRecordDataSize = SmmCommData->BootRecordSize; - SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize); + SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET; + SmmCommData->BootRecordOffset = mBootRecordOffset; + SmmBootRecordDataSize = SmmCommData->BootRecordSize - mBootRecordOffset; + SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize); + CurrentRecordOffset = 0; ASSERT (SmmBootRecordData != NULL); - SmmCommData->BootRecordOffset = 0; - SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE); - SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE; - while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) { + SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE); + SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE; + while (CurrentRecordOffset < SmmBootRecordDataSize) { Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize); ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (SmmCommData->ReturnStatus); - if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) { - CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset); + if (CurrentRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) { + CopyMem ((UINT8 *)SmmBootRecordData + CurrentRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - CurrentRecordOffset); } else { - CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); + CopyMem ((UINT8 *)SmmBootRecordData + CurrentRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); } - SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize; + CurrentRecordOffset += SmmCommData->BootRecordSize; + SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize; } + mBootRecordOffset = SmmCommData->BootRecordOffset; + *SmmPerfData = SmmBootRecordData; *SmmPerfDataSize = SmmBootRecordDataSize; } -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108001): https://edk2.groups.io/g/devel/message/108001 Mute This Topic: https://groups.io/mt/100931879/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-