drivers/virt/acrn/hsm.c
Source file repositories/reference/linux-study-clean/drivers/virt/acrn/hsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/acrn/hsm.c- Extension
.c- Size
- 13271 bytes
- Lines
- 540
- Domain
- Driver Families
- Bucket
- drivers/virt
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cpu.hlinux/io.hlinux/mm.hlinux/module.hlinux/slab.hasm/acrn.hasm/cpuid/api.hasm/hypervisor.hacrn_drv.h
Detected Declarations
function Modulefunction pmcmd_ioctlfunction acrn_dev_ioctlfunction acrn_dev_releasefunction remove_cpu_storefunction acrn_attr_visiblefunction hsm_initfunction hsm_exitmodule init hsm_init
Annotated Snippet
static const struct file_operations acrn_fops = {
.owner = THIS_MODULE,
.open = acrn_dev_open,
.release = acrn_dev_release,
.unlocked_ioctl = acrn_dev_ioctl,
};
struct miscdevice acrn_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "acrn_hsm",
.fops = &acrn_fops,
.groups = acrn_attr_groups,
};
static int __init hsm_init(void)
{
int ret;
if (x86_hyper_type != X86_HYPER_ACRN)
return -ENODEV;
if (!(cpuid_eax(ACRN_CPUID_FEATURES) & ACRN_FEATURE_PRIVILEGED_VM))
return -EPERM;
ret = misc_register(&acrn_dev);
if (ret) {
pr_err("Create misc dev failed!\n");
return ret;
}
ret = acrn_ioreq_intr_setup();
if (ret) {
pr_err("Setup I/O request handler failed!\n");
misc_deregister(&acrn_dev);
return ret;
}
return 0;
}
static void __exit hsm_exit(void)
{
acrn_ioreq_intr_remove();
misc_deregister(&acrn_dev);
}
module_init(hsm_init);
module_exit(hsm_exit);
MODULE_AUTHOR("Intel Corporation");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ACRN Hypervisor Service Module (HSM)");
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/io.h`, `linux/mm.h`, `linux/module.h`, `linux/slab.h`, `asm/acrn.h`, `asm/cpuid/api.h`, `asm/hypervisor.h`.
- Detected declarations: `function Module`, `function pmcmd_ioctl`, `function acrn_dev_ioctl`, `function acrn_dev_release`, `function remove_cpu_store`, `function acrn_attr_visible`, `function hsm_init`, `function hsm_exit`, `module init hsm_init`.
- Atlas domain: Driver Families / drivers/virt.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.