From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,399,1511856000"; d="scan'208";a="12262573" 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 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Liming Gao , Star Zeng 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: [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: , X-List-Received-Date: Tue, 23 Jan 2018 03:42:55 -0000 Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit After DXE driver communicating with SMM driver to get the size and contents of the SMM records, make SMM driver 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/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..160f6c0 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -9,11 +9,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. FpdtSmiHandler() will receive untrusted input and do basic validation. - 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 BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -49,10 +49,11 @@ UINT32 mBootRecordSize = 0; UINT32 mBootRecordMaxSize = 0; UINT8 *mBootRecordBuffer = NULL; SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource = FALSE; +BOOLEAN mHaveReportedSmmRecord = FALSE; /** Report status code listener for SMM. This is used to record the performance data for S3 Suspend Start and S3 Suspend End in FPDT. @@ -90,19 +91,27 @@ FpdtStatusCodeListenerSmm ( // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { return EFI_UNSUPPORTED; } - + // // Collect one or more Boot records in boot time // if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { // + // If SMM records have been reported to DXE driver, don't re-allocate buffer + // to collect the new SMM records when pre-allocate buffer is not enough. + // + if (mHaveReportedSmmRecord) { + ReleaseSpinLock (&mSmmFpdtLock); + return EFI_OUT_OF_RESOURCES; + } + // // Try to allocate big SMRAM data to store Boot record. // if (mSmramIsOutOfResource) { ReleaseSpinLock (&mSmmFpdtLock); return EFI_OUT_OF_RESOURCES; @@ -237,10 +246,11 @@ FpdtSmiHandler ( Status = EFI_SUCCESS; switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + mHaveReportedSmmRecord = TRUE; SmmCommData->BootRecordSize = mBootRecordSize; break; case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status = EFI_UNSUPPORTED; -- 1.9.5.msysgit.1