mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 16:57:20 +00:00
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:
@@ -248,15 +248,20 @@ static void vdev_pt_remap_generic_mem_vbar(struct pci_vdev *vdev, uint32_t idx)
|
||||
vbar->size);
|
||||
}
|
||||
|
||||
/* Map the physical BAR in the guest MMIO space */
|
||||
ept_add_mr(vm, (uint64_t *)(vm->arch_vm.nworld_eptp),
|
||||
pbar_base, /* HPA (pbar) */
|
||||
vbar_base, /* GPA (new vbar) */
|
||||
vbar->size,
|
||||
EPT_WR | EPT_RD | EPT_UNCACHED);
|
||||
if (ept_is_mr_valid(vm, vbar_base, vbar->size)) {
|
||||
/* Map the physical BAR in the guest MMIO space */
|
||||
ept_add_mr(vm, (uint64_t *)(vm->arch_vm.nworld_eptp),
|
||||
pbar_base, /* HPA (pbar) */
|
||||
vbar_base, /* GPA (new vbar) */
|
||||
vbar->size,
|
||||
EPT_WR | EPT_RD | EPT_UNCACHED);
|
||||
|
||||
/* Remember the previously mapped MMIO vbar */
|
||||
vdev->bar_base_mapped[idx] = vbar_base;
|
||||
/* Remember the previously mapped MMIO vbar */
|
||||
vdev->bar_base_mapped[idx] = vbar_base;
|
||||
} else {
|
||||
pr_fatal("%s, %x:%x.%x set invalid bar[%d] address: 0x%llx\n", __func__,
|
||||
vdev->bdf.bits.b, vdev->bdf.bits.d, vdev->bdf.bits.f, idx, vbar_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user