MdeModulePkg-FPDT(2): Add SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET in FpdtSmm...
authorLiming Gao <liming.gao@intel.com>
Fri, 22 Apr 2016 07:27:26 +0000 (15:27 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Fri, 29 Apr 2016 04:49:18 +0000 (12:49 +0800)
This patch enhance performance data SMM communication by using fixed
SMM communication buffer.

Update FpdtSmm to handle SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET
request.

This is designed to meet Microsoft WSMT table definition on FIXED_COMM_BUFFERS
requirement.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c

index 73188fb..c750331 100644 (file)
@@ -11,7 +11,7 @@
 \r
   FpdtSmiHandler() will receive untrusted input and do basic validation.\r
 \r
-  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -210,6 +210,7 @@ FpdtSmiHandler (
 {\r
   EFI_STATUS                   Status;\r
   SMM_BOOT_RECORD_COMMUNICATE  *SmmCommData;\r
+  UINTN                        BootRecordOffset;\r
   UINTN                        BootRecordSize;\r
   VOID                         *BootRecordData;\r
   UINTN                        TempCommBufferSize;\r
@@ -238,36 +239,44 @@ FpdtSmiHandler (
 \r
   switch (SmmCommData->Function) {\r
     case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE :\r
-       SmmCommData->BootRecordSize = mBootRecordSize;\r
-       break;\r
+      SmmCommData->BootRecordSize = mBootRecordSize;\r
+      break;\r
 \r
     case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA :\r
-       BootRecordData = SmmCommData->BootRecordData;\r
-       BootRecordSize = SmmCommData->BootRecordSize;\r
-       if (BootRecordData == NULL || BootRecordSize < mBootRecordSize) {\r
-         Status = EFI_INVALID_PARAMETER;\r
-         break;\r
-       } \r
-\r
-       //\r
-       // Sanity check\r
-       //\r
-       SmmCommData->BootRecordSize = mBootRecordSize;\r
-       if (!SmmIsBufferOutsideSmmValid ((UINTN)BootRecordData, mBootRecordSize)) {\r
-         DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM or overflow!\n"));\r
-         Status = EFI_ACCESS_DENIED;\r
-         break;\r
-       }\r
-\r
-       CopyMem (\r
-         (UINT8*)BootRecordData, \r
-         mBootRecordBuffer, \r
-         mBootRecordSize\r
-         );\r
-       break;\r
+      Status = EFI_UNSUPPORTED;\r
+      break;\r
+\r
+    case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET :\r
+      BootRecordOffset = SmmCommData->BootRecordOffset;\r
+      BootRecordData   = SmmCommData->BootRecordData;\r
+      BootRecordSize   = SmmCommData->BootRecordSize;\r
+      if (BootRecordData == NULL || BootRecordOffset >= mBootRecordSize) {\r
+        Status = EFI_INVALID_PARAMETER;\r
+        break;\r
+      }\r
+      \r
+      //\r
+      // Sanity check\r
+      //\r
+      if (BootRecordSize > mBootRecordSize - BootRecordOffset) {\r
+        BootRecordSize = mBootRecordSize - BootRecordOffset;\r
+      }\r
+      SmmCommData->BootRecordSize = BootRecordSize;\r
+      if (!SmmIsBufferOutsideSmmValid ((UINTN)BootRecordData, BootRecordSize)) {\r
+        DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM or overflow!\n"));\r
+        Status = EFI_ACCESS_DENIED;\r
+        break;\r
+      }\r
+      \r
+      CopyMem (\r
+       (UINT8*)BootRecordData, \r
+       mBootRecordBuffer + BootRecordOffset, \r
+       BootRecordSize\r
+       );\r
+      break;\r
 \r
     default:\r
-       Status = EFI_UNSUPPORTED;\r
+      Status = EFI_UNSUPPORTED;\r
   }\r
 \r
   SmmCommData->ReturnStatus = Status;\r