]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
MdeModulePkg/DxeCore: add sanity check for SetMemoryAttributes
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / HeapGuard.c
index fd6aeee8da9d70c5e7523d41064cdc2b85e5c6df..9d765c98f6ab3b5017d47bc8694a48671ad174f7 100644 (file)
@@ -580,6 +580,8 @@ SetGuardPage (
   IN  EFI_PHYSICAL_ADDRESS      BaseAddress\r
   )\r
 {\r
+  EFI_STATUS      Status;\r
+\r
   if (gCpu == NULL) {\r
     return;\r
   }\r
@@ -593,7 +595,8 @@ SetGuardPage (
   // Note: This might overwrite other attributes needed by other features,\r
   // such as NX memory protection.\r
   //\r
-  gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);\r
+  Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);\r
+  ASSERT_EFI_ERROR (Status);\r
   mOnGuarding = FALSE;\r
 }\r
 \r
@@ -613,6 +616,7 @@ UnsetGuardPage (
   )\r
 {\r
   UINT64          Attributes;\r
+  EFI_STATUS      Status;\r
 \r
   if (gCpu == NULL) {\r
     return;\r
@@ -638,7 +642,8 @@ UnsetGuardPage (
   // such as memory protection (NX). Please make sure they are not enabled\r
   // at the same time.\r
   //\r
-  gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);\r
+  Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, Attributes);\r
+  ASSERT_EFI_ERROR (Status);\r
   mOnGuarding = FALSE;\r
 }\r
 \r