Lines Matching +full:loc +full:- +full:code
1 /* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
3 * vboxguest vmm-req and hgcm-call code, VBoxGuestR0LibHGCMInternal.cpp,
6 * Copyright (C) 2006-2016 Oracle Corporation
79 req->size = len; in vbg_req_alloc()
80 req->version = VMMDEV_REQUEST_HEADER_VERSION; in vbg_req_alloc()
81 req->request_type = req_type; in vbg_req_alloc()
82 req->rc = VERR_GENERAL_FAILURE; in vbg_req_alloc()
83 req->reserved1 = 0; in vbg_req_alloc()
84 req->requestor = requestor; in vbg_req_alloc()
97 /* Note this function returns a VBox status code, not a negative errno!! */
102 outl(phys_req, gdev->io_port + VMMDEV_PORT_OFF_REQUEST); in vbg_req_perform()
109 return ((struct vmmdev_request_header *)req)->rc; in vbg_req_perform()
118 spin_lock_irqsave(&gdev->event_spinlock, flags); in hgcm_req_done()
119 done = header->flags & VMMDEV_HGCM_REQ_DONE; in hgcm_req_done()
120 spin_unlock_irqrestore(&gdev->event_spinlock, flags); in hgcm_req_done()
126 struct vmmdev_hgcm_service_location *loc, in vbg_hgcm_connect() argument
135 return -ENOMEM; in vbg_hgcm_connect()
137 hgcm_connect->header.flags = 0; in vbg_hgcm_connect()
138 memcpy(&hgcm_connect->loc, loc, sizeof(*loc)); in vbg_hgcm_connect()
139 hgcm_connect->client_id = 0; in vbg_hgcm_connect()
144 wait_event(gdev->hgcm_wq, in vbg_hgcm_connect()
145 hgcm_req_done(gdev, &hgcm_connect->header)); in vbg_hgcm_connect()
148 *client_id = hgcm_connect->client_id; in vbg_hgcm_connect()
149 rc = hgcm_connect->header.result; in vbg_hgcm_connect()
169 return -ENOMEM; in vbg_hgcm_disconnect()
171 hgcm_disconnect->header.flags = 0; in vbg_hgcm_disconnect()
172 hgcm_disconnect->client_id = client_id; in vbg_hgcm_disconnect()
177 wait_event(gdev->hgcm_wq, in vbg_hgcm_disconnect()
178 hgcm_req_done(gdev, &hgcm_disconnect->header)); in vbg_hgcm_disconnect()
181 rc = hgcm_disconnect->header.result; in vbg_hgcm_disconnect()
214 buf = (void *)src_parm->u.pointer.u.linear_addr; in hgcm_call_preprocess_linaddr()
215 len = src_parm->u.pointer.size; in hgcm_call_preprocess_linaddr()
216 copy_in = src_parm->type != VMMDEV_HGCM_PARM_TYPE_LINADDR_OUT; in hgcm_call_preprocess_linaddr()
219 return -E2BIG; in hgcm_call_preprocess_linaddr()
223 return -ENOMEM; in hgcm_call_preprocess_linaddr()
230 return -EFAULT; in hgcm_call_preprocess_linaddr()
240 * hgcm_call_preprocess - Preprocesses the HGCM call, validate parameters,
260 switch (src_parm->type) { in hgcm_call_preprocess()
273 return -ENOMEM; in hgcm_call_preprocess()
289 buf = (void *)src_parm->u.pointer.u.linear_addr; in hgcm_call_preprocess()
290 len = src_parm->u.pointer.size; in hgcm_call_preprocess()
292 return -E2BIG; in hgcm_call_preprocess()
298 return -EINVAL; in hgcm_call_preprocess()
306 * hgcm_call_linear_addr_type_to_pagelist_flags - Translates linear address
342 dst_parm->type = type; in hgcm_call_init_linaddr()
345 dst_parm->u.pointer.size = 0; in hgcm_call_init_linaddr()
346 dst_parm->u.pointer.u.linear_addr = 0; in hgcm_call_init_linaddr()
354 dst_parm->type = VMMDEV_HGCM_PARM_TYPE_PAGELIST; in hgcm_call_init_linaddr()
355 dst_parm->u.page_list.size = len; in hgcm_call_init_linaddr()
356 dst_parm->u.page_list.offset = *off_extra; in hgcm_call_init_linaddr()
357 dst_pg_lst->flags = hgcm_call_linear_addr_type_to_pagelist_flags(type); in hgcm_call_init_linaddr()
358 dst_pg_lst->offset_first_page = (unsigned long)buf & ~PAGE_MASK; in hgcm_call_init_linaddr()
359 dst_pg_lst->page_count = page_count; in hgcm_call_init_linaddr()
367 dst_pg_lst->pages[i] = page_to_phys(page); in hgcm_call_init_linaddr()
375 * hgcm_call_init_call - Initializes the call request that we're sending
391 u32 i, off_extra = (uintptr_t)(dst_parm + parm_count) - (uintptr_t)call; in hgcm_call_init_call()
394 call->header.flags = 0; in hgcm_call_init_call()
395 call->header.result = VINF_SUCCESS; in hgcm_call_init_call()
396 call->client_id = client_id; in hgcm_call_init_call()
397 call->function = function; in hgcm_call_init_call()
398 call->parm_count = parm_count; in hgcm_call_init_call()
401 switch (src_parm->type) { in hgcm_call_init_call()
411 src_parm->u.pointer.size, in hgcm_call_init_call()
412 src_parm->type, &off_extra); in hgcm_call_init_call()
418 buf = (void *)src_parm->u.pointer.u.linear_addr; in hgcm_call_init_call()
420 src_parm->u.pointer.size, in hgcm_call_init_call()
421 src_parm->type, &off_extra); in hgcm_call_init_call()
426 dst_parm->type = VMMDEV_HGCM_PARM_TYPE_INVALID; in hgcm_call_init_call()
432 * hgcm_cancel_call - Tries to cancel a pending HGCM call.
436 * Return: VBox status code
443 * We use a pre-allocated request for cancellations, which is in hgcm_cancel_call()
447 mutex_lock(&gdev->cancel_req_mutex); in hgcm_cancel_call()
448 gdev->cancel_req->phys_req_to_cancel = virt_to_phys(call); in hgcm_cancel_call()
449 rc = vbg_req_perform(gdev, gdev->cancel_req); in hgcm_cancel_call()
450 mutex_unlock(&gdev->cancel_req_mutex); in hgcm_cancel_call()
453 call->header.flags |= VMMDEV_HGCM_REQ_CANCELLED; in hgcm_cancel_call()
454 call->header.header.request_type = VMMDEVREQ_HGCM_CANCEL; in hgcm_cancel_call()
462 call->header.flags |= VMMDEV_HGCM_REQ_CANCELLED; in hgcm_cancel_call()
468 * vbg_hgcm_do_call - Performs the call and completion wait.
490 * interpret the result code in the packet. in vbg_hgcm_do_call()
493 call->header.result = rc; in vbg_hgcm_do_call()
507 timeout = wait_event_interruptible_timeout(gdev->hgcm_wq, in vbg_hgcm_do_call()
508 hgcm_req_done(gdev, &call->header), in vbg_hgcm_do_call()
511 timeout = wait_event_timeout(gdev->hgcm_wq, in vbg_hgcm_do_call()
512 hgcm_req_done(gdev, &call->header), in vbg_hgcm_do_call()
521 ret = -ETIMEDOUT; in vbg_hgcm_do_call()
523 ret = -EINTR; in vbg_hgcm_do_call()
539 timeout = wait_event_timeout(gdev->hgcm_wq, in vbg_hgcm_do_call()
540 hgcm_req_done(gdev, &call->header), in vbg_hgcm_do_call()
556 * hgcm_call_copy_back_result - Copies the result of the call back to
578 switch (dst_parm->type) { in hgcm_call_copy_back_result()
585 dst_parm->u.page_list.size = src_parm->u.page_list.size; in hgcm_call_copy_back_result()
592 dst_parm->u.pointer.size = src_parm->u.pointer.size; in hgcm_call_copy_back_result()
597 dst_parm->u.pointer.size = src_parm->u.pointer.size; in hgcm_call_copy_back_result()
599 p = (void __user *)dst_parm->u.pointer.u.linear_addr; in hgcm_call_copy_back_result()
601 min(src_parm->u.pointer.size, in hgcm_call_copy_back_result()
602 dst_parm->u.pointer.size)); in hgcm_call_copy_back_result()
604 return -EFAULT; in hgcm_call_copy_back_result()
609 return -EINVAL; in hgcm_call_copy_back_result()
641 ret = -ENOMEM; in vbg_hgcm_call()
651 *vbox_status = call->header.result; in vbg_hgcm_call()
684 return -ENOMEM; in vbg_hgcm_call32()
708 ret = -EINVAL; in vbg_hgcm_call32()
738 ret = -EINVAL; in vbg_hgcm_call32()
749 [-VERR_ACCESS_DENIED] = -EPERM,
750 [-VERR_FILE_NOT_FOUND] = -ENOENT,
751 [-VERR_PROCESS_NOT_FOUND] = -ESRCH,
752 [-VERR_INTERRUPTED] = -EINTR,
753 [-VERR_DEV_IO_ERROR] = -EIO,
754 [-VERR_TOO_MUCH_DATA] = -E2BIG,
755 [-VERR_BAD_EXE_FORMAT] = -ENOEXEC,
756 [-VERR_INVALID_HANDLE] = -EBADF,
757 [-VERR_TRY_AGAIN] = -EAGAIN,
758 [-VERR_NO_MEMORY] = -ENOMEM,
759 [-VERR_INVALID_POINTER] = -EFAULT,
760 [-VERR_RESOURCE_BUSY] = -EBUSY,
761 [-VERR_ALREADY_EXISTS] = -EEXIST,
762 [-VERR_NOT_SAME_DEVICE] = -EXDEV,
763 [-VERR_NOT_A_DIRECTORY] = -ENOTDIR,
764 [-VERR_PATH_NOT_FOUND] = -ENOTDIR,
765 [-VERR_INVALID_NAME] = -ENOENT,
766 [-VERR_IS_A_DIRECTORY] = -EISDIR,
767 [-VERR_INVALID_PARAMETER] = -EINVAL,
768 [-VERR_TOO_MANY_OPEN_FILES] = -ENFILE,
769 [-VERR_INVALID_FUNCTION] = -ENOTTY,
770 [-VERR_SHARING_VIOLATION] = -ETXTBSY,
771 [-VERR_FILE_TOO_BIG] = -EFBIG,
772 [-VERR_DISK_FULL] = -ENOSPC,
773 [-VERR_SEEK_ON_DEVICE] = -ESPIPE,
774 [-VERR_WRITE_PROTECT] = -EROFS,
775 [-VERR_BROKEN_PIPE] = -EPIPE,
776 [-VERR_DEADLOCK] = -EDEADLK,
777 [-VERR_FILENAME_TOO_LONG] = -ENAMETOOLONG,
778 [-VERR_FILE_LOCK_FAILED] = -ENOLCK,
779 [-VERR_NOT_IMPLEMENTED] = -ENOSYS,
780 [-VERR_NOT_SUPPORTED] = -ENOSYS,
781 [-VERR_DIR_NOT_EMPTY] = -ENOTEMPTY,
782 [-VERR_TOO_MANY_SYMLINKS] = -ELOOP,
783 [-VERR_NO_MORE_FILES] = -ENODATA,
784 [-VERR_NO_DATA] = -ENODATA,
785 [-VERR_NET_NO_NETWORK] = -ENONET,
786 [-VERR_NET_NOT_UNIQUE_NAME] = -ENOTUNIQ,
787 [-VERR_NO_TRANSLATION] = -EILSEQ,
788 [-VERR_NET_NOT_SOCKET] = -ENOTSOCK,
789 [-VERR_NET_DEST_ADDRESS_REQUIRED] = -EDESTADDRREQ,
790 [-VERR_NET_MSG_SIZE] = -EMSGSIZE,
791 [-VERR_NET_PROTOCOL_TYPE] = -EPROTOTYPE,
792 [-VERR_NET_PROTOCOL_NOT_AVAILABLE] = -ENOPROTOOPT,
793 [-VERR_NET_PROTOCOL_NOT_SUPPORTED] = -EPROTONOSUPPORT,
794 [-VERR_NET_SOCKET_TYPE_NOT_SUPPORTED] = -ESOCKTNOSUPPORT,
795 [-VERR_NET_OPERATION_NOT_SUPPORTED] = -EOPNOTSUPP,
796 [-VERR_NET_PROTOCOL_FAMILY_NOT_SUPPORTED] = -EPFNOSUPPORT,
797 [-VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED] = -EAFNOSUPPORT,
798 [-VERR_NET_ADDRESS_IN_USE] = -EADDRINUSE,
799 [-VERR_NET_ADDRESS_NOT_AVAILABLE] = -EADDRNOTAVAIL,
800 [-VERR_NET_DOWN] = -ENETDOWN,
801 [-VERR_NET_UNREACHABLE] = -ENETUNREACH,
802 [-VERR_NET_CONNECTION_RESET] = -ENETRESET,
803 [-VERR_NET_CONNECTION_ABORTED] = -ECONNABORTED,
804 [-VERR_NET_CONNECTION_RESET_BY_PEER] = -ECONNRESET,
805 [-VERR_NET_NO_BUFFER_SPACE] = -ENOBUFS,
806 [-VERR_NET_ALREADY_CONNECTED] = -EISCONN,
807 [-VERR_NET_NOT_CONNECTED] = -ENOTCONN,
808 [-VERR_NET_SHUTDOWN] = -ESHUTDOWN,
809 [-VERR_NET_TOO_MANY_REFERENCES] = -ETOOMANYREFS,
810 [-VERR_TIMEOUT] = -ETIMEDOUT,
811 [-VERR_NET_CONNECTION_REFUSED] = -ECONNREFUSED,
812 [-VERR_NET_HOST_DOWN] = -EHOSTDOWN,
813 [-VERR_NET_HOST_UNREACHABLE] = -EHOSTUNREACH,
814 [-VERR_NET_ALREADY_IN_PROGRESS] = -EALREADY,
815 [-VERR_NET_IN_PROGRESS] = -EINPROGRESS,
816 [-VERR_MEDIA_NOT_PRESENT] = -ENOMEDIUM,
817 [-VERR_MEDIA_NOT_RECOGNIZED] = -EMEDIUMTYPE,
825 rc = -rc; in vbg_status_code_to_errno()
828 vbg_warn("%s: Unhandled err %d\n", __func__, -rc); in vbg_status_code_to_errno()
829 return -EPROTO; in vbg_status_code_to_errno()