diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 1cd11eb3e..5d01f9f63 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -737,8 +737,9 @@ int32_t hcall_gpa_to_hpa(struct acrn_vm *vm, uint16_t vmid, uint64_t param) * * @param vm Pointer to VM data structure * @param vmid ID of the VM - * @param param guest physical address. This gpa points to - * 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 VM0 * @return 0 on success, non-zero on error. @@ -754,10 +755,14 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param) return -EINVAL; } - if (copy_from_gpa(vm, &bdf, param, sizeof(bdf)) != 0) { - pr_err("%s: Unable copy param from vm %d\n", + if (param < 0x10000UL) { + bdf = (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); - return -EIO; + return -EIO; + } } /* create a iommu domain for target VM if not created */ @@ -786,8 +791,9 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param) * * @param vm Pointer to VM data structure * @param vmid ID of the VM - * @param param guest physical address. This gpa points to - * 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 VM0 * @return 0 on success, non-zero on error. @@ -802,9 +808,13 @@ int32_t hcall_deassign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param) return -1; } - if (copy_from_gpa(vm, &bdf, param, sizeof(bdf)) != 0) { - pr_err("%s: Unable copy param to vm\n", __func__); - return -1; + if (param < 0x10000UL) { + bdf = (uint16_t) param; + } else { + if (copy_from_gpa(vm, &bdf, param, sizeof(bdf)) != 0) { + pr_err("%s: Unable copy param to vm\n", __func__); + return -1; + } } ret = unassign_iommu_device(target_vm->iommu, (uint8_t)(bdf >> 8U), (uint8_t)(bdf & 0xffU)); diff --git a/hypervisor/include/common/hypercall.h b/hypervisor/include/common/hypercall.h index 4c029874b..0ad4e97c2 100644 --- a/hypervisor/include/common/hypercall.h +++ b/hypervisor/include/common/hypercall.h @@ -257,8 +257,9 @@ int32_t hcall_gpa_to_hpa(struct acrn_vm *vm, uint16_t vmid, uint64_t param); * * @param vm Pointer to VM data structure * @param vmid ID of the VM - * @param param guest physical address. This gpa points to - * 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 VM0 * @return 0 on success, non-zero on error. @@ -270,8 +271,9 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param); * * @param vm Pointer to VM data structure * @param vmid ID of the VM - * @param param guest physical address. This gpa points to - * 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 VM0 * @return 0 on success, non-zero on error.