]> git.proxmox.com Git - mirror_edk2.git/commitdiff
QuarkSocPkg/SmmCpuFeaturesLib: Add SMRR PhysBase/PhysMask fields check
authorMichael Kinney <michael.d.kinney@intel.com>
Tue, 17 May 2016 18:15:54 +0000 (11:15 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Thu, 19 May 2016 17:04:34 +0000 (10:04 -0700)
SMRR range size and alignment should follow the rules like MTRR:
a. The minimum range size is 4 KBytes and the base address of the
   range must be on at least a 4-KByte boundary.
b. For ranges greater than 4 KBytes, each range must be of length
   2^n and its base address must be aligned on a 2^n boundary, where
   n is a value equal to or greater than 12. The base-address
   alignment value cannot be less than its length.
Thus, it could meet "Address_Within_Range AND PhysMask = PhysBase
AND PhysMask".

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
QuarkSocPkg/QuarkNorthCluster/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
QuarkSocPkg/QuarkNorthCluster/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf

index 6c4664553154d904c51bbd105dd9da1b6ec48073..54eeac6d19a33b84b72ba68f4f07191f9e74f81b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 The Quark CPU specific programming for PiSmmCpuDxeSmm module.\r
 \r
-Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 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
@@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <PiSmm.h>\r
 #include <Library/SmmCpuFeaturesLib.h>\r
 #include <Register/SmramSaveStateMap.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
 #include <Library/QNCAccessLib.h>\r
 \r
 #define  EFI_MSR_SMRR_PHYS_MASK_VALID          BIT11\r
@@ -61,6 +63,18 @@ SmmCpuFeaturesInitializeProcessor (
   CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);\r
   CpuState->x86.SMBASE = CpuHotPlugData->SmBase[CpuIndex];\r
 \r
+  //\r
+  // SMRR size cannot be less than 4-KBytes\r
+  // SMRR size must be of length 2^n\r
+  // SMRR base alignment cannot be less than SMRR length\r
+  //\r
+  if ((CpuHotPlugData->SmrrSize < SIZE_4KB) ||\r
+      (CpuHotPlugData->SmrrSize != GetPowerOfTwo32 (CpuHotPlugData->SmrrSize)) ||\r
+      ((CpuHotPlugData->SmrrBase & ~(CpuHotPlugData->SmrrSize - 1)) != CpuHotPlugData->SmrrBase)) {\r
+    DEBUG ((EFI_D_ERROR, "SMM Base/Size does not meet alignment/size requirement!\n"));\r
+    CpuDeadLoop ();\r
+  }\r
+\r
   //\r
   // Use QNC to initialize SMRR on Quark\r
   //\r
index 473ece0d495f57690a71ece44797d091e18a8faf..267ac8423df8383de0fd57b374e6926815ef7d04 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  The CPU specific programming for PiSmmCpuDxeSmm module.\r
 #\r
-#  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 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
@@ -30,5 +30,7 @@
   SmmCpuFeaturesLib.c\r
 \r
 [LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
   QNCAccessLib\r
 \r