public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] add sanity check for SetMemoryAttributes
@ 2018-04-11  8:38 Jian J Wang
  2018-04-11  8:38 ` [PATCH 1/2] MdeModulePkg/DxeCore: " Jian J Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jian J Wang @ 2018-04-11  8:38 UTC (permalink / raw)
  To: edk2-devel

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.

Jian J Wang (2):
  MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
  MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes

 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c   |  9 +++++++--
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 30 ++++++++++++++++++------------
 2 files changed, 25 insertions(+), 14 deletions(-)

-- 
2.16.2.windows.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
  2018-04-11  8:38 [PATCH 0/2] add sanity check for SetMemoryAttributes Jian J Wang
@ 2018-04-11  8:38 ` Jian J Wang
  2018-04-11  8:38 ` [PATCH 2/2] MdeModulePkg/SmmCore: " Jian J Wang
  2018-04-12  5:54 ` [PATCH 0/2] " Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Jian J Wang @ 2018-04-11  8:38 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Eric Dong, Jiewen Yao, Ruiyu Ni

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>
---
 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index fd6aeee8da..9d765c98f6 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -580,6 +580,8 @@ SetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress
   )
 {
+  EFI_STATUS      Status;
+
   if (gCpu == NULL) {
     return;
   }
@@ -593,7 +595,8 @@ SetGuardPage (
   // Note: This might overwrite other attributes needed by other features,
   // such as NX memory protection.
   //
-  gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
+  Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
+  ASSERT_EFI_ERROR (Status);
   mOnGuarding = FALSE;
 }
 
@@ -613,6 +616,7 @@ UnsetGuardPage (
   )
 {
   UINT64          Attributes;
+  EFI_STATUS      Status;
 
   if (gCpu == NULL) {
     return;
@@ -638,7 +642,8 @@ UnsetGuardPage (
   // such as memory protection (NX). Please make sure they are not enabled
   // at the same time.
   //
-  gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);
+  Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);
+  ASSERT_EFI_ERROR (Status);
   mOnGuarding = FALSE;
 }
 
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes
  2018-04-11  8:38 [PATCH 0/2] add sanity check for SetMemoryAttributes Jian J Wang
  2018-04-11  8:38 ` [PATCH 1/2] MdeModulePkg/DxeCore: " Jian J Wang
@ 2018-04-11  8:38 ` Jian J Wang
  2018-04-12  5:54 ` [PATCH 0/2] " Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Jian J Wang @ 2018-04-11  8:38 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Eric Dong, Jiewen Yao, Ruiyu Ni

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>
---
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index d5556eb79c..d9e54b96cb 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -592,14 +592,17 @@ SetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress
   )
 {
+  EFI_STATUS      Status;
+
   if (mSmmMemoryAttribute != NULL) {
     mOnGuarding = TRUE;
-    mSmmMemoryAttribute->SetMemoryAttributes (
-                           mSmmMemoryAttribute,
-                           BaseAddress,
-                           EFI_PAGE_SIZE,
-                           EFI_MEMORY_RP
-                           );
+    Status = mSmmMemoryAttribute->SetMemoryAttributes (
+                                    mSmmMemoryAttribute,
+                                    BaseAddress,
+                                    EFI_PAGE_SIZE,
+                                    EFI_MEMORY_RP
+                                    );
+    ASSERT_EFI_ERROR (Status);
     mOnGuarding = FALSE;
   }
 }
@@ -619,14 +622,17 @@ UnsetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress
   )
 {
+  EFI_STATUS      Status;
+
   if (mSmmMemoryAttribute != NULL) {
     mOnGuarding = TRUE;
-    mSmmMemoryAttribute->ClearMemoryAttributes (
-                           mSmmMemoryAttribute,
-                           BaseAddress,
-                           EFI_PAGE_SIZE,
-                           EFI_MEMORY_RP
-                           );
+    Status = mSmmMemoryAttribute->ClearMemoryAttributes (
+                                    mSmmMemoryAttribute,
+                                    BaseAddress,
+                                    EFI_PAGE_SIZE,
+                                    EFI_MEMORY_RP
+                                    );
+    ASSERT_EFI_ERROR (Status);
     mOnGuarding = FALSE;
   }
 }
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] add sanity check for SetMemoryAttributes
  2018-04-11  8:38 [PATCH 0/2] add sanity check for SetMemoryAttributes Jian J Wang
  2018-04-11  8:38 ` [PATCH 1/2] MdeModulePkg/DxeCore: " Jian J Wang
  2018-04-11  8:38 ` [PATCH 2/2] MdeModulePkg/SmmCore: " Jian J Wang
@ 2018-04-12  5:54 ` Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Zeng, Star @ 2018-04-12  5:54 UTC (permalink / raw)
  To: Wang, Jian J, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jian J Wang
Sent: Wednesday, April 11, 2018 4:39 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] add sanity check for SetMemoryAttributes

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.

Jian J Wang (2):
  MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
  MdeModulePkg/SmmCore: add sanity check for SetMemoryAttributes

 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c   |  9 +++++++--
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 30 ++++++++++++++++++------------
 2 files changed, 25 insertions(+), 14 deletions(-)

--
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-12  5:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-11  8:38 [PATCH 0/2] add sanity check for SetMemoryAttributes Jian J Wang
2018-04-11  8:38 ` [PATCH 1/2] MdeModulePkg/DxeCore: " Jian J Wang
2018-04-11  8:38 ` [PATCH 2/2] MdeModulePkg/SmmCore: " Jian J Wang
2018-04-12  5:54 ` [PATCH 0/2] " Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox