TianoCore EDK2 master
|
#include "PiSmmCore.h"
Go to the source code of this file.
Data Structures | |
struct | HEAP_GUARD_NODE |
Macros | |
#define | BYTE_LENGTH_SHIFT 3 |
#define | GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT (EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT) |
#define | GUARDED_HEAP_MAP_TABLE_DEPTH 5 |
#define | GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 |
#define | GUARDED_HEAP_MAP_ENTRY_BITS (1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) |
#define | GUARDED_HEAP_MAP_ENTRY_BYTES (GUARDED_HEAP_MAP_ENTRY_BITS / 8) |
#define | GUARDED_HEAP_MAP_ENTRY_SHIFT |
#define | GUARDED_HEAP_MAP_ENTRY_MASK ((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1) |
#define | GUARDED_HEAP_MAP_SIZE ((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES) |
#define | GUARDED_HEAP_MAP_UNIT_SIZE (GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE) |
#define | GUARDED_HEAP_MAP_ENTRIES_PER_UNIT (GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES) |
#define | GUARDED_HEAP_MAP_ENTRY_INDEX(Address) |
#define | GUARDED_HEAP_MAP_ENTRY_BIT_INDEX(Address) |
#define | GUARDED_HEAP_MAP_BITS |
#define | GUARDED_HEAP_MAP_BIT_INDEX(Address) |
#define | GUARDED_HEAP_MAP_TABLE_SHIFT |
#define | GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS |
#define | GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS |
#define | GUARD_HEAP_TYPE_PAGE BIT2 |
#define | GUARD_HEAP_TYPE_POOL BIT3 |
#define | HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE) |
Variables | |
BOOLEAN | mOnGuarding |
Data structure and functions to allocate and free memory space.
Copyright (c) 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file HeapGuard.h.
#define BYTE_LENGTH_SHIFT 3 |
Definition at line 56 of file HeapGuard.h.
#define GUARD_HEAP_TYPE_PAGE BIT2 |
Definition at line 157 of file HeapGuard.h.
#define GUARD_HEAP_TYPE_POOL BIT3 |
Definition at line 158 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_BIT_INDEX | ( | Address | ) |
Definition at line 116 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_BITS |
Definition at line 109 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRIES_PER_UNIT (GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES) |
Definition at line 92 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_BIT_INDEX | ( | Address | ) |
Definition at line 102 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 |
Definition at line 64 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_BITS (1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) |
Definition at line 66 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_BYTES (GUARDED_HEAP_MAP_ENTRY_BITS / 8) |
Definition at line 69 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_INDEX | ( | Address | ) |
Definition at line 96 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_MASK ((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1) |
Definition at line 80 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_ENTRY_SHIFT |
Definition at line 73 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_SIZE ((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES) |
Definition at line 84 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5 |
Definition at line 61 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS |
Definition at line 145 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS |
Definition at line 132 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT (EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT) |
Definition at line 58 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_TABLE_SHIFT |
Definition at line 124 of file HeapGuard.h.
#define GUARDED_HEAP_MAP_UNIT_SIZE (GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE) |
Definition at line 88 of file HeapGuard.h.
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE) |
Definition at line 163 of file HeapGuard.h.
Adjust the base and number of pages to really allocate according to Guard.
[in,out] | Memory | Base address of free memory. |
[in,out] | NumberOfPages | Size of memory to allocate. |
Definition at line 982 of file HeapGuard.c.
Adjust the start address and number of pages to free according to Guard.
The purpose of this function is to keep the shared Guard page with adjacent memory block if it's still in guard, or free it if no more sharing. Another is to reserve pages as Guard pages in partial page free situation.
[in,out] | Memory | Base address of memory to free. |
[in,out] | NumberOfPages | Size of memory to free. |
Definition at line 884 of file HeapGuard.c.
Adjust the pool head position to make sure the Guard page is adjavent to pool tail or pool head.
[in] | Memory | Base address of memory allocated. |
[in] | NoPages | Number of pages actually allocated. |
[in] | Size | Size of memory requested. (plus pool head/tail overhead) |
Adjust the pool head position to make sure the Guard page is adjavent to pool tail or pool head.
[in] | Memory | Base address of memory allocated. |
[in] | NoPages | Number of pages actually allocated. |
[in] | Size | Size of memory requested. (plus pool head/tail overhead) |
Definition at line 1016 of file HeapGuard.c.
VOID * AdjustPoolHeadF | ( | IN EFI_PHYSICAL_ADDRESS | Memory | ) |
Get the page base address according to pool head address.
[in] | Memory | Head address of pool to free. |
Definition at line 976 of file HeapGuard.c.
VOID EFIAPI DumpGuardedMemoryBitmap | ( | VOID | ) |
Dump the guarded memory bit map.
Definition at line 1659 of file HeapGuard.c.
UINTN InternalAllocMaxAddressWithGuard | ( | IN OUT LIST_ENTRY * | FreePageList, |
IN UINTN | NumberOfPages, | ||
IN UINTN | MaxAddress, | ||
IN EFI_MEMORY_TYPE | MemoryType | ||
) |
Helper function of memory allocation with Guard pages.
FreePageList | The free page node. |
NumberOfPages | Number of pages to be allocated. |
MaxAddress | Request to allocate memory below this address. |
MemoryType | Type of memory requested. |
Definition at line 1004 of file HeapGuard.c.
BOOLEAN EFIAPI IsGuardPage | ( | IN EFI_PHYSICAL_ADDRESS | Address | ) |
Check to see if the page at the given address is a Guard page or not.
[in] | Address | The address to check for. |
Definition at line 461 of file HeapGuard.c.
BOOLEAN IsHeapGuardEnabled | ( | VOID | ) |
Check to see if the heap guard is enabled for page and/or pool allocation.
Definition at line 672 of file HeapGuard.c.
BOOLEAN EFIAPI IsMemoryGuarded | ( | IN EFI_PHYSICAL_ADDRESS | Address | ) |
Check to see if the page at the given address is guarded or not.
[in] | Address | The address to check for. |
Definition at line 486 of file HeapGuard.c.
BOOLEAN IsPageTypeToGuard | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN EFI_ALLOCATE_TYPE | AllocateType | ||
) |
Check to see if the page at the given address should be guarded or not.
[in] | MemoryType | Page type to check. |
[in] | AllocateType | Allocation type to check. |
Definition at line 658 of file HeapGuard.c.
BOOLEAN IsPoolTypeToGuard | ( | IN EFI_MEMORY_TYPE | MemoryType | ) |
Check to see if the pool at the given address should be guarded or not.
[in] | MemoryType | Pool type to check. |
Definition at line 637 of file HeapGuard.c.
VOID SetGuardForMemory | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
IN UINTN | NumberOfPages | ||
) |
Set head Guard and tail Guard for the given memory range.
[in] | Memory | Base address of memory to set guard for. |
[in] | NumberOfPages | Memory size in pages. |
Set head Guard and tail Guard for the given memory range.
[in] | Memory | Base address of memory to set guard for. |
[in] | NumberOfPages | Memory size in pages. |
Definition at line 690 of file HeapGuard.c.
EFI_STATUS SmmInternalFreePagesExWithGuard | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
IN UINTN | NumberOfPages, | ||
IN BOOLEAN | AddRegion | ||
) |
Helper function of memory free with Guard pages.
[in] | Memory | Base address of memory being freed. |
[in] | NumberOfPages | The number of pages to free. |
[in] | AddRegion | If this memory is new added region. |
EFI_NOT_FOUND | Could not find the entry that covers the range. |
EFI_INVALID_PARAMETER | Address not aligned, Address is zero or NumberOfPages is zero. |
Definition at line 1083 of file HeapGuard.c.
VOID UnsetGuardForMemory | ( | IN EFI_PHYSICAL_ADDRESS | Memory, |
IN UINTN | NumberOfPages | ||
) |
Unset head Guard and tail Guard for the given memory range.
[in] | Memory | Base address of memory to unset guard for. |
[in] | NumberOfPages | Memory size in pages. |
Unset head Guard and tail Guard for the given memory range.
[in] | Memory | Base address of memory to unset guard for. |
[in] | NumberOfPages | Memory size in pages. |
Definition at line 726 of file HeapGuard.c.
BOOLEAN VerifyMemoryGuard | ( | IN EFI_PHYSICAL_ADDRESS | BaseAddress, |
IN UINTN | NumberOfPages | ||
) |
Debug function used to verify if the Guard page is well set or not.
[in] | BaseAddress | Address of memory to check. |
[in] | NumberOfPages | Size of memory in pages. |
Definition at line 1378 of file HeapGuard.c.
|
extern |
Definition at line 17 of file HeapGuard.c.