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

Go to the source code of this file.

Data Structures

struct  IMAGE_PROPERTIES_PRIVATE_DATA
 

Macros

#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size)    ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
 
#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('I','P','P','D')
 
#define EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA   BIT0
 

Functions

STATIC VOID MergeMemoryMap (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN OUT UINTN *MemoryMapSize, IN UINTN DescriptorSize)
 
STATIC VOID EnforceMemoryMapAttribute (IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, IN UINTN MemoryMapSize, IN UINTN DescriptorSize)
 
STATIC EFI_STATUS EFIAPI SmmCoreGetMemoryMapMemoryAttributesTable (IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
 
VOID SmmInsertImageRecord (IN EFI_SMM_DRIVER_ENTRY *DriverEntry)
 
VOID PublishMemoryAttributesTable (VOID)
 
VOID SmmInstallImageRecord (VOID)
 
EFI_STATUS EFIAPI SmmInstallMemoryAttributesTable (IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
 
VOID EFIAPI SmmCoreInitializeMemoryAttributesTable (VOID)
 

Variables

IMAGE_PROPERTIES_PRIVATE_DATA mImagePropertiesPrivateData
 
UINT64 mMemoryProtectionAttribute = EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA
 

Detailed Description

PI SMM MemoryAttributes support

Copyright (c) 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file MemoryAttributesTable.c.

Macro Definition Documentation

◆ EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA

#define EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA   BIT0

Definition at line 45 of file MemoryAttributesTable.c.

◆ IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE

#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('I','P','P','D')

Definition at line 29 of file MemoryAttributesTable.c.

◆ PREVIOUS_MEMORY_DESCRIPTOR

#define PREVIOUS_MEMORY_DESCRIPTOR (   MemoryDescriptor,
  Size 
)     ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))

Definition at line 26 of file MemoryAttributesTable.c.

Function Documentation

◆ EnforceMemoryMapAttribute()

STATIC VOID EnforceMemoryMapAttribute ( IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
IN UINTN  MemoryMapSize,
IN UINTN  DescriptorSize 
)

Enforce memory map attributes. This function will set EfiRuntimeServicesData/EfiMemoryMappedIO/EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.

Parameters
[in,out]MemoryMapA pointer to the buffer in which firmware places the current memory map.
[in]MemoryMapSizeSize, in bytes, of the MemoryMap buffer.
[in]DescriptorSizeSize, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.

Definition at line 125 of file MemoryAttributesTable.c.

◆ MergeMemoryMap()

STATIC VOID MergeMemoryMap ( IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
IN OUT UINTN *  MemoryMapSize,
IN UINTN  DescriptorSize 
)

Merge continuous memory map entries whose have same attributes.

Parameters
[in,out]MemoryMapA pointer to the buffer in which firmware places the current memory map.
[in,out]MemoryMapSizeA pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the current memory map. On output, it is the size of new memory map after merge.
[in]DescriptorSizeSize, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.

Definition at line 66 of file MemoryAttributesTable.c.

◆ PublishMemoryAttributesTable()

VOID PublishMemoryAttributesTable ( VOID  )

Publish MemoryAttributesTable to SMM configuration table.

Definition at line 343 of file MemoryAttributesTable.c.

◆ SmmCoreGetMemoryMapMemoryAttributesTable()

STATIC EFI_STATUS EFIAPI SmmCoreGetMemoryMapMemoryAttributesTable ( IN OUT UINTN *  MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *  MemoryMap,
OUT UINTN *  MapKey,
OUT UINTN *  DescriptorSize,
OUT UINT32 *  DescriptorVersion 
)

This function for GetMemoryMap() with memory attributes table.

It calls original GetMemoryMap() to get the original memory map information. Then plus the additional memory map entries for PE Code/Data separation.

Parameters
[in,out]MemoryMapSizeA pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the buffer allocated by the caller. On output, it is the size of the buffer returned by the firmware if the buffer was large enough, or the size of the buffer needed to contain the map if the buffer was too small.
[in,out]MemoryMapA pointer to the buffer in which firmware places the current memory map.
[out]MapKeyA pointer to the location in which firmware returns the key for the current memory map.
[out]DescriptorSizeA pointer to the location in which firmware returns the size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
[out]DescriptorVersionA pointer to the location in which firmware returns the version number associated with the EFI_MEMORY_DESCRIPTOR.
Return values
EFI_SUCCESSThe memory map was returned in the MemoryMap buffer.
EFI_BUFFER_TOO_SMALLThe MemoryMap buffer was too small. The current buffer size needed to hold the memory map is returned in MemoryMapSize.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.

Definition at line 192 of file MemoryAttributesTable.c.

◆ SmmCoreInitializeMemoryAttributesTable()

VOID EFIAPI SmmCoreInitializeMemoryAttributesTable ( VOID  )

Initialize MemoryAttributesTable support.

Definition at line 520 of file MemoryAttributesTable.c.

◆ SmmInsertImageRecord()

VOID SmmInsertImageRecord ( IN EFI_SMM_DRIVER_ENTRY *  DriverEntry)

Insert image record.

Parameters
[in]DriverEntryDriver information

Definition at line 260 of file MemoryAttributesTable.c.

◆ SmmInstallImageRecord()

VOID SmmInstallImageRecord ( VOID  )

This function installs all SMM image record information.

Definition at line 425 of file MemoryAttributesTable.c.

◆ SmmInstallMemoryAttributesTable()

EFI_STATUS EFIAPI SmmInstallMemoryAttributesTable ( IN CONST EFI_GUID *  Protocol,
IN VOID *  Interface,
IN EFI_HANDLE  Handle 
)

Install MemoryAttributesTable.

Parameters
[in]ProtocolPoints to the protocol's unique identifier.
[in]InterfacePoints to the interface instance.
[in]HandleThe handle on which the interface was installed.
Return values
EFI_SUCCESSNotification runs successfully.

Definition at line 488 of file MemoryAttributesTable.c.

Variable Documentation

◆ mImagePropertiesPrivateData

IMAGE_PROPERTIES_PRIVATE_DATA mImagePropertiesPrivateData
Initial value:
= {
IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE,
0,
0,
}

Definition at line 38 of file MemoryAttributesTable.c.

◆ mMemoryProtectionAttribute

UINT64 mMemoryProtectionAttribute = EFI_MEMORY_ATTRIBUTES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA

Definition at line 47 of file MemoryAttributesTable.c.