drivers/xen/gntdev.c
Source file repositories/reference/linux-study-clean/drivers/xen/gntdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/gntdev.c- Extension
.c- Size
- 30934 bytes
- Lines
- 1195
- 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.
- 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/dma-mapping.hlinux/module.hlinux/kernel.hlinux/init.hlinux/miscdevice.hlinux/fs.hlinux/uaccess.hlinux/sched.hlinux/sched/mm.hlinux/spinlock.hlinux/slab.hlinux/highmem.hlinux/refcount.hlinux/workqueue.hxen/xen.hxen/grant_table.hxen/balloon.hxen/gntdev.hxen/events.hxen/page.hasm/xen/hypervisor.hasm/xen/hypercall.hgntdev-common.hgntdev-dmabuf.h
Detected Declarations
struct gntdev_copy_batchfunction gntdev_test_page_countfunction gntdev_print_mapsfunction gntdev_free_mapfunction gntdev_add_mapfunction list_for_each_entryfunction list_for_each_entryfunction gntdev_put_mapfunction find_grant_ptesfunction gntdev_map_grant_pagesfunction __unmap_grant_pages_donefunction __unmap_grant_pagesfunction unmap_grant_pagesfunction gntdev_vma_openfunction gntdev_vma_closefunction gntdev_invalidatefunction gntdev_openfunction gntdev_releasefunction gntdev_ioctl_map_grant_reffunction gntdev_ioctl_unmap_grant_reffunction gntdev_ioctl_get_offset_for_vaddrfunction gntdev_ioctl_notifyfunction list_for_each_entryfunction gntdev_get_pagefunction gntdev_put_pagesfunction gntdev_copyfunction gntdev_grant_copy_segfunction gntdev_ioctl_grant_copyfunction gntdev_ioctlfunction gntdev_mmapfunction gntdev_initfunction gntdev_exitmodule init gntdev_init
Annotated Snippet
static const struct file_operations gntdev_fops = {
.owner = THIS_MODULE,
.open = gntdev_open,
.release = gntdev_release,
.mmap = gntdev_mmap,
.unlocked_ioctl = gntdev_ioctl
};
static struct miscdevice gntdev_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "xen/gntdev",
.fops = &gntdev_fops,
};
/* ------------------------------------------------------------------ */
static int __init gntdev_init(void)
{
int err;
if (!xen_domain())
return -ENODEV;
err = misc_register(&gntdev_miscdev);
if (err != 0) {
pr_err("Could not register gntdev device\n");
return err;
}
return 0;
}
static void __exit gntdev_exit(void)
{
misc_deregister(&gntdev_miscdev);
}
module_init(gntdev_init);
module_exit(gntdev_exit);
/* ------------------------------------------------------------------ */
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/miscdevice.h`, `linux/fs.h`, `linux/uaccess.h`, `linux/sched.h`.
- Detected declarations: `struct gntdev_copy_batch`, `function gntdev_test_page_count`, `function gntdev_print_maps`, `function gntdev_free_map`, `function gntdev_add_map`, `function list_for_each_entry`, `function list_for_each_entry`, `function gntdev_put_map`, `function find_grant_ptes`, `function gntdev_map_grant_pages`.
- 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.
- 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.