mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 01:07:57 +00:00
hv: minimize the case of "identifier reuse"
Identifier reuse may arise confusion. So should minimize the case of it as much as possible. This patch is try to do this except the PCI related module. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
@@ -30,23 +30,23 @@ static inline uint64_t ppt_pgentry_present(uint64_t pte)
|
||||
|
||||
static inline struct page *ppt_get_pml4_page(const union pgtable_pages_info *info)
|
||||
{
|
||||
struct page *page = info->ppt.pml4_base;
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
struct page *pml4_page = info->ppt.pml4_base;
|
||||
(void)memset(pml4_page, 0U, PAGE_SIZE);
|
||||
return pml4_page;
|
||||
}
|
||||
|
||||
static inline struct page *ppt_get_pdpt_page(const union pgtable_pages_info *info, uint64_t gpa)
|
||||
{
|
||||
struct page *page = info->ppt.pdpt_base + (gpa >> PML4E_SHIFT);
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
struct page *pdpt_page = info->ppt.pdpt_base + (gpa >> PML4E_SHIFT);
|
||||
(void)memset(pdpt_page, 0U, PAGE_SIZE);
|
||||
return pdpt_page;
|
||||
}
|
||||
|
||||
static inline struct page *ppt_get_pd_page(const union pgtable_pages_info *info, uint64_t gpa)
|
||||
{
|
||||
struct page *page = info->ppt.pd_base + (gpa >> PDPTE_SHIFT);
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
struct page *pd_page = info->ppt.pd_base + (gpa >> PDPTE_SHIFT);
|
||||
(void)memset(pd_page, 0U, PAGE_SIZE);
|
||||
return pd_page;
|
||||
}
|
||||
|
||||
const struct memory_ops ppt_mem_ops = {
|
||||
@@ -103,43 +103,43 @@ static inline uint64_t ept_pgentry_present(uint64_t pte)
|
||||
|
||||
static inline struct page *ept_get_pml4_page(const union pgtable_pages_info *info)
|
||||
{
|
||||
struct page *page = info->ept.nworld_pml4_base;
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
struct page *pml4_page = info->ept.nworld_pml4_base;
|
||||
(void)memset(pml4_page, 0U, PAGE_SIZE);
|
||||
return pml4_page;
|
||||
}
|
||||
|
||||
static inline struct page *ept_get_pdpt_page(const union pgtable_pages_info *info, uint64_t gpa)
|
||||
{
|
||||
struct page *page = info->ept.nworld_pdpt_base + (gpa >> PML4E_SHIFT);
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
struct page *pdpt_page = info->ept.nworld_pdpt_base + (gpa >> PML4E_SHIFT);
|
||||
(void)memset(pdpt_page, 0U, PAGE_SIZE);
|
||||
return pdpt_page;
|
||||
}
|
||||
|
||||
static inline struct page *ept_get_pd_page(const union pgtable_pages_info *info, uint64_t gpa)
|
||||
{
|
||||
struct page *page;
|
||||
struct page *pd_page;
|
||||
if (gpa < TRUSTY_EPT_REBASE_GPA) {
|
||||
page = info->ept.nworld_pd_base + (gpa >> PDPTE_SHIFT);
|
||||
pd_page = info->ept.nworld_pd_base + (gpa >> PDPTE_SHIFT);
|
||||
} else {
|
||||
page = info->ept.sworld_pgtable_base + TRUSTY_PML4_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) +
|
||||
pd_page = info->ept.sworld_pgtable_base + TRUSTY_PML4_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) +
|
||||
TRUSTY_PDPT_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) + ((gpa - TRUSTY_EPT_REBASE_GPA) >> PDPTE_SHIFT);
|
||||
}
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
(void)memset(pd_page, 0U, PAGE_SIZE);
|
||||
return pd_page;
|
||||
}
|
||||
|
||||
static inline struct page *ept_get_pt_page(const union pgtable_pages_info *info, uint64_t gpa)
|
||||
{
|
||||
struct page *page;
|
||||
struct page *pt_page;
|
||||
if (gpa < TRUSTY_EPT_REBASE_GPA) {
|
||||
page = info->ept.nworld_pt_base + (gpa >> PDE_SHIFT);
|
||||
pt_page = info->ept.nworld_pt_base + (gpa >> PDE_SHIFT);
|
||||
} else {
|
||||
page = info->ept.sworld_pgtable_base + TRUSTY_PML4_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) +
|
||||
pt_page = info->ept.sworld_pgtable_base + TRUSTY_PML4_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) +
|
||||
TRUSTY_PDPT_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) + TRUSTY_PD_PAGE_NUM(TRUSTY_EPT_REBASE_GPA) +
|
||||
((gpa - TRUSTY_EPT_REBASE_GPA) >> PDE_SHIFT);
|
||||
}
|
||||
(void)memset(page, 0U, PAGE_SIZE);
|
||||
return page;
|
||||
(void)memset(pt_page, 0U, PAGE_SIZE);
|
||||
return pt_page;
|
||||
}
|
||||
|
||||
static inline void *ept_get_sworld_memory_base(const union pgtable_pages_info *info)
|
||||
|
@@ -829,7 +829,7 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8
|
||||
struct dmar_drhd_rt *dmar_unit;
|
||||
struct dmar_root_entry *root_table;
|
||||
uint64_t context_table_addr;
|
||||
struct dmar_context_entry *context_table;
|
||||
struct dmar_context_entry *context;
|
||||
struct dmar_root_entry *root_entry;
|
||||
struct dmar_context_entry *context_entry;
|
||||
uint64_t upper;
|
||||
@@ -888,8 +888,8 @@ static int add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8
|
||||
|
||||
context_table_addr = context_table_addr << PAGE_SHIFT;
|
||||
|
||||
context_table = (struct dmar_context_entry *)hpa2hva(context_table_addr);
|
||||
context_entry = context_table + devfun;
|
||||
context = (struct dmar_context_entry *)hpa2hva(context_table_addr);
|
||||
context_entry = context + devfun;
|
||||
|
||||
/* the context entry should not be present */
|
||||
if (dmar_get_bitslice(context_entry->lower, CTX_ENTRY_LOWER_P_MASK, CTX_ENTRY_LOWER_P_POS) != 0UL) {
|
||||
@@ -942,7 +942,7 @@ static int remove_iommu_device(const struct iommu_domain *domain, uint16_t segme
|
||||
struct dmar_drhd_rt *dmar_unit;
|
||||
struct dmar_root_entry *root_table;
|
||||
uint64_t context_table_addr;
|
||||
struct dmar_context_entry *context_table;
|
||||
struct dmar_context_entry *context;
|
||||
struct dmar_root_entry *root_entry;
|
||||
struct dmar_context_entry *context_entry;
|
||||
uint16_t dom_id;
|
||||
@@ -958,9 +958,9 @@ static int remove_iommu_device(const struct iommu_domain *domain, uint16_t segme
|
||||
|
||||
context_table_addr = dmar_get_bitslice(root_entry->lower, ROOT_ENTRY_LOWER_CTP_MASK, ROOT_ENTRY_LOWER_CTP_POS);
|
||||
context_table_addr = context_table_addr << PAGE_SHIFT;
|
||||
context_table = (struct dmar_context_entry *)hpa2hva(context_table_addr);
|
||||
context = (struct dmar_context_entry *)hpa2hva(context_table_addr);
|
||||
|
||||
context_entry = context_table + devfun;
|
||||
context_entry = context + devfun;
|
||||
|
||||
dom_id = (uint16_t)dmar_get_bitslice(context_entry->upper, CTX_ENTRY_UPPER_DID_MASK, CTX_ENTRY_UPPER_DID_POS);
|
||||
if (dom_id != vmid_to_domainid(domain->vm_id)) {
|
||||
|
Reference in New Issue
Block a user