TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuPageTableMap.c File Reference
#include "CpuPageTable.h"

Go to the source code of this file.

Functions

VOID PageTableLibSetPte4K (IN OUT volatile IA32_PTE_4K *Pte4K, IN UINT64 Offset, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask)
 
VOID PageTableLibSetPleB (IN OUT volatile IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE *PleB, IN UINT64 Offset, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask)
 
VOID PageTableLibSetPle (IN UINTN Level, IN OUT volatile IA32_PAGING_ENTRY *Ple, IN UINT64 Offset, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask)
 
VOID PageTableLibSetPnle (IN OUT volatile IA32_PAGE_NON_LEAF_ENTRY *Pnle, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask)
 
RETURN_STATUS IsAttributesAndMaskValidForNonPresentEntry (IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask)
 
RETURN_STATUS PageTableLibMapInLevel (IN IA32_PAGING_ENTRY *ParentPagingEntry, IN IA32_MAP_ATTRIBUTE *ParentAttribute, IN BOOLEAN Modify, IN VOID *Buffer, IN OUT INTN *BufferSize, IN IA32_PAGE_LEVEL Level, IN IA32_PAGE_LEVEL MaxLeafLevel, IN UINT64 LinearAddress, IN UINT64 Length, IN UINT64 Offset, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, IN OUT BOOLEAN *IsModified)
 
RETURN_STATUS EFIAPI PageTableMap (IN OUT UINTN *PageTable OPTIONAL, IN PAGING_MODE PagingMode, IN VOID *Buffer, IN OUT UINTN *BufferSize, IN UINT64 LinearAddress, IN UINT64 Length, IN IA32_MAP_ATTRIBUTE *Attribute, IN IA32_MAP_ATTRIBUTE *Mask, OUT BOOLEAN *IsModified OPTIONAL)
 

Detailed Description

This library implements CpuPageTableLib that are generic for IA32 family CPU.

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

Definition in file CpuPageTableMap.c.

Function Documentation

◆ IsAttributesAndMaskValidForNonPresentEntry()

RETURN_STATUS IsAttributesAndMaskValidForNonPresentEntry ( IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask 
)

Check if the combination for Attribute and Mask is valid for non-present entry. 1.Mask.Present is 0 but some other attributes is provided. This case should be invalid. 2.Map non-present range to present. In this case, all attributes should be provided.

Parameters
[in]AttributeThe attribute of the linear address range.
[in]MaskThe mask used for attribute to check.
Return values
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided.
RETURN_SUCCESSThe combination for Attribute and Mask is valid.

Definition at line 251 of file CpuPageTableMap.c.

◆ PageTableLibMapInLevel()

RETURN_STATUS PageTableLibMapInLevel ( IN IA32_PAGING_ENTRY ParentPagingEntry,
IN IA32_MAP_ATTRIBUTE ParentAttribute,
IN BOOLEAN  Modify,
IN VOID *  Buffer,
IN OUT INTN BufferSize,
IN IA32_PAGE_LEVEL  Level,
IN IA32_PAGE_LEVEL  MaxLeafLevel,
IN UINT64  LinearAddress,
IN UINT64  Length,
IN UINT64  Offset,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask,
IN OUT BOOLEAN *  IsModified 
)

Update page table to map [LinearAddress, LinearAddress + Length) with specified attribute in the specified level.

Parameters
[in]ParentPagingEntryThe pointer to the page table entry to update.
[in]ParentAttributeThe accumulated attribute of all parents' attribute.
[in]ModifyFALSE to indicate Buffer is not used and BufferSize is increased by the required buffer size.
[in]BufferThe free buffer to be used for page table creation/updating. When Modify is TRUE, it's used from the end. When Modify is FALSE, it's ignored.
[in,out]BufferSizeThe available buffer size. Return the remaining buffer size.
[in]LevelPage table level. Could be 5, 4, 3, 2, or 1.
[in]MaxLeafLevelMaximum level that can be a leaf entry. Could be 1, 2 or 3 (if Page 1G is supported).
[in]LinearAddressThe start of the linear address range.
[in]LengthThe length of the linear address range.
[in]OffsetThe offset within the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entries that map the linear address range are reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.
[in,out]IsModifiedChange IsModified to True if page table is modified and input parameter Modify is TRUE.
Return values
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided.
RETURN_SUCCESSPageTable is created/updated successfully.

Definition at line 304 of file CpuPageTableMap.c.

◆ PageTableLibSetPle()

