public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [patch 7/8] MdeModulePkg/FirmwarePerfSmm: Add check for collecting SMM records
Date: Tue, 23 Jan 2018 11:47:34 +0800	[thread overview]
Message-ID: <1516679255-12328-8-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1516679255-12328-1-git-send-email-dandan.bi@intel.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3412 bytes --]

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 <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../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.<BR>
+  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
   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



  parent reply	other threads:[~2018-01-23  3:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23  3:47 [patch 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table Dandan Bi
2018-01-23  3:47 ` [patch 1/8] MdeModulePkg:Add definitions for new Performance infrastructure Dandan Bi
2018-01-23  3:47 ` [patch 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase Dandan Bi
2018-01-23  3:47 ` [patch 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase Dandan Bi
2018-01-23  3:47 ` [patch 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase Dandan Bi
2018-01-23  3:47 ` [patch 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase Dandan Bi
2018-01-23  3:47 ` [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure Dandan Bi
2018-01-23  3:47 ` Dandan Bi [this message]
2018-01-23  3:47 ` [patch 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table Dandan Bi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516679255-12328-8-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox