drivers/hv/mshv_vtl_main.c
Source file repositories/reference/linux-study-clean/drivers/hv/mshv_vtl_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/mshv_vtl_main.c- Extension
.c- Size
- 36886 bytes
- Lines
- 1400
- Domain
- Driver Families
- Bucket
- drivers/hv
- 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/kernel.hlinux/module.hlinux/miscdevice.hlinux/anon_inodes.hlinux/cpuhotplug.hlinux/count_zeros.hlinux/entry-virt.hlinux/eventfd.hlinux/poll.hlinux/file.hlinux/vmalloc.hasm/debugreg.hasm/mshyperv.htrace/events/ipi.huapi/asm/mtrr.huapi/linux/mshv.hhyperv/hvhdk.h../../kernel/fpu/legacy.hmshv.hmshv_vtl.hhyperv_vmbus.h
Detected Declarations
struct mshv_vtl_hvcall_fdstruct mshv_vtl_poll_filestruct mshv_vtlstruct mshv_vtl_per_cpufunction mshv_ioctl_create_vtlfunction mshv_ioctl_check_extensionfunction mshv_dev_ioctlfunction mshv_vtl_configure_reg_pagefunction mshv_vtl_synic_enable_regsfunction mshv_vtl_get_vsm_regsfunction mshv_vtl_configure_vsm_partitionfunction mshv_vtl_vmbus_isrfunction mshv_vtl_alloc_contextfunction hv_vtl_setup_synicfunction hv_vtl_remove_synicfunction vtl_get_vp_registerfunction vtl_set_vp_registerfunction mshv_vtl_ioctl_add_vtl0_memfunction mshv_vtl_cancelfunction mshv_vtl_poll_file_wakefunction mshv_vtl_ptable_queue_procfunction mshv_vtl_ioctl_set_poll_filefunction mshv_vtl_get_set_regfunction mshv_vtl_returnfunction mshv_vtl_process_interceptfunction mshv_vtl_ioctl_return_to_lower_vtlfunction mshv_vtl_ioctl_get_regsfunction mshv_vtl_ioctl_set_regsfunction mshv_vtl_ioctlfunction mshv_vtl_faultfunction cpu_onlinefunction mshv_vtl_mmapfunction mshv_vtl_releasefunction mshv_vtl_synic_mask_vmbus_sintfunction mshv_vtl_read_remotefunction mshv_vtl_sint_readfunction mshv_vtl_sint_pollfunction mshv_vtl_sint_on_msg_dpcfunction mshv_vtl_sint_ioctl_post_msgfunction mshv_vtl_sint_ioctl_signal_eventfunction mshv_vtl_sint_ioctl_set_eventfdfunction mshv_vtl_sint_ioctl_pause_msg_streamfunction mshv_vtl_sint_ioctlfunction mshv_vtl_hvcall_dev_openfunction mshv_vtl_hvcall_dev_releasefunction mshv_vtl_hvcall_do_setupfunction mshv_vtl_hvcall_is_allowedfunction mshv_vtl_hvcall_call
Annotated Snippet
static const struct file_operations mshv_vtl_fops;
static long
mshv_ioctl_create_vtl(void __user *user_arg, struct device *module_dev)
{
struct mshv_vtl *vtl;
struct file *file;
int fd;
vtl = kzalloc_obj(*vtl);
if (!vtl)
return -ENOMEM;
fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0) {
kfree(vtl);
return fd;
}
file = anon_inode_getfile("mshv_vtl", &mshv_vtl_fops,
vtl, O_RDWR);
if (IS_ERR(file)) {
kfree(vtl);
return PTR_ERR(file);
}
vtl->module_dev = module_dev;
fd_install(fd, file);
return fd;
}
static long
mshv_ioctl_check_extension(void __user *user_arg)
{
u32 arg;
if (copy_from_user(&arg, user_arg, sizeof(arg)))
return -EFAULT;
switch (arg) {
case MSHV_CAP_CORE_API_STABLE:
return 0;
case MSHV_CAP_REGISTER_PAGE:
return mshv_has_reg_page;
case MSHV_CAP_VTL_RETURN_ACTION:
return mshv_vsm_capabilities.return_action_available;
case MSHV_CAP_DR6_SHARED:
return mshv_vsm_capabilities.dr6_shared;
}
return -EOPNOTSUPP;
}
static long
mshv_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
{
struct miscdevice *misc = filp->private_data;
switch (ioctl) {
case MSHV_CHECK_EXTENSION:
return mshv_ioctl_check_extension((void __user *)arg);
case MSHV_CREATE_VTL:
return mshv_ioctl_create_vtl((void __user *)arg, misc->this_device);
}
return -ENOTTY;
}
static const struct file_operations mshv_dev_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = mshv_dev_ioctl,
.llseek = noop_llseek,
};
static struct miscdevice mshv_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "mshv",
.fops = &mshv_dev_fops,
.mode = 0600,
};
static struct mshv_vtl_run *mshv_vtl_this_run(void)
{
return *this_cpu_ptr(&mshv_vtl_per_cpu.run);
}
static struct mshv_vtl_run *mshv_vtl_cpu_run(int cpu)
{
return *per_cpu_ptr(&mshv_vtl_per_cpu.run, cpu);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/miscdevice.h`, `linux/anon_inodes.h`, `linux/cpuhotplug.h`, `linux/count_zeros.h`, `linux/entry-virt.h`, `linux/eventfd.h`.
- Detected declarations: `struct mshv_vtl_hvcall_fd`, `struct mshv_vtl_poll_file`, `struct mshv_vtl`, `struct mshv_vtl_per_cpu`, `function mshv_ioctl_create_vtl`, `function mshv_ioctl_check_extension`, `function mshv_dev_ioctl`, `function mshv_vtl_configure_reg_page`, `function mshv_vtl_synic_enable_regs`, `function mshv_vtl_get_vsm_regs`.
- Atlas domain: Driver Families / drivers/hv.
- 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.