mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-17 15:44:32 +00:00
Add arch_hva2hpa_early/arch_hpa2hva_early to common, and wrap it in hva2hpa_early/hpa2hva_early. Tracked-On: #8831 Signed-off-by: hangliu1 <hang1.liu@intel.com> Reviewed-by: Liu, Yifan1 <yifan1.liu@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
154 lines
2.9 KiB
C
154 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2018-2024 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
#ifndef PGTABLE_H
|
|
#define PGTABLE_H
|
|
|
|
#include <asm/page.h>
|
|
|
|
/**
|
|
* @addtogroup hwmgmt_page
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* @brief All APIs to support page table management
|
|
*
|
|
* This file defines macros, structures, declarations and functions related for managing page tables.
|
|
*
|
|
*/
|
|
|
|
#define PAGE_PRESENT (1UL << 0U)
|
|
#define PAGE_RW (1UL << 1U)
|
|
#define PAGE_USER (1UL << 2U)
|
|
#define PAGE_PWT (1UL << 3U)
|
|
#define PAGE_PCD (1UL << 4U)
|
|
#define PAGE_ACCESSED (1UL << 5U)
|
|
#define PAGE_DIRTY (1UL << 6U)
|
|
#define PAGE_PSE (1UL << 7U)
|
|
#define PAGE_GLOBAL (1UL << 8U)
|
|
#define PAGE_PAT_LARGE (1UL << 12U)
|
|
#define PAGE_NX (1UL << 63U)
|
|
|
|
#define PAGE_CACHE_MASK (PAGE_PCD | PAGE_PWT)
|
|
#define PAGE_CACHE_WB 0UL
|
|
#define PAGE_CACHE_WT PAGE_PWT
|
|
#define PAGE_CACHE_UC_MINUS PAGE_PCD
|
|
#define PAGE_CACHE_UC (PAGE_PCD | PAGE_PWT)
|
|
|
|
#define PAGE_ATTR_USER (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_NX)
|
|
|
|
/**
|
|
* @defgroup ept_mem_access_right EPT Memory Access Right
|
|
*
|
|
* This is a group that includes EPT Memory Access Right Definitions.
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @brief EPT memory access right is read-only.
|
|
*/
|
|
#define EPT_RD (1UL << 0U)
|
|
|
|
/**
|
|
* @brief EPT memory access right is read/write.
|
|
*/
|
|
#define EPT_WR (1UL << 1U)
|
|
|
|
/**
|
|
* @brief EPT memory access right is executable.
|
|
*/
|
|
#define EPT_EXE (1UL << 2U)
|
|
|
|
/**
|
|
* @brief EPT memory access right is read/write and executable.
|
|
*/
|
|
#define EPT_RWX (EPT_RD | EPT_WR | EPT_EXE)
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
/* End of ept_mem_access_right */
|
|
|
|
/**
|
|
* @defgroup ept_mem_type EPT Memory Type
|
|
*
|
|
* This is a group that includes EPT Memory Type Definitions.
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @brief EPT memory type is specified in bits 5:3 of the EPT paging-structure entry.
|
|
*/
|
|
#define EPT_MT_SHIFT 3U
|
|
|
|
/**
|
|
* @brief EPT memory type is uncacheable.
|
|
*/
|
|
#define EPT_UNCACHED (0UL << EPT_MT_SHIFT)
|
|
|
|
/**
|
|
* @brief EPT memory type is write combining.
|
|
*/
|
|
#define EPT_WC (1UL << EPT_MT_SHIFT)
|
|
|
|
/**
|
|
* @brief EPT memory type is write through.
|
|
*/
|
|
#define EPT_WT (4UL << EPT_MT_SHIFT)
|
|
|
|
/**
|
|
* @brief EPT memory type is write protected.
|
|
*/
|
|
#define EPT_WP (5UL << EPT_MT_SHIFT)
|
|
|
|
/**
|
|
* @brief EPT memory type is write back.
|
|
*/
|
|
#define EPT_WB (6UL << EPT_MT_SHIFT)
|
|
|
|
/**
|
|
* @brief Ignore PAT memory type.
|
|
*/
|
|
#define EPT_IGNORE_PAT (1UL << 6U)
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
/* End of ept_mem_type */
|
|
|
|
#define EPT_MT_MASK (7UL << EPT_MT_SHIFT)
|
|
#define EPT_VE (1UL << 63U)
|
|
/* EPT leaf entry bits (bit 52 - bit 63) should be maksed when calculate PFN */
|
|
#define EPT_PFN_HIGH_MASK 0xFFF0000000000000UL
|
|
|
|
#define PML4E_SHIFT 39U
|
|
#define PTRS_PER_PML4E 512UL
|
|
|
|
#define PDPTE_SHIFT 30U
|
|
#define PTRS_PER_PDPTE 512UL
|
|
|
|
#define PDE_SHIFT 21U
|
|
#define PTRS_PER_PDE 512UL
|
|
|
|
#define PTE_SHIFT 12U
|
|
#define PTRS_PER_PTE 512UL
|
|
|
|
#define PFN_MASK 0x0000FFFFFFFFF000UL
|
|
|
|
#define EPT_ENTRY_PFN_MASK ((~EPT_PFN_HIGH_MASK) & PAGE_MASK)
|
|
|
|
#define HAS_EARLY_MAP
|
|
|
|
#endif /* PGTABLE_H */
|
|
|
|
/**
|
|
* @}
|
|
*/
|