Skip to content

Commit 00edd83

Browse files
JasonChenCJlijinxia
authored andcommitted
hypercall: no need check HV memory overlap for MR_DEL
in local_set_vm_memory_region, hpa is not used for MR_DEL, and it does not need check HV memory overlap for a MR_DEL operation. this is a bug exposed by remapping SOS first page, as the remap page whose gpa = 0 actually fall into HV memory area; while during MR_DEL, the input param vm0_gpa is set to 0 by default. Tracked-On: #1124 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent 876cc68 commit 00edd83

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

hypervisor/common/hypercall.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,21 +430,23 @@ static int32_t local_set_vm_memory_region(struct vm *vm,
430430
return -EINVAL;
431431
}
432432

433-
hpa = gpa2hpa(vm, region->vm0_gpa);
434-
dev_dbg(ACRN_DBG_HYCALL, "[vm%d] gpa=0x%x hpa=0x%x size=0x%x",
435-
target_vm->vm_id, region->gpa, hpa, region->size);
436-
437-
base_paddr = get_hv_image_base();
438-
if (((hpa <= base_paddr) &&
439-
((hpa + region->size) > base_paddr)) ||
440-
((hpa >= base_paddr) &&
441-
(hpa < (base_paddr + CONFIG_RAM_SIZE)))) {
442-
pr_err("%s: overlap the HV memory region.", __func__);
443-
return -EFAULT;
444-
}
433+
dev_dbg(ACRN_DBG_HYCALL,
434+
"[vm%d] type=%d gpa=0x%x vm0_gpa=0x%x size=0x%x",
435+
target_vm->vm_id, region->type, region->gpa,
436+
region->vm0_gpa, region->size);
445437

446438
pml4_page = (uint64_t *)target_vm->arch_vm.nworld_eptp;
447439
if (region->type != MR_DEL) {
440+
hpa = gpa2hpa(vm, region->vm0_gpa);
441+
base_paddr = get_hv_image_base();
442+
if (((hpa <= base_paddr) &&
443+
((hpa + region->size) > base_paddr)) ||
444+
((hpa >= base_paddr) &&
445+
(hpa < (base_paddr + CONFIG_RAM_SIZE)))) {
446+
pr_err("%s: overlap the HV memory region.", __func__);
447+
return -EFAULT;
448+
}
449+
448450
prot = 0UL;
449451
/* access right */
450452
if ((region->prot & MEM_ACCESS_READ) != 0U) {

0 commit comments

Comments
 (0)