hv: remove depreciated code for hc_assign/deassign_ptdev

'param' is BDF value instead of GPA when VHM driver
  issues below 2 hypercalls:
   - HC_ASSIGN_PTEDEV
   - HC_DEASSIGN_PTDEV
 This patch is to remove related code in hc_assign/deassign()
 functions.

Tracked-On: #4334
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
This commit is contained in:
Yonghua Huang 2020-01-06 16:07:04 +08:00 committed by wenlingz
parent 96aba9bd45
commit ddebefb9b4
2 changed files with 17 additions and 48 deletions

View File

@ -820,8 +820,6 @@ int32_t hcall_gpa_to_hpa(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
* @param vm Pointer to VM data structure * @param vm Pointer to VM data structure
* @param vmid ID of the VM * @param vmid ID of the VM
* @param param the physical BDF of the assigning ptdev * @param param the physical BDF of the assigning ptdev
* For the compatibility it still can be the guest physical address that
* points to the physical BDF of the assigning ptdev.(Depreciated)
* *
* @pre Pointer vm shall point to SOS_VM * @pre Pointer vm shall point to SOS_VM
* @return 0 on success, non-zero on error. * @return 0 on success, non-zero on error.
@ -831,22 +829,11 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
int32_t ret = 0; int32_t ret = 0;
union pci_bdf bdf; union pci_bdf bdf;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid); struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
bool bdf_valid = true;
struct pci_vdev *vdev; struct pci_vdev *vdev;
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) { if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
if (param < 0x10000UL) {
bdf.value = (uint16_t)param; bdf.value = (uint16_t)param;
} else {
if (copy_from_gpa(vm, &bdf, param, sizeof(bdf)) != 0) {
pr_err("%s: Unable copy param from vm %d\n",
__func__, vm->vm_id);
bdf_valid = false;
ret = -EIO;
}
}
if (bdf_valid) {
spinlock_obtain(&vm->vpci.lock); spinlock_obtain(&vm->vpci.lock);
vdev = pci_find_vdev(&vm->vpci, bdf); vdev = pci_find_vdev(&vm->vpci, bdf);
if (vdev == NULL) { if (vdev == NULL) {
@ -863,7 +850,6 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
if (ret == 0) { if (ret == 0) {
ret = move_pt_device(vm->iommu, target_vm->iommu, bdf.fields.bus, bdf.fields.devfun); ret = move_pt_device(vm->iommu, target_vm->iommu, bdf.fields.bus, bdf.fields.devfun);
} }
}
} else { } else {
pr_err("%s, target vm is invalid\n", __func__); pr_err("%s, target vm is invalid\n", __func__);
ret = -EINVAL; ret = -EINVAL;
@ -878,8 +864,6 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
* @param vm Pointer to VM data structure * @param vm Pointer to VM data structure
* @param vmid ID of the VM * @param vmid ID of the VM
* @param param the physical BDF of the deassigning ptdev * @param param the physical BDF of the deassigning ptdev
* To keep the compatibility it still can be the guest physical address that
* points to the physical BDF of the deassigning ptdev.(Depreciated)
* *
* @pre Pointer vm shall point to SOS_VM * @pre Pointer vm shall point to SOS_VM
* @return 0 on success, non-zero on error. * @return 0 on success, non-zero on error.
@ -888,23 +872,12 @@ int32_t hcall_deassign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)
{ {
int32_t ret = -1; int32_t ret = -1;
union pci_bdf bdf; union pci_bdf bdf;
bool bdf_valid = true;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid); struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) { if (!is_poweroff_vm(target_vm) && is_postlaunched_vm(target_vm)) {
if (param < 0x10000UL) {
bdf.value = (uint16_t)param; bdf.value = (uint16_t)param;
} else {
if (copy_from_gpa(vm, &bdf, param, sizeof(bdf)) != 0) {
pr_err("%s: Unable copy param to vm\n", __func__);
bdf_valid = false;
}
}
if (bdf_valid) {
ret = move_pt_device(target_vm->iommu, vm->iommu, bdf.fields.bus, bdf.fields.devfun); ret = move_pt_device(target_vm->iommu, vm->iommu, bdf.fields.bus, bdf.fields.devfun);
} }
}
return ret; return ret;
} }

View File

@ -254,8 +254,6 @@ int32_t hcall_gpa_to_hpa(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
* @param vm Pointer to VM data structure * @param vm Pointer to VM data structure
* @param vmid ID of the VM * @param vmid ID of the VM
* @param param the physical BDF of the assigning ptdev * @param param the physical BDF of the assigning ptdev
* To keep the compatibility it still can be the guest physical address that
* points to the physical BDF of the assigning ptdev.(Depreciated)
* *
* @pre Pointer vm shall point to SOS_VM * @pre Pointer vm shall point to SOS_VM
* @return 0 on success, non-zero on error. * @return 0 on success, non-zero on error.
@ -268,8 +266,6 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
* @param vm Pointer to VM data structure * @param vm Pointer to VM data structure
* @param vmid ID of the VM * @param vmid ID of the VM
* @param param the physical BDF of the deassigning ptdev * @param param the physical BDF of the deassigning ptdev
* To keep the compatibility it still can be the guest physical address that
* points to the physical BDF of the deassigning ptdev.(Depreciated)
* *
* @pre Pointer vm shall point to SOS_VM * @pre Pointer vm shall point to SOS_VM
* @return 0 on success, non-zero on error. * @return 0 on success, non-zero on error.