HV: ptdev hide SRIOV capability for VM

Hide sriov capability of passthrough devices for VMs at init_vdev_pt().
And for post-launched VM, allow assign PF.

Tracked-On: #5041
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
yuhong.tao@intel.com 2020-07-10 05:54:30 +08:00 committed by wenlingz
parent eb36337622
commit 6992d00e45
2 changed files with 7 additions and 7 deletions

View File

@ -418,6 +418,11 @@ void init_vdev_pt(struct pci_vdev *vdev, bool is_pf_vdev)
} }
} }
} }
if (!is_sos_vm(vpci2vm(vdev->vpci)) && (has_sriov_cap(vdev))) {
vdev_pt_hide_sriov_cap(vdev);
}
} }
/* /*

View File

@ -676,15 +676,10 @@ int32_t vpci_assign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *pc
sos_vm = get_sos_vm(); sos_vm = get_sos_vm();
spinlock_obtain(&sos_vm->vpci.lock); spinlock_obtain(&sos_vm->vpci.lock);
vdev_in_sos = pci_find_vdev(&sos_vm->vpci, bdf); vdev_in_sos = pci_find_vdev(&sos_vm->vpci, bdf);
/*
* TODO We didn't support SR-IOV capability of PF in UOS for now, we should
* hide the SR-IOV capability if we pass through the PF to a UOS.
*
* For now, we don't support assignment of PF to a UOS.
*/
if ((vdev_in_sos != NULL) && (vdev_in_sos->user == vdev_in_sos) && if ((vdev_in_sos != NULL) && (vdev_in_sos->user == vdev_in_sos) &&
(vdev_in_sos->pdev != NULL) && (!has_sriov_cap(vdev_in_sos)) && (vdev_in_sos->pdev != NULL) &&
!is_host_bridge(vdev_in_sos->pdev) && !is_bridge(vdev_in_sos->pdev)) { !is_host_bridge(vdev_in_sos->pdev) && !is_bridge(vdev_in_sos->pdev)) {
/* ToDo: Each PT device must support one type reset */ /* ToDo: Each PT device must support one type reset */
if (!vdev_in_sos->pdev->has_pm_reset && !vdev_in_sos->pdev->has_flr && if (!vdev_in_sos->pdev->has_pm_reset && !vdev_in_sos->pdev->has_flr &&
!vdev_in_sos->pdev->has_af_flr) { !vdev_in_sos->pdev->has_af_flr) {