hv: vpci: add PCI BAR re-program address check

In theory, guest could re-program PCI BAR address to any address. However, ACRN
hypervisor only support [0, top_address_space) EPT memory mapping. So we need to
check whether the PCI BAR re-program address is within this scope.

Tracked-On: #3475
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1
2019-10-14 23:26:57 +08:00
committed by wenlingz
parent dab14856c2
commit dc1e2adaec
4 changed files with 37 additions and 11 deletions

View File

@@ -626,7 +626,6 @@ static int32_t add_vm_memory_region(struct acrn_vm *vm, struct acrn_vm *target_v
static int32_t set_vm_memory_region(struct acrn_vm *vm,
struct acrn_vm *target_vm, const struct vm_memory_region *region)
{
uint64_t gpa_end;
uint64_t *pml4_page;
int32_t ret;
@@ -635,8 +634,7 @@ static int32_t set_vm_memory_region(struct acrn_vm *vm,
__func__, target_vm->vm_id, region->size);
ret = -EINVAL;
} else {
gpa_end = region->gpa + region->size;
if (gpa_end > target_vm->arch_vm.ept_mem_ops.info->ept.top_address_space) {
if (!ept_is_mr_valid(target_vm, region->gpa, region->size)) {
pr_err("%s, invalid gpa: 0x%llx, size: 0x%llx, top_address_space: 0x%llx", __func__,
region->gpa, region->size,
target_vm->arch_vm.ept_mem_ops.info->ept.top_address_space);