]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes
authorJian J Wang <jian.j.wang@intel.com>
Wed, 11 Apr 2018 08:35:32 +0000 (16:35 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 13 Apr 2018 05:04:59 +0000 (13:04 +0800)
Heap Guard feature needs enough memory and paging to work. Otherwise
calling SetMemoryAttributes to change page attribute will fail. This
patch add necessary check of result of calling SetMemoryAttributes.
This can help users to debug their problem in enabling this feature.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/PiSmmCore/HeapGuard.c

index d5556eb79cb1cfd73ba1569fe8c9e2ee02708cbb..d9e54b96cb0074bc66e5bc137f72bb4844fc673d 100644 (file)
@@ -592,14 +592,17 @@ SetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress\r
   )\r
 {\r
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress\r
   )\r
 {\r
+  EFI_STATUS      Status;\r
+\r
   if (mSmmMemoryAttribute != NULL) {\r
     mOnGuarding = TRUE;\r
   if (mSmmMemoryAttribute != NULL) {\r
     mOnGuarding = TRUE;\r
-    mSmmMemoryAttribute->SetMemoryAttributes (\r
-                           mSmmMemoryAttribute,\r
-                           BaseAddress,\r
-                           EFI_PAGE_SIZE,\r
-                           EFI_MEMORY_RP\r
-                           );\r
+    Status = mSmmMemoryAttribute->SetMemoryAttributes (\r
+                                    mSmmMemoryAttribute,\r
+                                    BaseAddress,\r
+                                    EFI_PAGE_SIZE,\r
+                                    EFI_MEMORY_RP\r
+                                    );\r
+    ASSERT_EFI_ERROR (Status);\r
     mOnGuarding = FALSE;\r
   }\r
 }\r
     mOnGuarding = FALSE;\r
   }\r
 }\r
@@ -619,14 +622,17 @@ UnsetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress\r
   )\r
 {\r
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress\r
   )\r
 {\r
+  EFI_STATUS      Status;\r
+\r
   if (mSmmMemoryAttribute != NULL) {\r
     mOnGuarding = TRUE;\r
   if (mSmmMemoryAttribute != NULL) {\r
     mOnGuarding = TRUE;\r
-    mSmmMemoryAttribute->ClearMemoryAttributes (\r
-                           mSmmMemoryAttribute,\r
-                           BaseAddress,\r
-                           EFI_PAGE_SIZE,\r
-                           EFI_MEMORY_RP\r
-                           );\r
+    Status = mSmmMemoryAttribute->ClearMemoryAttributes (\r
+                                    mSmmMemoryAttribute,\r
+                                    BaseAddress,\r
+                                    EFI_PAGE_SIZE,\r
+                                    EFI_MEMORY_RP\r
+                                    );\r
+    ASSERT_EFI_ERROR (Status);\r
     mOnGuarding = FALSE;\r
   }\r
 }\r
     mOnGuarding = FALSE;\r
   }\r
 }\r