summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/HeapGuard.c13
-rw-r--r--MdeModulePkg/Core/PiSmmCore/HeapGuard.c13
2 files changed, 18 insertions, 8 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index 98d597b..752befa 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -373,7 +373,7 @@ ClearGuardedMemoryBits (
@param[in] Address Memory address to retrieve from.
@param[in] NumberOfPages Number of pages to retrieve.
- @return VOID.
+ @return An integer containing the guarded memory bitmap.
**/
UINTN
GetGuardedMemoryBits (
@@ -501,8 +501,13 @@ IsGuardPage (
{
UINTN BitMap;
+ //
+ // There must be at least one guarded page before and/or after given
+ // address if it's a Guard page. The bitmap pattern should be one of
+ // 001, 100 and 101
+ //
BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
- return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+ return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
}
/**
@@ -519,7 +524,7 @@ IsHeadGuard (
IN EFI_PHYSICAL_ADDRESS Address
)
{
- return (GetGuardedMemoryBits (Address, 2) == 0b10);
+ return (GetGuardedMemoryBits (Address, 2) == BIT1);
}
/**
@@ -536,7 +541,7 @@ IsTailGuard (
IN EFI_PHYSICAL_ADDRESS Address
)
{
- return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+ return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
}
/**
diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index 6fda9ba..c7a1408 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -385,7 +385,7 @@ ClearGuardedMemoryBits (
@param[in] Address Memory address to retrieve from.
@param[in] NumberOfPages Number of pages to retrieve.
- @return VOID
+ @return An integer containing the guarded memory bitmap.
**/
UINTN
GetGuardedMemoryBits (
@@ -513,8 +513,13 @@ IsGuardPage (
{
UINTN BitMap;
+ //
+ // There must be at least one guarded page before and/or after given
+ // address if it's a Guard page. The bitmap pattern should be one of
+ // 001, 100 and 101
+ //
BitMap = GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 3);
- return ((BitMap == 0b001) || (BitMap == 0b100) || (BitMap == 0b101));
+ return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
}
/**
@@ -531,7 +536,7 @@ IsHeadGuard (
IN EFI_PHYSICAL_ADDRESS Address
)
{
- return (GetGuardedMemoryBits (Address, 2) == 0b10);
+ return (GetGuardedMemoryBits (Address, 2) == BIT1);
}
/**
@@ -548,7 +553,7 @@ IsTailGuard (
IN EFI_PHYSICAL_ADDRESS Address
)
{
- return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == 0b01);
+ return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
}
/**