drivers/xen/gntalloc.c
Source file repositories/reference/linux-study-clean/drivers/xen/gntalloc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/gntalloc.c- Extension
.c- Size
- 15155 bytes
- Lines
- 599
- Domain
- Driver Families
- Bucket
- drivers/xen
- 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/atomic.hlinux/module.hlinux/miscdevice.hlinux/kernel.hlinux/init.hlinux/slab.hlinux/fs.hlinux/device.hlinux/mm.hlinux/uaccess.hlinux/types.hlinux/list.hlinux/highmem.hxen/xen.hxen/page.hxen/grant_table.hxen/gntalloc.hxen/events.h
Detected Declarations
struct notify_infostruct gntalloc_grefstruct gntalloc_file_private_datastruct gntalloc_vma_private_datafunction do_cleanupfunction add_grefsfunction list_for_each_entry_safefunction __del_greffunction gntalloc_openfunction gntalloc_releasefunction gntalloc_ioctl_allocfunction itfunction gntalloc_ioctl_deallocfunction gntalloc_ioctl_unmap_notifyfunction gntalloc_ioctlfunction gntalloc_vma_openfunction gntalloc_vma_closefunction gntalloc_mmapfunction gntalloc_initfunction gntalloc_exitmodule init gntalloc_init
Annotated Snippet
static const struct file_operations gntalloc_fops = {
.owner = THIS_MODULE,
.open = gntalloc_open,
.release = gntalloc_release,
.unlocked_ioctl = gntalloc_ioctl,
.mmap = gntalloc_mmap
};
/*
* -------------------------------------
* Module creation/destruction.
* -------------------------------------
*/
static struct miscdevice gntalloc_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "xen/gntalloc",
.fops = &gntalloc_fops,
};
static int __init gntalloc_init(void)
{
int err;
if (!xen_domain())
return -ENODEV;
err = misc_register(&gntalloc_miscdev);
if (err != 0) {
pr_err("Could not register misc gntalloc device\n");
return err;
}
pr_debug("Created grant allocation device at %d,%d\n",
MISC_MAJOR, gntalloc_miscdev.minor);
return 0;
}
static void __exit gntalloc_exit(void)
{
misc_deregister(&gntalloc_miscdev);
}
module_init(gntalloc_init);
module_exit(gntalloc_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Carter Weatherly <carter.weatherly@jhuapl.edu>, "
"Daniel De Graaf <dgdegra@tycho.nsa.gov>");
MODULE_DESCRIPTION("User-space grant reference allocator driver");
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/module.h`, `linux/miscdevice.h`, `linux/kernel.h`, `linux/init.h`, `linux/slab.h`, `linux/fs.h`, `linux/device.h`.
- Detected declarations: `struct notify_info`, `struct gntalloc_gref`, `struct gntalloc_file_private_data`, `struct gntalloc_vma_private_data`, `function do_cleanup`, `function add_grefs`, `function list_for_each_entry_safe`, `function __del_gref`, `function gntalloc_open`, `function gntalloc_release`.
- Atlas domain: Driver Families / drivers/xen.
- 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.