TianoCore EDK2 master
|
#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) |
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.
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.
[in] | Attribute | The attribute of the linear address range. |
[in] | Mask | The mask used for attribute to check. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 0 but some other attributes are provided. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided. |
RETURN_SUCCESS | The combination for Attribute and Mask is valid. |
Definition at line 251 of file CpuPageTableMap.c.
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.
[in] | ParentPagingEntry | The pointer to the page table entry to update. |
[in] | ParentAttribute | The accumulated attribute of all parents' attribute. |
[in] | Modify | FALSE to indicate Buffer is not used and BufferSize is increased by the required buffer size. |
[in] | Buffer | The 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] | BufferSize | The available buffer size. Return the remaining buffer size. |
[in] | Level | Page table level. Could be 5, 4, 3, 2, or 1. |
[in] | MaxLeafLevel | Maximum level that can be a leaf entry. Could be 1, 2 or 3 (if Page 1G is supported). |
[in] | LinearAddress | The start of the linear address range. |
[in] | Length | The length of the linear address range. |
[in] | Offset | The offset within the linear address range. |
[in] | Attribute | The 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] | Mask | The mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0. |
[in,out] | IsModified | Change IsModified to True if page table is modified and input parameter Modify is TRUE. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 0 but some other attributes are provided. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided. |
RETURN_SUCCESS | PageTable is created/updated successfully. |
Definition at line 304 of file CpuPageTableMap.c.
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.
[in] | Level | 3, 2 or 1. |
[in] | Ple | Pointer to PDPTE_1G, PDE_2M or IA32_PTE_4K, depending on the Level. |
[in] | Offset | The offset within the linear address range. |
[in] | Attribute | The 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] | Mask | The 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.
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.
[in] | PleB | Pointer to PDPTE_1G or PDE_2M. Both share the same structure definition. |
[in] | Offset | The offset within the linear address range. |
[in] | Attribute | The 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] | Mask | The 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.
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.
[in] | Pnle | Pointer to IA32_PML5, IA32_PML4, IA32_PDPTE or IA32_PDE. All share the same structure definition. |
[in] | Attribute | The attribute of the page directory referenced by the non-leaf. |
[in] | Mask | The mask of the page directory referenced by the non-leaf. |
Definition at line 197 of file CpuPageTableMap.c.
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.
[in] | Pte4K | Pointer to IA32_PTE_4K. |
[in] | Offset | The offset within the linear address range. |
[in] | Attribute | The 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] | Mask | The 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.
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.
[in,out] | PageTable | The 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] | PagingMode | The paging mode. |
[in] | Buffer | The free buffer to be used for page table creation/updating. |
[in,out] | BufferSize | The 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] | LinearAddress | The start of the linear address range. |
[in] | Length | The length of the linear address range. |
[in] | Attribute | The 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] | Mask | The mask used for attribute. The corresponding field in Attribute is ignored if that in Mask is 0. |
[out] | IsModified | TRUE 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_UNSUPPORTED | PagingMode is not supported. |
RETURN_INVALID_PARAMETER | PageTable, BufferSize, Attribute or Mask is NULL. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 0 but some other attributes are provided. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 1 but some other attributes are not provided. |
RETURN_INVALID_PARAMETER | For non-present range, Mask->Bits.Present is 1, Attribute->Bits.Present is 0 but some other attributes are provided. |
RETURN_INVALID_PARAMETER | For 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_SMALL | The 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_SUCCESS | PageTable is created/updated successfully or the input Length is 0. |
Definition at line 686 of file CpuPageTableMap.c.