summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/FaultTolerantWriteDxe
diff options
context:
space:
mode:
authorYao, Jiewen <jiewen.yao@intel.com>2015-02-02 14:42:22 +0000
committerjyao1 <jyao1@Edk2>2015-02-02 14:42:22 +0000
commit842b1242d19225bb6d6146861d3418a5c9549175 (patch)
tree36474e4579659ccdda856567ea91f4e0f37f4352 /MdeModulePkg/Universal/FaultTolerantWriteDxe
parentd425764e3f55f949e17daa42aaf0b8c2c2ad4046 (diff)
downloadedk2-842b1242d19225bb6d6146861d3418a5c9549175.tar.gz
edk2-842b1242d19225bb6d6146861d3418a5c9549175.tar.bz2
edk2-842b1242d19225bb6d6146861d3418a5c9549175.zip
Use SmmMemLib to check communication buffer.
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
Diffstat (limited to 'MdeModulePkg/Universal/FaultTolerantWriteDxe')
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c85
-rw-r--r--MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf3
2 files changed, 5 insertions, 83 deletions
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
index 82219804d1..c96469f189 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
@@ -43,7 +43,7 @@
Caution: This module requires additional review when modified.
This driver need to make sure the CommBuffer is not in the SMRAM range.
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2015, 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
@@ -56,6 +56,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiSmm.h>
#include <Library/SmmServicesTableLib.h>
+#include <Library/SmmMemLib.h>
#include <Protocol/SmmSwapAddressRange.h>
#include "FaultTolerantWrite.h"
#include "FaultTolerantWriteSmmCommon.h"
@@ -64,8 +65,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_EVENT mFvbRegistration = NULL;
EFI_FTW_DEVICE *mFtwDevice = NULL;
-EFI_SMRAM_DESCRIPTOR *mSmramRanges;
-UINTN mSmramRangeCount;
///
/// The flag to indicate whether the platform has left the DXE phase of execution.
@@ -73,60 +72,6 @@ UINTN mSmramRangeCount;
BOOLEAN mEndOfDxe = FALSE;
/**
- This function check if the address is in SMRAM.
-
- @param Buffer the buffer address to be checked.
- @param Length the buffer length to be checked.
-
- @retval TRUE this address is in SMRAM.
- @retval FALSE this address is NOT in SMRAM.
-**/
-BOOLEAN
-InternalIsAddressInSmram (
- IN EFI_PHYSICAL_ADDRESS Buffer,
- IN UINT64 Length
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < mSmramRangeCount; Index ++) {
- if (((Buffer >= mSmramRanges[Index].CpuStart) && (Buffer < mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)) ||
- ((mSmramRanges[Index].CpuStart >= Buffer) && (mSmramRanges[Index].CpuStart < Buffer + Length))) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**
- This function check if the address refered by Buffer and Length is valid.
-
- @param Buffer the buffer address to be checked.
- @param Length the buffer length to be checked.
-
- @retval TRUE this address is valid.
- @retval FALSE this address is NOT valid.
-**/
-BOOLEAN
-InternalIsAddressValid (
- IN UINTN Buffer,
- IN UINTN Length
- )
-{
- if (Buffer > (MAX_ADDRESS - Length)) {
- //
- // Overflow happen
- //
- return FALSE;
- }
- if (InternalIsAddressInSmram ((EFI_PHYSICAL_ADDRESS)Buffer, (UINT64)Length)) {
- return FALSE;
- }
- return TRUE;
-}
-
-/**
Retrive the SMM FVB protocol interface by HANDLE.
@param[in] FvBlockHandle The handle of SMM FVB protocol that provides services for
@@ -391,7 +336,7 @@ SmmFaultTolerantWriteHandler (
}
CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE;
- if (!InternalIsAddressValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+ if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n"));
return EFI_SUCCESS;
}
@@ -670,8 +615,6 @@ SmmFaultTolerantWriteInitialize (
)
{
EFI_STATUS Status;
- EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
- UINTN Size;
VOID *SmmEndOfDxeRegistration;
//
@@ -683,28 +626,6 @@ SmmFaultTolerantWriteInitialize (
}
//
- // Get SMRAM information
- //
- Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
- ASSERT_EFI_ERROR (Status);
-
- Size = 0;
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
-
- Status = gSmst->SmmAllocatePool (
- EfiRuntimeServicesData,
- Size,
- (VOID **)&mSmramRanges
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);
- ASSERT_EFI_ERROR (Status);
-
- mSmramRangeCount = Size / sizeof (EFI_SMRAM_DESCRIPTOR);
-
- //
// Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
//
Status = gSmst->SmmRegisterProtocolNotify (
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
index 105820c17b..b9177cd29b 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
@@ -6,7 +6,7 @@
# depends on the full functionality SMM FVB protocol that support read, write/erase
# flash access.
#
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2015, 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
@@ -54,6 +54,7 @@
UefiLib
PcdLib
ReportStatusCodeLib
+ SmmMemLib
[Guids]
#