TianoCore EDK2 master
|
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/Msr.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/CpuLib.h>
#include <Library/BaseLib.h>
#include <Guid/MigratedFvInfo.h>
#include "CpuMpPei.h"
Go to the source code of this file.
Data Structures | |
struct | PAGE_ATTRIBUTE_TABLE |
Macros | |
#define | IA32_PG_P BIT0 |
#define | IA32_PG_RW BIT1 |
#define | IA32_PG_U BIT2 |
#define | IA32_PG_A BIT5 |
#define | IA32_PG_D BIT6 |
#define | IA32_PG_PS BIT7 |
#define | IA32_PG_NX BIT63 |
#define | PAGE_ATTRIBUTE_BITS (IA32_PG_RW | IA32_PG_P) |
#define | PAGE_PROGATE_BITS |
#define | PAGING_PAE_INDEX_MASK 0x1FF |
#define | PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull |
#define | PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull |
#define | PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull |
#define | PAGING_512G_ADDRESS_MASK_64 0x000FFF8000000000ull |
Functions | |
BOOLEAN | IsIa32PaeSupported (VOID) |
VOID * | AllocatePageTableMemory (IN UINTN Pages) |
PAGE_ATTRIBUTE | GetPageTableTopLevelType (VOID) |
VOID * | GetPageTableEntry (IN PHYSICAL_ADDRESS Address, OUT PAGE_ATTRIBUTE *PageAttribute) |
RETURN_STATUS | SplitPage (IN UINT64 *PageEntry, IN PAGE_ATTRIBUTE PageAttribute, IN PAGE_ATTRIBUTE SplitAttribute, IN BOOLEAN Recursively) |
RETURN_STATUS EFIAPI | ConvertMemoryPageAttributes (IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes) |
EFI_STATUS | EnablePaePageTable (VOID) |
VOID EFIAPI | GetStackBase (IN OUT VOID *Buffer) |
VOID | SetupStackGuardPage (VOID) |
EFI_STATUS EFIAPI | MemoryDiscoveredPpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) |
Variables | |
PAGE_ATTRIBUTE_TABLE | mPageAttributeTable [] |
EFI_PEI_NOTIFY_DESCRIPTOR | mPostMemNotifyList [] |
Basic paging support for the CPU to enable Stack Guard.
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CpuPaging.c.
#define IA32_PG_A BIT5 |
Definition at line 22 of file CpuPaging.c.
#define IA32_PG_D BIT6 |
Definition at line 23 of file CpuPaging.c.
#define IA32_PG_NX BIT63 |
Definition at line 25 of file CpuPaging.c.
#define IA32_PG_P BIT0 |
Definition at line 19 of file CpuPaging.c.
#define IA32_PG_PS BIT7 |
Definition at line 24 of file CpuPaging.c.
#define IA32_PG_RW BIT1 |
Definition at line 20 of file CpuPaging.c.
#define IA32_PG_U BIT2 |
Definition at line 21 of file CpuPaging.c.
#define PAGE_ATTRIBUTE_BITS (IA32_PG_RW | IA32_PG_P) |
Definition at line 27 of file CpuPaging.c.
#define PAGE_PROGATE_BITS |
Definition at line 28 of file CpuPaging.c.
#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull |
Definition at line 34 of file CpuPaging.c.
#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull |
Definition at line 33 of file CpuPaging.c.
#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull |
Definition at line 32 of file CpuPaging.c.
#define PAGING_512G_ADDRESS_MASK_64 0x000FFF8000000000ull |
Definition at line 35 of file CpuPaging.c.
#define PAGING_PAE_INDEX_MASK 0x1FF |
Definition at line 31 of file CpuPaging.c.
enum PAGE_ATTRIBUTE |
Definition at line 37 of file CpuPaging.c.
This API provides a way to allocate memory for page table.
Pages | The number of 4 KB pages to allocate. |
Definition at line 106 of file CpuPaging.c.
RETURN_STATUS EFIAPI ConvertMemoryPageAttributes | ( | IN PHYSICAL_ADDRESS | BaseAddress, |
IN UINT64 | Length, | ||
IN UINT64 | Attributes | ||
) |
This function modifies the page attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.
Caller should make sure BaseAddress and Length is at page boundary.
[in] | BaseAddress | Start address of a memory region. |
[in] | Length | Size in bytes of the memory region. |
[in] | Attributes | Bit mask of attributes to modify. |
RETURN_SUCCESS | The attributes were modified for the memory region. |
RETURN_INVALID_PARAMETER | Length is zero; or, Attributes specified an illegal combination of attributes that cannot be set together; or Addressis not 4KB aligned. |
RETURN_OUT_OF_RESOURCES | There are not enough system resources to modify the attributes. |
RETURN_UNSUPPORTED | Cannot modify the attributes of given memory. |
Definition at line 283 of file CpuPaging.c.
EFI_STATUS EnablePaePageTable | ( | VOID | ) |
Enable PAE Page Table.
EFI_SUCCESS | The PAE Page Table was enabled successfully. |
EFI_OUT_OF_RESOURCES | The PAE Page Table could not be enabled due to lack of available memory. |
Definition at line 361 of file CpuPaging.c.
Return page table entry matching the address.
[in] | Address | The address to be checked. |
[out] | PageAttributes | The page attribute of the page entry. |
Definition at line 148 of file CpuPaging.c.
PAGE_ATTRIBUTE GetPageTableTopLevelType | ( | VOID | ) |
Get the type of top level page table.
Page512G | PML4 paging. |
Page1G | PAE paging. |
Definition at line 128 of file CpuPaging.c.
Get the base address of current AP's stack.
This function is called in AP's context and assumes that whole calling stacks (till this function) consumed by AP's wakeup procedure will not exceed 4KB.
PcdCpuApStackSize must be configured with value taking the Guard page into account.
[in,out] | Buffer | The pointer to private data buffer. |
Definition at line 444 of file CpuPaging.c.
BOOLEAN IsIa32PaeSupported | ( | VOID | ) |
The function will check if IA32 PAE is supported.
TRUE | IA32 PAE is supported. |
FALSE | IA32 PAE is not supported. |
Definition at line 79 of file CpuPaging.c.
EFI_STATUS EFIAPI MemoryDiscoveredPpiNotifyCallback | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_NOTIFY_DESCRIPTOR * | NotifyDescriptor, | ||
IN VOID * | Ppi | ||
) |
Enable/setup stack guard for each processor if PcdCpuStackGuard is set to TRUE.
Doing this in the memory-discovered callback is to make sure the Stack Guard feature to cover as most PEI code as possible.
[in] | PeiServices | General purpose services available to every PEIM. |
[in] | NotifyDescriptor | The notification structure this PEIM registered on install. |
[in] | Ppi | The memory discovered PPI. Not used. |
EFI_SUCCESS | The function completed successfully. |
others | There's error in MP initialization. |
Definition at line 549 of file CpuPaging.c.
VOID SetupStackGuardPage | ( | VOID | ) |
Setup stack Guard page at the stack base of each processor. BSP and APs have different way to get stack base address.
Definition at line 464 of file CpuPaging.c.
RETURN_STATUS SplitPage | ( | IN UINT64 * | PageEntry, |
IN PAGE_ATTRIBUTE | PageAttribute, | ||
IN PAGE_ATTRIBUTE | SplitAttribute, | ||
IN BOOLEAN | Recursively | ||
) |
This function splits one page entry to smaller page entries.
[in] | PageEntry | The page entry to be splitted. |
[in] | PageAttribute | The page attribute of the page entry. |
[in] | SplitAttribute | How to split the page entry. |
[in] | Recursively | Do the split recursively or not. |
RETURN_SUCCESS | The page entry is splitted. |
RETURN_INVALID_PARAMETER | If target page attribute is invalid |
RETURN_OUT_OF_RESOURCES | No resource to split page entry. |
Definition at line 205 of file CpuPaging.c.
PAGE_ATTRIBUTE_TABLE mPageAttributeTable[] |
Definition at line 55 of file CpuPaging.c.
EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList[] |
Definition at line 63 of file CpuPaging.c.