]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpuDxeSmm: Add IsInSmmRanges() to check SMM range
authorJeff Fan <jeff.fan@intel.com>
Tue, 28 Mar 2017 05:51:52 +0000 (13:51 +0800)
committerJeff Fan <jeff.fan@intel.com>
Sat, 1 Apr 2017 03:44:55 +0000 (11:44 +0800)
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>
UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c

index 1b84e2c5f3d0db1037886a83d383db90cdc15203..7125aec8a9d5093fc8fc663d12c54e76a1dcbfa7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Enable SMM profile.\r
 \r
-Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
@@ -246,6 +246,33 @@ DebugExceptionHandler (
   ClearTrapFlag (SystemContext);\r
 }\r
 \r
+/**\r
+  Check if the input address is in SMM ranges.\r
+\r
+  @param[in]  Address       The input address.\r
+\r
+  @retval TRUE     The input address is in SMM.\r
+  @retval FALSE    The input address is not in SMM.\r
+**/\r
+BOOLEAN\r
+IsInSmmRanges (\r
+  IN EFI_PHYSICAL_ADDRESS   Address\r
+  )\r
+{\r
+  UINTN  Index;\r
+\r
+  if ((Address < mCpuHotPlugData.SmrrBase) || (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {\r
+    return TRUE;\r
+  }\r
+  for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {\r
+    if (Address >= mSmmCpuSmramRanges[Index].CpuStart &&\r
+        Address < mSmmCpuSmramRanges[Index].CpuStart + mSmmCpuSmramRanges[Index].PhysicalSize) {\r
+      return TRUE;\r
+    }\r
+  }\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Check if the memory address will be mapped by 4KB-page.\r
 \r
@@ -261,7 +288,6 @@ IsAddressValid (
 {\r
   UINTN  Index;\r
 \r
-  *Nx = FALSE;\r
   if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
     //\r
     // Check configuration\r
@@ -276,9 +302,9 @@ IsAddressValid (
     return FALSE;\r
 \r
   } else {\r
-    if ((Address < mCpuHotPlugData.SmrrBase) ||\r
-        (Address >= mCpuHotPlugData.SmrrBase + mCpuHotPlugData.SmrrSize)) {\r
-      *Nx = TRUE;\r
+    *Nx = TRUE;\r
+    if (IsInSmmRanges (Address)) {\r
+      *Nx = FALSE;\r
     }\r
     return TRUE;\r
   }\r