]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Use SmmMemLib to check communication buffer.
authorYao, Jiewen <jiewen.yao@intel.com>
Mon, 2 Feb 2015 14:42:22 +0000 (14:42 +0000)
committerjyao1 <jyao1@Edk2>
Mon, 2 Feb 2015 14:42:22 +0000 (14:42 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com>
Reviewed-by: "Gao, Liming" <liming.gao@intel.com>
Reviewed-by: "Fan, Jeff" <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16694 6f19259b-4bc3-4df7-8a09-765794883524

19 files changed:
MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c
MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf

index d8790241e3fd172aa1987443f288bf2846f9ee39..187cb8e68e4870322c22cff6e3c6f127424f20e1 100644 (file)
@@ -85,11 +85,6 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
 UINTN                           mFullSmramRangeCount;\r
 EFI_SMRAM_DESCRIPTOR            *mFullSmramRanges;\r
 \r
 UINTN                           mFullSmramRangeCount;\r
 EFI_SMRAM_DESCRIPTOR            *mFullSmramRanges;\r
 \r
-//\r
-// Maximum support address used to check input CommunicationBuffer\r
-//\r
-UINTN  mMaximumSupportAddress = 0;\r
-\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
@@ -279,76 +274,6 @@ SmmEndOfDxeHandler (
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
-/**\r
-  Caculate and save the maximum support address.\r
-\r
-**/\r
-VOID\r
-CaculateMaximumSupportAddress (\r
-  VOID\r
-  )\r
-{\r
-  VOID         *Hob;\r
-  UINT32       RegEax;\r
-  UINT8        PhysicalAddressBits;\r
-\r
-  //\r
-  // Get physical address bits supported.\r
-  //\r
-  Hob = GetFirstHob (EFI_HOB_TYPE_CPU);\r
-  if (Hob != NULL) {\r
-    PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;\r
-  } else {\r
-    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);\r
-    if (RegEax >= 0x80000008) {\r
-      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);\r
-      PhysicalAddressBits = (UINT8) RegEax;\r
-    } else {\r
-      PhysicalAddressBits = 36;\r
-    }\r
-  }\r
-  //\r
-  // IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.\r
-  //\r
-  ASSERT (PhysicalAddressBits <= 52);\r
-  if (PhysicalAddressBits > 48) {\r
-    PhysicalAddressBits = 48;\r
-  }\r
-  \r
-  //\r
-  // Save the maximum support address in one global variable  \r
-  //\r
-  mMaximumSupportAddress = (UINTN) (LShiftU64 (1, PhysicalAddressBits) - 1);\r
-  DEBUG ((EFI_D_INFO, "mMaximumSupportAddress = 0x%lx\n", mMaximumSupportAddress));\r
-}\r
-\r
-/**\r
-  Check if input buffer is in valid address scope or not.\r
-\r
-  @param[in]  Pointer      Pointer to the input buffer.\r
-  @param[in]  BufferSize   Input buffer size in bytes.\r
-\r
-  @retval TRUE    The input buffer is in valid address scope.  \r
-  @retval FALSE   The input buffer is not in valid address scope.  \r
-\r
-**/\r
-BOOLEAN\r
-IsValidPointer (\r
-  IN VOID     *Pointer,\r
-  IN UINTN    BufferSize\r
-  )\r
-{\r
-  if ((UINTN) Pointer > mMaximumSupportAddress) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (BufferSize > (mMaximumSupportAddress - (UINTN) Pointer)) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   The main entry point to SMM Foundation.\r
 \r
 /**\r
   The main entry point to SMM Foundation.\r
 \r
@@ -398,7 +323,7 @@ SmmEntryPoint (
       //\r
       // Synchronous SMI for SMM Core or request from Communicate protocol\r
       //\r
       //\r
       // Synchronous SMI for SMM Core or request from Communicate protocol\r
       //\r
-      if (!IsValidPointer (gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize)) {\r
+      if (!SmmIsBufferOutsideSmmValid ((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize)) {\r
         //\r
         // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER\r
         //\r
         //\r
         // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER\r
         //\r
@@ -484,9 +409,10 @@ SmmMain (
   gSmmCorePrivate->SmmEntryPoint = SmmEntryPoint;\r
   \r
   //\r
   gSmmCorePrivate->SmmEntryPoint = SmmEntryPoint;\r
   \r
   //\r
-  // Initialize memory service using free SMRAM\r
+  // No need to initialize memory service.\r
+  // It is done in constructor of PiSmmCoreMemoryAllocationLib(),\r
+  // so that the library linked with PiSmmCore can use AllocatePool() in constuctor.\r
   //\r
   //\r
-  SmmInitializeMemoryServices (gSmmCorePrivate->SmramRangeCount, gSmmCorePrivate->SmramRanges);\r
 \r
   SmramProfileInit ();\r
 \r
 \r
   SmramProfileInit ();\r
 \r
@@ -512,10 +438,5 @@ SmmMain (
 \r
   RegisterSmramProfileHandler ();\r
 \r
 \r
   RegisterSmramProfileHandler ();\r
 \r
-  //\r
-  // Caculate and save maximum support address used in SmmEntryPoint().\r
-  //\r
-  CaculateMaximumSupportAddress ();\r
-\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
index 34bd6411d655e730f12ca028e5ecba82d30a90a1..41e8f83155205a19204ce8b8ea0f07cfbc10ed49 100644 (file)
@@ -51,6 +51,7 @@
 #include <Library/PerformanceLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/HobLib.h>\r
+#include <Library/SmmMemLib.h>\r
 \r
 #include "PiSmmCorePrivateData.h"\r
 \r
 \r
 #include "PiSmmCorePrivateData.h"\r
 \r
index bf030d60e73767de7fb5752f671c35bf2f7b56c3..784dea64a5799bcc5dfae4e011c71c9c928560f3 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This module provide an SMM CIS compliant implementation of SMM Core.\r
 #\r
 ## @file\r
 # This module provide an SMM CIS compliant implementation of SMM Core.\r
 #\r
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -60,6 +60,7 @@
   PerformanceLib\r
   TimerLib\r
   HobLib\r
   PerformanceLib\r
   TimerLib\r
   HobLib\r
+  SmmMemLib\r
 \r
 [Protocols]\r
   gEfiDxeSmmReadyToLockProtocolGuid             ## UNDEFINED # SmiHandlerRegister\r
 \r
 [Protocols]\r
   gEfiDxeSmmReadyToLockProtocolGuid             ## UNDEFINED # SmiHandlerRegister\r
index e119fadb67e5cd3669972e226bf104dd5f29f54f..a78442901bafa80d036c58ce4a9fb0f3bc49dbbd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support routines for SMRAM profile.\r
 \r
 /** @file\r
   Support routines for SMRAM profile.\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, 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
   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
@@ -1175,61 +1175,6 @@ SmramProfileReadyToLock (
 \r
 ////////////////////\r
 \r
 \r
 ////////////////////\r
 \r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-\r
-**/\r
-BOOLEAN\r
-InternalIsAddressInSmram (\r
-  IN PHYSICAL_ADDRESS   Buffer,\r
-  IN UINT64             Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mFullSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mFullSmramRanges[Index].CpuStart) && (Buffer < mFullSmramRanges[Index].CpuStart + mFullSmramRanges[Index].PhysicalSize)) ||\r
-        ((mFullSmramRanges[Index].CpuStart >= Buffer) && (mFullSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (InternalIsAddressInSmram ((PHYSICAL_ADDRESS) Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Get SMRAM profile data size.\r
 \r
 /**\r
   Get SMRAM profile data size.\r
 \r
@@ -1485,7 +1430,7 @@ SmramProfileHandlerGetData (
   //\r
   // Sanity check\r
   //\r
   //\r
   // Sanity check\r
   //\r
-  if (!InternalIsAddressValid ((UINTN) SmramProfileGetData.ProfileBuffer, (UINTN) ProfileSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN) SmramProfileGetData.ProfileBuffer, (UINTN) ProfileSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetData: SMM ProfileBuffer in SMRAM or overflow!\n"));\r
     SmramProfileParameterGetData->ProfileSize = ProfileSize;\r
     SmramProfileParameterGetData->Header.ReturnStatus = (UINT64) (INT64) (INTN) EFI_ACCESS_DENIED;\r
     DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetData: SMM ProfileBuffer in SMRAM or overflow!\n"));\r
     SmramProfileParameterGetData->ProfileSize = ProfileSize;\r
     SmramProfileParameterGetData->Header.ReturnStatus = (UINT64) (INT64) (INTN) EFI_ACCESS_DENIED;\r
@@ -1610,7 +1555,7 @@ SmramProfileHandler (
     return EFI_SUCCESS;\r
   }\r
 \r
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (mSmramReadyToLock && !InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (mSmramReadyToLock && !SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
index f0f48438f4581e2ca8411e6007c0ddb425d15ff4..e4f7756f72e108bbb220feff9e5a30ac5ff35040 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support routines for memory allocation routines based on SMM Core internal functions.\r
 \r
 /** @file\r
   Support routines for memory allocation routines based on SMM Core internal functions.\r
 \r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2015, 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
   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
@@ -936,3 +936,28 @@ FreePool (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
+/**\r
+  The constructor function calls SmmInitializeMemoryServices to initialize memory in SMRAM.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PiSmmCoreMemoryAllocationLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  SMM_CORE_PRIVATE_DATA  *SmmCorePrivate;\r
+\r
+  SmmCorePrivate = (SMM_CORE_PRIVATE_DATA *)ImageHandle;\r
+  //\r
+  // Initialize memory service using free SMRAM\r
+  //\r
+  SmmInitializeMemoryServices (SmmCorePrivate->SmramRangeCount, SmmCorePrivate->SmramRanges);\r
+  return EFI_SUCCESS;\r
+}\r
index cfd2f4a56d434f34d71dcda513247ff7ef5a1996..e8f7081149cbf09334c83b29ceccd2fc41a21c45 100644 (file)
@@ -4,7 +4,7 @@
 # for memory allocation instead of using SMM System Table servces in an indirect way.\r
 # It is assumed that this library instance must be linked with SMM Cre in this package. \r
 #\r
 # for memory allocation instead of using SMM System Table servces in an indirect way.\r
 # It is assumed that this library instance must be linked with SMM Cre in this package. \r
 #\r
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -24,7 +24,8 @@
   VERSION_STRING                 = 1.0\r
   PI_SPECIFICATION_VERSION       = 0x0001000A\r
   LIBRARY_CLASS                  = MemoryAllocationLib|SMM_CORE\r
   VERSION_STRING                 = 1.0\r
   PI_SPECIFICATION_VERSION       = 0x0001000A\r
   LIBRARY_CLASS                  = MemoryAllocationLib|SMM_CORE\r
-  \r
+  CONSTRUCTOR                    = PiSmmCoreMemoryAllocationLibConstructor\r
+\r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
index 84893af85c6401a1877583989b115884db0b3dd6..5c74045039e43395c0138f1c372cd6e2db095274 100644 (file)
@@ -4,7 +4,7 @@
   This header file borrows the PiSmmCore Memory Allocation services as the primitive\r
   for memory allocation. \r
 \r
   This header file borrows the PiSmmCore Memory Allocation services as the primitive\r
   for memory allocation. \r
 \r
-  Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2015, 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
   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
 #ifndef _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_\r
 #define _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_\r
 \r
 #ifndef _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_\r
 #define _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_\r
 \r
+typedef struct {\r
+  UINTN                           Signature;\r
+  ///\r
+  /// The ImageHandle passed into the entry point of the SMM IPL.  This ImageHandle\r
+  /// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded\r
+  /// Image Protocol for each SMM Driver that is dispatched by the SMM Core.\r
+  ///\r
+  EFI_HANDLE                      SmmIplImageHandle;\r
+  ///\r
+  /// The number of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM\r
+  /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.\r
+  ///\r
+  UINTN                           SmramRangeCount;\r
+  ///\r
+  /// A table of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM\r
+  /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.\r
+  ///\r
+  EFI_SMRAM_DESCRIPTOR            *SmramRanges;\r
+} SMM_CORE_PRIVATE_DATA;\r
+\r
+/**\r
+  Called to initialize the memory service.\r
+\r
+  @param   SmramRangeCount       Number of SMRAM Regions\r
+  @param   SmramRanges           Pointer to SMRAM Descriptors\r
+\r
+**/\r
+VOID\r
+SmmInitializeMemoryServices (\r
+  IN UINTN                 SmramRangeCount,\r
+  IN EFI_SMRAM_DESCRIPTOR  *SmramRanges\r
+  );\r
+\r
 /**\r
   Allocates pages from the memory map.\r
 \r
 /**\r
   Allocates pages from the memory map.\r
 \r
index f95079bd272201f8100bd38f0f1f58918ef36809..da2adf0fc5dedb099f4e54cfccf6b33a797e27e9 100644 (file)
@@ -16,7 +16,7 @@
 \r
  SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.\r
 \r
 \r
  SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.\r
 \r
-Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2015, 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
 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
@@ -51,9 +51,6 @@ BOOLEAN                 mPerformanceMeasurementEnabled;
 \r
 SPIN_LOCK               mSmmPerfLock;\r
 \r
 \r
 SPIN_LOCK               mSmmPerfLock;\r
 \r
-EFI_SMRAM_DESCRIPTOR    *mSmramRanges;\r
-UINTN                   mSmramRangeCount;\r
-\r
 //\r
 // Interfaces for SMM Performance Protocol.\r
 //\r
 //\r
 // Interfaces for SMM Performance Protocol.\r
 //\r
@@ -450,60 +447,6 @@ GetGauge (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-**/\r
-BOOLEAN\r
-IsAddressInSmram (\r
-  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
-  IN UINT64                Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||\r
-        ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-IsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Communication service SMI Handler entry.\r
 \r
 /**\r
   Communication service SMI Handler entry.\r
 \r
@@ -560,7 +503,7 @@ SmmPerformanceHandlerEx (
     return EFI_SUCCESS;\r
   }\r
 \r
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM communcation data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM communcation data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -587,7 +530,7 @@ SmmPerformanceHandlerEx (
        // Sanity check\r
        //\r
        DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);\r
        // Sanity check\r
        //\r
        DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);\r
-       if (!IsAddressValid ((UINTN)GaugeDataEx, DataSize)) {\r
+       if (!SmmIsBufferOutsideSmmValid ((UINTN)GaugeDataEx, DataSize)) {\r
          DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
          Status = EFI_ACCESS_DENIED;\r
          break;\r
          DEBUG ((EFI_D_ERROR, "SmmPerformanceHandlerEx: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
          Status = EFI_ACCESS_DENIED;\r
          break;\r
@@ -669,7 +612,7 @@ SmmPerformanceHandler (
     return EFI_SUCCESS;\r
   }\r
 \r
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM communcation data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM communcation data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -696,7 +639,7 @@ SmmPerformanceHandler (
        // Sanity check\r
        //\r
        DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY);\r
        // Sanity check\r
        //\r
        DataSize = NumberOfEntries * sizeof(GAUGE_DATA_ENTRY);\r
-       if (!IsAddressValid ((UINTN)GaugeData, DataSize)) {\r
+       if (!SmmIsBufferOutsideSmmValid ((UINTN)GaugeData, DataSize)) {\r
          DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
          Status = EFI_ACCESS_DENIED;\r
          break;\r
          DEBUG ((EFI_D_ERROR, "SmmPerformanceHandler: SMM Performance Data buffer in SMRAM or overflow!\n"));\r
          Status = EFI_ACCESS_DENIED;\r
          break;\r
@@ -741,9 +684,6 @@ InitializeSmmCorePerformanceLib (
 {\r
   EFI_STATUS                Status;\r
   EFI_HANDLE                Handle;\r
 {\r
   EFI_STATUS                Status;\r
   EFI_HANDLE                Handle;\r
-  EFI_SMM_ACCESS2_PROTOCOL  *SmmAccess;\r
-  UINTN                     Size;\r
-\r
 \r
   //\r
   // Initialize spin lock\r
 \r
   //\r
   // Initialize spin lock\r
@@ -755,28 +695,6 @@ InitializeSmmCorePerformanceLib (
   mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));\r
   ASSERT (mGaugeData != NULL);\r
   \r
   mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));\r
   ASSERT (mGaugeData != NULL);\r
   \r
-  //\r
-  // Get SMRAM information\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Size = 0;\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = gSmst->SmmAllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    Size,\r
-                    (VOID **)&mSmramRanges\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);\r
-\r
   //\r
   // Install the protocol interfaces.\r
   //\r
   //\r
   // Install the protocol interfaces.\r
   //\r
index b8bef281d20e041158eedb4b8dffd12c95f84dec..c87e159ba41266ffd1b0d283710e6a797ea6a1a5 100644 (file)
@@ -8,7 +8,7 @@
 #  This library is mainly used by SMM Core to start performance logging to ensure that\r
 #  SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.\r
 #  \r
 #  This library is mainly used by SMM Core to start performance logging to ensure that\r
 #  SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.\r
 #  \r
-#  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2015, 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
 #  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
@@ -56,6 +56,7 @@
   DebugLib\r
   SynchronizationLib\r
   SmmServicesTableLib\r
   DebugLib\r
   SynchronizationLib\r
   SmmServicesTableLib\r
+  SmmMemLib\r
 \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                  ## CONSUMES\r
 \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                  ## CONSUMES\r
index a02368827885ac789dbdfe68cf7ea99ef600034d..c0e0a0076c6aecbf0653229745f44483ce819516 100644 (file)
@@ -4,7 +4,7 @@
   This header file holds the prototypes of the SMM Performance and PerformanceEx Protocol published by this\r
   library instance at its constructor.\r
 \r
   This header file holds the prototypes of the SMM Performance and PerformanceEx Protocol published by this\r
   library instance at its constructor.\r
 \r
-Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2015, 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
 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
@@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/SynchronizationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/SynchronizationLib.h>\r
+#include <Library/SmmMemLib.h>\r
 \r
 #include <Protocol/SmmBase2.h>\r
 #include <Protocol/SmmAccess2.h>\r
 \r
 #include <Protocol/SmmBase2.h>\r
 #include <Protocol/SmmAccess2.h>\r
index 702ffc2ef2c70f9a31613bdbd6dd29c24121d704..d6668ad575ad64ee632e8df3c2c3cc37b2d10d54 100644 (file)
@@ -2,7 +2,7 @@
 # EFI/PI Reference Module Package for All Architectures\r
 #\r
 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
 # EFI/PI Reference Module Package for All Architectures\r
 #\r
 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #    This program and the accompanying materials\r
 #    are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #    This program and the accompanying materials\r
 #    are licensed and made available under the terms and conditions of the BSD License\r
   MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf\r
   SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf\r
   SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf  \r
   MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf\r
   SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf\r
   SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf  \r
+  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf\r
 \r
 [LibraryClasses.common.DXE_SMM_DRIVER]\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
 \r
 [LibraryClasses.common.DXE_SMM_DRIVER]\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf\r
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf\r
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf\r
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf\r
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf\r
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf\r
+  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf\r
 \r
 [LibraryClasses.common.UEFI_DRIVER]\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
 \r
 [LibraryClasses.common.UEFI_DRIVER]\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
index 9c5fd4db85a61ae2de20c3a4ac10732f20d38ef7..47e63e9851aefdc888158508be9f0feecb6f706c 100644 (file)
@@ -11,7 +11,7 @@
 \r
   FpdtSmiHandler() will receive untrusted input and do basic validation.\r
 \r
 \r
   FpdtSmiHandler() will receive untrusted input and do basic validation.\r
 \r
-  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2015, 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
   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
@@ -39,6 +39,7 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/SynchronizationLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/SynchronizationLib.h>\r
+#include <Library/SmmMemLib.h>\r
 \r
 #define EXTENSION_RECORD_SIZE     0x1000\r
 \r
 \r
 #define EXTENSION_RECORD_SIZE     0x1000\r
 \r
@@ -49,8 +50,6 @@ UINT32                        mBootRecordSize = 0;
 UINT32                        mBootRecordMaxSize = 0;\r
 UINT8                         *mBootRecordBuffer = NULL;\r
 \r
 UINT32                        mBootRecordMaxSize = 0;\r
 UINT8                         *mBootRecordBuffer = NULL;\r
 \r
-EFI_SMRAM_DESCRIPTOR          *mSmramRanges;\r
-UINTN                         mSmramRangeCount;\r
 SPIN_LOCK                     mSmmFpdtLock;\r
 BOOLEAN                       mSmramIsOutOfResource = FALSE;\r
 \r
 SPIN_LOCK                     mSmmFpdtLock;\r
 BOOLEAN                       mSmramIsOutOfResource = FALSE;\r
 \r
@@ -177,60 +176,6 @@ FpdtStatusCodeListenerSmm (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressInSmram (\r
-  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
-  IN UINT64                Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||\r
-        ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Communication service SMI Handler entry.\r
 \r
 /**\r
   Communication service SMI Handler entry.\r
 \r
@@ -283,7 +228,7 @@ FpdtSmiHandler (
     return EFI_SUCCESS;\r
   }\r
   \r
     return EFI_SUCCESS;\r
   }\r
   \r
-  if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM communication data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM communication data buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -309,7 +254,7 @@ FpdtSmiHandler (
        // Sanity check\r
        //\r
        SmmCommData->BootRecordSize = mBootRecordSize;\r
        // Sanity check\r
        //\r
        SmmCommData->BootRecordSize = mBootRecordSize;\r
-       if (!InternalIsAddressValid ((UINTN)BootRecordData, 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
          DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM or overflow!\n"));\r
          Status = EFI_ACCESS_DENIED;\r
          break;\r
@@ -350,8 +295,6 @@ FirmwarePerformanceSmmEntryPoint (
 {\r
   EFI_STATUS                Status;\r
   EFI_HANDLE                Handle;\r
 {\r
   EFI_STATUS                Status;\r
   EFI_HANDLE                Handle;\r
-  EFI_SMM_ACCESS2_PROTOCOL  *SmmAccess;\r
-  UINTN                     Size;\r
 \r
   //\r
   // Initialize spin lock\r
 \r
   //\r
   // Initialize spin lock\r
@@ -374,28 +317,6 @@ FirmwarePerformanceSmmEntryPoint (
   Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerSmm);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerSmm);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Get SMRAM information\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Size = 0;\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = gSmst->SmmAllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    Size,\r
-                    (VOID **)&mSmramRanges\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);\r
-\r
   //\r
   // Register SMI handler.\r
   //\r
   //\r
   // Register SMI handler.\r
   //\r
index c90da9c2fe54925a6c9dd741fd769e39a5326f55..a4027f131657941b4ba6ff3531a09c31f2492549 100644 (file)
@@ -4,7 +4,7 @@
 #  This module registers report status code listener to collect performance data\r
 #  for SMM boot performance records and S3 Suspend Performance Record.\r
 #\r
 #  This module registers report status code listener to collect performance data\r
 #  for SMM boot performance records and S3 Suspend Performance Record.\r
 #\r
-#  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2015, 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
 #  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
@@ -50,6 +50,7 @@
   MemoryAllocationLib\r
   UefiBootServicesTableLib\r
   SynchronizationLib\r
   MemoryAllocationLib\r
   UefiBootServicesTableLib\r
   SynchronizationLib\r
+  SmmMemLib\r
 \r
 [Protocols]\r
   gEfiSmmRscHandlerProtocolGuid                 ## CONSUMES\r
 \r
 [Protocols]\r
   gEfiSmmRscHandlerProtocolGuid                 ## CONSUMES\r
index 82219804d1196d682d28a6feec4657f068e6fdde..c96469f18949dcb1020e9f0e41d2abe899490aba 100644 (file)
@@ -43,7 +43,7 @@
   Caution: This module requires additional review when modified.\r
   This driver need to make sure the CommBuffer is not in the SMRAM range. \r
 \r
   Caution: This module requires additional review when modified.\r
   This driver need to make sure the CommBuffer is not in the SMRAM range. \r
 \r
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2015, 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
 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
@@ -56,6 +56,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <PiSmm.h>\r
 #include <Library/SmmServicesTableLib.h>\r
 \r
 #include <PiSmm.h>\r
 #include <Library/SmmServicesTableLib.h>\r
+#include <Library/SmmMemLib.h>\r
 #include <Protocol/SmmSwapAddressRange.h>\r
 #include "FaultTolerantWrite.h"\r
 #include "FaultTolerantWriteSmmCommon.h"\r
 #include <Protocol/SmmSwapAddressRange.h>\r
 #include "FaultTolerantWrite.h"\r
 #include "FaultTolerantWriteSmmCommon.h"\r
@@ -64,68 +65,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 EFI_EVENT                                 mFvbRegistration = NULL;\r
 EFI_FTW_DEVICE                            *mFtwDevice      = NULL;\r
 \r
 EFI_EVENT                                 mFvbRegistration = NULL;\r
 EFI_FTW_DEVICE                            *mFtwDevice      = NULL;\r
-EFI_SMRAM_DESCRIPTOR                      *mSmramRanges;\r
-UINTN                                     mSmramRangeCount;\r
 \r
 ///\r
 /// The flag to indicate whether the platform has left the DXE phase of execution.\r
 ///\r
 BOOLEAN                                   mEndOfDxe = FALSE;\r
 \r
 \r
 ///\r
 /// The flag to indicate whether the platform has left the DXE phase of execution.\r
 ///\r
 BOOLEAN                                   mEndOfDxe = FALSE;\r
 \r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressInSmram (\r
-  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
-  IN UINT64                Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||\r
-        ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Retrive the SMM FVB protocol interface by HANDLE.\r
 \r
 /**\r
   Retrive the SMM FVB protocol interface by HANDLE.\r
 \r
@@ -391,7 +336,7 @@ SmmFaultTolerantWriteHandler (
   }\r
   CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE;\r
 \r
   }\r
   CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE;\r
 \r
-  if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -670,8 +615,6 @@ SmmFaultTolerantWriteInitialize (
   )\r
 {\r
   EFI_STATUS                              Status;\r
   )\r
 {\r
   EFI_STATUS                              Status;\r
-  EFI_SMM_ACCESS2_PROTOCOL                *SmmAccess;\r
-  UINTN                                   Size;\r
   VOID                                    *SmmEndOfDxeRegistration;\r
 \r
   //\r
   VOID                                    *SmmEndOfDxeRegistration;\r
 \r
   //\r
@@ -682,28 +625,6 @@ SmmFaultTolerantWriteInitialize (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-  //\r
-  // Get SMRAM information\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Size = 0;\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = gSmst->SmmAllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    Size,\r
-                    (VOID **)&mSmramRanges\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);\r
-\r
   //\r
   // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.\r
   //\r
   //\r
   // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.\r
   //\r
index 105820c17b7d1af61461079e7e5a548a31f7d344..b9177cd29b20d6889c1aeb491c499680ab4b29b5 100644 (file)
@@ -6,7 +6,7 @@
 #   depends on the full functionality SMM FVB protocol that support read, write/erase \r
 #   flash access.\r
 #\r
 #   depends on the full functionality SMM FVB protocol that support read, write/erase \r
 #   flash access.\r
 #\r
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -54,6 +54,7 @@
   UefiLib\r
   PcdLib\r
   ReportStatusCodeLib\r
   UefiLib\r
   PcdLib\r
   ReportStatusCodeLib\r
+  SmmMemLib\r
 \r
 [Guids]\r
   #\r
 \r
 [Guids]\r
   #\r
index ad4b2645cb257eb9461df2a9393f88f0682a3389..dc8cc1df1ca9f873f3b3ca1f97ee8197365ed000 100644 (file)
@@ -9,7 +9,7 @@
   SmmLockBoxHandler(), SmmLockBoxRestore(), SmmLockBoxUpdate(), SmmLockBoxSave()\r
   will receive untrusted input and do basic validation.\r
 \r
   SmmLockBoxHandler(), SmmLockBoxRestore(), SmmLockBoxUpdate(), SmmLockBoxSave()\r
   will receive untrusted input and do basic validation.\r
 \r
-Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -30,7 +30,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/SmmMemLib.h>\r
 #include <Library/LockBoxLib.h>\r
 #include <Library/LockBoxLib.h>\r
+\r
 #include <Protocol/SmmReadyToLock.h>\r
 #include <Protocol/SmmCommunication.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmReadyToLock.h>\r
 #include <Protocol/SmmCommunication.h>\r
 #include <Protocol/SmmAccess2.h>\r
@@ -39,63 +41,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 BOOLEAN              mLocked = FALSE;\r
 \r
 \r
 BOOLEAN              mLocked = FALSE;\r
 \r
-EFI_SMRAM_DESCRIPTOR *mSmramRanges;\r
-UINTN                mSmramRangeCount;\r
-\r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-**/\r
-BOOLEAN\r
-IsAddressInSmram (\r
-  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
-  IN UINT64                Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||\r
-        ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-IsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Dispatch function for SMM lock box save.\r
 \r
 /**\r
   Dispatch function for SMM lock box save.\r
 \r
@@ -127,7 +72,7 @@ SmmLockBoxSave (
   //\r
   // Sanity check\r
   //\r
   //\r
   // Sanity check\r
   //\r
-  if (!IsAddressValid ((UINTN)TempLockBoxParameterSave.Buffer, (UINTN)TempLockBoxParameterSave.Length)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterSave.Buffer, (UINTN)TempLockBoxParameterSave.Length)) {\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Save address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Save address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
@@ -211,7 +156,7 @@ SmmLockBoxUpdate (
   //\r
   // Sanity check\r
   //\r
   //\r
   // Sanity check\r
   //\r
-  if (!IsAddressValid ((UINTN)TempLockBoxParameterUpdate.Buffer, (UINTN)TempLockBoxParameterUpdate.Length)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterUpdate.Buffer, (UINTN)TempLockBoxParameterUpdate.Length)) {\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Update address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Update address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
@@ -252,7 +197,7 @@ SmmLockBoxRestore (
   //\r
   // Sanity check\r
   //\r
   //\r
   // Sanity check\r
   //\r
-  if (!IsAddressValid ((UINTN)TempLockBoxParameterRestore.Buffer, (UINTN)TempLockBoxParameterRestore.Length)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterRestore.Buffer, (UINTN)TempLockBoxParameterRestore.Length)) {\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Restore address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterRestore->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Restore address in SMRAM or buffer overflow!\n"));\r
     LockBoxParameterRestore->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;\r
     return ;\r
@@ -341,7 +286,7 @@ SmmLockBoxHandler (
     DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size invalid!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size invalid!\n"));\r
     return EFI_SUCCESS;\r
   }\r
-  if (!IsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -444,30 +389,6 @@ SmmLockBoxEntryPoint (
   EFI_STATUS                    Status;\r
   EFI_HANDLE                    DispatchHandle;\r
   VOID                          *Registration;\r
   EFI_STATUS                    Status;\r
   EFI_HANDLE                    DispatchHandle;\r
   VOID                          *Registration;\r
-  EFI_SMM_ACCESS2_PROTOCOL      *SmmAccess;\r
-  UINTN                         Size;\r
-\r
-  //\r
-  // Get SMRAM information\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Size = 0;\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = gSmst->SmmAllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    Size,\r
-                    (VOID **)&mSmramRanges\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);\r
 \r
   //\r
   // Register LockBox communication handler\r
 \r
   //\r
   // Register LockBox communication handler\r
index 07c1b14d3e54238fdd2e267152066cb12dd5862d..aef6cd9065d11e51e8c797a87deb91282170000e 100644 (file)
@@ -6,7 +6,7 @@
 #  This external input must be validated carefully to avoid security issue like\r
 #  buffer overflow, integer overflow.\r
 #\r
 #  This external input must be validated carefully to avoid security issue like\r
 #  buffer overflow, integer overflow.\r
 #\r
-#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions\r
@@ -50,6 +50,7 @@
   BaseMemoryLib\r
   DebugLib\r
   LockBoxLib\r
   BaseMemoryLib\r
   DebugLib\r
   LockBoxLib\r
+  SmmMemLib\r
 \r
 [Guids]\r
   gEfiSmmLockBoxCommunicationGuid   ## PRODUCES ## GUID # SmiHandlerRegister\r
 \r
 [Guids]\r
   gEfiSmmLockBoxCommunicationGuid   ## PRODUCES ## GUID # SmiHandlerRegister\r
index 3bf545a4e083609c37b2ad27ecb54b77946cfd61..f9ead5df7fbcfa55d343e96022523fe207a429ae 100644 (file)
@@ -33,14 +33,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SmmVarCheck.h>\r
 \r
 #include <Library/SmmServicesTableLib.h>\r
 #include <Protocol/SmmVarCheck.h>\r
 \r
 #include <Library/SmmServicesTableLib.h>\r
+#include <Library/SmmMemLib.h>\r
 \r
 #include <Guid/VariableFormat.h>\r
 #include <Guid/SmmVariableCommon.h>\r
 #include "Variable.h"\r
 \r
 \r
 #include <Guid/VariableFormat.h>\r
 #include <Guid/SmmVariableCommon.h>\r
 #include "Variable.h"\r
 \r
-EFI_SMRAM_DESCRIPTOR                                 *mSmramRanges;\r
-UINTN                                                mSmramRangeCount;\r
-\r
 extern VARIABLE_INFO_ENTRY                           *gVariableInfo;\r
 EFI_HANDLE                                           mSmmVariableHandle      = NULL;\r
 EFI_HANDLE                                           mVariableHandle         = NULL;\r
 extern VARIABLE_INFO_ENTRY                           *gVariableInfo;\r
 EFI_HANDLE                                           mSmmVariableHandle      = NULL;\r
 EFI_HANDLE                                           mVariableHandle         = NULL;\r
@@ -120,60 +118,6 @@ AtRuntime (
   return mAtRuntime;\r
 }\r
 \r
   return mAtRuntime;\r
 }\r
 \r
-/**\r
-  This function check if the address is in SMRAM.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is in SMRAM.\r
-  @retval FALSE this address is NOT in SMRAM.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressInSmram (\r
-  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
-  IN UINT64                Length\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mSmramRangeCount; Index ++) {\r
-    if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||\r
-        ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
-/**\r
-  This function check if the address refered by Buffer and Length is valid.\r
-\r
-  @param Buffer  the buffer address to be checked.\r
-  @param Length  the buffer length to be checked.\r
-\r
-  @retval TRUE  this address is valid.\r
-  @retval FALSE this address is NOT valid.\r
-**/\r
-BOOLEAN\r
-InternalIsAddressValid (\r
-  IN UINTN                 Buffer,\r
-  IN UINTN                 Length\r
-  )\r
-{\r
-  if (Buffer > (MAX_ADDRESS - Length)) {\r
-    //\r
-    // Overflow happen\r
-    //\r
-    return FALSE;\r
-  }\r
-  if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {\r
-    return FALSE;\r
-  }\r
-  return TRUE;\r
-}\r
-\r
 /**\r
   Initializes a basic mutual exclusion lock.\r
 \r
 /**\r
   Initializes a basic mutual exclusion lock.\r
 \r
@@ -528,7 +472,7 @@ SmmVariableHandler (
     return EFI_SUCCESS;\r
   }\r
 \r
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
+  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {\r
     DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
     DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));\r
     return EFI_SUCCESS;\r
   }\r
@@ -719,7 +663,7 @@ SmmVariableHandler (
       // It is covered by previous CommBuffer check \r
       //\r
      \r
       // It is covered by previous CommBuffer check \r
       //\r
      \r
-      if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {\r
+      if (!SmmIsBufferOutsideSmmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)CommBufferSize, sizeof(UINTN))) {\r
         DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in SMRAM!\n"));\r
         Status = EFI_ACCESS_DENIED;\r
         goto EXIT;\r
         DEBUG ((EFI_D_ERROR, "GetStatistics: SMM communication buffer in SMRAM!\n"));\r
         Status = EFI_ACCESS_DENIED;\r
         goto EXIT;\r
@@ -937,8 +881,6 @@ VariableServiceInitialize (
   EFI_STATUS                              Status;\r
   EFI_HANDLE                              VariableHandle;\r
   VOID                                    *SmmFtwRegistration;\r
   EFI_STATUS                              Status;\r
   EFI_HANDLE                              VariableHandle;\r
   VOID                                    *SmmFtwRegistration;\r
-  EFI_SMM_ACCESS2_PROTOCOL                *SmmAccess;\r
-  UINTN                                   Size;\r
   VOID                                    *SmmEndOfDxeRegistration;\r
 \r
   //\r
   VOID                                    *SmmEndOfDxeRegistration;\r
 \r
   //\r
@@ -967,28 +909,6 @@ VariableServiceInitialize (
                     );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
                     );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // Get SMRAM information\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Size = 0;\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-\r
-  Status = gSmst->SmmAllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    Size,\r
-                    (VOID **)&mSmramRanges\r
-                    );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);\r
-\r
   mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +\r
                                OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - sizeof (VARIABLE_HEADER);\r
 \r
   mVariableBufferPayloadSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize)) +\r
                                OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - sizeof (VARIABLE_HEADER);\r
 \r
index b84ff87e43c8a2a5db8e7033fa09038924022e1b..46a62a568cb6dced7ee5bea67e9425bdbd732472 100644 (file)
@@ -64,6 +64,7 @@
   HobLib\r
   PcdLib\r
   DevicePathLib\r
   HobLib\r
   PcdLib\r
   DevicePathLib\r
+  SmmMemLib\r
 \r
 [Protocols]\r
   gEfiSmmFirmwareVolumeBlockProtocolGuid        ## CONSUMES\r
 \r
 [Protocols]\r
   gEfiSmmFirmwareVolumeBlockProtocolGuid        ## CONSUMES\r