diff --git a/hypervisor/dm/vpci/pci_pt.c b/hypervisor/dm/vpci/pci_pt.c index 429e2e21d..1861a96ca 100644 --- a/hypervisor/dm/vpci/pci_pt.c +++ b/hypervisor/dm/vpci/pci_pt.c @@ -140,31 +140,12 @@ static void vdev_pt_allow_io_vbar(struct pci_vdev *vdev, uint32_t idx) /* For SOS, all port IO access is allowed by default, so skip SOS here */ if (!is_sos_vm(vm)) { struct pci_vbar *vbar = &vdev->vbars[idx]; - if (vbar->base_gpa != 0UL) { - allow_guest_pio_access(vm, (uint16_t)vbar->base_gpa, (uint32_t)(vbar->size)); + if (vbar->base_hpa != 0UL) { + allow_guest_pio_access(vm, (uint16_t)vbar->base_hpa, (uint32_t)(vbar->size)); } } } -/** - * @brief Deny IO bar access - * @pre vdev != NULL - * @pre vdev->vpci != NULL - */ -static void vdev_pt_deny_io_vbar(struct pci_vdev *vdev, uint32_t idx) -{ - struct acrn_vm *vm = vpci2vm(vdev->vpci); - - /* For SOS, all port IO access is allowed by default, so skip SOS here */ - if (!is_sos_vm(vm)) { - struct pci_vbar *vbar = &vdev->vbars[idx]; - if (vbar->base_gpa != 0UL) { - deny_guest_pio_access(vm, (uint16_t)(vbar->base_gpa), (uint32_t)(vbar->size)); - } - - } -} - /** * @pre vdev != NULL */ @@ -176,10 +157,8 @@ void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t idx, uint32_t val) switch (vbar->type) { case PCIBAR_IO_SPACE: - vdev_pt_deny_io_vbar(vdev, update_idx); if (val != ~0U) { pci_vdev_write_vbar(vdev, idx, val); - vdev_pt_allow_io_vbar(vdev, update_idx); } else { pci_vdev_write_vcfg(vdev, offset, 4U, val); vdev->vbars[update_idx].base_gpa = 0UL; @@ -334,6 +313,10 @@ static void init_bars(struct pci_vdev *vdev, bool is_sriov_bar) if (!is_sriov_bar) { pci_vdev_write_vbar(vdev, idx, lo); } + + if (type == PCIBAR_IO_SPACE) { + vdev_pt_allow_io_vbar(vdev, idx); + } } } }