mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-17 07:40:14 +00:00
hv: trusty: move post_uos_sworld_memory into vm.c
post_uos_sworld_memory are used for post-launched VM which support trusty. It's more VM related. So move it definition into vm.c Tracked-On: #5830 Signed-off-by: Li Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
ddc017a691
commit
80bd3ac02a
@ -39,10 +39,18 @@
|
|||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
|
|
||||||
|
/* pre-assumption: TRUSTY_RAM_SIZE is 2M aligned */
|
||||||
|
static struct page post_uos_sworld_memory[MAX_POST_VM_NUM][TRUSTY_RAM_SIZE >> PAGE_SHIFT] __aligned(MEM_2M);
|
||||||
|
|
||||||
static struct acrn_vm vm_array[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE);
|
static struct acrn_vm vm_array[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE);
|
||||||
|
|
||||||
static struct acrn_vm *sos_vm_ptr = NULL;
|
static struct acrn_vm *sos_vm_ptr = NULL;
|
||||||
|
|
||||||
|
void *get_sworld_memory_base(void)
|
||||||
|
{
|
||||||
|
return post_uos_sworld_memory;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t get_vmid_by_uuid(const uint8_t *uuid)
|
uint16_t get_vmid_by_uuid(const uint8_t *uuid)
|
||||||
{
|
{
|
||||||
uint16_t vm_id = 0U;
|
uint16_t vm_id = 0U;
|
||||||
@ -511,8 +519,11 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v
|
|||||||
vm->sworld_control.flag.supported = 1U;
|
vm->sworld_control.flag.supported = 1U;
|
||||||
}
|
}
|
||||||
if (vm->sworld_control.flag.supported != 0UL) {
|
if (vm->sworld_control.flag.supported != 0UL) {
|
||||||
|
uint16_t sos_vm_id = (get_sos_vm())->vm_id;
|
||||||
|
uint16_t page_idx = vmid_2_rel_vmid(sos_vm_id, vm_id) - 1U;
|
||||||
|
|
||||||
ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
||||||
hva2hpa(vm->arch_vm.sworld_memory_base_hva),
|
hva2hpa(post_uos_sworld_memory[page_idx]),
|
||||||
TRUSTY_EPT_REBASE_GPA, TRUSTY_RAM_SIZE, EPT_WB | EPT_RWX);
|
TRUSTY_EPT_REBASE_GPA, TRUSTY_RAM_SIZE, EPT_WB | EPT_RWX);
|
||||||
}
|
}
|
||||||
if (vm_config->name[0] == '\0') {
|
if (vm_config->name[0] == '\0') {
|
||||||
|
@ -294,7 +294,7 @@ void init_paging(void)
|
|||||||
round_pde_up((uint64_t)&ld_text_end) - round_pde_down(hv_hva), 0UL,
|
round_pde_up((uint64_t)&ld_text_end) - round_pde_down(hv_hva), 0UL,
|
||||||
PAGE_NX, &ppt_pgtable, MR_MODIFY);
|
PAGE_NX, &ppt_pgtable, MR_MODIFY);
|
||||||
#if (SOS_VM_NUM == 1)
|
#if (SOS_VM_NUM == 1)
|
||||||
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_reserve_sworld_memory_base(),
|
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_sworld_memory_base(),
|
||||||
TRUSTY_RAM_SIZE * MAX_POST_VM_NUM, PAGE_USER, 0UL, &ppt_pgtable, MR_MODIFY);
|
TRUSTY_RAM_SIZE * MAX_POST_VM_NUM, PAGE_USER, 0UL, &ppt_pgtable, MR_MODIFY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -166,9 +166,6 @@ static struct page ept_dummy_pages[CONFIG_MAX_VM_NUM];
|
|||||||
/* ept: extended page pool*/
|
/* ept: extended page pool*/
|
||||||
static struct page_pool ept_page_pool[CONFIG_MAX_VM_NUM];
|
static struct page_pool ept_page_pool[CONFIG_MAX_VM_NUM];
|
||||||
|
|
||||||
/* pre-assumption: TRUSTY_RAM_SIZE is 2M aligned */
|
|
||||||
static struct page post_uos_sworld_memory[MAX_POST_VM_NUM][TRUSTY_RAM_SIZE >> PAGE_SHIFT] __aligned(MEM_2M);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -189,11 +186,6 @@ void reserve_buffer_for_ept_pages(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *get_reserve_sworld_memory_base(void)
|
|
||||||
{
|
|
||||||
return post_uos_sworld_memory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pages without execution right, such as MMIO, can always use large page
|
* Pages without execution right, such as MMIO, can always use large page
|
||||||
* base on hardware capability, even if the VM is an RTVM. This can save
|
* base on hardware capability, even if the VM is an RTVM. This can save
|
||||||
@ -247,13 +239,6 @@ void init_ept_pgtable(struct pgtable *table, uint16_t vm_id)
|
|||||||
memset((void *)ept_page_pool[vm_id].bitmap, 0, ept_page_pool[vm_id].bitmap_size * sizeof(uint64_t));
|
memset((void *)ept_page_pool[vm_id].bitmap, 0, ept_page_pool[vm_id].bitmap_size * sizeof(uint64_t));
|
||||||
ept_page_pool[vm_id].last_hint_id = 0UL;
|
ept_page_pool[vm_id].last_hint_id = 0UL;
|
||||||
|
|
||||||
if (is_postlaunched_vm(vm)) {
|
|
||||||
uint16_t sos_vm_id = (get_sos_vm())->vm_id;
|
|
||||||
uint16_t page_idx = vmid_2_rel_vmid(sos_vm_id, vm_id) - 1U;
|
|
||||||
|
|
||||||
vm->arch_vm.sworld_memory_base_hva = post_uos_sworld_memory[page_idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
table->pool = &ept_page_pool[vm_id];
|
table->pool = &ept_page_pool[vm_id];
|
||||||
table->default_access_right = EPT_RWX;
|
table->default_access_right = EPT_RWX;
|
||||||
table->pgentry_present = ept_pgentry_present;
|
table->pgentry_present = ept_pgentry_present;
|
||||||
|
@ -107,7 +107,6 @@ struct vm_arch {
|
|||||||
* but Normal World can not access Secure World's memory.
|
* but Normal World can not access Secure World's memory.
|
||||||
*/
|
*/
|
||||||
void *sworld_eptp;
|
void *sworld_eptp;
|
||||||
void *sworld_memory_base_hva;
|
|
||||||
struct pgtable ept_pgtable;
|
struct pgtable ept_pgtable;
|
||||||
|
|
||||||
struct acrn_vioapics vioapics; /* Virtual IOAPIC/s */
|
struct acrn_vioapics vioapics; /* Virtual IOAPIC/s */
|
||||||
@ -270,6 +269,8 @@ void get_vm_lock(struct acrn_vm *vm);
|
|||||||
* @pre vm != NULL
|
* @pre vm != NULL
|
||||||
*/
|
*/
|
||||||
void put_vm_lock(struct acrn_vm *vm);
|
void put_vm_lock(struct acrn_vm *vm);
|
||||||
|
|
||||||
|
void *get_sworld_memory_base(void);
|
||||||
#endif /* !ASSEMBLER */
|
#endif /* !ASSEMBLER */
|
||||||
|
|
||||||
#endif /* VM_H_ */
|
#endif /* VM_H_ */
|
||||||
|
@ -80,6 +80,5 @@ extern const struct pgtable ppt_pgtable;
|
|||||||
void init_ept_pgtable(struct pgtable *table, uint16_t vm_id);
|
void init_ept_pgtable(struct pgtable *table, uint16_t vm_id);
|
||||||
struct page *alloc_page(struct page_pool *pool);
|
struct page *alloc_page(struct page_pool *pool);
|
||||||
void free_page(struct page_pool *pool, struct page *page);
|
void free_page(struct page_pool *pool, struct page *page);
|
||||||
void *get_reserve_sworld_memory_base(void);
|
|
||||||
void reserve_buffer_for_ept_pages(void);
|
void reserve_buffer_for_ept_pages(void);
|
||||||
#endif /* PAGE_H */
|
#endif /* PAGE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user