summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2017-03-28 13:51:52 +0800
committerJeff Fan <jeff.fan@intel.com>2017-04-01 11:44:55 +0800
commit97f1061e8b3fa638a445ee6ea68d4cf0a342f91d (patch)
tree2a04e64ab265ce9b6fbacf1779248e00c701e5a2
parent7ed6f78145ee63d27c7fbcba2fbc9f562c4ed0ae (diff)
UefiCpuPkg/PiSmmCpuDxeSmm: Add IsInSmmRanges() to check SMM range
Internal function IsInSmmRanges() is added t check SMM range by saved SMM ranges beside by mCpuHotPlugData.SmrrBase/mCpuHotPlugData.SmrrSiz. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
index 1b84e2c5f3..7125aec8a9 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
@@ -1,7 +1,7 @@
/** @file
Enable SMM profile.
-Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
This program and the accompanying materials
@@ -247,6 +247,33 @@ DebugExceptionHandler (
}
/**
+ Check if the input address is in SMM ranges.
+
+ @param[in] Address The input address.
+
+ @retval TRUE The input address is in SMM.
+ @retval FALSE The input address is not in SMM.
+**/
+BOOLEAN
+IsInSmmRanges (
+ IN EFI_PHYSICAL_ADDRESS Address
+ )
+{
+ UINTN Index;
+
+ if ((Address < mCpuHotPlugData.SmrrBase) || (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {
+ return TRUE;
+ }
+ for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
+ if (Address >= mSmmCpuSmramRanges[Index].CpuStart &&
+ Address < mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
Check if the memory address will be mapped by 4KB-page.
@param Address The address of Memory.
@@ -261,7 +288,6 @@ IsAddressValid (
{
UINTN Index;
- *Nx = FALSE;
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
//
// Check configuration
@@ -276,9 +302,9 @@ IsAddressValid (
return FALSE;
} else {
- if ((Address < mCpuHotPlugData.SmrrBase) ||
- (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {
- *Nx = TRUE;
+ *Nx = TRUE;
+ if (IsInSmmRanges (Address)) {
+ *Nx = FALSE;
}
return TRUE;
}