hv: trusty: refine trusty memory region mapping
Now it's using the memory reserve by hypervisor. So there's not necessaty to map or ummap this region from SOS. Tracked-On: #1942 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
bd1c0838d1
commit
a0582c99cf
|
@ -445,9 +445,6 @@ Address Space Translation
|
|||
.. doxygenfunction:: vm0_hpa2gpa
|
||||
:project: Project ACRN
|
||||
|
||||
.. doxygenfunction:: check_continuous_hpa
|
||||
:project: Project ACRN
|
||||
|
||||
EPT
|
||||
---
|
||||
|
||||
|
|
|
@ -295,27 +295,3 @@ void init_paging(void)
|
|||
/* set ptep in sanitized_page point to itself */
|
||||
sanitize_pte((uint64_t *)sanitized_page);
|
||||
}
|
||||
|
||||
bool check_continuous_hpa(struct acrn_vm *vm, uint64_t gpa_arg, uint64_t size_arg)
|
||||
{
|
||||
uint64_t curr_hpa;
|
||||
uint64_t next_hpa;
|
||||
uint64_t gpa = gpa_arg;
|
||||
uint64_t size = size_arg;
|
||||
|
||||
/* if size <= PAGE_SIZE_4K, it is continuous,no need check
|
||||
* if size > PAGE_SIZE_4K, need to fetch next page
|
||||
*/
|
||||
while (size > PAGE_SIZE_4K) {
|
||||
curr_hpa = gpa2hpa(vm, gpa);
|
||||
gpa += PAGE_SIZE_4K;
|
||||
next_hpa = gpa2hpa(vm, gpa);
|
||||
if ((curr_hpa == INVALID_HPA) || (next_hpa == INVALID_HPA)
|
||||
|| (next_hpa != (curr_hpa + PAGE_SIZE_4K))) {
|
||||
return false;
|
||||
}
|
||||
size -= PAGE_SIZE_4K;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
@ -62,13 +62,11 @@ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig,
|
|||
{
|
||||
uint64_t nworld_pml4e;
|
||||
uint64_t sworld_pml4e;
|
||||
uint64_t gpa;
|
||||
/* Check the HPA of parameter gpa_orig when invoking check_continuos_hpa */
|
||||
uint64_t hpa;
|
||||
uint64_t table_present = EPT_RWX;
|
||||
uint64_t pdpte, *dest_pdpte_p, *src_pdpte_p;
|
||||
void *sub_table_addr, *pml4_base;
|
||||
struct acrn_vm *vm0;
|
||||
uint16_t i;
|
||||
|
||||
if ((vm->sworld_control.flag.supported == 0UL)
|
||||
|
@ -77,15 +75,6 @@ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig,
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the HPA of parameter gpa_orig should exist
|
||||
* Check the physical address should be continuous
|
||||
*/
|
||||
if (!check_continuous_hpa(vm, gpa_orig, size)) {
|
||||
ASSERT(false, "The physical addr is not continuous for Trusty");
|
||||
return;
|
||||
}
|
||||
|
||||
hpa = gpa2hpa(vm, gpa_orig);
|
||||
|
||||
/* Unmap gpa_orig~gpa_orig+size from guest normal world ept mapping */
|
||||
|
@ -133,15 +122,7 @@ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig,
|
|||
/* Map [gpa_rebased, gpa_rebased + size) to secure ept mapping */
|
||||
ept_mr_add(vm, (uint64_t *)vm->arch_vm.sworld_eptp, hpa, gpa_rebased, size, EPT_RWX | EPT_WB);
|
||||
|
||||
/* Get the gpa address in SOS */
|
||||
gpa = vm0_hpa2gpa(hpa);
|
||||
|
||||
/* Unmap trusty memory space from sos ept mapping*/
|
||||
vm0 = get_vm_from_vmid(0U);
|
||||
ept_mr_del(vm0, (uint64_t *)vm0->arch_vm.nworld_eptp, gpa, size);
|
||||
|
||||
/* Backup secure world info, will be used when destroy secure world and suspend UOS */
|
||||
vm->sworld_control.sworld_memory.base_gpa_in_sos = gpa;
|
||||
vm->sworld_control.sworld_memory.base_gpa_in_uos = gpa_orig;
|
||||
vm->sworld_control.sworld_memory.base_hpa = hpa;
|
||||
vm->sworld_control.sworld_memory.length = size;
|
||||
|
@ -149,9 +130,7 @@ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig,
|
|||
|
||||
void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem)
|
||||
{
|
||||
struct acrn_vm *vm0;
|
||||
uint64_t hpa = vm->sworld_control.sworld_memory.base_hpa;
|
||||
uint64_t gpa_sos = vm->sworld_control.sworld_memory.base_gpa_in_sos;
|
||||
uint64_t gpa_uos = vm->sworld_control.sworld_memory.base_gpa_in_uos;
|
||||
uint64_t size = vm->sworld_control.sworld_memory.length;
|
||||
|
||||
|
@ -170,13 +149,8 @@ void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem)
|
|||
sanitize_pte((uint64_t *)vm->arch_vm.sworld_eptp);
|
||||
vm->arch_vm.sworld_eptp = NULL;
|
||||
|
||||
/* restore memory to SOS ept mapping */
|
||||
vm0 = get_vm_from_vmid(0U);
|
||||
ept_mr_add(vm0, vm0->arch_vm.nworld_eptp, hpa, gpa_sos, size, EPT_RWX | EPT_WB);
|
||||
|
||||
/* Restore memory to guest normal world */
|
||||
ept_mr_add(vm, vm->arch_vm.nworld_eptp, hpa, gpa_uos, size, EPT_RWX | EPT_WB);
|
||||
|
||||
}
|
||||
|
||||
static inline void save_fxstore_guest_area(struct ext_context *ext_ctx)
|
||||
|
|
|
@ -150,17 +150,6 @@ void flush_vpid_global(void);
|
|||
* @return None
|
||||
*/
|
||||
void invept(const struct acrn_vcpu *vcpu);
|
||||
/**
|
||||
* @brief Host-physical address continous checking
|
||||
*
|
||||
* @param[in] vm the pointer that points the VM data structure
|
||||
* @param[in] gpa_arg the start GPA address of the guest memory region
|
||||
* @param[in] size_arg the size of the guest memory region
|
||||
*
|
||||
* @retval true The HPA of the guest memory region is continuous
|
||||
* @retval false The HPA of the guest memory region is non-continuous
|
||||
*/
|
||||
bool check_continuous_hpa(struct acrn_vm *vm, uint64_t gpa_arg, uint64_t size_arg);
|
||||
/**
|
||||
*@pre (pml4_page != NULL) && (pg_size != NULL)
|
||||
*/
|
||||
|
|
|
@ -94,8 +94,6 @@ struct trusty_key_info {
|
|||
};
|
||||
|
||||
struct secure_world_memory {
|
||||
/* The secure world base address of GPA in SOS */
|
||||
uint64_t base_gpa_in_sos;
|
||||
/* The original secure world base address allocated by bootloader */
|
||||
uint64_t base_gpa_in_uos;
|
||||
/* The secure world base address of HPA */
|
||||
|
|
Loading…
Reference in New Issue