mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-16 16:32:51 +00:00
hv:check continuous hpa when create secure world
Add check_continuous_hpa API: when create secure world,if the physical address is not continuous, will assert. Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
e5be957945
commit
92d86383be
@ -520,6 +520,25 @@ void free_paging_struct(void *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
bool check_continuous_hpa(struct vm *vm, uint64_t gpa, uint64_t size)
|
||||
{
|
||||
uint64_t curr_hpa = 0;
|
||||
uint64_t next_hpa = 0;
|
||||
|
||||
/* 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 (next_hpa != (curr_hpa + PAGE_SIZE_4K))
|
||||
return false;
|
||||
size -= PAGE_SIZE_4K;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
uint64_t config_page_table_attr(struct map_params *map_params, uint32_t flags)
|
||||
{
|
||||
int table_type = map_params->page_table_type;
|
||||
|
@ -116,6 +116,12 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
map_params.page_table_type = PTT_EPT;
|
||||
map_params.pml4_inverted = vm->arch_vm.m2p;
|
||||
|
||||
|
@ -325,6 +325,7 @@ void unmap_mem(struct map_params *map_params, void *paddr, void *vaddr,
|
||||
void modify_mem(struct map_params *map_params, void *paddr, void *vaddr,
|
||||
uint64_t size, uint32_t flags);
|
||||
void mmu_invept(struct vcpu *vcpu);
|
||||
bool check_continuous_hpa(struct vm *vm, uint64_t gpa, uint64_t size);
|
||||
void obtain_last_page_table_entry(struct map_params *map_params,
|
||||
struct entry_params *entry, void *addr, bool direct);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user