VOID PageTableLibSetPle ( IN UINTN  Level,
IN OUT volatile IA32_PAGING_ENTRY Ple,
IN UINT64  Offset,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask 
)

Set the IA32_PDPTE_1G, IA32_PDE_2M or IA32_PTE_4K.

Parameters
[in]Level3, 2 or 1.
[in]PlePointer to PDPTE_1G, PDE_2M or IA32_PTE_4K, depending on the Level.
[in]OffsetThe offset within the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entry is reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.

Definition at line 173 of file CpuPageTableMap.c.

◆ PageTableLibSetPleB()

VOID PageTableLibSetPleB ( IN OUT volatile IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE PleB,
IN UINT64  Offset,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask 
)

Set the IA32_PDPTE_1G or IA32_PDE_2M.

Parameters
[in]PleBPointer to PDPTE_1G or PDE_2M. Both share the same structure definition.
[in]OffsetThe offset within the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entry is reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.

Definition at line 96 of file CpuPageTableMap.c.

◆ PageTableLibSetPnle()

VOID PageTableLibSetPnle ( IN OUT volatile IA32_PAGE_NON_LEAF_ENTRY Pnle,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask 
)

Set the IA32_PML5, IA32_PML4, IA32_PDPTE or IA32_PDE.

Parameters
[in]PnlePointer to IA32_PML5, IA32_PML4, IA32_PDPTE or IA32_PDE. All share the same structure definition.
[in]AttributeThe attribute of the page directory referenced by the non-leaf.
[in]MaskThe mask of the page directory referenced by the non-leaf.

Definition at line 197 of file CpuPageTableMap.c.

◆ PageTableLibSetPte4K()

VOID PageTableLibSetPte4K ( IN OUT volatile IA32_PTE_4K Pte4K,
IN UINT64  Offset,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask 
)

Set the IA32_PTE_4K.

Parameters
[in]Pte4KPointer to IA32_PTE_4K.
[in]OffsetThe offset within the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entry is reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.

Definition at line 22 of file CpuPageTableMap.c.

◆ PageTableMap()

RETURN_STATUS EFIAPI PageTableMap ( IN OUT UINTN *PageTable  OPTIONAL,
IN PAGING_MODE  PagingMode,
IN VOID *  Buffer,
IN OUT UINTN BufferSize,
IN UINT64  LinearAddress,
IN UINT64  Length,
IN IA32_MAP_ATTRIBUTE Attribute,
IN IA32_MAP_ATTRIBUTE Mask,
OUT BOOLEAN *IsModified  OPTIONAL 
)

Create or update page table to map [LinearAddress, LinearAddress + Length) with specified attribute.

Parameters
[in,out]PageTableThe pointer to the page table to update, or pointer to NULL if a new page table is to be created. If not pointer to NULL, the value it points to won't be changed in this function.
[in]PagingModeThe paging mode.
[in]BufferThe free buffer to be used for page table creation/updating.
[in,out]BufferSizeThe buffer size. On return, the remaining buffer size. The free buffer is used from the end so caller can supply the same Buffer pointer with an updated BufferSize in the second call to this API.
[in]LinearAddressThe start of the linear address range.
[in]LengthThe length of the linear address range.
[in]AttributeThe attribute of the linear address range. All non-reserved fields in IA32_MAP_ATTRIBUTE are supported to set in the page table. Page table entries that map the linear address range are reset to 0 before set to the new attribute when a new physical base address is set.
[in]MaskThe mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0.
[out]IsModifiedTRUE means page table is modified by software or hardware. FALSE means page table is not modified by software. If the output IsModified is FALSE, there is possibility that the page table is changed by hardware. It is ok because page table can be changed by hardware anytime, and caller don't need to Flush TLB.
Return values
RETURN_UNSUPPORTEDPagingMode is not supported.
RETURN_INVALID_PARAMETERPageTable, BufferSize, Attribute or Mask is NULL.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided.
RETURN_INVALID_PARAMETERFor non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETERFor present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 0 but some other attributes are provided.
RETURN_INVALID_PARAMETER*BufferSize is not multiple of 4KB.
RETURN_BUFFER_TOO_SMALLThe buffer is too small for page table creation/updating. BufferSize is updated to indicate the expected buffer size. Caller may still get RETURN_BUFFER_TOO_SMALL with the new BufferSize.
RETURN_SUCCESSPageTable is created/updated successfully or the input Length is 0.

Definition at line 686 of file CpuPageTableMap.c.