From nobody Mon Dec 23 16:40:02 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 Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516679303857706.3738049813967; Mon, 22 Jan 2018 19:48:23 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 31AC02232BE0E; Mon, 22 Jan 2018 19:42:56 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 CD2F222333762 for ; Mon, 22 Jan 2018 19:42:54 -0800 (PST) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 19:48:21 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 22 Jan 2018 19:48:20 -0800 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=192.55.52.88; helo=mga01.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.46,399,1511856000"; d="scan'208";a="12262573" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 23 Jan 2018 11:47:34 +0800 Message-Id: <1516679255-12328-8-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> References: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> MIME-Version: 1.0 Subject: [edk2] [patch 7/8] MdeModulePkg/FirmwarePerfSmm: Add check for collecting SMM records X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng , Liming Gao Content-Type: multipart/mixed; boundary="===============4553507035262864371==" Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 --===============4553507035262864371== Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After DXE driver communicating with SMM driver to get the size and contents of the SMM records, make SMM=E3=80=80driver not to allocate buffer to collect new SMM records if the pre-allocate buffer is not enough. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 14 ++++++++++= ++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fi= rmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDat= aTableSmm/FirmwarePerformanceSmm.c index c750331..160f6c0 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwareP= erformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwareP= erformanceSmm.c @@ -9,11 +9,11 @@ This external input must be validated carefully to avoid security issue = like buffer overflow, integer overflow. =20 FpdtSmiHandler() will receive untrusted input and do basic validation. =20 - Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php =20 @@ -49,10 +49,11 @@ UINT32 mBootRecordSize =3D 0; UINT32 mBootRecordMaxSize =3D 0; UINT8 *mBootRecordBuffer =3D NULL; =20 SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource =3D FALSE; +BOOLEAN mHaveReportedSmmRecord =3D FALSE; =20 /** Report status code listener for SMM. This is used to record the performa= nce data for S3 Suspend Start and S3 Suspend End in FPDT. =20 @@ -90,19 +91,27 @@ FpdtStatusCodeListenerSmm ( // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) !=3D EFI_PROGRESS_CODE) { return EFI_UNSUPPORTED; } - =20 + // // Collect one or more Boot records in boot time // if (Data !=3D NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformance= Guid)) { AcquireSpinLock (&mSmmFpdtLock); =20 if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { // + // If SMM records have been reported to DXE driver, don't re-allocat= e buffer + // to collect the new SMM records when pre-allocate buffer is not en= ough. + // + if (mHaveReportedSmmRecord) { + ReleaseSpinLock (&mSmmFpdtLock); + return EFI_OUT_OF_RESOURCES; + } + // // Try to allocate big SMRAM data to store Boot record.=20 // if (mSmramIsOutOfResource) { ReleaseSpinLock (&mSmmFpdtLock); return EFI_OUT_OF_RESOURCES; @@ -237,10 +246,11 @@ FpdtSmiHandler ( =20 Status =3D EFI_SUCCESS; =20 switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + mHaveReportedSmmRecord =3D TRUE; SmmCommData->BootRecordSize =3D mBootRecordSize; break; =20 case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status =3D EFI_UNSUPPORTED; --=20 1.9.5.msysgit.1 --===============4553507035262864371== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel --===============4553507035262864371==--