drivers/misc/vmw_vmci/vmci_host.c
Source file repositories/reference/linux-study-clean/drivers/misc/vmw_vmci/vmci_host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/vmw_vmci/vmci_host.c- Extension
.c- Size
- 27608 bytes
- Lines
- 1027
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/vmw_vmci_defs.hlinux/vmw_vmci_api.hlinux/miscdevice.hlinux/interrupt.hlinux/highmem.hlinux/atomic.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/sched.hlinux/cred.hlinux/slab.hlinux/file.hlinux/init.hlinux/poll.hlinux/pci.hlinux/smp.hlinux/fs.hlinux/io.hvmci_handle_array.hvmci_queue_pair.hvmci_datagram.hvmci_doorbell.hvmci_resource.hvmci_context.hvmci_driver.hvmci_event.h
Detected Declarations
struct vmci_init_blkstruct vmci_qp_alloc_info_vmvmstruct vmci_set_notify_infostruct vmci_host_devfunction vmci_host_code_activefunction vmci_host_usersfunction vmci_host_openfunction vmci_host_closefunction selectfunction drv_cp_harray_to_userfunction vmci_host_setup_notifyfunction vmci_host_get_versionfunction vmci_host_do_init_contextfunction vmci_host_do_send_datagramfunction vmci_host_do_receive_datagramfunction vmci_host_do_alloc_queuepairfunction vmci_host_do_queuepair_setvafunction vmci_host_do_queuepair_setpffunction ioctlfunction vmci_host_do_qp_detachfunction vmci_host_do_ctx_add_notifyfunction vmci_host_do_ctx_remove_notifyfunction vmci_host_do_ctx_get_cpt_statefunction vmci_host_do_ctx_set_cpt_statefunction vmci_host_do_get_context_idfunction vmci_host_do_set_notifyfunction vmci_host_do_notify_resourcefunction vmci_host_do_recv_notificationsfunction vmci_host_unlocked_ioctlfunction vmci_host_initfunction vmci_host_exit
Annotated Snippet
static const struct file_operations vmuser_fops = {
.owner = THIS_MODULE,
.open = vmci_host_open,
.release = vmci_host_close,
.poll = vmci_host_poll,
.unlocked_ioctl = vmci_host_unlocked_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
static struct miscdevice vmci_host_miscdev = {
.name = "vmci",
.minor = MISC_DYNAMIC_MINOR,
.fops = &vmuser_fops,
};
int __init vmci_host_init(void)
{
int error;
host_context = vmci_ctx_create(VMCI_HOST_CONTEXT_ID,
VMCI_DEFAULT_PROC_PRIVILEGE_FLAGS,
-1, VMCI_VERSION, NULL);
if (IS_ERR(host_context)) {
error = PTR_ERR(host_context);
pr_warn("Failed to initialize VMCIContext (error%d)\n",
error);
return error;
}
error = misc_register(&vmci_host_miscdev);
if (error) {
pr_warn("Module registration error (name=%s, major=%d, minor=%d, err=%d)\n",
vmci_host_miscdev.name,
MISC_MAJOR, vmci_host_miscdev.minor,
error);
pr_warn("Unable to initialize host personality\n");
vmci_ctx_destroy(host_context);
return error;
}
pr_info("VMCI host device registered (name=%s, major=%d, minor=%d)\n",
vmci_host_miscdev.name, MISC_MAJOR, vmci_host_miscdev.minor);
vmci_host_device_initialized = true;
return 0;
}
void __exit vmci_host_exit(void)
{
vmci_host_device_initialized = false;
misc_deregister(&vmci_host_miscdev);
vmci_ctx_destroy(host_context);
vmci_qp_broker_exit();
pr_debug("VMCI host driver module unloaded\n");
}
Annotation
- Immediate include surface: `linux/vmw_vmci_defs.h`, `linux/vmw_vmci_api.h`, `linux/miscdevice.h`, `linux/interrupt.h`, `linux/highmem.h`, `linux/atomic.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct vmci_init_blk`, `struct vmci_qp_alloc_info_vmvm`, `struct vmci_set_notify_info`, `struct vmci_host_dev`, `function vmci_host_code_active`, `function vmci_host_users`, `function vmci_host_open`, `function vmci_host_close`, `function select`, `function drv_cp_harray_to_user`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: pattern 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.