diff options
-rw-r--r-- | MdeModulePkg/Core/Dxe/Mem/HeapGuard.h | 14 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Mem/Page.c | 11 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Mem/Pool.c | 11 | ||||
-rw-r--r-- | MdeModulePkg/MdeModulePkg.dec | 10 |
4 files changed, 46 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.h b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.h index 24b4206c0e..578e857465 100644 --- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.h +++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.h @@ -469,4 +469,18 @@ PromoteGuardedFreePages ( extern BOOLEAN mOnGuarding;
+//
+// The heap guard system does not support non-EFI_PAGE_SIZE alignments.
+// Architectures that require larger RUNTIME_PAGE_ALLOCATION_GRANULARITY
+// cannot have EfiRuntimeServicesCode, EfiRuntimeServicesData, EfiReservedMemoryType,
+// and EfiACPIMemoryNVS guarded. OSes do not map guard pages anyway, so this is a
+// minimal loss. Not guarding prevents alignment mismatches
+//
+STATIC_ASSERT (
+ RUNTIME_PAGE_ALLOCATION_GRANULARITY == EFI_PAGE_SIZE ||
+ (((FixedPcdGet64 (PcdHeapGuardPageType) & 0x461) == 0) &&
+ ((FixedPcdGet64 (PcdHeapGuardPoolType) & 0x461) == 0)),
+ "Unsupported Heap Guard configuration on system with greater than EFI_PAGE_SIZE RUNTIME_PAGE_ALLOCATION_GRANULARITY"
+ );
+
#endif
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index cd201d36a3..26584648c2 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1411,6 +1411,17 @@ CoreInternalAllocatePages ( Alignment = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
}
+ //
+ // The heap guard system does not support non-EFI_PAGE_SIZE alignments.
+ // Architectures that require larger RUNTIME_PAGE_ALLOCATION_GRANULARITY
+ // will have the runtime memory regions unguarded. OSes do not
+ // map guard pages anyway, so this is a minimal loss. Not guarding prevents
+ // alignment mismatches
+ //
+ if (Alignment != EFI_PAGE_SIZE) {
+ NeedGuard = FALSE;
+ }
+
if (Type == AllocateAddress) {
if ((*Memory & (Alignment - 1)) != 0) {
return EFI_NOT_FOUND;
diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index ccfce8c5f9..72293e6dfe 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -381,6 +381,17 @@ CoreAllocatePoolI ( }
//
+ // The heap guard system does not support non-EFI_PAGE_SIZE alignments.
+ // Architectures that require larger RUNTIME_PAGE_ALLOCATION_GRANULARITY
+ // will have the runtime memory regions unguarded. OSes do not
+ // map guard pages anyway, so this is a minimal loss. Not guarding prevents
+ // alignment mismatches
+ //
+ if (Granularity != EFI_PAGE_SIZE) {
+ NeedGuard = FALSE;
+ }
+
+ //
// Adjust the size by the pool header & tail overhead
//
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index a2cd83345f..a82dedc070 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1027,6 +1027,11 @@ # free pages for all of them. The page allocation for the type related to
# cleared bits keeps the same as ususal.
#
+ # The heap guard system only supports guarding EfiRuntimeServicesCode, EfiRuntimeServicesData,
+ # EfiReservedMemoryType, and EfiACPIMemoryNVS memory types for systems that have
+ # RUNTIME_PAGE_ALLOCATION_GRANULARITY == EFI_PAGE_SIZE. This is to preserve alignment requirements
+ # without extending the page guard size to very large granularities.
+ #
# This PCD is only valid if BIT0 and/or BIT2 are set in PcdHeapGuardPropertyMask.
#
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
@@ -1058,6 +1063,11 @@ # if there's enough free memory for all of them. The pool allocation for the
# type related to cleared bits keeps the same as ususal.
#
+ # The heap guard system only supports guarding EfiRuntimeServicesCode, EfiRuntimeServicesData,
+ # EfiReservedMemoryType, and EfiACPIMemoryNVS memory types for systems that have
+ # RUNTIME_PAGE_ALLOCATION_GRANULARITY == EFI_PAGE_SIZE. This is to preserve alignment requirements
+ # without extending the page guard size to very large granularities.
+ #
# This PCD is only valid if BIT1 and/or BIT3 are set in PcdHeapGuardPropertyMask.
#
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
|