]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg PiSmmCpuDxeSmm: SMM profile and static paging mutual exclusion
authorStar Zeng <star.zeng@intel.com>
Thu, 7 Dec 2017 09:00:48 +0000 (17:00 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 8 Dec 2017 04:29:24 +0000 (12:29 +0800)
SMM profile and static paging could not be enabled at the same time,
this patch is to add check and comments to make sure it.

Similar comments are also added for the case of static paging and
heap guard for SMM.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
UefiCpuPkg/UefiCpuPkg.dec
UefiCpuPkg/UefiCpuPkg.uni

index 6e1ffe7c62879677a96f905e6dcd309932802417..9300a232e4a6658ba6720c618defbd5cff7f795b 100644 (file)
@@ -199,12 +199,21 @@ SetPageTableAttributes (
   BOOLEAN               PageTableSplitted;\r
 \r
   //\r
-  // Don't mark page table as read-only if heap guard is enabled.\r
+  // Don't mark page table to read-only if heap guard is enabled.\r
   //\r
   //      BIT2: SMM page guard enabled\r
   //      BIT3: SMM pool guard enabled\r
   //\r
   if ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {\r
+    DEBUG ((DEBUG_INFO, "Don't mark page table to read-only as heap guard is enabled\n"));\r
+    return ;\r
+  }\r
+\r
+  //\r
+  // Don't mark page table to read-only if SMM profile is enabled.\r
+  //\r
+  if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
+    DEBUG ((DEBUG_INFO, "Don't mark page table to read-only as SMM profile is enabled\n"));\r
     return ;\r
   }\r
 \r
index 6478c6c3e355e28afa0c46af94538ef61b11ec8a..0fe944fc18cc9402c0217110ba723363ec0ae855 100644 (file)
@@ -919,17 +919,24 @@ SetPageTableAttributes (
   //\r
   // Don't do this if\r
   //  - no static page table; or\r
-  //  - SMM heap guard feature enabled\r
+  //  - SMM heap guard feature enabled; or\r
   //      BIT2: SMM page guard enabled\r
   //      BIT3: SMM pool guard enabled\r
+  //  - SMM profile feature enabled\r
   //\r
   if (!mCpuSmmStaticPageTable ||\r
-      (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {\r
+      ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) ||\r
+      FeaturePcdGet (PcdCpuSmmProfileEnable)) {\r
     //\r
-    // Static paging and heap guard should not be enabled at the same time.\r
+    // Static paging and heap guard could not be enabled at the same time.\r
     //\r
     ASSERT (!(mCpuSmmStaticPageTable &&\r
               (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0));\r
+\r
+    //\r
+    // Static paging and SMM profile could not be enabled at the same time.\r
+    //\r
+    ASSERT (!(mCpuSmmStaticPageTable && FeaturePcdGet (PcdCpuSmmProfileEnable)));\r
     return ;\r
   }\r
 \r
index d2965ba14c2dba0154db0fde032464527ea2f99e..6bac23ff52bcc89324fe22a7a8e48b46d3fc6405 100644 (file)
@@ -84,6 +84,7 @@
 [PcdsFeatureFlag]\r
   ## Indicates if SMM Profile will be enabled.\r
   #  If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged.\r
+  #  It could not be enabled at the same time with SMM static page table feature (PcdCpuSmmStaticPageTable).\r
   #  This PCD is only for validation purpose. It should be set to false in production.<BR><BR>\r
   #   TRUE  - SMM Profile will be enabled.<BR>\r
   #   FALSE - SMM Profile will be disabled.<BR>\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate|0|UINT8|0x00000007\r
 \r
   ## Indicates if SMM uses static page table.\r
-  #  If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.<BR><BR>\r
-  #  This flag only impacts X64 build, because SMM alway builds static page table for IA32.\r
+  #  If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.\r
+  #  This flag only impacts X64 build, because SMM always builds static page table for IA32.\r
+  #  It could not be enabled at the same time with SMM profile feature (PcdCpuSmmProfileEnable).\r
+  #  It could not be enabled also at the same time with heap guard feature for SMM\r
+  #  (PcdHeapGuardPropertyMask in MdeModulePkg).<BR><BR>\r
   #   TRUE  - SMM uses static page table for all memory.<BR>\r
   #   FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.<BR>\r
   # @Prompt Use static page table for all memory in SMM.\r
index 9472b185e46e6d6f6315f4370e23a3e122cdd0f8..a7073b10c80d0f92cb1a1d65f741257353dd1919 100644 (file)
 \r
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_PROMPT  #language en-US "Enable SMM Profile"\r
 \r
-#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_HELP  #language en-US "Indicates if SMM Profile will be enabled. If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged. This PCD is only for validation purpose. It should be set to false in production.<BR><BR>\n"\r
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmProfileEnable_HELP  #language en-US "Indicates if SMM Profile will be enabled.\n"\r
+                                                                                   "If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged.\n"\r
+                                                                                   "It could not be enabled at the same time with SMM static page table feature (PcdCpuSmmStaticPageTable).\n"\r
+                                                                                   "This PCD is only for validation purpose. It should be set to false in production.<BR><BR>\n"\r
                                                                                    "TRUE  - SMM Profile will be enabled.<BR>\n"\r
                                                                                    "FALSE - SMM Profile will be disabled.<BR>"\r
 \r
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_PROMPT  #language en-US "Use static page table for all memory in SMM."\r
 \r
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuSmmStaticPageTable_HELP  #language en-US "Indicates if SMM uses static page table.\n"\r
-                                                                                     "If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.<BR><BR>\n"\r
-                                                                                     "This flag only impacts X64 build, because SMM alway builds static page table for IA32.\n"\r
+                                                                                     "If enabled, SMM will not use on-demand paging. SMM will build static page table for all memory.\n"\r
+                                                                                     "This flag only impacts X64 build, because SMM always builds static page table for IA32.\n"\r
+                                                                                     "It could not be enabled at the same time with SMM profile feature (PcdCpuSmmProfileEnable).\n"\r
+                                                                                     "It could not be enabled also at the same time with heap guard feature for SMM\n"\r
+                                                                                     "(PcdHeapGuardPropertyMask in MdeModulePkg).<BR><BR>\n"\r
                                                                                      "TRUE  - SMM uses static page table for all memory.<BR>\n"\r
                                                                                      "FALSE - SMM uses static page table for below 4G memory and use on-demand paging for above 4G memory.<BR>"\r
 \r