drivers/virt/vboxguest/vboxguest_utils.c
Source file repositories/reference/linux-study-clean/drivers/virt/vboxguest/vboxguest_utils.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/vboxguest/vboxguest_utils.c- Extension
.c- Size
- 24410 bytes
- Lines
- 835
- Domain
- Driver Families
- Bucket
- drivers/virt
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/io.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/sizes.hlinux/slab.hlinux/uaccess.hlinux/vmalloc.hlinux/vbox_err.hlinux/vbox_utils.hvboxguest_core.h
Detected Declarations
function vbg_req_freefunction vbg_req_performfunction hgcm_req_donefunction vbg_hgcm_connectfunction vbg_hgcm_disconnectfunction hgcm_call_buf_size_in_pagesfunction hgcm_call_add_pagelist_sizefunction hgcm_call_preprocess_linaddrfunction hgcm_call_preprocessfunction hgcm_call_linear_addr_type_to_pagelist_flagsfunction hgcm_call_init_linaddrfunction hgcm_call_init_callfunction hgcm_cancel_callfunction vbg_hgcm_do_callfunction hgcm_call_copy_back_resultfunction vbg_hgcm_callfunction vbg_hgcm_call32function vbg_status_code_to_errnoexport nameexport vbg_hgcm_connectexport vbg_hgcm_disconnectexport vbg_hgcm_callexport vbg_status_code_to_errno
Annotated Snippet
switch (src_parm->type) {
case VMMDEV_HGCM_PARM_TYPE_32BIT:
case VMMDEV_HGCM_PARM_TYPE_64BIT:
break;
case VMMDEV_HGCM_PARM_TYPE_LINADDR:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_IN:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_OUT:
if (!bounce_bufs) {
bounce_bufs = kcalloc(parm_count,
sizeof(void *),
GFP_KERNEL);
if (!bounce_bufs)
return -ENOMEM;
*bounce_bufs_ret = bounce_bufs;
}
ret = hgcm_call_preprocess_linaddr(src_parm,
&bounce_bufs[i],
extra);
if (ret)
return ret;
break;
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT:
buf = (void *)src_parm->u.pointer.u.linear_addr;
len = src_parm->u.pointer.size;
if (WARN_ON(len > VBG_MAX_HGCM_KERNEL_PARM))
return -E2BIG;
hgcm_call_add_pagelist_size(buf, len, extra);
break;
default:
return -EINVAL;
}
}
return 0;
}
/**
* hgcm_call_linear_addr_type_to_pagelist_flags - Translates linear address
* types to page list direction flags.
* @type: The type.
*
* Return: page list flags.
*/
static u32 hgcm_call_linear_addr_type_to_pagelist_flags(
enum vmmdev_hgcm_function_parameter_type type)
{
switch (type) {
default:
WARN_ON(1);
fallthrough;
case VMMDEV_HGCM_PARM_TYPE_LINADDR:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL:
return VMMDEV_HGCM_F_PARM_DIRECTION_BOTH;
case VMMDEV_HGCM_PARM_TYPE_LINADDR_IN:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN:
return VMMDEV_HGCM_F_PARM_DIRECTION_TO_HOST;
case VMMDEV_HGCM_PARM_TYPE_LINADDR_OUT:
case VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT:
return VMMDEV_HGCM_F_PARM_DIRECTION_FROM_HOST;
}
}
static void hgcm_call_init_linaddr(struct vmmdev_hgcm_call *call,
struct vmmdev_hgcm_function_parameter *dst_parm, void *buf, u32 len,
enum vmmdev_hgcm_function_parameter_type type, u32 *off_extra)
{
struct vmmdev_hgcm_pagelist *dst_pg_lst;
struct page *page;
bool is_vmalloc;
u32 i, page_count;
dst_parm->type = type;
if (len == 0) {
dst_parm->u.pointer.size = 0;
dst_parm->u.pointer.u.linear_addr = 0;
return;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/io.h`, `linux/kernel.h`, `linux/mm.h`, `linux/module.h`, `linux/sizes.h`, `linux/slab.h`, `linux/uaccess.h`.
- Detected declarations: `function vbg_req_free`, `function vbg_req_perform`, `function hgcm_req_done`, `function vbg_hgcm_connect`, `function vbg_hgcm_disconnect`, `function hgcm_call_buf_size_in_pages`, `function hgcm_call_add_pagelist_size`, `function hgcm_call_preprocess_linaddr`, `function hgcm_call_preprocess`, `function hgcm_call_linear_addr_type_to_pagelist_flags`.
- Atlas domain: Driver Families / drivers/virt.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.