mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Fix unix style of EOL
Cc: Wu Hao <hao.a.wu@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
parent
a89b923ea9
commit
e63da9f033
|
@ -56,7 +56,7 @@
|
||||||
Mem/MemData.c
|
Mem/MemData.c
|
||||||
Mem/Imem.h
|
Mem/Imem.h
|
||||||
Mem/MemoryProfileRecord.c
|
Mem/MemoryProfileRecord.c
|
||||||
Mem/HeapGuard.c
|
Mem/HeapGuard.c
|
||||||
FwVolBlock/FwVolBlock.c
|
FwVolBlock/FwVolBlock.c
|
||||||
FwVolBlock/FwVolBlock.h
|
FwVolBlock/FwVolBlock.h
|
||||||
FwVol/FwVolWrite.c
|
FwVol/FwVolWrite.c
|
||||||
|
@ -194,9 +194,9 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
||||||
|
|
||||||
# [Hob]
|
# [Hob]
|
||||||
# RESOURCE_DESCRIPTOR ## CONSUMES
|
# RESOURCE_DESCRIPTOR ## CONSUMES
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,394 +1,394 @@
|
||||||
/** @file
|
/** @file
|
||||||
Data type, macros and function prototypes of heap guard feature.
|
Data type, macros and function prototypes of heap guard feature.
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef _HEAPGUARD_H_
|
#ifndef _HEAPGUARD_H_
|
||||||
#define _HEAPGUARD_H_
|
#define _HEAPGUARD_H_
|
||||||
|
|
||||||
//
|
//
|
||||||
// Following macros are used to define and access the guarded memory bitmap
|
// Following macros are used to define and access the guarded memory bitmap
|
||||||
// table.
|
// table.
|
||||||
//
|
//
|
||||||
// To simplify the access and reduce the memory used for this table, the
|
// To simplify the access and reduce the memory used for this table, the
|
||||||
// table is constructed in the similar way as page table structure but in
|
// table is constructed in the similar way as page table structure but in
|
||||||
// reverse direction, i.e. from bottom growing up to top.
|
// reverse direction, i.e. from bottom growing up to top.
|
||||||
//
|
//
|
||||||
// - 1-bit tracks 1 page (4KB)
|
// - 1-bit tracks 1 page (4KB)
|
||||||
// - 1-UINT64 map entry tracks 256KB memory
|
// - 1-UINT64 map entry tracks 256KB memory
|
||||||
// - 1K-UINT64 map table tracks 256MB memory
|
// - 1K-UINT64 map table tracks 256MB memory
|
||||||
// - Five levels of tables can track any address of memory of 64-bit
|
// - Five levels of tables can track any address of memory of 64-bit
|
||||||
// system, like below.
|
// system, like below.
|
||||||
//
|
//
|
||||||
// 512 * 512 * 512 * 512 * 1K * 64b * 4K
|
// 512 * 512 * 512 * 512 * 1K * 64b * 4K
|
||||||
// 111111111 111111111 111111111 111111111 1111111111 111111 111111111111
|
// 111111111 111111111 111111111 111111111 1111111111 111111 111111111111
|
||||||
// 63 54 45 36 27 17 11 0
|
// 63 54 45 36 27 17 11 0
|
||||||
// 9b 9b 9b 9b 10b 6b 12b
|
// 9b 9b 9b 9b 10b 6b 12b
|
||||||
// L0 -> L1 -> L2 -> L3 -> L4 -> bits -> page
|
// L0 -> L1 -> L2 -> L3 -> L4 -> bits -> page
|
||||||
// 1FF 1FF 1FF 1FF 3FF 3F FFF
|
// 1FF 1FF 1FF 1FF 3FF 3F FFF
|
||||||
//
|
//
|
||||||
// L4 table has 1K * sizeof(UINT64) = 8K (2-page), which can track 256MB
|
// L4 table has 1K * sizeof(UINT64) = 8K (2-page), which can track 256MB
|
||||||
// memory. Each table of L0-L3 will be allocated when its memory address
|
// memory. Each table of L0-L3 will be allocated when its memory address
|
||||||
// range is to be tracked. Only 1-page will be allocated each time. This
|
// range is to be tracked. Only 1-page will be allocated each time. This
|
||||||
// can save memories used to establish this map table.
|
// can save memories used to establish this map table.
|
||||||
//
|
//
|
||||||
// For a normal configuration of system with 4G memory, two levels of tables
|
// For a normal configuration of system with 4G memory, two levels of tables
|
||||||
// can track the whole memory, because two levels (L3+L4) of map tables have
|
// can track the whole memory, because two levels (L3+L4) of map tables have
|
||||||
// already coverred 37-bit of memory address. And for a normal UEFI BIOS,
|
// already coverred 37-bit of memory address. And for a normal UEFI BIOS,
|
||||||
// less than 128M memory would be consumed during boot. That means we just
|
// less than 128M memory would be consumed during boot. That means we just
|
||||||
// need
|
// need
|
||||||
//
|
//
|
||||||
// 1-page (L3) + 2-page (L4)
|
// 1-page (L3) + 2-page (L4)
|
||||||
//
|
//
|
||||||
// memory (3 pages) to track the memory allocation works. In this case,
|
// memory (3 pages) to track the memory allocation works. In this case,
|
||||||
// there's no need to setup L0-L2 tables.
|
// there's no need to setup L0-L2 tables.
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Each entry occupies 8B/64b. 1-page can hold 512 entries, which spans 9
|
// Each entry occupies 8B/64b. 1-page can hold 512 entries, which spans 9
|
||||||
// bits in address. (512 = 1 << 9)
|
// bits in address. (512 = 1 << 9)
|
||||||
//
|
//
|
||||||
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT \
|
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT \
|
||||||
(EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT)
|
(EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
||||||
|
|
||||||
// Use UINT64_index + bit_index_of_UINT64 to locate the bit in may
|
// Use UINT64_index + bit_index_of_UINT64 to locate the bit in may
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BITS \
|
#define GUARDED_HEAP_MAP_ENTRY_BITS \
|
||||||
(1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)
|
(1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BYTES \
|
#define GUARDED_HEAP_MAP_ENTRY_BYTES \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_BITS / 8)
|
(GUARDED_HEAP_MAP_ENTRY_BITS / 8)
|
||||||
|
|
||||||
// L4 table address width: 64 - 9 * 4 - 6 - 12 = 10b
|
// L4 table address width: 64 - 9 * 4 - 6 - 12 = 10b
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
#define GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_BITS \
|
(GUARDED_HEAP_MAP_ENTRY_BITS \
|
||||||
- GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 4 \
|
- GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 4 \
|
||||||
- GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
- GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
- EFI_PAGE_SHIFT)
|
- EFI_PAGE_SHIFT)
|
||||||
|
|
||||||
// L4 table address mask: (1 << 10 - 1) = 0x3FF
|
// L4 table address mask: (1 << 10 - 1) = 0x3FF
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_MASK \
|
#define GUARDED_HEAP_MAP_ENTRY_MASK \
|
||||||
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1)
|
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1)
|
||||||
|
|
||||||
// Size of each L4 table: (1 << 10) * 8 = 8KB = 2-page
|
// Size of each L4 table: (1 << 10) * 8 = 8KB = 2-page
|
||||||
#define GUARDED_HEAP_MAP_SIZE \
|
#define GUARDED_HEAP_MAP_SIZE \
|
||||||
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES)
|
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES)
|
||||||
|
|
||||||
// Memory size tracked by one L4 table: 8KB * 8 * 4KB = 256MB
|
// Memory size tracked by one L4 table: 8KB * 8 * 4KB = 256MB
|
||||||
#define GUARDED_HEAP_MAP_UNIT_SIZE \
|
#define GUARDED_HEAP_MAP_UNIT_SIZE \
|
||||||
(GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE)
|
(GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE)
|
||||||
|
|
||||||
// L4 table entry number: 8KB / 8 = 1024
|
// L4 table entry number: 8KB / 8 = 1024
|
||||||
#define GUARDED_HEAP_MAP_ENTRIES_PER_UNIT \
|
#define GUARDED_HEAP_MAP_ENTRIES_PER_UNIT \
|
||||||
(GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES)
|
(GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES)
|
||||||
|
|
||||||
// L4 table entry indexing
|
// L4 table entry indexing
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_ENTRY_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) \
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) \
|
||||||
& GUARDED_HEAP_MAP_ENTRY_MASK)
|
& GUARDED_HEAP_MAP_ENTRY_MASK)
|
||||||
|
|
||||||
// L4 table entry bit indexing
|
// L4 table entry bit indexing
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_ENTRY_BIT_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
||||||
& ((1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) - 1))
|
& ((1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) - 1))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Total bits (pages) tracked by one L4 table (65536-bit)
|
// Total bits (pages) tracked by one L4 table (65536-bit)
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_BITS \
|
#define GUARDED_HEAP_MAP_BITS \
|
||||||
(1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
(1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT))
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bit indexing inside the whole L4 table (0 - 65535)
|
// Bit indexing inside the whole L4 table (0 - 65535)
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_BIT_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_BIT_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
||||||
& ((1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
& ((1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)) - 1))
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)) - 1))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory address bit width tracked by L4 table: 10 + 6 + 12 = 28
|
// Memory address bit width tracked by L4 table: 10 + 6 + 12 = 28
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_SHIFT \
|
#define GUARDED_HEAP_MAP_TABLE_SHIFT \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
(GUARDED_HEAP_MAP_ENTRY_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
+ EFI_PAGE_SHIFT)
|
+ EFI_PAGE_SHIFT)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macro used to initialize the local array variable for map table traversing
|
// Macro used to initialize the local array variable for map table traversing
|
||||||
// {55, 46, 37, 28, 18}
|
// {55, 46, 37, 28, 18}
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS \
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS \
|
||||||
{ \
|
{ \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 3, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 3, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 2, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 2, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT, \
|
||||||
EFI_PAGE_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
EFI_PAGE_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Masks used to extract address range of each level of table
|
// Masks used to extract address range of each level of table
|
||||||
// {0x1FF, 0x1FF, 0x1FF, 0x1FF, 0x3FF}
|
// {0x1FF, 0x1FF, 0x1FF, 0x1FF, 0x3FF}
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS \
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS \
|
||||||
{ \
|
{ \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1 \
|
(1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1 \
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory type to guard (matching the related PCD definition)
|
// Memory type to guard (matching the related PCD definition)
|
||||||
//
|
//
|
||||||
#define GUARD_HEAP_TYPE_POOL BIT0
|
#define GUARD_HEAP_TYPE_POOL BIT0
|
||||||
#define GUARD_HEAP_TYPE_PAGE BIT1
|
#define GUARD_HEAP_TYPE_PAGE BIT1
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug message level
|
// Debug message level
|
||||||
//
|
//
|
||||||
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE)
|
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 TailMark;
|
UINT32 TailMark;
|
||||||
UINT32 HeadMark;
|
UINT32 HeadMark;
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
LIST_ENTRY Link;
|
LIST_ENTRY Link;
|
||||||
} HEAP_GUARD_NODE;
|
} HEAP_GUARD_NODE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal function. Converts a memory range to the specified type.
|
Internal function. Converts a memory range to the specified type.
|
||||||
The range must exist in the memory map.
|
The range must exist in the memory map.
|
||||||
|
|
||||||
@param Start The first address of the range Must be page
|
@param Start The first address of the range Must be page
|
||||||
aligned.
|
aligned.
|
||||||
@param NumberOfPages The number of pages to convert.
|
@param NumberOfPages The number of pages to convert.
|
||||||
@param NewType The new type for the memory range.
|
@param NewType The new type for the memory range.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Invalid parameter.
|
@retval EFI_INVALID_PARAMETER Invalid parameter.
|
||||||
@retval EFI_NOT_FOUND Could not find a descriptor cover the specified
|
@retval EFI_NOT_FOUND Could not find a descriptor cover the specified
|
||||||
range or convertion not allowed.
|
range or convertion not allowed.
|
||||||
@retval EFI_SUCCESS Successfully converts the memory range to the
|
@retval EFI_SUCCESS Successfully converts the memory range to the
|
||||||
specified type.
|
specified type.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CoreConvertPages (
|
CoreConvertPages (
|
||||||
IN UINT64 Start,
|
IN UINT64 Start,
|
||||||
IN UINT64 NumberOfPages,
|
IN UINT64 NumberOfPages,
|
||||||
IN EFI_MEMORY_TYPE NewType
|
IN EFI_MEMORY_TYPE NewType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate or free guarded memory.
|
Allocate or free guarded memory.
|
||||||
|
|
||||||
@param[in] Start Start address of memory to allocate or free.
|
@param[in] Start Start address of memory to allocate or free.
|
||||||
@param[in] NumberOfPages Memory size in pages.
|
@param[in] NumberOfPages Memory size in pages.
|
||||||
@param[in] NewType Memory type to convert to.
|
@param[in] NewType Memory type to convert to.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
CoreConvertPagesWithGuard (
|
CoreConvertPagesWithGuard (
|
||||||
IN UINT64 Start,
|
IN UINT64 Start,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN EFI_MEMORY_TYPE NewType
|
IN EFI_MEMORY_TYPE NewType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set head Guard and tail Guard for the given memory range.
|
Set head Guard and tail Guard for the given memory range.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory to set guard for.
|
@param[in] Memory Base address of memory to set guard for.
|
||||||
@param[in] NumberOfPages Memory size in pages.
|
@param[in] NumberOfPages Memory size in pages.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetGuardForMemory (
|
SetGuardForMemory (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Unset head Guard and tail Guard for the given memory range.
|
Unset head Guard and tail Guard for the given memory range.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory to unset guard for.
|
@param[in] Memory Base address of memory to unset guard for.
|
||||||
@param[in] NumberOfPages Memory size in pages.
|
@param[in] NumberOfPages Memory size in pages.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
UnsetGuardForMemory (
|
UnsetGuardForMemory (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the base and number of pages to really allocate according to Guard.
|
Adjust the base and number of pages to really allocate according to Guard.
|
||||||
|
|
||||||
@param[in,out] Memory Base address of free memory.
|
@param[in,out] Memory Base address of free memory.
|
||||||
@param[in,out] NumberOfPages Size of memory to allocate.
|
@param[in,out] NumberOfPages Size of memory to allocate.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
AdjustMemoryA (
|
AdjustMemoryA (
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN OUT UINTN *NumberOfPages
|
IN OUT UINTN *NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the start address and number of pages to free according to Guard.
|
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
|
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
|
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.
|
is to reserve pages as Guard pages in partial page free situation.
|
||||||
|
|
||||||
@param[in,out] Memory Base address of memory to free.
|
@param[in,out] Memory Base address of memory to free.
|
||||||
@param[in,out] NumberOfPages Size of memory to free.
|
@param[in,out] NumberOfPages Size of memory to free.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
AdjustMemoryF (
|
AdjustMemoryF (
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN OUT UINTN *NumberOfPages
|
IN OUT UINTN *NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust address of free memory according to existing and/or required Guard.
|
Adjust address of free memory according to existing and/or required Guard.
|
||||||
|
|
||||||
This function will check if there're existing Guard pages of adjacent
|
This function will check if there're existing Guard pages of adjacent
|
||||||
memory blocks, and try to use it as the Guard page of the memory to be
|
memory blocks, and try to use it as the Guard page of the memory to be
|
||||||
allocated.
|
allocated.
|
||||||
|
|
||||||
@param[in] Start Start address of free memory block.
|
@param[in] Start Start address of free memory block.
|
||||||
@param[in] Size Size of free memory block.
|
@param[in] Size Size of free memory block.
|
||||||
@param[in] SizeRequested Size of memory to allocate.
|
@param[in] SizeRequested Size of memory to allocate.
|
||||||
|
|
||||||
@return The end address of memory block found.
|
@return The end address of memory block found.
|
||||||
@return 0 if no enough space for the required size of memory and its Guard.
|
@return 0 if no enough space for the required size of memory and its Guard.
|
||||||
**/
|
**/
|
||||||
UINT64
|
UINT64
|
||||||
AdjustMemoryS (
|
AdjustMemoryS (
|
||||||
IN UINT64 Start,
|
IN UINT64 Start,
|
||||||
IN UINT64 Size,
|
IN UINT64 Size,
|
||||||
IN UINT64 SizeRequested
|
IN UINT64 SizeRequested
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the pool at the given address should be guarded or not.
|
Check to see if the pool at the given address should be guarded or not.
|
||||||
|
|
||||||
@param[in] MemoryType Pool type to check.
|
@param[in] MemoryType Pool type to check.
|
||||||
|
|
||||||
|
|
||||||
@return TRUE The given type of pool should be guarded.
|
@return TRUE The given type of pool should be guarded.
|
||||||
@return FALSE The given type of pool should not be guarded.
|
@return FALSE The given type of pool should not be guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPoolTypeToGuard (
|
IsPoolTypeToGuard (
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address should be guarded or not.
|
Check to see if the page at the given address should be guarded or not.
|
||||||
|
|
||||||
@param[in] MemoryType Page type to check.
|
@param[in] MemoryType Page type to check.
|
||||||
@param[in] AllocateType Allocation type to check.
|
@param[in] AllocateType Allocation type to check.
|
||||||
|
|
||||||
@return TRUE The given type of page should be guarded.
|
@return TRUE The given type of page should be guarded.
|
||||||
@return FALSE The given type of page should not be guarded.
|
@return FALSE The given type of page should not be guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPageTypeToGuard (
|
IsPageTypeToGuard (
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN EFI_ALLOCATE_TYPE AllocateType
|
IN EFI_ALLOCATE_TYPE AllocateType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address is guarded or not.
|
Check to see if the page at the given address is guarded or not.
|
||||||
|
|
||||||
@param[in] Address The address to check for.
|
@param[in] Address The address to check for.
|
||||||
|
|
||||||
@return TRUE The page at Address is guarded.
|
@return TRUE The page at Address is guarded.
|
||||||
@return FALSE The page at Address is not guarded.
|
@return FALSE The page at Address is not guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsMemoryGuarded (
|
IsMemoryGuarded (
|
||||||
IN EFI_PHYSICAL_ADDRESS Address
|
IN EFI_PHYSICAL_ADDRESS Address
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address is a Guard page or not.
|
Check to see if the page at the given address is a Guard page or not.
|
||||||
|
|
||||||
@param[in] Address The address to check for.
|
@param[in] Address The address to check for.
|
||||||
|
|
||||||
@return TRUE The page at Address is a Guard page.
|
@return TRUE The page at Address is a Guard page.
|
||||||
@return FALSE The page at Address is not a Guard page.
|
@return FALSE The page at Address is not a Guard page.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsGuardPage (
|
IsGuardPage (
|
||||||
IN EFI_PHYSICAL_ADDRESS Address
|
IN EFI_PHYSICAL_ADDRESS Address
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dump the guarded memory bit map.
|
Dump the guarded memory bit map.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DumpGuardedMemoryBitmap (
|
DumpGuardedMemoryBitmap (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the pool head position to make sure the Guard page is adjavent to
|
Adjust the pool head position to make sure the Guard page is adjavent to
|
||||||
pool tail or pool head.
|
pool tail or pool head.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory allocated.
|
@param[in] Memory Base address of memory allocated.
|
||||||
@param[in] NoPages Number of pages actually allocated.
|
@param[in] NoPages Number of pages actually allocated.
|
||||||
@param[in] Size Size of memory requested.
|
@param[in] Size Size of memory requested.
|
||||||
(plus pool head/tail overhead)
|
(plus pool head/tail overhead)
|
||||||
|
|
||||||
@return Address of pool head.
|
@return Address of pool head.
|
||||||
**/
|
**/
|
||||||
VOID *
|
VOID *
|
||||||
AdjustPoolHeadA (
|
AdjustPoolHeadA (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NoPages,
|
IN UINTN NoPages,
|
||||||
IN UINTN Size
|
IN UINTN Size
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the page base address according to pool head address.
|
Get the page base address according to pool head address.
|
||||||
|
|
||||||
@param[in] Memory Head address of pool to free.
|
@param[in] Memory Head address of pool to free.
|
||||||
|
|
||||||
@return Address of pool head.
|
@return Address of pool head.
|
||||||
**/
|
**/
|
||||||
VOID *
|
VOID *
|
||||||
AdjustPoolHeadF (
|
AdjustPoolHeadF (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory
|
IN EFI_PHYSICAL_ADDRESS Memory
|
||||||
);
|
);
|
||||||
|
|
||||||
extern BOOLEAN mOnGuarding;
|
extern BOOLEAN mOnGuarding;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Data structure and functions to allocate and free memory space.
|
Data structure and functions to allocate and free memory space.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -61,7 +61,7 @@ typedef struct {
|
||||||
@param PoolType The type of memory for the new pool pages
|
@param PoolType The type of memory for the new pool pages
|
||||||
@param NumberOfPages No of pages to allocate
|
@param NumberOfPages No of pages to allocate
|
||||||
@param Alignment Bits to align.
|
@param Alignment Bits to align.
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The allocated memory, or NULL
|
@return The allocated memory, or NULL
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ VOID *
|
||||||
CoreAllocatePoolPages (
|
CoreAllocatePoolPages (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN UINTN Alignment,
|
IN UINTN Alignment,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ CoreFreePoolPages (
|
||||||
|
|
||||||
@param PoolType Type of pool to allocate
|
@param PoolType Type of pool to allocate
|
||||||
@param Size The amount of pool to allocate
|
@param Size The amount of pool to allocate
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The allocate pool, or NULL
|
@return The allocate pool, or NULL
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@ CoreFreePoolPages (
|
||||||
VOID *
|
VOID *
|
||||||
CoreAllocatePoolI (
|
CoreAllocatePoolI (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN UINTN Size,
|
IN UINTN Size,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,34 +149,34 @@ CoreReleaseMemoryLock (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocates pages from the memory map.
|
Allocates pages from the memory map.
|
||||||
|
|
||||||
@param Type The type of allocation to perform
|
@param Type The type of allocation to perform
|
||||||
@param MemoryType The type of memory to turn the allocated pages
|
@param MemoryType The type of memory to turn the allocated pages
|
||||||
into
|
into
|
||||||
@param NumberOfPages The number of pages to allocate
|
@param NumberOfPages The number of pages to allocate
|
||||||
@param Memory A pointer to receive the base allocated memory
|
@param Memory A pointer to receive the base allocated memory
|
||||||
address
|
address
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return Status. On success, Memory is filled in with the base address allocated
|
@return Status. On success, Memory is filled in with the base address allocated
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
||||||
spec.
|
spec.
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
||||||
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
|
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
|
||||||
@retval EFI_SUCCESS Pages successfully allocated.
|
@retval EFI_SUCCESS Pages successfully allocated.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CoreInternalAllocatePages (
|
CoreInternalAllocatePages (
|
||||||
IN EFI_ALLOCATE_TYPE Type,
|
IN EFI_ALLOCATE_TYPE Type,
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Internal Global data
|
// Internal Global data
|
||||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include "DxeMain.h"
|
#include "DxeMain.h"
|
||||||
#include "Imem.h"
|
#include "Imem.h"
|
||||||
#include "HeapGuard.h"
|
#include "HeapGuard.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Entry for tracking the memory regions for each memory type to coalesce similar memory types
|
// Entry for tracking the memory regions for each memory type to coalesce similar memory types
|
||||||
|
@ -288,12 +288,12 @@ AllocateMemoryMapEntry (
|
||||||
//
|
//
|
||||||
// The list is empty, to allocate one page to refuel the list
|
// The list is empty, to allocate one page to refuel the list
|
||||||
//
|
//
|
||||||
FreeDescriptorEntries = CoreAllocatePoolPages (
|
FreeDescriptorEntries = CoreAllocatePoolPages (
|
||||||
EfiBootServicesData,
|
EfiBootServicesData,
|
||||||
EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION_GRANULARITY),
|
EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION_GRANULARITY),
|
||||||
DEFAULT_PAGE_ALLOCATION_GRANULARITY,
|
DEFAULT_PAGE_ALLOCATION_GRANULARITY,
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
if (FreeDescriptorEntries != NULL) {
|
if (FreeDescriptorEntries != NULL) {
|
||||||
//
|
//
|
||||||
// Enque the free memmory map entries into the list
|
// Enque the free memmory map entries into the list
|
||||||
|
@ -901,40 +901,40 @@ CoreConvertPagesEx (
|
||||||
CoreAddRange (MemType, Start, RangeEnd, Attribute);
|
CoreAddRange (MemType, Start, RangeEnd, Attribute);
|
||||||
if (ChangingType && (MemType == EfiConventionalMemory)) {
|
if (ChangingType && (MemType == EfiConventionalMemory)) {
|
||||||
if (Start == 0) {
|
if (Start == 0) {
|
||||||
//
|
//
|
||||||
// Avoid calling DEBUG_CLEAR_MEMORY() for an address of 0 because this
|
// Avoid calling DEBUG_CLEAR_MEMORY() for an address of 0 because this
|
||||||
// macro will ASSERT() if address is 0. Instead, CoreAddRange()
|
// macro will ASSERT() if address is 0. Instead, CoreAddRange()
|
||||||
// guarantees that the page starting at address 0 is always filled
|
// guarantees that the page starting at address 0 is always filled
|
||||||
// with zeros.
|
// with zeros.
|
||||||
//
|
//
|
||||||
if (RangeEnd > EFI_PAGE_SIZE) {
|
if (RangeEnd > EFI_PAGE_SIZE) {
|
||||||
DEBUG_CLEAR_MEMORY ((VOID *)(UINTN) EFI_PAGE_SIZE, (UINTN) (RangeEnd - EFI_PAGE_SIZE + 1));
|
DEBUG_CLEAR_MEMORY ((VOID *)(UINTN) EFI_PAGE_SIZE, (UINTN) (RangeEnd - EFI_PAGE_SIZE + 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// If Heap Guard is enabled, the page at the top and/or bottom of
|
// If Heap Guard is enabled, the page at the top and/or bottom of
|
||||||
// this memory block to free might be inaccessible. Skipping them
|
// this memory block to free might be inaccessible. Skipping them
|
||||||
// to avoid page fault exception.
|
// to avoid page fault exception.
|
||||||
//
|
//
|
||||||
UINT64 StartToClear;
|
UINT64 StartToClear;
|
||||||
UINT64 EndToClear;
|
UINT64 EndToClear;
|
||||||
|
|
||||||
StartToClear = Start;
|
StartToClear = Start;
|
||||||
EndToClear = RangeEnd;
|
EndToClear = RangeEnd;
|
||||||
if (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT1|BIT0)) {
|
if (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT1|BIT0)) {
|
||||||
if (IsGuardPage(StartToClear)) {
|
if (IsGuardPage(StartToClear)) {
|
||||||
StartToClear += EFI_PAGE_SIZE;
|
StartToClear += EFI_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
if (IsGuardPage (EndToClear)) {
|
if (IsGuardPage (EndToClear)) {
|
||||||
EndToClear -= EFI_PAGE_SIZE;
|
EndToClear -= EFI_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
ASSERT (EndToClear > StartToClear);
|
ASSERT (EndToClear > StartToClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_CLEAR_MEMORY(
|
DEBUG_CLEAR_MEMORY(
|
||||||
(VOID *)(UINTN)StartToClear,
|
(VOID *)(UINTN)StartToClear,
|
||||||
(UINTN)(EndToClear - StartToClear + 1)
|
(UINTN)(EndToClear - StartToClear + 1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1021,7 @@ CoreUpdateMemoryAttributes (
|
||||||
@param NewType The type of memory the range is going to be
|
@param NewType The type of memory the range is going to be
|
||||||
turned into
|
turned into
|
||||||
@param Alignment Bits to align with
|
@param Alignment Bits to align with
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The base address of the range, or 0 if the range was not found
|
@return The base address of the range, or 0 if the range was not found
|
||||||
|
|
||||||
|
@ -1032,8 +1032,8 @@ CoreFindFreePagesI (
|
||||||
IN UINT64 MinAddress,
|
IN UINT64 MinAddress,
|
||||||
IN UINT64 NumberOfPages,
|
IN UINT64 NumberOfPages,
|
||||||
IN EFI_MEMORY_TYPE NewType,
|
IN EFI_MEMORY_TYPE NewType,
|
||||||
IN UINTN Alignment,
|
IN UINTN Alignment,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 NumberOfBytes;
|
UINT64 NumberOfBytes;
|
||||||
|
@ -1125,17 +1125,17 @@ CoreFindFreePagesI (
|
||||||
// If this is the best match so far remember it
|
// If this is the best match so far remember it
|
||||||
//
|
//
|
||||||
if (DescEnd > Target) {
|
if (DescEnd > Target) {
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
DescEnd = AdjustMemoryS (
|
DescEnd = AdjustMemoryS (
|
||||||
DescEnd + 1 - DescNumberOfBytes,
|
DescEnd + 1 - DescNumberOfBytes,
|
||||||
DescNumberOfBytes,
|
DescNumberOfBytes,
|
||||||
NumberOfBytes
|
NumberOfBytes
|
||||||
);
|
);
|
||||||
if (DescEnd == 0) {
|
if (DescEnd == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Target = DescEnd;
|
Target = DescEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1166,7 @@ CoreFindFreePagesI (
|
||||||
@param NewType The type of memory the range is going to be
|
@param NewType The type of memory the range is going to be
|
||||||
turned into
|
turned into
|
||||||
@param Alignment Bits to align with
|
@param Alignment Bits to align with
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The base address of the range, or 0 if the range was not found.
|
@return The base address of the range, or 0 if the range was not found.
|
||||||
|
|
||||||
|
@ -1176,8 +1176,8 @@ FindFreePages (
|
||||||
IN UINT64 MaxAddress,
|
IN UINT64 MaxAddress,
|
||||||
IN UINT64 NoPages,
|
IN UINT64 NoPages,
|
||||||
IN EFI_MEMORY_TYPE NewType,
|
IN EFI_MEMORY_TYPE NewType,
|
||||||
IN UINTN Alignment,
|
IN UINTN Alignment,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 Start;
|
UINT64 Start;
|
||||||
|
@ -1191,8 +1191,8 @@ FindFreePages (
|
||||||
mMemoryTypeStatistics[NewType].BaseAddress,
|
mMemoryTypeStatistics[NewType].BaseAddress,
|
||||||
NoPages,
|
NoPages,
|
||||||
NewType,
|
NewType,
|
||||||
Alignment,
|
Alignment,
|
||||||
NeedGuard
|
NeedGuard
|
||||||
);
|
);
|
||||||
if (Start != 0) {
|
if (Start != 0) {
|
||||||
return Start;
|
return Start;
|
||||||
|
@ -1203,8 +1203,8 @@ FindFreePages (
|
||||||
// Attempt to find free pages in the default allocation bin
|
// Attempt to find free pages in the default allocation bin
|
||||||
//
|
//
|
||||||
if (MaxAddress >= mDefaultMaximumAddress) {
|
if (MaxAddress >= mDefaultMaximumAddress) {
|
||||||
Start = CoreFindFreePagesI (mDefaultMaximumAddress, 0, NoPages, NewType,
|
Start = CoreFindFreePagesI (mDefaultMaximumAddress, 0, NoPages, NewType,
|
||||||
Alignment, NeedGuard);
|
Alignment, NeedGuard);
|
||||||
if (Start != 0) {
|
if (Start != 0) {
|
||||||
if (Start < mDefaultBaseAddress) {
|
if (Start < mDefaultBaseAddress) {
|
||||||
mDefaultBaseAddress = Start;
|
mDefaultBaseAddress = Start;
|
||||||
|
@ -1219,8 +1219,8 @@ FindFreePages (
|
||||||
// address range. If this allocation fails, then there are not enough
|
// address range. If this allocation fails, then there are not enough
|
||||||
// resources anywhere to satisfy the request.
|
// resources anywhere to satisfy the request.
|
||||||
//
|
//
|
||||||
Start = CoreFindFreePagesI (MaxAddress, 0, NoPages, NewType, Alignment,
|
Start = CoreFindFreePagesI (MaxAddress, 0, NoPages, NewType, Alignment,
|
||||||
NeedGuard);
|
NeedGuard);
|
||||||
if (Start != 0) {
|
if (Start != 0) {
|
||||||
return Start;
|
return Start;
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1235,7 @@ FindFreePages (
|
||||||
//
|
//
|
||||||
// If any memory resources were promoted, then re-attempt the allocation
|
// If any memory resources were promoted, then re-attempt the allocation
|
||||||
//
|
//
|
||||||
return FindFreePages (MaxAddress, NoPages, NewType, Alignment, NeedGuard);
|
return FindFreePages (MaxAddress, NoPages, NewType, Alignment, NeedGuard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ FindFreePages (
|
||||||
@param NumberOfPages The number of pages to allocate
|
@param NumberOfPages The number of pages to allocate
|
||||||
@param Memory A pointer to receive the base allocated memory
|
@param Memory A pointer to receive the base allocated memory
|
||||||
address
|
address
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return Status. On success, Memory is filled in with the base address allocated
|
@return Status. On success, Memory is filled in with the base address allocated
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
||||||
|
@ -1264,8 +1264,8 @@ CoreInternalAllocatePages (
|
||||||
IN EFI_ALLOCATE_TYPE Type,
|
IN EFI_ALLOCATE_TYPE Type,
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
@ -1351,8 +1351,8 @@ CoreInternalAllocatePages (
|
||||||
// If not a specific address, then find an address to allocate
|
// If not a specific address, then find an address to allocate
|
||||||
//
|
//
|
||||||
if (Type != AllocateAddress) {
|
if (Type != AllocateAddress) {
|
||||||
Start = FindFreePages (MaxAddress, NumberOfPages, MemoryType, Alignment,
|
Start = FindFreePages (MaxAddress, NumberOfPages, MemoryType, Alignment,
|
||||||
NeedGuard);
|
NeedGuard);
|
||||||
if (Start == 0) {
|
if (Start == 0) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Done;
|
goto Done;
|
||||||
|
@ -1362,19 +1362,19 @@ CoreInternalAllocatePages (
|
||||||
//
|
//
|
||||||
// Convert pages from FreeMemory to the requested type
|
// Convert pages from FreeMemory to the requested type
|
||||||
//
|
//
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
Status = CoreConvertPagesWithGuard(Start, NumberOfPages, MemoryType);
|
Status = CoreConvertPagesWithGuard(Start, NumberOfPages, MemoryType);
|
||||||
} else {
|
} else {
|
||||||
Status = CoreConvertPages(Start, NumberOfPages, MemoryType);
|
Status = CoreConvertPages(Start, NumberOfPages, MemoryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
CoreReleaseMemoryLock ();
|
CoreReleaseMemoryLock ();
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
SetGuardForMemory (Start, NumberOfPages);
|
SetGuardForMemory (Start, NumberOfPages);
|
||||||
}
|
}
|
||||||
*Memory = Start;
|
*Memory = Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1409,11 +1409,11 @@ CoreAllocatePages (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BOOLEAN NeedGuard;
|
BOOLEAN NeedGuard;
|
||||||
|
|
||||||
NeedGuard = IsPageTypeToGuard (MemoryType, Type) && !mOnGuarding;
|
NeedGuard = IsPageTypeToGuard (MemoryType, Type) && !mOnGuarding;
|
||||||
Status = CoreInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory,
|
Status = CoreInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory,
|
||||||
NeedGuard);
|
NeedGuard);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CoreUpdateProfile (
|
CoreUpdateProfile (
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||||
|
@ -1454,7 +1454,7 @@ CoreInternalFreePages (
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
MEMORY_MAP *Entry;
|
MEMORY_MAP *Entry;
|
||||||
UINTN Alignment;
|
UINTN Alignment;
|
||||||
BOOLEAN IsGuarded;
|
BOOLEAN IsGuarded;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Free the range
|
// Free the range
|
||||||
|
@ -1464,7 +1464,7 @@ CoreInternalFreePages (
|
||||||
//
|
//
|
||||||
// Find the entry that the covers the range
|
// Find the entry that the covers the range
|
||||||
//
|
//
|
||||||
IsGuarded = FALSE;
|
IsGuarded = FALSE;
|
||||||
Entry = NULL;
|
Entry = NULL;
|
||||||
for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
|
for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
|
||||||
Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
|
Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
|
||||||
|
@ -1501,20 +1501,20 @@ CoreInternalFreePages (
|
||||||
*MemoryType = Entry->Type;
|
*MemoryType = Entry->Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsGuarded = IsPageTypeToGuard (Entry->Type, AllocateAnyPages) &&
|
IsGuarded = IsPageTypeToGuard (Entry->Type, AllocateAnyPages) &&
|
||||||
IsMemoryGuarded (Memory);
|
IsMemoryGuarded (Memory);
|
||||||
if (IsGuarded) {
|
if (IsGuarded) {
|
||||||
Status = CoreConvertPagesWithGuard (Memory, NumberOfPages,
|
Status = CoreConvertPagesWithGuard (Memory, NumberOfPages,
|
||||||
EfiConventionalMemory);
|
EfiConventionalMemory);
|
||||||
} else {
|
} else {
|
||||||
Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
|
Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
CoreReleaseMemoryLock ();
|
CoreReleaseMemoryLock ();
|
||||||
if (IsGuarded) {
|
if (IsGuarded) {
|
||||||
UnsetGuardForMemory(Memory, NumberOfPages);
|
UnsetGuardForMemory(Memory, NumberOfPages);
|
||||||
}
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1912,12 +1912,12 @@ Done:
|
||||||
|
|
||||||
*MemoryMapSize = BufferSize;
|
*MemoryMapSize = BufferSize;
|
||||||
|
|
||||||
DEBUG_CODE (
|
DEBUG_CODE (
|
||||||
if (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT1|BIT0)) {
|
if (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT1|BIT0)) {
|
||||||
DumpGuardedMemoryBitmap ();
|
DumpGuardedMemoryBitmap ();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1929,7 +1929,7 @@ Done:
|
||||||
@param PoolType The type of memory for the new pool pages
|
@param PoolType The type of memory for the new pool pages
|
||||||
@param NumberOfPages No of pages to allocate
|
@param NumberOfPages No of pages to allocate
|
||||||
@param Alignment Bits to align.
|
@param Alignment Bits to align.
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The allocated memory, or NULL
|
@return The allocated memory, or NULL
|
||||||
|
|
||||||
|
@ -1938,8 +1938,8 @@ VOID *
|
||||||
CoreAllocatePoolPages (
|
CoreAllocatePoolPages (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN UINTN Alignment,
|
IN UINTN Alignment,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT64 Start;
|
UINT64 Start;
|
||||||
|
@ -1947,8 +1947,8 @@ CoreAllocatePoolPages (
|
||||||
//
|
//
|
||||||
// Find the pages to convert
|
// Find the pages to convert
|
||||||
//
|
//
|
||||||
Start = FindFreePages (MAX_ADDRESS, NumberOfPages, PoolType, Alignment,
|
Start = FindFreePages (MAX_ADDRESS, NumberOfPages, PoolType, Alignment,
|
||||||
NeedGuard);
|
NeedGuard);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert it to boot services data
|
// Convert it to boot services data
|
||||||
|
@ -1956,11 +1956,11 @@ CoreAllocatePoolPages (
|
||||||
if (Start == 0) {
|
if (Start == 0) {
|
||||||
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages));
|
DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", (UINT32)NumberOfPages));
|
||||||
} else {
|
} else {
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
CoreConvertPagesWithGuard (Start, NumberOfPages, PoolType);
|
CoreConvertPagesWithGuard (Start, NumberOfPages, PoolType);
|
||||||
} else {
|
} else {
|
||||||
CoreConvertPages (Start, NumberOfPages, PoolType);
|
CoreConvertPages (Start, NumberOfPages, PoolType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (VOID *)(UINTN) Start;
|
return (VOID *)(UINTN) Start;
|
||||||
|
|
|
@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include "DxeMain.h"
|
#include "DxeMain.h"
|
||||||
#include "Imem.h"
|
#include "Imem.h"
|
||||||
#include "HeapGuard.h"
|
#include "HeapGuard.h"
|
||||||
|
|
||||||
STATIC EFI_LOCK mPoolMemoryLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
|
STATIC EFI_LOCK mPoolMemoryLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ LookupPoolHead (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pool = CoreAllocatePoolI (EfiBootServicesData, sizeof (POOL), FALSE);
|
Pool = CoreAllocatePoolI (EfiBootServicesData, sizeof (POOL), FALSE);
|
||||||
if (Pool == NULL) {
|
if (Pool == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -215,8 +215,8 @@ CoreInternalAllocatePool (
|
||||||
OUT VOID **Buffer
|
OUT VOID **Buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BOOLEAN NeedGuard;
|
BOOLEAN NeedGuard;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If it's not a valid type, fail it
|
// If it's not a valid type, fail it
|
||||||
|
@ -240,8 +240,8 @@ CoreInternalAllocatePool (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
NeedGuard = IsPoolTypeToGuard (PoolType) && !mOnGuarding;
|
NeedGuard = IsPoolTypeToGuard (PoolType) && !mOnGuarding;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Acquire the memory lock and make the allocation
|
// Acquire the memory lock and make the allocation
|
||||||
//
|
//
|
||||||
|
@ -250,7 +250,7 @@ CoreInternalAllocatePool (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
|
*Buffer = CoreAllocatePoolI (PoolType, Size, NeedGuard);
|
||||||
CoreReleaseLock (&mPoolMemoryLock);
|
CoreReleaseLock (&mPoolMemoryLock);
|
||||||
return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
|
return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ CoreAllocatePool (
|
||||||
@param PoolType The type of memory for the new pool pages
|
@param PoolType The type of memory for the new pool pages
|
||||||
@param NoPages No of pages to allocate
|
@param NoPages No of pages to allocate
|
||||||
@param Granularity Bits to align.
|
@param Granularity Bits to align.
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The allocated memory, or NULL
|
@return The allocated memory, or NULL
|
||||||
|
|
||||||
|
@ -312,8 +312,8 @@ VOID *
|
||||||
CoreAllocatePoolPagesI (
|
CoreAllocatePoolPagesI (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN UINTN NoPages,
|
IN UINTN NoPages,
|
||||||
IN UINTN Granularity,
|
IN UINTN Granularity,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *Buffer;
|
VOID *Buffer;
|
||||||
|
@ -324,14 +324,14 @@ CoreAllocatePoolPagesI (
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer = CoreAllocatePoolPages (PoolType, NoPages, Granularity, NeedGuard);
|
Buffer = CoreAllocatePoolPages (PoolType, NoPages, Granularity, NeedGuard);
|
||||||
CoreReleaseMemoryLock ();
|
CoreReleaseMemoryLock ();
|
||||||
|
|
||||||
if (Buffer != NULL) {
|
if (Buffer != NULL) {
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
SetGuardForMemory ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, NoPages);
|
SetGuardForMemory ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, NoPages);
|
||||||
}
|
}
|
||||||
ApplyMemoryProtectionPolicy(EfiConventionalMemory, PoolType,
|
ApplyMemoryProtectionPolicy(EfiConventionalMemory, PoolType,
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, EFI_PAGES_TO_SIZE (NoPages));
|
(EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, EFI_PAGES_TO_SIZE (NoPages));
|
||||||
}
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
|
@ -343,7 +343,7 @@ CoreAllocatePoolPagesI (
|
||||||
|
|
||||||
@param PoolType Type of pool to allocate
|
@param PoolType Type of pool to allocate
|
||||||
@param Size The amount of pool to allocate
|
@param Size The amount of pool to allocate
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@return The allocate pool, or NULL
|
@return The allocate pool, or NULL
|
||||||
|
|
||||||
|
@ -351,8 +351,8 @@ CoreAllocatePoolPagesI (
|
||||||
VOID *
|
VOID *
|
||||||
CoreAllocatePoolI (
|
CoreAllocatePoolI (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN UINTN Size,
|
IN UINTN Size,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
POOL *Pool;
|
POOL *Pool;
|
||||||
|
@ -366,7 +366,7 @@ CoreAllocatePoolI (
|
||||||
UINTN Offset, MaxOffset;
|
UINTN Offset, MaxOffset;
|
||||||
UINTN NoPages;
|
UINTN NoPages;
|
||||||
UINTN Granularity;
|
UINTN Granularity;
|
||||||
BOOLEAN HasPoolTail;
|
BOOLEAN HasPoolTail;
|
||||||
|
|
||||||
ASSERT_LOCKED (&mPoolMemoryLock);
|
ASSERT_LOCKED (&mPoolMemoryLock);
|
||||||
|
|
||||||
|
@ -384,9 +384,9 @@ CoreAllocatePoolI (
|
||||||
// Adjust the size by the pool header & tail overhead
|
// Adjust the size by the pool header & tail overhead
|
||||||
//
|
//
|
||||||
|
|
||||||
HasPoolTail = !(NeedGuard &&
|
HasPoolTail = !(NeedGuard &&
|
||||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Adjusting the Size to be of proper alignment so that
|
// Adjusting the Size to be of proper alignment so that
|
||||||
// we don't get an unaligned access fault later when
|
// we don't get an unaligned access fault later when
|
||||||
|
@ -406,16 +406,16 @@ CoreAllocatePoolI (
|
||||||
// If allocation is over max size, just allocate pages for the request
|
// If allocation is over max size, just allocate pages for the request
|
||||||
// (slow)
|
// (slow)
|
||||||
//
|
//
|
||||||
if (Index >= SIZE_TO_LIST (Granularity) || NeedGuard) {
|
if (Index >= SIZE_TO_LIST (Granularity) || NeedGuard) {
|
||||||
if (!HasPoolTail) {
|
if (!HasPoolTail) {
|
||||||
Size -= sizeof (POOL_TAIL);
|
Size -= sizeof (POOL_TAIL);
|
||||||
}
|
}
|
||||||
NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
|
NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
|
||||||
NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
|
NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
|
||||||
Head = CoreAllocatePoolPagesI (PoolType, NoPages, Granularity, NeedGuard);
|
Head = CoreAllocatePoolPagesI (PoolType, NoPages, Granularity, NeedGuard);
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
Head = AdjustPoolHeadA ((EFI_PHYSICAL_ADDRESS)(UINTN)Head, NoPages, Size);
|
Head = AdjustPoolHeadA ((EFI_PHYSICAL_ADDRESS)(UINTN)Head, NoPages, Size);
|
||||||
}
|
}
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +443,8 @@ CoreAllocatePoolI (
|
||||||
//
|
//
|
||||||
// Get another page
|
// Get another page
|
||||||
//
|
//
|
||||||
NewPage = CoreAllocatePoolPagesI (PoolType, EFI_SIZE_TO_PAGES (Granularity),
|
NewPage = CoreAllocatePoolPagesI (PoolType, EFI_SIZE_TO_PAGES (Granularity),
|
||||||
Granularity, NeedGuard);
|
Granularity, NeedGuard);
|
||||||
if (NewPage == NULL) {
|
if (NewPage == NULL) {
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
@ -490,11 +490,11 @@ Done:
|
||||||
|
|
||||||
if (Head != NULL) {
|
if (Head != NULL) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Account the allocation
|
// Account the allocation
|
||||||
//
|
//
|
||||||
Pool->Used += Size;
|
Pool->Used += Size;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we have a pool buffer, fill in the header & tail info
|
// If we have a pool buffer, fill in the header & tail info
|
||||||
//
|
//
|
||||||
|
@ -502,24 +502,24 @@ Done:
|
||||||
Head->Size = Size;
|
Head->Size = Size;
|
||||||
Head->Type = (EFI_MEMORY_TYPE) PoolType;
|
Head->Type = (EFI_MEMORY_TYPE) PoolType;
|
||||||
Buffer = Head->Data;
|
Buffer = Head->Data;
|
||||||
|
|
||||||
if (HasPoolTail) {
|
if (HasPoolTail) {
|
||||||
Tail = HEAD_TO_TAIL (Head);
|
Tail = HEAD_TO_TAIL (Head);
|
||||||
Tail->Signature = POOL_TAIL_SIGNATURE;
|
Tail->Signature = POOL_TAIL_SIGNATURE;
|
||||||
Tail->Size = Size;
|
Tail->Size = Size;
|
||||||
|
|
||||||
Size -= POOL_OVERHEAD;
|
Size -= POOL_OVERHEAD;
|
||||||
} else {
|
} else {
|
||||||
Size -= SIZE_OF_POOL_HEAD;
|
Size -= SIZE_OF_POOL_HEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_CLEAR_MEMORY (Buffer, Size);
|
DEBUG_CLEAR_MEMORY (Buffer, Size);
|
||||||
|
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_POOL,
|
DEBUG_POOL,
|
||||||
"AllocatePoolI: Type %x, Addr %p (len %lx) %,ld\n", PoolType,
|
"AllocatePoolI: Type %x, Addr %p (len %lx) %,ld\n", PoolType,
|
||||||
Buffer,
|
Buffer,
|
||||||
(UINT64)Size,
|
(UINT64)Size,
|
||||||
(UINT64) Pool->Used
|
(UINT64) Pool->Used
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -619,34 +619,34 @@ CoreFreePoolPagesI (
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Memory, EFI_PAGES_TO_SIZE (NoPages));
|
(EFI_PHYSICAL_ADDRESS)(UINTN)Memory, EFI_PAGES_TO_SIZE (NoPages));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal function. Frees guarded pool pages.
|
Internal function. Frees guarded pool pages.
|
||||||
|
|
||||||
@param PoolType The type of memory for the pool pages
|
@param PoolType The type of memory for the pool pages
|
||||||
@param Memory The base address to free
|
@param Memory The base address to free
|
||||||
@param NoPages The number of pages to free
|
@param NoPages The number of pages to free
|
||||||
|
|
||||||
**/
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
CoreFreePoolPagesWithGuard (
|
CoreFreePoolPagesWithGuard (
|
||||||
IN EFI_MEMORY_TYPE PoolType,
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NoPages
|
IN UINTN NoPages
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_PHYSICAL_ADDRESS MemoryGuarded;
|
EFI_PHYSICAL_ADDRESS MemoryGuarded;
|
||||||
UINTN NoPagesGuarded;
|
UINTN NoPagesGuarded;
|
||||||
|
|
||||||
MemoryGuarded = Memory;
|
MemoryGuarded = Memory;
|
||||||
NoPagesGuarded = NoPages;
|
NoPagesGuarded = NoPages;
|
||||||
|
|
||||||
AdjustMemoryF (&Memory, &NoPages);
|
AdjustMemoryF (&Memory, &NoPages);
|
||||||
CoreFreePoolPagesI (PoolType, Memory, NoPages);
|
CoreFreePoolPagesI (PoolType, Memory, NoPages);
|
||||||
|
|
||||||
UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);
|
UnsetGuardForMemory (MemoryGuarded, NoPagesGuarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal function to free a pool entry.
|
Internal function to free a pool entry.
|
||||||
Caller must have the memory lock held
|
Caller must have the memory lock held
|
||||||
|
@ -675,8 +675,8 @@ CoreFreePoolI (
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
BOOLEAN AllFree;
|
BOOLEAN AllFree;
|
||||||
UINTN Granularity;
|
UINTN Granularity;
|
||||||
BOOLEAN IsGuarded;
|
BOOLEAN IsGuarded;
|
||||||
BOOLEAN HasPoolTail;
|
BOOLEAN HasPoolTail;
|
||||||
|
|
||||||
ASSERT(Buffer != NULL);
|
ASSERT(Buffer != NULL);
|
||||||
//
|
//
|
||||||
|
@ -689,32 +689,32 @@ CoreFreePoolI (
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsGuarded = IsPoolTypeToGuard (Head->Type) &&
|
IsGuarded = IsPoolTypeToGuard (Head->Type) &&
|
||||||
IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Head);
|
IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Head);
|
||||||
HasPoolTail = !(IsGuarded &&
|
HasPoolTail = !(IsGuarded &&
|
||||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||||
|
|
||||||
if (HasPoolTail) {
|
if (HasPoolTail) {
|
||||||
Tail = HEAD_TO_TAIL (Head);
|
Tail = HEAD_TO_TAIL (Head);
|
||||||
ASSERT (Tail != NULL);
|
ASSERT (Tail != NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug
|
// Debug
|
||||||
//
|
//
|
||||||
ASSERT (Tail->Signature == POOL_TAIL_SIGNATURE);
|
ASSERT (Tail->Signature == POOL_TAIL_SIGNATURE);
|
||||||
ASSERT (Head->Size == Tail->Size);
|
ASSERT (Head->Size == Tail->Size);
|
||||||
|
|
||||||
if (Tail->Signature != POOL_TAIL_SIGNATURE) {
|
if (Tail->Signature != POOL_TAIL_SIGNATURE) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Head->Size != Tail->Size) {
|
if (Head->Size != Tail->Size) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_LOCKED (&mPoolMemoryLock);
|
ASSERT_LOCKED (&mPoolMemoryLock);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Determine the pool type and account for it
|
// Determine the pool type and account for it
|
||||||
//
|
//
|
||||||
|
@ -749,27 +749,27 @@ CoreFreePoolI (
|
||||||
//
|
//
|
||||||
// If it's not on the list, it must be pool pages
|
// If it's not on the list, it must be pool pages
|
||||||
//
|
//
|
||||||
if (Index >= SIZE_TO_LIST (Granularity) || IsGuarded) {
|
if (Index >= SIZE_TO_LIST (Granularity) || IsGuarded) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the memory pages back to free memory
|
// Return the memory pages back to free memory
|
||||||
//
|
//
|
||||||
NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
|
NoPages = EFI_SIZE_TO_PAGES (Size) + EFI_SIZE_TO_PAGES (Granularity) - 1;
|
||||||
NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
|
NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1);
|
||||||
if (IsGuarded) {
|
if (IsGuarded) {
|
||||||
Head = AdjustPoolHeadF ((EFI_PHYSICAL_ADDRESS)(UINTN)Head);
|
Head = AdjustPoolHeadF ((EFI_PHYSICAL_ADDRESS)(UINTN)Head);
|
||||||
CoreFreePoolPagesWithGuard (
|
CoreFreePoolPagesWithGuard (
|
||||||
Pool->MemoryType,
|
Pool->MemoryType,
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Head,
|
(EFI_PHYSICAL_ADDRESS)(UINTN)Head,
|
||||||
NoPages
|
NoPages
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
CoreFreePoolPagesI (
|
CoreFreePoolPagesI (
|
||||||
Pool->MemoryType,
|
Pool->MemoryType,
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Head,
|
(EFI_PHYSICAL_ADDRESS)(UINTN)Head,
|
||||||
NoPages
|
NoPages
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -1065,15 +1065,15 @@ CoreInitializeMemoryProtection (
|
||||||
// - code regions should have no EFI_MEMORY_XP attribute
|
// - code regions should have no EFI_MEMORY_XP attribute
|
||||||
// - EfiConventionalMemory and EfiBootServicesData should use the
|
// - EfiConventionalMemory and EfiBootServicesData should use the
|
||||||
// same attribute
|
// same attribute
|
||||||
// - heap guard should not be enabled for the same type of memory
|
// - heap guard should not be enabled for the same type of memory
|
||||||
//
|
//
|
||||||
ASSERT ((GetPermissionAttributeForMemoryType (EfiBootServicesCode) & EFI_MEMORY_XP) == 0);
|
ASSERT ((GetPermissionAttributeForMemoryType (EfiBootServicesCode) & EFI_MEMORY_XP) == 0);
|
||||||
ASSERT ((GetPermissionAttributeForMemoryType (EfiRuntimeServicesCode) & EFI_MEMORY_XP) == 0);
|
ASSERT ((GetPermissionAttributeForMemoryType (EfiRuntimeServicesCode) & EFI_MEMORY_XP) == 0);
|
||||||
ASSERT ((GetPermissionAttributeForMemoryType (EfiLoaderCode) & EFI_MEMORY_XP) == 0);
|
ASSERT ((GetPermissionAttributeForMemoryType (EfiLoaderCode) & EFI_MEMORY_XP) == 0);
|
||||||
ASSERT (GetPermissionAttributeForMemoryType (EfiBootServicesData) ==
|
ASSERT (GetPermissionAttributeForMemoryType (EfiBootServicesData) ==
|
||||||
GetPermissionAttributeForMemoryType (EfiConventionalMemory));
|
GetPermissionAttributeForMemoryType (EfiConventionalMemory));
|
||||||
ASSERT ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & PcdGet64 (PcdHeapGuardPoolType)) == 0);
|
ASSERT ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & PcdGet64 (PcdHeapGuardPoolType)) == 0);
|
||||||
ASSERT ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & PcdGet64 (PcdHeapGuardPageType)) == 0);
|
ASSERT ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & PcdGet64 (PcdHeapGuardPageType)) == 0);
|
||||||
|
|
||||||
if (mImageProtectionPolicy != 0 || PcdGet64 (PcdDxeNxMemoryProtectionPolicy) != 0) {
|
if (mImageProtectionPolicy != 0 || PcdGet64 (PcdDxeNxMemoryProtectionPolicy) != 0) {
|
||||||
Status = CoreCreateEvent (
|
Status = CoreCreateEvent (
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
||||||
|
|
||||||
[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
|
[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
|
||||||
|
|
|
@ -211,37 +211,37 @@ IsExecuteDisableBitAvailable (
|
||||||
return Available;
|
return Available;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The function will check if page table should be setup or not.
|
The function will check if page table should be setup or not.
|
||||||
|
|
||||||
@retval TRUE Page table should be created.
|
@retval TRUE Page table should be created.
|
||||||
@retval FALSE Page table should not be created.
|
@retval FALSE Page table should not be created.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
ToBuildPageTable (
|
ToBuildPageTable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!IsIa32PaeSupport ()) {
|
if (!IsIa32PaeSupport ()) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsNullDetectionEnabled ()) {
|
if (IsNullDetectionEnabled ()) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PcdGet8 (PcdHeapGuardPropertyMask) != 0) {
|
if (PcdGet8 (PcdHeapGuardPropertyMask) != 0) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PcdGetBool (PcdSetNxForStack) && IsExecuteDisableBitAvailable ()) {
|
if (PcdGetBool (PcdSetNxForStack) && IsExecuteDisableBitAvailable ()) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Transfers control to DxeCore.
|
Transfers control to DxeCore.
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ HandOffToDxeCore (
|
||||||
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||||
|
|
||||||
PageTables = 0;
|
PageTables = 0;
|
||||||
BuildPageTablesIa32Pae = ToBuildPageTable ();
|
BuildPageTablesIa32Pae = ToBuildPageTable ();
|
||||||
if (BuildPageTablesIa32Pae) {
|
if (BuildPageTablesIa32Pae) {
|
||||||
PageTables = Create4GPageTablesIa32Pae (BaseOfStack, STACK_SIZE);
|
PageTables = Create4GPageTablesIa32Pae (BaseOfStack, STACK_SIZE);
|
||||||
if (IsExecuteDisableBitAvailable ()) {
|
if (IsExecuteDisableBitAvailable ()) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,398 +1,398 @@
|
||||||
/** @file
|
/** @file
|
||||||
Data structure and functions to allocate and free memory space.
|
Data structure and functions to allocate and free memory space.
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef _HEAPGUARD_H_
|
#ifndef _HEAPGUARD_H_
|
||||||
#define _HEAPGUARD_H_
|
#define _HEAPGUARD_H_
|
||||||
|
|
||||||
#include "PiSmmCore.h"
|
#include "PiSmmCore.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Following macros are used to define and access the guarded memory bitmap
|
// Following macros are used to define and access the guarded memory bitmap
|
||||||
// table.
|
// table.
|
||||||
//
|
//
|
||||||
// To simplify the access and reduce the memory used for this table, the
|
// To simplify the access and reduce the memory used for this table, the
|
||||||
// table is constructed in the similar way as page table structure but in
|
// table is constructed in the similar way as page table structure but in
|
||||||
// reverse direction, i.e. from bottom growing up to top.
|
// reverse direction, i.e. from bottom growing up to top.
|
||||||
//
|
//
|
||||||
// - 1-bit tracks 1 page (4KB)
|
// - 1-bit tracks 1 page (4KB)
|
||||||
// - 1-UINT64 map entry tracks 256KB memory
|
// - 1-UINT64 map entry tracks 256KB memory
|
||||||
// - 1K-UINT64 map table tracks 256MB memory
|
// - 1K-UINT64 map table tracks 256MB memory
|
||||||
// - Five levels of tables can track any address of memory of 64-bit
|
// - Five levels of tables can track any address of memory of 64-bit
|
||||||
// system, like below.
|
// system, like below.
|
||||||
//
|
//
|
||||||
// 512 * 512 * 512 * 512 * 1K * 64b * 4K
|
// 512 * 512 * 512 * 512 * 1K * 64b * 4K
|
||||||
// 111111111 111111111 111111111 111111111 1111111111 111111 111111111111
|
// 111111111 111111111 111111111 111111111 1111111111 111111 111111111111
|
||||||
// 63 54 45 36 27 17 11 0
|
// 63 54 45 36 27 17 11 0
|
||||||
// 9b 9b 9b 9b 10b 6b 12b
|
// 9b 9b 9b 9b 10b 6b 12b
|
||||||
// L0 -> L1 -> L2 -> L3 -> L4 -> bits -> page
|
// L0 -> L1 -> L2 -> L3 -> L4 -> bits -> page
|
||||||
// 1FF 1FF 1FF 1FF 3FF 3F FFF
|
// 1FF 1FF 1FF 1FF 3FF 3F FFF
|
||||||
//
|
//
|
||||||
// L4 table has 1K * sizeof(UINT64) = 8K (2-page), which can track 256MB
|
// L4 table has 1K * sizeof(UINT64) = 8K (2-page), which can track 256MB
|
||||||
// memory. Each table of L0-L3 will be allocated when its memory address
|
// memory. Each table of L0-L3 will be allocated when its memory address
|
||||||
// range is to be tracked. Only 1-page will be allocated each time. This
|
// range is to be tracked. Only 1-page will be allocated each time. This
|
||||||
// can save memories used to establish this map table.
|
// can save memories used to establish this map table.
|
||||||
//
|
//
|
||||||
// For a normal configuration of system with 4G memory, two levels of tables
|
// For a normal configuration of system with 4G memory, two levels of tables
|
||||||
// can track the whole memory, because two levels (L3+L4) of map tables have
|
// can track the whole memory, because two levels (L3+L4) of map tables have
|
||||||
// already coverred 37-bit of memory address. And for a normal UEFI BIOS,
|
// already coverred 37-bit of memory address. And for a normal UEFI BIOS,
|
||||||
// less than 128M memory would be consumed during boot. That means we just
|
// less than 128M memory would be consumed during boot. That means we just
|
||||||
// need
|
// need
|
||||||
//
|
//
|
||||||
// 1-page (L3) + 2-page (L4)
|
// 1-page (L3) + 2-page (L4)
|
||||||
//
|
//
|
||||||
// memory (3 pages) to track the memory allocation works. In this case,
|
// memory (3 pages) to track the memory allocation works. In this case,
|
||||||
// there's no need to setup L0-L2 tables.
|
// there's no need to setup L0-L2 tables.
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Each entry occupies 8B/64b. 1-page can hold 512 entries, which spans 9
|
// Each entry occupies 8B/64b. 1-page can hold 512 entries, which spans 9
|
||||||
// bits in address. (512 = 1 << 9)
|
// bits in address. (512 = 1 << 9)
|
||||||
//
|
//
|
||||||
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
#define BYTE_LENGTH_SHIFT 3 // (8 = 1 << 3)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT \
|
#define GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT \
|
||||||
(EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT)
|
(EFI_PAGE_SHIFT - BYTE_LENGTH_SHIFT)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH 5
|
||||||
|
|
||||||
// Use UINT64_index + bit_index_of_UINT64 to locate the bit in may
|
// Use UINT64_index + bit_index_of_UINT64 to locate the bit in may
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
#define GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT 6 // (64 = 1 << 6)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BITS \
|
#define GUARDED_HEAP_MAP_ENTRY_BITS \
|
||||||
(1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)
|
(1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)
|
||||||
|
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BYTES \
|
#define GUARDED_HEAP_MAP_ENTRY_BYTES \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_BITS / 8)
|
(GUARDED_HEAP_MAP_ENTRY_BITS / 8)
|
||||||
|
|
||||||
// L4 table address width: 64 - 9 * 4 - 6 - 12 = 10b
|
// L4 table address width: 64 - 9 * 4 - 6 - 12 = 10b
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
#define GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_BITS \
|
(GUARDED_HEAP_MAP_ENTRY_BITS \
|
||||||
- GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 4 \
|
- GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 4 \
|
||||||
- GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
- GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
- EFI_PAGE_SHIFT)
|
- EFI_PAGE_SHIFT)
|
||||||
|
|
||||||
// L4 table address mask: (1 << 10 - 1) = 0x3FF
|
// L4 table address mask: (1 << 10 - 1) = 0x3FF
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_MASK \
|
#define GUARDED_HEAP_MAP_ENTRY_MASK \
|
||||||
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1)
|
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1)
|
||||||
|
|
||||||
// Size of each L4 table: (1 << 10) * 8 = 8KB = 2-page
|
// Size of each L4 table: (1 << 10) * 8 = 8KB = 2-page
|
||||||
#define GUARDED_HEAP_MAP_SIZE \
|
#define GUARDED_HEAP_MAP_SIZE \
|
||||||
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES)
|
((1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) * GUARDED_HEAP_MAP_ENTRY_BYTES)
|
||||||
|
|
||||||
// Memory size tracked by one L4 table: 8KB * 8 * 4KB = 256MB
|
// Memory size tracked by one L4 table: 8KB * 8 * 4KB = 256MB
|
||||||
#define GUARDED_HEAP_MAP_UNIT_SIZE \
|
#define GUARDED_HEAP_MAP_UNIT_SIZE \
|
||||||
(GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE)
|
(GUARDED_HEAP_MAP_SIZE * 8 * EFI_PAGE_SIZE)
|
||||||
|
|
||||||
// L4 table entry number: 8KB / 8 = 1024
|
// L4 table entry number: 8KB / 8 = 1024
|
||||||
#define GUARDED_HEAP_MAP_ENTRIES_PER_UNIT \
|
#define GUARDED_HEAP_MAP_ENTRIES_PER_UNIT \
|
||||||
(GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES)
|
(GUARDED_HEAP_MAP_SIZE / GUARDED_HEAP_MAP_ENTRY_BYTES)
|
||||||
|
|
||||||
// L4 table entry indexing
|
// L4 table entry indexing
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_ENTRY_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) \
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) \
|
||||||
& GUARDED_HEAP_MAP_ENTRY_MASK)
|
& GUARDED_HEAP_MAP_ENTRY_MASK)
|
||||||
|
|
||||||
// L4 table entry bit indexing
|
// L4 table entry bit indexing
|
||||||
#define GUARDED_HEAP_MAP_ENTRY_BIT_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_ENTRY_BIT_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
||||||
& ((1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) - 1))
|
& ((1 << GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT) - 1))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Total bits (pages) tracked by one L4 table (65536-bit)
|
// Total bits (pages) tracked by one L4 table (65536-bit)
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_BITS \
|
#define GUARDED_HEAP_MAP_BITS \
|
||||||
(1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
(1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT))
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bit indexing inside the whole L4 table (0 - 65535)
|
// Bit indexing inside the whole L4 table (0 - 65535)
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_BIT_INDEX(Address) \
|
#define GUARDED_HEAP_MAP_BIT_INDEX(Address) \
|
||||||
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
(RShiftU64 (Address, EFI_PAGE_SHIFT) \
|
||||||
& ((1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
& ((1 << (GUARDED_HEAP_MAP_ENTRY_SHIFT \
|
||||||
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)) - 1))
|
+ GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT)) - 1))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory address bit width tracked by L4 table: 10 + 6 + 12 = 28
|
// Memory address bit width tracked by L4 table: 10 + 6 + 12 = 28
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_SHIFT \
|
#define GUARDED_HEAP_MAP_TABLE_SHIFT \
|
||||||
(GUARDED_HEAP_MAP_ENTRY_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
(GUARDED_HEAP_MAP_ENTRY_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
+ EFI_PAGE_SHIFT)
|
+ EFI_PAGE_SHIFT)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macro used to initialize the local array variable for map table traversing
|
// Macro used to initialize the local array variable for map table traversing
|
||||||
// {55, 46, 37, 28, 18}
|
// {55, 46, 37, 28, 18}
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS \
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH_SHIFTS \
|
||||||
{ \
|
{ \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 3, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 3, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 2, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT * 2, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT + GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT, \
|
||||||
GUARDED_HEAP_MAP_TABLE_SHIFT, \
|
GUARDED_HEAP_MAP_TABLE_SHIFT, \
|
||||||
EFI_PAGE_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
EFI_PAGE_SHIFT + GUARDED_HEAP_MAP_ENTRY_BIT_SHIFT \
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Masks used to extract address range of each level of table
|
// Masks used to extract address range of each level of table
|
||||||
// {0x1FF, 0x1FF, 0x1FF, 0x1FF, 0x3FF}
|
// {0x1FF, 0x1FF, 0x1FF, 0x1FF, 0x3FF}
|
||||||
//
|
//
|
||||||
#define GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS \
|
#define GUARDED_HEAP_MAP_TABLE_DEPTH_MASKS \
|
||||||
{ \
|
{ \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
(1 << GUARDED_HEAP_MAP_TABLE_ENTRY_SHIFT) - 1, \
|
||||||
(1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1 \
|
(1 << GUARDED_HEAP_MAP_ENTRY_SHIFT) - 1 \
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Memory type to guard (matching the related PCD definition)
|
// Memory type to guard (matching the related PCD definition)
|
||||||
//
|
//
|
||||||
#define GUARD_HEAP_TYPE_POOL BIT2
|
#define GUARD_HEAP_TYPE_POOL BIT2
|
||||||
#define GUARD_HEAP_TYPE_PAGE BIT3
|
#define GUARD_HEAP_TYPE_PAGE BIT3
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug message level
|
// Debug message level
|
||||||
//
|
//
|
||||||
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE)
|
#define HEAP_GUARD_DEBUG_LEVEL (DEBUG_POOL|DEBUG_PAGE)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT32 TailMark;
|
UINT32 TailMark;
|
||||||
UINT32 HeadMark;
|
UINT32 HeadMark;
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
LIST_ENTRY Link;
|
LIST_ENTRY Link;
|
||||||
} HEAP_GUARD_NODE;
|
} HEAP_GUARD_NODE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set head Guard and tail Guard for the given memory range.
|
Set head Guard and tail Guard for the given memory range.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory to set guard for.
|
@param[in] Memory Base address of memory to set guard for.
|
||||||
@param[in] NumberOfPages Memory size in pages.
|
@param[in] NumberOfPages Memory size in pages.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SetGuardForMemory (
|
SetGuardForMemory (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Unset head Guard and tail Guard for the given memory range.
|
Unset head Guard and tail Guard for the given memory range.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory to unset guard for.
|
@param[in] Memory Base address of memory to unset guard for.
|
||||||
@param[in] NumberOfPages Memory size in pages.
|
@param[in] NumberOfPages Memory size in pages.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
UnsetGuardForMemory (
|
UnsetGuardForMemory (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the base and number of pages to really allocate according to Guard.
|
Adjust the base and number of pages to really allocate according to Guard.
|
||||||
|
|
||||||
@param[in,out] Memory Base address of free memory.
|
@param[in,out] Memory Base address of free memory.
|
||||||
@param[in,out] NumberOfPages Size of memory to allocate.
|
@param[in,out] NumberOfPages Size of memory to allocate.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
AdjustMemoryA (
|
AdjustMemoryA (
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN OUT UINTN *NumberOfPages
|
IN OUT UINTN *NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the start address and number of pages to free according to Guard.
|
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
|
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
|
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.
|
is to reserve pages as Guard pages in partial page free situation.
|
||||||
|
|
||||||
@param[in,out] Memory Base address of memory to free.
|
@param[in,out] Memory Base address of memory to free.
|
||||||
@param[in,out] NumberOfPages Size of memory to free.
|
@param[in,out] NumberOfPages Size of memory to free.
|
||||||
|
|
||||||
@return VOID.
|
@return VOID.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
AdjustMemoryF (
|
AdjustMemoryF (
|
||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN OUT UINTN *NumberOfPages
|
IN OUT UINTN *NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the pool at the given address should be guarded or not.
|
Check to see if the pool at the given address should be guarded or not.
|
||||||
|
|
||||||
@param[in] MemoryType Pool type to check.
|
@param[in] MemoryType Pool type to check.
|
||||||
|
|
||||||
|
|
||||||
@return TRUE The given type of pool should be guarded.
|
@return TRUE The given type of pool should be guarded.
|
||||||
@return FALSE The given type of pool should not be guarded.
|
@return FALSE The given type of pool should not be guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPoolTypeToGuard (
|
IsPoolTypeToGuard (
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address should be guarded or not.
|
Check to see if the page at the given address should be guarded or not.
|
||||||
|
|
||||||
@param[in] MemoryType Page type to check.
|
@param[in] MemoryType Page type to check.
|
||||||
@param[in] AllocateType Allocation type to check.
|
@param[in] AllocateType Allocation type to check.
|
||||||
|
|
||||||
@return TRUE The given type of page should be guarded.
|
@return TRUE The given type of page should be guarded.
|
||||||
@return FALSE The given type of page should not be guarded.
|
@return FALSE The given type of page should not be guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsPageTypeToGuard (
|
IsPageTypeToGuard (
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN EFI_ALLOCATE_TYPE AllocateType
|
IN EFI_ALLOCATE_TYPE AllocateType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address is guarded or not.
|
Check to see if the page at the given address is guarded or not.
|
||||||
|
|
||||||
@param[in] Address The address to check for.
|
@param[in] Address The address to check for.
|
||||||
|
|
||||||
@return TRUE The page at Address is guarded.
|
@return TRUE The page at Address is guarded.
|
||||||
@return FALSE The page at Address is not guarded.
|
@return FALSE The page at Address is not guarded.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsMemoryGuarded (
|
IsMemoryGuarded (
|
||||||
IN EFI_PHYSICAL_ADDRESS Address
|
IN EFI_PHYSICAL_ADDRESS Address
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the page at the given address is a Guard page or not.
|
Check to see if the page at the given address is a Guard page or not.
|
||||||
|
|
||||||
@param[in] Address The address to check for.
|
@param[in] Address The address to check for.
|
||||||
|
|
||||||
@return TRUE The page at Address is a Guard page.
|
@return TRUE The page at Address is a Guard page.
|
||||||
@return FALSE The page at Address is not a Guard page.
|
@return FALSE The page at Address is not a Guard page.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
IsGuardPage (
|
IsGuardPage (
|
||||||
IN EFI_PHYSICAL_ADDRESS Address
|
IN EFI_PHYSICAL_ADDRESS Address
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dump the guarded memory bit map.
|
Dump the guarded memory bit map.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DumpGuardedMemoryBitmap (
|
DumpGuardedMemoryBitmap (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adjust the pool head position to make sure the Guard page is adjavent to
|
Adjust the pool head position to make sure the Guard page is adjavent to
|
||||||
pool tail or pool head.
|
pool tail or pool head.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory allocated.
|
@param[in] Memory Base address of memory allocated.
|
||||||
@param[in] NoPages Number of pages actually allocated.
|
@param[in] NoPages Number of pages actually allocated.
|
||||||
@param[in] Size Size of memory requested.
|
@param[in] Size Size of memory requested.
|
||||||
(plus pool head/tail overhead)
|
(plus pool head/tail overhead)
|
||||||
|
|
||||||
@return Address of pool head.
|
@return Address of pool head.
|
||||||
**/
|
**/
|
||||||
VOID *
|
VOID *
|
||||||
AdjustPoolHeadA (
|
AdjustPoolHeadA (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NoPages,
|
IN UINTN NoPages,
|
||||||
IN UINTN Size
|
IN UINTN Size
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the page base address according to pool head address.
|
Get the page base address according to pool head address.
|
||||||
|
|
||||||
@param[in] Memory Head address of pool to free.
|
@param[in] Memory Head address of pool to free.
|
||||||
|
|
||||||
@return Address of pool head.
|
@return Address of pool head.
|
||||||
**/
|
**/
|
||||||
VOID *
|
VOID *
|
||||||
AdjustPoolHeadF (
|
AdjustPoolHeadF (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory
|
IN EFI_PHYSICAL_ADDRESS Memory
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper function of memory allocation with Guard pages.
|
Helper function of memory allocation with Guard pages.
|
||||||
|
|
||||||
@param FreePageList The free page node.
|
@param FreePageList The free page node.
|
||||||
@param NumberOfPages Number of pages to be allocated.
|
@param NumberOfPages Number of pages to be allocated.
|
||||||
@param MaxAddress Request to allocate memory below this address.
|
@param MaxAddress Request to allocate memory below this address.
|
||||||
@param MemoryType Type of memory requested.
|
@param MemoryType Type of memory requested.
|
||||||
|
|
||||||
@return Memory address of allocated pages.
|
@return Memory address of allocated pages.
|
||||||
**/
|
**/
|
||||||
UINTN
|
UINTN
|
||||||
InternalAllocMaxAddressWithGuard (
|
InternalAllocMaxAddressWithGuard (
|
||||||
IN OUT LIST_ENTRY *FreePageList,
|
IN OUT LIST_ENTRY *FreePageList,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN UINTN MaxAddress,
|
IN UINTN MaxAddress,
|
||||||
IN EFI_MEMORY_TYPE MemoryType
|
IN EFI_MEMORY_TYPE MemoryType
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper function of memory free with Guard pages.
|
Helper function of memory free with Guard pages.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory being freed.
|
@param[in] Memory Base address of memory being freed.
|
||||||
@param[in] NumberOfPages The number of pages to free.
|
@param[in] NumberOfPages The number of pages to free.
|
||||||
@param[in] AddRegion If this memory is new added region.
|
@param[in] AddRegion If this memory is new added region.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or
|
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or
|
||||||
NumberOfPages is zero.
|
NumberOfPages is zero.
|
||||||
@return EFI_SUCCESS Pages successfully freed.
|
@return EFI_SUCCESS Pages successfully freed.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SmmInternalFreePagesExWithGuard (
|
SmmInternalFreePagesExWithGuard (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN BOOLEAN AddRegion
|
IN BOOLEAN AddRegion
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Check to see if the heap guard is enabled for page and/or pool allocation.
|
Check to see if the heap guard is enabled for page and/or pool allocation.
|
||||||
|
|
||||||
@return TRUE/FALSE.
|
@return TRUE/FALSE.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsHeapGuardEnabled (
|
IsHeapGuardEnabled (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Debug function used to verify if the Guard page is well set or not.
|
Debug function used to verify if the Guard page is well set or not.
|
||||||
|
|
||||||
@param[in] BaseAddress Address of memory to check.
|
@param[in] BaseAddress Address of memory to check.
|
||||||
@param[in] NumberOfPages Size of memory in pages.
|
@param[in] NumberOfPages Size of memory in pages.
|
||||||
|
|
||||||
@return TRUE The head Guard and tail Guard are both well set.
|
@return TRUE The head Guard and tail Guard are both well set.
|
||||||
@return FALSE The head Guard and/or tail Guard are not well set.
|
@return FALSE The head Guard and/or tail Guard are not well set.
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
VerifyMemoryGuard (
|
VerifyMemoryGuard (
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINTN NumberOfPages
|
IN UINTN NumberOfPages
|
||||||
);
|
);
|
||||||
|
|
||||||
extern BOOLEAN mOnGuarding;
|
extern BOOLEAN mOnGuarding;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,8 +64,8 @@ LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemor
|
||||||
@param[out] Memory A pointer to receive the base allocated memory
|
@param[out] Memory A pointer to receive the base allocated memory
|
||||||
address.
|
address.
|
||||||
@param[in] AddRegion If this memory is new added region.
|
@param[in] AddRegion If this memory is new added region.
|
||||||
@param[in] NeedGuard Flag to indicate Guard page is needed
|
@param[in] NeedGuard Flag to indicate Guard page is needed
|
||||||
or not
|
or not
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
||||||
|
@ -79,8 +79,8 @@ SmmInternalAllocatePagesEx (
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN AddRegion,
|
IN BOOLEAN AddRegion,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,8 +115,8 @@ AllocateMemoryMapEntry (
|
||||||
EfiRuntimeServicesData,
|
EfiRuntimeServicesData,
|
||||||
EFI_SIZE_TO_PAGES (RUNTIME_PAGE_ALLOCATION_GRANULARITY),
|
EFI_SIZE_TO_PAGES (RUNTIME_PAGE_ALLOCATION_GRANULARITY),
|
||||||
&Mem,
|
&Mem,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if(!EFI_ERROR (Status)) {
|
if(!EFI_ERROR (Status)) {
|
||||||
|
@ -692,8 +692,8 @@ InternalAllocAddress (
|
||||||
@param[out] Memory A pointer to receive the base allocated memory
|
@param[out] Memory A pointer to receive the base allocated memory
|
||||||
address.
|
address.
|
||||||
@param[in] AddRegion If this memory is new added region.
|
@param[in] AddRegion If this memory is new added region.
|
||||||
@param[in] NeedGuard Flag to indicate Guard page is needed
|
@param[in] NeedGuard Flag to indicate Guard page is needed
|
||||||
or not
|
or not
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
||||||
|
@ -707,8 +707,8 @@ SmmInternalAllocatePagesEx (
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN AddRegion,
|
IN BOOLEAN AddRegion,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN RequestedAddress;
|
UINTN RequestedAddress;
|
||||||
|
@ -730,21 +730,21 @@ SmmInternalAllocatePagesEx (
|
||||||
case AllocateAnyPages:
|
case AllocateAnyPages:
|
||||||
RequestedAddress = (UINTN)(-1);
|
RequestedAddress = (UINTN)(-1);
|
||||||
case AllocateMaxAddress:
|
case AllocateMaxAddress:
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
*Memory = InternalAllocMaxAddressWithGuard (
|
*Memory = InternalAllocMaxAddressWithGuard (
|
||||||
&mSmmMemoryMap,
|
&mSmmMemoryMap,
|
||||||
NumberOfPages,
|
NumberOfPages,
|
||||||
RequestedAddress,
|
RequestedAddress,
|
||||||
MemoryType
|
MemoryType
|
||||||
);
|
);
|
||||||
if (*Memory == (UINTN)-1) {
|
if (*Memory == (UINTN)-1) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
ASSERT (VerifyMemoryGuard (*Memory, NumberOfPages) == TRUE);
|
ASSERT (VerifyMemoryGuard (*Memory, NumberOfPages) == TRUE);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*Memory = InternalAllocMaxAddress (
|
*Memory = InternalAllocMaxAddress (
|
||||||
&mSmmMemoryMap,
|
&mSmmMemoryMap,
|
||||||
NumberOfPages,
|
NumberOfPages,
|
||||||
|
@ -788,8 +788,8 @@ SmmInternalAllocatePagesEx (
|
||||||
@param[in] NumberOfPages The number of pages to allocate.
|
@param[in] NumberOfPages The number of pages to allocate.
|
||||||
@param[out] Memory A pointer to receive the base allocated memory
|
@param[out] Memory A pointer to receive the base allocated memory
|
||||||
address.
|
address.
|
||||||
@param[in] NeedGuard Flag to indicate Guard page is needed
|
@param[in] NeedGuard Flag to indicate Guard page is needed
|
||||||
or not
|
or not
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
||||||
|
@ -803,12 +803,12 @@ SmmInternalAllocatePages (
|
||||||
IN EFI_ALLOCATE_TYPE Type,
|
IN EFI_ALLOCATE_TYPE Type,
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SmmInternalAllocatePagesEx (Type, MemoryType, NumberOfPages, Memory,
|
return SmmInternalAllocatePagesEx (Type, MemoryType, NumberOfPages, Memory,
|
||||||
FALSE, NeedGuard);
|
FALSE, NeedGuard);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -837,11 +837,11 @@ SmmAllocatePages (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BOOLEAN NeedGuard;
|
BOOLEAN NeedGuard;
|
||||||
|
|
||||||
NeedGuard = IsPageTypeToGuard (MemoryType, Type);
|
NeedGuard = IsPageTypeToGuard (MemoryType, Type);
|
||||||
Status = SmmInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory,
|
Status = SmmInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory,
|
||||||
NeedGuard);
|
NeedGuard);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
SmmCoreUpdateProfile (
|
SmmCoreUpdateProfile (
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||||
|
@ -960,7 +960,7 @@ SmmInternalFreePagesEx (
|
||||||
|
|
||||||
@param[in] Memory Base address of memory being freed.
|
@param[in] Memory Base address of memory being freed.
|
||||||
@param[in] NumberOfPages The number of pages to free.
|
@param[in] NumberOfPages The number of pages to free.
|
||||||
@param[in] IsGuarded Is the memory to free guarded or not.
|
@param[in] IsGuarded Is the memory to free guarded or not.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
||||||
|
@ -971,13 +971,13 @@ EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SmmInternalFreePages (
|
SmmInternalFreePages (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN BOOLEAN IsGuarded
|
IN BOOLEAN IsGuarded
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (IsGuarded) {
|
if (IsGuarded) {
|
||||||
return SmmInternalFreePagesExWithGuard (Memory, NumberOfPages, FALSE);
|
return SmmInternalFreePagesExWithGuard (Memory, NumberOfPages, FALSE);
|
||||||
}
|
}
|
||||||
return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);
|
return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,10 +1000,10 @@ SmmFreePages (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BOOLEAN IsGuarded;
|
BOOLEAN IsGuarded;
|
||||||
|
|
||||||
IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
|
IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
|
||||||
Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
|
Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
SmmCoreUpdateProfile (
|
SmmCoreUpdateProfile (
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
(EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
|
||||||
|
|
|
@ -506,11 +506,11 @@ SmmEntryPoint (
|
||||||
//
|
//
|
||||||
PlatformHookBeforeSmmDispatch ();
|
PlatformHookBeforeSmmDispatch ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call memory management hook function
|
// Call memory management hook function
|
||||||
//
|
//
|
||||||
SmmEntryPointMemoryManagementHook ();
|
SmmEntryPointMemoryManagementHook ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed
|
// If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed
|
||||||
//
|
//
|
||||||
|
@ -704,7 +704,7 @@ SmmMain (
|
||||||
//
|
//
|
||||||
gSmmCorePrivate->Smst = &gSmmCoreSmst;
|
gSmmCorePrivate->Smst = &gSmmCoreSmst;
|
||||||
gSmmCorePrivate->SmmEntryPoint = SmmEntryPoint;
|
gSmmCorePrivate->SmmEntryPoint = SmmEntryPoint;
|
||||||
|
|
||||||
//
|
//
|
||||||
// No need to initialize memory service.
|
// No need to initialize memory service.
|
||||||
// It is done in constructor of PiSmmCoreMemoryAllocationLib(),
|
// It is done in constructor of PiSmmCoreMemoryAllocationLib(),
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <Protocol/SmmLegacyBoot.h>
|
#include <Protocol/SmmLegacyBoot.h>
|
||||||
#include <Protocol/SmmReadyToBoot.h>
|
#include <Protocol/SmmReadyToBoot.h>
|
||||||
#include <Protocol/SmmEndOfS3Resume.h>
|
#include <Protocol/SmmEndOfS3Resume.h>
|
||||||
#include <Protocol/SmmMemoryAttribute.h>
|
#include <Protocol/SmmMemoryAttribute.h>
|
||||||
|
|
||||||
#include <Guid/Apriori.h>
|
#include <Guid/Apriori.h>
|
||||||
#include <Guid/EventGroup.h>
|
#include <Guid/EventGroup.h>
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
#include <Library/SmmMemLib.h>
|
#include <Library/SmmMemLib.h>
|
||||||
|
|
||||||
#include "PiSmmCorePrivateData.h"
|
#include "PiSmmCorePrivateData.h"
|
||||||
#include "HeapGuard.h"
|
#include "HeapGuard.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Used to build a table of SMI Handlers that the SMM Core registers
|
// Used to build a table of SMI Handlers that the SMM Core registers
|
||||||
|
@ -320,7 +320,7 @@ SmmAllocatePages (
|
||||||
@param NumberOfPages The number of pages to allocate
|
@param NumberOfPages The number of pages to allocate
|
||||||
@param Memory A pointer to receive the base allocated memory
|
@param Memory A pointer to receive the base allocated memory
|
||||||
address
|
address
|
||||||
@param NeedGuard Flag to indicate Guard page is needed or not
|
@param NeedGuard Flag to indicate Guard page is needed or not
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
|
||||||
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
||||||
|
@ -334,8 +334,8 @@ SmmInternalAllocatePages (
|
||||||
IN EFI_ALLOCATE_TYPE Type,
|
IN EFI_ALLOCATE_TYPE Type,
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
OUT EFI_PHYSICAL_ADDRESS *Memory,
|
||||||
IN BOOLEAN NeedGuard
|
IN BOOLEAN NeedGuard
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,8 +361,8 @@ SmmFreePages (
|
||||||
|
|
||||||
@param Memory Base address of memory being freed
|
@param Memory Base address of memory being freed
|
||||||
@param NumberOfPages The number of pages to free
|
@param NumberOfPages The number of pages to free
|
||||||
@param IsGuarded Flag to indicate if the memory is guarded
|
@param IsGuarded Flag to indicate if the memory is guarded
|
||||||
or not
|
or not
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
||||||
|
@ -373,8 +373,8 @@ EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SmmInternalFreePages (
|
SmmInternalFreePages (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN BOOLEAN IsGuarded
|
IN BOOLEAN IsGuarded
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1262,74 +1262,74 @@ typedef enum {
|
||||||
|
|
||||||
extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];
|
extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal Function. Allocate n pages from given free page node.
|
Internal Function. Allocate n pages from given free page node.
|
||||||
|
|
||||||
@param Pages The free page node.
|
@param Pages The free page node.
|
||||||
@param NumberOfPages Number of pages to be allocated.
|
@param NumberOfPages Number of pages to be allocated.
|
||||||
@param MaxAddress Request to allocate memory below this address.
|
@param MaxAddress Request to allocate memory below this address.
|
||||||
|
|
||||||
@return Memory address of allocated pages.
|
@return Memory address of allocated pages.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINTN
|
UINTN
|
||||||
InternalAllocPagesOnOneNode (
|
InternalAllocPagesOnOneNode (
|
||||||
IN OUT FREE_PAGE_LIST *Pages,
|
IN OUT FREE_PAGE_LIST *Pages,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN UINTN MaxAddress
|
IN UINTN MaxAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update SMM memory map entry.
|
Update SMM memory map entry.
|
||||||
|
|
||||||
@param[in] Type The type of allocation to perform.
|
@param[in] Type The type of allocation to perform.
|
||||||
@param[in] Memory The base of memory address.
|
@param[in] Memory The base of memory address.
|
||||||
@param[in] NumberOfPages The number of pages to allocate.
|
@param[in] NumberOfPages The number of pages to allocate.
|
||||||
@param[in] AddRegion If this memory is new added region.
|
@param[in] AddRegion If this memory is new added region.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ConvertSmmMemoryMapEntry (
|
ConvertSmmMemoryMapEntry (
|
||||||
IN EFI_MEMORY_TYPE Type,
|
IN EFI_MEMORY_TYPE Type,
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN BOOLEAN AddRegion
|
IN BOOLEAN AddRegion
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal function. Moves any memory descriptors that are on the
|
Internal function. Moves any memory descriptors that are on the
|
||||||
temporary descriptor stack to heap.
|
temporary descriptor stack to heap.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
CoreFreeMemoryMapStack (
|
CoreFreeMemoryMapStack (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Frees previous allocated pages.
|
Frees previous allocated pages.
|
||||||
|
|
||||||
@param[in] Memory Base address of memory being freed.
|
@param[in] Memory Base address of memory being freed.
|
||||||
@param[in] NumberOfPages The number of pages to free.
|
@param[in] NumberOfPages The number of pages to free.
|
||||||
@param[in] AddRegion If this memory is new added region.
|
@param[in] AddRegion If this memory is new added region.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range.
|
||||||
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
@retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
|
||||||
@return EFI_SUCCESS Pages successfully freed.
|
@return EFI_SUCCESS Pages successfully freed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SmmInternalFreePagesEx (
|
SmmInternalFreePagesEx (
|
||||||
IN EFI_PHYSICAL_ADDRESS Memory,
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
||||||
IN UINTN NumberOfPages,
|
IN UINTN NumberOfPages,
|
||||||
IN BOOLEAN AddRegion
|
IN BOOLEAN AddRegion
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Hook function used to set all Guard pages after entering SMM mode.
|
Hook function used to set all Guard pages after entering SMM mode.
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
SmmEntryPointMemoryManagementHook (
|
SmmEntryPointMemoryManagementHook (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
SmramProfileRecord.c
|
SmramProfileRecord.c
|
||||||
MemoryAttributesTable.c
|
MemoryAttributesTable.c
|
||||||
SmiHandlerProfile.c
|
SmiHandlerProfile.c
|
||||||
HeapGuard.c
|
HeapGuard.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
@ -90,8 +90,8 @@
|
||||||
gEfiSmmGpiDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiSmmGpiDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiSmmIoTrapDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiSmmIoTrapDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiSmmUsbDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiSmmUsbDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiSmmCpuProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiSmmCpuProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEdkiiSmmMemoryAttributeProtocolGuid ## CONSUMES
|
gEdkiiSmmMemoryAttributeProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber ## SOMETIMES_CONSUMES
|
||||||
|
@ -100,9 +100,9 @@
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdSmiHandlerProfilePropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSmiHandlerProfilePropertyMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gAprioriGuid ## SOMETIMES_CONSUMES ## File
|
gAprioriGuid ## SOMETIMES_CONSUMES ## File
|
||||||
|
|
|
@ -144,9 +144,9 @@ InternalAllocPoolByIndex (
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
Hdr = NULL;
|
Hdr = NULL;
|
||||||
if (PoolIndex == MAX_POOL_INDEX) {
|
if (PoolIndex == MAX_POOL_INDEX) {
|
||||||
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType,
|
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType,
|
||||||
EFI_SIZE_TO_PAGES (MAX_POOL_SIZE << 1),
|
EFI_SIZE_TO_PAGES (MAX_POOL_SIZE << 1),
|
||||||
&Address, FALSE);
|
&Address, FALSE);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
@ -245,9 +245,9 @@ SmmInternalAllocatePool (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
UINTN PoolIndex;
|
UINTN PoolIndex;
|
||||||
BOOLEAN HasPoolTail;
|
BOOLEAN HasPoolTail;
|
||||||
BOOLEAN NeedGuard;
|
BOOLEAN NeedGuard;
|
||||||
UINTN NoPages;
|
UINTN NoPages;
|
||||||
|
|
||||||
Address = 0;
|
Address = 0;
|
||||||
|
|
||||||
|
@ -256,47 +256,47 @@ SmmInternalAllocatePool (
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
NeedGuard = IsPoolTypeToGuard (PoolType);
|
NeedGuard = IsPoolTypeToGuard (PoolType);
|
||||||
HasPoolTail = !(NeedGuard &&
|
HasPoolTail = !(NeedGuard &&
|
||||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Adjust the size by the pool header & tail overhead
|
// Adjust the size by the pool header & tail overhead
|
||||||
//
|
//
|
||||||
Size += POOL_OVERHEAD;
|
Size += POOL_OVERHEAD;
|
||||||
if (Size > MAX_POOL_SIZE || NeedGuard) {
|
if (Size > MAX_POOL_SIZE || NeedGuard) {
|
||||||
if (!HasPoolTail) {
|
if (!HasPoolTail) {
|
||||||
Size -= sizeof (POOL_TAIL);
|
Size -= sizeof (POOL_TAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
NoPages = EFI_SIZE_TO_PAGES (Size);
|
NoPages = EFI_SIZE_TO_PAGES (Size);
|
||||||
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType, NoPages,
|
Status = SmmInternalAllocatePages (AllocateAnyPages, PoolType, NoPages,
|
||||||
&Address, NeedGuard);
|
&Address, NeedGuard);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedGuard) {
|
if (NeedGuard) {
|
||||||
ASSERT (VerifyMemoryGuard (Address, NoPages) == TRUE);
|
ASSERT (VerifyMemoryGuard (Address, NoPages) == TRUE);
|
||||||
Address = (EFI_PHYSICAL_ADDRESS)(UINTN)AdjustPoolHeadA (
|
Address = (EFI_PHYSICAL_ADDRESS)(UINTN)AdjustPoolHeadA (
|
||||||
Address,
|
Address,
|
||||||
NoPages,
|
NoPages,
|
||||||
Size
|
Size
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolHdr = (POOL_HEADER*)(UINTN)Address;
|
PoolHdr = (POOL_HEADER*)(UINTN)Address;
|
||||||
PoolHdr->Signature = POOL_HEAD_SIGNATURE;
|
PoolHdr->Signature = POOL_HEAD_SIGNATURE;
|
||||||
PoolHdr->Size = EFI_PAGES_TO_SIZE (NoPages);
|
PoolHdr->Size = EFI_PAGES_TO_SIZE (NoPages);
|
||||||
PoolHdr->Available = FALSE;
|
PoolHdr->Available = FALSE;
|
||||||
PoolHdr->Type = PoolType;
|
PoolHdr->Type = PoolType;
|
||||||
|
|
||||||
if (HasPoolTail) {
|
if (HasPoolTail) {
|
||||||
PoolTail = HEAD_TO_TAIL (PoolHdr);
|
PoolTail = HEAD_TO_TAIL (PoolHdr);
|
||||||
PoolTail->Signature = POOL_TAIL_SIGNATURE;
|
PoolTail->Signature = POOL_TAIL_SIGNATURE;
|
||||||
PoolTail->Size = PoolHdr->Size;
|
PoolTail->Size = PoolHdr->Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Buffer = PoolHdr + 1;
|
*Buffer = PoolHdr + 1;
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -368,18 +368,18 @@ SmmInternalFreePool (
|
||||||
{
|
{
|
||||||
FREE_POOL_HEADER *FreePoolHdr;
|
FREE_POOL_HEADER *FreePoolHdr;
|
||||||
POOL_TAIL *PoolTail;
|
POOL_TAIL *PoolTail;
|
||||||
BOOLEAN HasPoolTail;
|
BOOLEAN HasPoolTail;
|
||||||
BOOLEAN MemoryGuarded;
|
BOOLEAN MemoryGuarded;
|
||||||
|
|
||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryGuarded = IsHeapGuardEnabled () &&
|
MemoryGuarded = IsHeapGuardEnabled () &&
|
||||||
IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer);
|
IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer);
|
||||||
HasPoolTail = !(MemoryGuarded &&
|
HasPoolTail = !(MemoryGuarded &&
|
||||||
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
|
||||||
|
|
||||||
FreePoolHdr = (FREE_POOL_HEADER*)((POOL_HEADER*)Buffer - 1);
|
FreePoolHdr = (FREE_POOL_HEADER*)((POOL_HEADER*)Buffer - 1);
|
||||||
ASSERT (FreePoolHdr->Header.Signature == POOL_HEAD_SIGNATURE);
|
ASSERT (FreePoolHdr->Header.Signature == POOL_HEAD_SIGNATURE);
|
||||||
ASSERT (!FreePoolHdr->Header.Available);
|
ASSERT (!FreePoolHdr->Header.Available);
|
||||||
|
@ -387,28 +387,28 @@ SmmInternalFreePool (
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasPoolTail) {
|
if (HasPoolTail) {
|
||||||
PoolTail = HEAD_TO_TAIL (&FreePoolHdr->Header);
|
PoolTail = HEAD_TO_TAIL (&FreePoolHdr->Header);
|
||||||
ASSERT (PoolTail->Signature == POOL_TAIL_SIGNATURE);
|
ASSERT (PoolTail->Signature == POOL_TAIL_SIGNATURE);
|
||||||
ASSERT (FreePoolHdr->Header.Size == PoolTail->Size);
|
ASSERT (FreePoolHdr->Header.Size == PoolTail->Size);
|
||||||
if (PoolTail->Signature != POOL_TAIL_SIGNATURE) {
|
if (PoolTail->Signature != POOL_TAIL_SIGNATURE) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FreePoolHdr->Header.Size != PoolTail->Size) {
|
if (FreePoolHdr->Header.Size != PoolTail->Size) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PoolTail = NULL;
|
PoolTail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MemoryGuarded) {
|
if (MemoryGuarded) {
|
||||||
Buffer = AdjustPoolHeadF ((EFI_PHYSICAL_ADDRESS)(UINTN)FreePoolHdr);
|
Buffer = AdjustPoolHeadF ((EFI_PHYSICAL_ADDRESS)(UINTN)FreePoolHdr);
|
||||||
return SmmInternalFreePages (
|
return SmmInternalFreePages (
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)Buffer,
|
(EFI_PHYSICAL_ADDRESS)(UINTN)Buffer,
|
||||||
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size),
|
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size),
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FreePoolHdr->Header.Size > MAX_POOL_SIZE) {
|
if (FreePoolHdr->Header.Size > MAX_POOL_SIZE) {
|
||||||
|
@ -416,8 +416,8 @@ SmmInternalFreePool (
|
||||||
ASSERT ((FreePoolHdr->Header.Size & EFI_PAGE_MASK) == 0);
|
ASSERT ((FreePoolHdr->Header.Size & EFI_PAGE_MASK) == 0);
|
||||||
return SmmInternalFreePages (
|
return SmmInternalFreePages (
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)FreePoolHdr,
|
(EFI_PHYSICAL_ADDRESS)(UINTN)FreePoolHdr,
|
||||||
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size),
|
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size),
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return InternalFreePoolByIndex (FreePoolHdr, PoolTail);
|
return InternalFreePoolByIndex (FreePoolHdr, PoolTail);
|
||||||
|
|
|
@ -1,136 +1,136 @@
|
||||||
/** @file
|
/** @file
|
||||||
SMM Memory Attribute Protocol provides retrieval and update service
|
SMM Memory Attribute Protocol provides retrieval and update service
|
||||||
for memory attributes in EFI SMM environment.
|
for memory attributes in EFI SMM environment.
|
||||||
|
|
||||||
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef __SMM_MEMORYATTRIBUTE_H__
|
#ifndef __SMM_MEMORYATTRIBUTE_H__
|
||||||
#define __SMM_MEMORYATTRIBUTE_H__
|
#define __SMM_MEMORYATTRIBUTE_H__
|
||||||
|
|
||||||
//{69B792EA-39CE-402D-A2A6-F721DE351DFE}
|
//{69B792EA-39CE-402D-A2A6-F721DE351DFE}
|
||||||
#define EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL_GUID \
|
#define EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL_GUID \
|
||||||
{ \
|
{ \
|
||||||
0x69b792ea, 0x39ce, 0x402d, { 0xa2, 0xa6, 0xf7, 0x21, 0xde, 0x35, 0x1d, 0xfe } \
|
0x69b792ea, 0x39ce, 0x402d, { 0xa2, 0xa6, 0xf7, 0x21, 0xde, 0x35, 0x1d, 0xfe } \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL;
|
typedef struct _EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function set given attributes of the memory region specified by
|
This function set given attributes of the memory region specified by
|
||||||
BaseAddress and Length.
|
BaseAddress and Length.
|
||||||
|
|
||||||
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
@param BaseAddress The physical address that is the start address of
|
@param BaseAddress The physical address that is the start address of
|
||||||
a memory region.
|
a memory region.
|
||||||
@param Length The size in bytes of the memory region.
|
@param Length The size in bytes of the memory region.
|
||||||
@param Attributes The bit mask of attributes to set for the memory
|
@param Attributes The bit mask of attributes to set for the memory
|
||||||
region.
|
region.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The attributes were set for the memory region.
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
@retval EFI_INVALID_PARAMETER Length is zero.
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
Attributes specified an illegal combination of
|
Attributes specified an illegal combination of
|
||||||
attributes that cannot be set together.
|
attributes that cannot be set together.
|
||||||
@retval EFI_UNSUPPORTED The processor does not support one or more
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
bytes of the memory resource range specified
|
bytes of the memory resource range specified
|
||||||
by BaseAddress and Length.
|
by BaseAddress and Length.
|
||||||
The bit mask of attributes is not support for
|
The bit mask of attributes is not support for
|
||||||
the memory resource range specified by
|
the memory resource range specified by
|
||||||
BaseAddress and Length.
|
BaseAddress and Length.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *EDKII_SMM_SET_MEMORY_ATTRIBUTES)(
|
(EFIAPI *EDKII_SMM_SET_MEMORY_ATTRIBUTES)(
|
||||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function clears given attributes of the memory region specified by
|
This function clears given attributes of the memory region specified by
|
||||||
BaseAddress and Length.
|
BaseAddress and Length.
|
||||||
|
|
||||||
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
@param BaseAddress The physical address that is the start address of
|
@param BaseAddress The physical address that is the start address of
|
||||||
a memory region.
|
a memory region.
|
||||||
@param Length The size in bytes of the memory region.
|
@param Length The size in bytes of the memory region.
|
||||||
@param Attributes The bit mask of attributes to set for the memory
|
@param Attributes The bit mask of attributes to set for the memory
|
||||||
region.
|
region.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The attributes were set for the memory region.
|
@retval EFI_SUCCESS The attributes were set for the memory region.
|
||||||
@retval EFI_INVALID_PARAMETER Length is zero.
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
Attributes specified an illegal combination of
|
Attributes specified an illegal combination of
|
||||||
attributes that cannot be set together.
|
attributes that cannot be set together.
|
||||||
@retval EFI_UNSUPPORTED The processor does not support one or more
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
bytes of the memory resource range specified
|
bytes of the memory resource range specified
|
||||||
by BaseAddress and Length.
|
by BaseAddress and Length.
|
||||||
The bit mask of attributes is not support for
|
The bit mask of attributes is not support for
|
||||||
the memory resource range specified by
|
the memory resource range specified by
|
||||||
BaseAddress and Length.
|
BaseAddress and Length.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *EDKII_SMM_CLEAR_MEMORY_ATTRIBUTES)(
|
(EFIAPI *EDKII_SMM_CLEAR_MEMORY_ATTRIBUTES)(
|
||||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
IN UINT64 Attributes
|
IN UINT64 Attributes
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function retrieve the attributes of the memory region specified by
|
This function retrieve the attributes of the memory region specified by
|
||||||
BaseAddress and Length. If different attributes are got from different part
|
BaseAddress and Length. If different attributes are got from different part
|
||||||
of the memory region, EFI_NO_MAPPING will be returned.
|
of the memory region, EFI_NO_MAPPING will be returned.
|
||||||
|
|
||||||
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
@param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
||||||
@param BaseAddress The physical address that is the start address of
|
@param BaseAddress The physical address that is the start address of
|
||||||
a memory region.
|
a memory region.
|
||||||
@param Length The size in bytes of the memory region.
|
@param Length The size in bytes of the memory region.
|
||||||
@param Attributes Pointer to attributes returned.
|
@param Attributes Pointer to attributes returned.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The attributes got for the memory region.
|
@retval EFI_SUCCESS The attributes got for the memory region.
|
||||||
@retval EFI_INVALID_PARAMETER Length is zero.
|
@retval EFI_INVALID_PARAMETER Length is zero.
|
||||||
Attributes is NULL.
|
Attributes is NULL.
|
||||||
@retval EFI_NO_MAPPING Attributes are not consistent cross the memory
|
@retval EFI_NO_MAPPING Attributes are not consistent cross the memory
|
||||||
region.
|
region.
|
||||||
@retval EFI_UNSUPPORTED The processor does not support one or more
|
@retval EFI_UNSUPPORTED The processor does not support one or more
|
||||||
bytes of the memory resource range specified
|
bytes of the memory resource range specified
|
||||||
by BaseAddress and Length.
|
by BaseAddress and Length.
|
||||||
The bit mask of attributes is not support for
|
The bit mask of attributes is not support for
|
||||||
the memory resource range specified by
|
the memory resource range specified by
|
||||||
BaseAddress and Length.
|
BaseAddress and Length.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *EDKII_SMM_GET_MEMORY_ATTRIBUTES)(
|
(EFIAPI *EDKII_SMM_GET_MEMORY_ATTRIBUTES)(
|
||||||
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
||||||
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
||||||
IN UINT64 Length,
|
IN UINT64 Length,
|
||||||
OUT UINT64 *Attributes
|
OUT UINT64 *Attributes
|
||||||
);
|
);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// SMM Memory Attribute Protocol provides services to retrieve or update
|
/// SMM Memory Attribute Protocol provides services to retrieve or update
|
||||||
/// attribute of memory in the EFI SMM environment.
|
/// attribute of memory in the EFI SMM environment.
|
||||||
///
|
///
|
||||||
struct _EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL {
|
struct _EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL {
|
||||||
EDKII_SMM_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;
|
EDKII_SMM_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;
|
||||||
EDKII_SMM_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;
|
EDKII_SMM_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;
|
||||||
EDKII_SMM_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;
|
EDKII_SMM_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EFI_GUID gEdkiiSmmMemoryAttributeProtocolGuid;
|
extern EFI_GUID gEdkiiSmmMemoryAttributeProtocolGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -559,9 +559,9 @@
|
||||||
## Include/Protocol/SmmEndofS3Resume.h
|
## Include/Protocol/SmmEndofS3Resume.h
|
||||||
gEdkiiSmmEndOfS3ResumeProtocolGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } }
|
gEdkiiSmmEndOfS3ResumeProtocolGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } }
|
||||||
|
|
||||||
## Include/Protocol/SmmMemoryAttribute.h
|
## Include/Protocol/SmmMemoryAttribute.h
|
||||||
gEdkiiSmmMemoryAttributeProtocolGuid = { 0x69b792ea, 0x39ce, 0x402d, { 0xa2, 0xa6, 0xf7, 0x21, 0xde, 0x35, 0x1d, 0xfe } }
|
gEdkiiSmmMemoryAttributeProtocolGuid = { 0x69b792ea, 0x39ce, 0x402d, { 0xa2, 0xa6, 0xf7, 0x21, 0xde, 0x35, 0x1d, 0xfe } }
|
||||||
|
|
||||||
#
|
#
|
||||||
# [Error.gEfiMdeModulePkgTokenSpaceGuid]
|
# [Error.gEfiMdeModulePkgTokenSpaceGuid]
|
||||||
# 0x80000001 | Invalid value provided.
|
# 0x80000001 | Invalid value provided.
|
||||||
|
@ -892,63 +892,63 @@
|
||||||
# @Prompt Init Value in Temp Stack
|
# @Prompt Init Value in Temp Stack
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack|0x5AA55AA5|UINT32|0x30001051
|
gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack|0x5AA55AA5|UINT32|0x30001051
|
||||||
|
|
||||||
## Indicates which type allocation need guard page.
|
## Indicates which type allocation need guard page.
|
||||||
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
|
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
|
||||||
# EfiReservedMemoryType 0x0000000000000001<BR>
|
# EfiReservedMemoryType 0x0000000000000001<BR>
|
||||||
# EfiLoaderCode 0x0000000000000002<BR>
|
# EfiLoaderCode 0x0000000000000002<BR>
|
||||||
# EfiLoaderData 0x0000000000000004<BR>
|
# EfiLoaderData 0x0000000000000004<BR>
|
||||||
# EfiBootServicesCode 0x0000000000000008<BR>
|
# EfiBootServicesCode 0x0000000000000008<BR>
|
||||||
# EfiBootServicesData 0x0000000000000010<BR>
|
# EfiBootServicesData 0x0000000000000010<BR>
|
||||||
# EfiRuntimeServicesCode 0x0000000000000020<BR>
|
# EfiRuntimeServicesCode 0x0000000000000020<BR>
|
||||||
# EfiRuntimeServicesData 0x0000000000000040<BR>
|
# EfiRuntimeServicesData 0x0000000000000040<BR>
|
||||||
# EfiConventionalMemory 0x0000000000000080<BR>
|
# EfiConventionalMemory 0x0000000000000080<BR>
|
||||||
# EfiUnusableMemory 0x0000000000000100<BR>
|
# EfiUnusableMemory 0x0000000000000100<BR>
|
||||||
# EfiACPIReclaimMemory 0x0000000000000200<BR>
|
# EfiACPIReclaimMemory 0x0000000000000200<BR>
|
||||||
# EfiACPIMemoryNVS 0x0000000000000400<BR>
|
# EfiACPIMemoryNVS 0x0000000000000400<BR>
|
||||||
# EfiMemoryMappedIO 0x0000000000000800<BR>
|
# EfiMemoryMappedIO 0x0000000000000800<BR>
|
||||||
# EfiMemoryMappedIOPortSpace 0x0000000000001000<BR>
|
# EfiMemoryMappedIOPortSpace 0x0000000000001000<BR>
|
||||||
# EfiPalCode 0x0000000000002000<BR>
|
# EfiPalCode 0x0000000000002000<BR>
|
||||||
# EfiPersistentMemory 0x0000000000004000<BR>
|
# EfiPersistentMemory 0x0000000000004000<BR>
|
||||||
# OEM Reserved 0x4000000000000000<BR>
|
# OEM Reserved 0x4000000000000000<BR>
|
||||||
# OS Reserved 0x8000000000000000<BR>
|
# OS Reserved 0x8000000000000000<BR>
|
||||||
# e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>
|
# e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>
|
||||||
# @Prompt The memory type mask for Page Guard.
|
# @Prompt The memory type mask for Page Guard.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType|0x0|UINT64|0x30001052
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPageType|0x0|UINT64|0x30001052
|
||||||
|
|
||||||
## Indicates which type allocation need guard page.
|
## Indicates which type allocation need guard page.
|
||||||
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
|
# Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>
|
||||||
# EfiReservedMemoryType 0x0000000000000001<BR>
|
# EfiReservedMemoryType 0x0000000000000001<BR>
|
||||||
# EfiLoaderCode 0x0000000000000002<BR>
|
# EfiLoaderCode 0x0000000000000002<BR>
|
||||||
# EfiLoaderData 0x0000000000000004<BR>
|
# EfiLoaderData 0x0000000000000004<BR>
|
||||||
# EfiBootServicesCode 0x0000000000000008<BR>
|
# EfiBootServicesCode 0x0000000000000008<BR>
|
||||||
# EfiBootServicesData 0x0000000000000010<BR>
|
# EfiBootServicesData 0x0000000000000010<BR>
|
||||||
# EfiRuntimeServicesCode 0x0000000000000020<BR>
|
# EfiRuntimeServicesCode 0x0000000000000020<BR>
|
||||||
# EfiRuntimeServicesData 0x0000000000000040<BR>
|
# EfiRuntimeServicesData 0x0000000000000040<BR>
|
||||||
# EfiConventionalMemory 0x0000000000000080<BR>
|
# EfiConventionalMemory 0x0000000000000080<BR>
|
||||||
# EfiUnusableMemory 0x0000000000000100<BR>
|
# EfiUnusableMemory 0x0000000000000100<BR>
|
||||||
# EfiACPIReclaimMemory 0x0000000000000200<BR>
|
# EfiACPIReclaimMemory 0x0000000000000200<BR>
|
||||||
# EfiACPIMemoryNVS 0x0000000000000400<BR>
|
# EfiACPIMemoryNVS 0x0000000000000400<BR>
|
||||||
# EfiMemoryMappedIO 0x0000000000000800<BR>
|
# EfiMemoryMappedIO 0x0000000000000800<BR>
|
||||||
# EfiMemoryMappedIOPortSpace 0x0000000000001000<BR>
|
# EfiMemoryMappedIOPortSpace 0x0000000000001000<BR>
|
||||||
# EfiPalCode 0x0000000000002000<BR>
|
# EfiPalCode 0x0000000000002000<BR>
|
||||||
# EfiPersistentMemory 0x0000000000004000<BR>
|
# EfiPersistentMemory 0x0000000000004000<BR>
|
||||||
# OEM Reserved 0x4000000000000000<BR>
|
# OEM Reserved 0x4000000000000000<BR>
|
||||||
# OS Reserved 0x8000000000000000<BR>
|
# OS Reserved 0x8000000000000000<BR>
|
||||||
# e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>
|
# e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>
|
||||||
# @Prompt The memory type mask for Pool Guard.
|
# @Prompt The memory type mask for Pool Guard.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType|0x0|UINT64|0x30001053
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPoolType|0x0|UINT64|0x30001053
|
||||||
|
|
||||||
## This mask is to control Heap Guard behavior.
|
## This mask is to control Heap Guard behavior.
|
||||||
# BIT0 - Enable UEFI page guard.<BR>
|
# BIT0 - Enable UEFI page guard.<BR>
|
||||||
# BIT1 - Enable UEFI pool guard.<BR>
|
# BIT1 - Enable UEFI pool guard.<BR>
|
||||||
# BIT2 - Enable SMM page guard.<BR>
|
# BIT2 - Enable SMM page guard.<BR>
|
||||||
# BIT3 - Enable SMM pool guard.<BR>
|
# BIT3 - Enable SMM pool guard.<BR>
|
||||||
# BIT7 - The direction of Guard Page for Pool Guard.
|
# BIT7 - The direction of Guard Page for Pool Guard.
|
||||||
# 0 - The returned pool is adjacent to the bottom guard page.<BR>
|
# 0 - The returned pool is adjacent to the bottom guard page.<BR>
|
||||||
# 1 - The returned pool is adjacent to the top guard page.<BR>
|
# 1 - The returned pool is adjacent to the top guard page.<BR>
|
||||||
# @Prompt The Heap Guard feature mask
|
# @Prompt The Heap Guard feature mask
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask|0x0|UINT8|0x30001054
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask|0x0|UINT8|0x30001054
|
||||||
|
|
||||||
[PcdsFixedAtBuild, PcdsPatchableInModule]
|
[PcdsFixedAtBuild, PcdsPatchableInModule]
|
||||||
## Dynamic type PCD can be registered callback function for Pcd setting action.
|
## Dynamic type PCD can be registered callback function for Pcd setting action.
|
||||||
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
|
# PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
|
||||||
|
|
|
@ -1146,61 +1146,61 @@
|
||||||
"SEC fills the full temp stack with this values. When switch stack, PeiCore can check\n"
|
"SEC fills the full temp stack with this values. When switch stack, PeiCore can check\n"
|
||||||
"this value in the temp stack to know how many stack has been used.\n"
|
"this value in the temp stack to know how many stack has been used.\n"
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPageType_PROMPT #language en-US "The memory type mask for Page Guard"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPageType_PROMPT #language en-US "The memory type mask for Page Guard"
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPageType_HELP #language en-US "Indicates which type allocation need guard page.\n"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPageType_HELP #language en-US "Indicates which type allocation need guard page.\n"
|
||||||
" Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>\n"
|
" Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>\n"
|
||||||
" EfiReservedMemoryType 0x0000000000000001\n"
|
" EfiReservedMemoryType 0x0000000000000001\n"
|
||||||
" EfiLoaderCode 0x0000000000000002\n"
|
" EfiLoaderCode 0x0000000000000002\n"
|
||||||
" EfiLoaderData 0x0000000000000004\n"
|
" EfiLoaderData 0x0000000000000004\n"
|
||||||
" EfiBootServicesCode 0x0000000000000008\n"
|
" EfiBootServicesCode 0x0000000000000008\n"
|
||||||
" EfiBootServicesData 0x0000000000000010\n"
|
" EfiBootServicesData 0x0000000000000010\n"
|
||||||
" EfiRuntimeServicesCode 0x0000000000000020\n"
|
" EfiRuntimeServicesCode 0x0000000000000020\n"
|
||||||
" EfiRuntimeServicesData 0x0000000000000040\n"
|
" EfiRuntimeServicesData 0x0000000000000040\n"
|
||||||
" EfiConventionalMemory 0x0000000000000080\n"
|
" EfiConventionalMemory 0x0000000000000080\n"
|
||||||
" EfiUnusableMemory 0x0000000000000100\n"
|
" EfiUnusableMemory 0x0000000000000100\n"
|
||||||
" EfiACPIReclaimMemory 0x0000000000000200\n"
|
" EfiACPIReclaimMemory 0x0000000000000200\n"
|
||||||
" EfiACPIMemoryNVS 0x0000000000000400\n"
|
" EfiACPIMemoryNVS 0x0000000000000400\n"
|
||||||
" EfiMemoryMappedIO 0x0000000000000800\n"
|
" EfiMemoryMappedIO 0x0000000000000800\n"
|
||||||
" EfiMemoryMappedIOPortSpace 0x0000000000001000\n"
|
" EfiMemoryMappedIOPortSpace 0x0000000000001000\n"
|
||||||
" EfiPalCode 0x0000000000002000\n"
|
" EfiPalCode 0x0000000000002000\n"
|
||||||
" EfiPersistentMemory 0x0000000000004000\n"
|
" EfiPersistentMemory 0x0000000000004000\n"
|
||||||
" OEM Reserved 0x4000000000000000\n"
|
" OEM Reserved 0x4000000000000000\n"
|
||||||
" OS Reserved 0x8000000000000000\n"
|
" OS Reserved 0x8000000000000000\n"
|
||||||
" e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>"
|
" e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>"
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPoolType_PROMPT #language en-US "The memory type mask for Pool Guard"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPoolType_PROMPT #language en-US "The memory type mask for Pool Guard"
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPoolType_HELP #language en-US "Indicates which type allocation need guard page.\n"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPoolType_HELP #language en-US "Indicates which type allocation need guard page.\n"
|
||||||
" Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>\n"
|
" Below is bit mask for this PCD: (Order is same as UEFI spec)<BR>\n"
|
||||||
" EfiReservedMemoryType 0x0000000000000001\n"
|
" EfiReservedMemoryType 0x0000000000000001\n"
|
||||||
" EfiLoaderCode 0x0000000000000002\n"
|
" EfiLoaderCode 0x0000000000000002\n"
|
||||||
" EfiLoaderData 0x0000000000000004\n"
|
" EfiLoaderData 0x0000000000000004\n"
|
||||||
" EfiBootServicesCode 0x0000000000000008\n"
|
" EfiBootServicesCode 0x0000000000000008\n"
|
||||||
" EfiBootServicesData 0x0000000000000010\n"
|
" EfiBootServicesData 0x0000000000000010\n"
|
||||||
" EfiRuntimeServicesCode 0x0000000000000020\n"
|
" EfiRuntimeServicesCode 0x0000000000000020\n"
|
||||||
" EfiRuntimeServicesData 0x0000000000000040\n"
|
" EfiRuntimeServicesData 0x0000000000000040\n"
|
||||||
" EfiConventionalMemory 0x0000000000000080\n"
|
" EfiConventionalMemory 0x0000000000000080\n"
|
||||||
" EfiUnusableMemory 0x0000000000000100\n"
|
" EfiUnusableMemory 0x0000000000000100\n"
|
||||||
" EfiACPIReclaimMemory 0x0000000000000200\n"
|
" EfiACPIReclaimMemory 0x0000000000000200\n"
|
||||||
" EfiACPIMemoryNVS 0x0000000000000400\n"
|
" EfiACPIMemoryNVS 0x0000000000000400\n"
|
||||||
" EfiMemoryMappedIO 0x0000000000000800\n"
|
" EfiMemoryMappedIO 0x0000000000000800\n"
|
||||||
" EfiMemoryMappedIOPortSpace 0x0000000000001000\n"
|
" EfiMemoryMappedIOPortSpace 0x0000000000001000\n"
|
||||||
" EfiPalCode 0x0000000000002000\n"
|
" EfiPalCode 0x0000000000002000\n"
|
||||||
" EfiPersistentMemory 0x0000000000004000\n"
|
" EfiPersistentMemory 0x0000000000004000\n"
|
||||||
" OEM Reserved 0x4000000000000000\n"
|
" OEM Reserved 0x4000000000000000\n"
|
||||||
" OS Reserved 0x8000000000000000\n"
|
" OS Reserved 0x8000000000000000\n"
|
||||||
" e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>"
|
" e.g. LoaderCode+LoaderData+BootServicesCode+BootServicesData are needed, 0x1E should be used.<BR>"
|
||||||
|
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPropertyMask_PROMPT #language en-US "The Heap Guard feature mask"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPropertyMask_PROMPT #language en-US "The Heap Guard feature mask"
|
||||||
|
|
||||||
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPropertyMask_HELP #language en-US "This mask is to control Heap Guard behavior.\n"
|
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdHeapGuardPropertyMask_HELP #language en-US "This mask is to control Heap Guard behavior.\n"
|
||||||
" BIT0 - Enable UEFI page guard.<BR>\n"
|
" BIT0 - Enable UEFI page guard.<BR>\n"
|
||||||
" BIT1 - Enable UEFI pool guard.<BR>\n"
|
" BIT1 - Enable UEFI pool guard.<BR>\n"
|
||||||
" BIT2 - Enable SMM page guard.<BR>\n"
|
" BIT2 - Enable SMM page guard.<BR>\n"
|
||||||
" BIT3 - Enable SMM pool guard.<BR>\n"
|
" BIT3 - Enable SMM pool guard.<BR>\n"
|
||||||
" BIT7 - The direction of Guard Page for Pool Guard.\n"
|
" BIT7 - The direction of Guard Page for Pool Guard.\n"
|
||||||
" 0 - The returned pool is adjacent to the bottom guard page.<BR>\n"
|
" 0 - The returned pool is adjacent to the bottom guard page.<BR>\n"
|
||||||
" 1 - The returned pool is adjacent to the top guard page.<BR>"
|
" 1 - The returned pool is adjacent to the top guard page.<BR>"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue