From nobody Tue May 7 22:19:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1530509414332216.7957138744123; Sun, 1 Jul 2018 22:30:14 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5F1842096F346; Sun, 1 Jul 2018 22:30:13 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E38972096F33B for ; Sun, 1 Jul 2018 22:30:12 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jul 2018 22:30:12 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga004.jf.intel.com with ESMTP; 01 Jul 2018 22:30:11 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,298,1526367600"; d="scan'208";a="212712785" From: Dandan Bi To: edk2-devel@lists.01.org Date: Mon, 2 Jul 2018 13:29:52 +0800 Message-Id: <20180702052952.201536-1-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [patch] MdeModulePkg/SmmCorePerformanceLib: Update mPerformanceLength X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In mSmmBootPerformanceTable there are two parts, one is the FPDT table header and the other is FPDT records. Currently: mPerformanceLength: The length of existing FPDT records. mMaxPerformanceLength: The maximum length allocated for mSmmBootPerformanceTable(including FPDT table header length and existing FPDT records length) But when compare mPerformanceLength with mMaxPerformanceLength to check whether need to allocate new buffer for new FPDT record, we miss to add mPerformanceLength with header length, which will cause pool allocation behavior is not correct. Now update the mPerformanceLength to fix this issue: updated mPerformanceLength =3D FPDT table header length + existing FPDT records length. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 8 ++++= ---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL= ib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index f18c3fb60d..e03d41ed37 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -43,11 +43,11 @@ typedef struct { } HANDLE_GUID_MAP; =20 HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; UINTN mCachePairCount =3D 0; =20 -UINT32 mPerformanceLength =3D 0; +UINT32 mPerformanceLength =3D sizeof (SMM_BOOT_PERFORMANC= E_TABLE); UINT32 mMaxPerformanceLength =3D 0; UINT32 mLoadImageCount =3D 0; BOOLEAN mFpdtDataIsReported =3D FALSE; BOOLEAN mLackSpaceIsReport =3D FALSE; CHAR8 *mPlatformLanguage =3D NULL; @@ -98,19 +98,19 @@ GetFpdtRecordPtr ( // Check if pre-allocated buffer is full // if (mPerformanceLength + RecordSize > mMaxPerformanceLength) { mSmmBootPerformanceTable =3D ReallocatePool ( mPerformanceLength, - mPerformanceLength + sizeof (SMM_BOOT_P= ERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER, + mPerformanceLength + RecordSize + FIRMW= ARE_RECORD_BUFFER, mSmmBootPerformanceTable ); =20 if (mSmmBootPerformanceTable =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } - mSmmBootPerformanceTable->Header.Length =3D sizeof (SMM_BOOT_PERFORM= ANCE_TABLE) + mPerformanceLength; - mMaxPerformanceLength =3D mPerformanceLength + sizeof (SMM_BOOT_PERF= ORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER; + mSmmBootPerformanceTable->Header.Length =3D mPerformanceLength; + mMaxPerformanceLength =3D mPerformanceLength + RecordSize + FIRMWARE= _RECORD_BUFFER; } // // Covert buffer to FPDT Ptr Union type. // FpdtRecordPtr->RecordHeader =3D (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_= HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Head= er.Length); --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel