TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuPaging.c File Reference

Go to the source code of this file.

Macros

#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull
 

Functions

BOOLEAN IsIa32PaeSupported (VOID)
 
VOID * AllocatePageTableMemory (IN UINTN Pages)
 
RETURN_STATUS ConvertMemoryPageToNotPresent (IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
 
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

EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList []
 

Detailed Description

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.

Macro Definition Documentation

◆ PAGING_4K_ADDRESS_MASK_64

#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull

Definition at line 18 of file CpuPaging.c.

Function Documentation

◆ AllocatePageTableMemory()

VOID * AllocatePageTableMemory ( IN UINTN  Pages)

This API provides a way to allocate memory for page table.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 63 of file CpuPaging.c.

◆ ConvertMemoryPageToNotPresent()

RETURN_STATUS ConvertMemoryPageToNotPresent ( IN PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length 
)

This function modifies the page attributes for the memory region specified by BaseAddress and Length to not present. This function only change page table, but not flush TLB. Caller have the responsbility to flush TLB.

Caller should make sure BaseAddress and Length is at page boundary.

Parameters
[in]BaseAddressStart address of a memory region.
[in]LengthSize in bytes of the memory region.
Return values
RETURN_SUCCESSThe memory region is changed to not present.
RETURN_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes.
RETURN_UNSUPPORTEDCannot modify the attributes of given memory.

Definition at line 94 of file CpuPaging.c.

◆ EnablePaePageTable()

EFI_STATUS EnablePaePageTable ( VOID  )

Enable PAE Page Table.

Return values
EFI_SUCCESSThe PAE Page Table was enabled successfully.
EFI_OUT_OF_RESOURCESThe PAE Page Table could not be enabled due to lack of available memory.

Definition at line 182 of file CpuPaging.c.

◆ GetStackBase()

VOID EFIAPI GetStackBase ( IN OUT VOID *  Buffer)

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.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 265 of file CpuPaging.c.

◆ IsIa32PaeSupported()

BOOLEAN IsIa32PaeSupported ( VOID  )

The function will check if IA32 PAE is supported.

Return values
TRUEIA32 PAE is supported.
FALSEIA32 PAE is not supported.

Definition at line 36 of file CpuPaging.c.

◆ MemoryDiscoveredPpiNotifyCallback()

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.

Parameters
[in]PeiServicesGeneral purpose services available to every PEIM.
[in]NotifyDescriptorThe notification structure this PEIM registered on install.
[in]PpiThe memory discovered PPI. Not used.
Return values
EFI_SUCCESSThe function completed successfully.
othersThere's error in MP initialization.

Definition at line 372 of file CpuPaging.c.

◆ SetupStackGuardPage()

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 287 of file CpuPaging.c.

Variable Documentation

◆ mPostMemNotifyList

EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList[]
Initial value:
= {
{
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMemoryDiscoveredPpiGuid,
}
}
EFI_STATUS EFIAPI MemoryDiscoveredPpiNotifyCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: CpuPaging.c:372

Definition at line 20 of file CpuPaging.c.