arch/um/drivers/vfio_kern.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/vfio_kern.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/vfio_kern.c- Extension
.c- Size
- 15379 bytes
- Lines
- 708
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/module.hlinux/logic_iomem.hlinux/mutex.hlinux/list.hlinux/string.hlinux/unaligned.hirq_kern.hinit.hos.hmconsole_kern.hvirt-pci.hvfio_user.h
Detected Declarations
struct uml_vfio_intr_ctxstruct uml_vfio_devicestruct uml_vfio_groupfunction uml_vfio_set_containerfunction uml_vfio_unset_containerfunction uml_vfio_open_groupfunction list_for_each_entryfunction uml_vfio_release_groupfunction list_for_each_entryfunction uml_vfio_interruptfunction uml_vfio_activate_irqfunction uml_vfio_deactivate_irqfunction uml_vfio_update_msix_capfunction uml_vfio_update_msix_tablefunction __uml_vfio_cfgspace_readfunction uml_vfio_cfgspace_readfunction __uml_vfio_cfgspace_writefunction uml_vfio_cfgspace_writefunction uml_vfio_bar_copy_fromfunction uml_vfio_bar_readfunction uml_vfio_bar_copy_tofunction uml_vfio_bar_writefunction uml_vfio_bar_setfunction uml_vfio_find_capabilityfunction uml_vfio_read_msix_tablefunction uml_vfio_open_devicefunction uml_vfio_release_devicefunction list_for_each_entryfunction uml_vfio_cmdline_setfunction uml_vfio_cmdline_getfunction uml_vfio_mc_configfunction uml_vfio_mc_idfunction uml_vfio_mc_removefunction uml_vfio_initfunction uml_vfio_exit
Annotated Snippet
struct uml_vfio_intr_ctx {
struct uml_vfio_device *dev;
int irq;
};
struct uml_vfio_device {
const char *name;
int group;
struct um_pci_device pdev;
struct uml_vfio_user_device udev;
struct uml_vfio_intr_ctx *intr_ctx;
int msix_cap;
int msix_bar;
int msix_offset;
int msix_size;
u32 *msix_data;
struct list_head list;
};
struct uml_vfio_group {
int id;
int fd;
int users;
struct list_head list;
};
static struct {
int fd;
int users;
} uml_vfio_container = { .fd = -1 };
static DEFINE_MUTEX(uml_vfio_container_mtx);
static LIST_HEAD(uml_vfio_groups);
static DEFINE_MUTEX(uml_vfio_groups_mtx);
static LIST_HEAD(uml_vfio_devices);
static DEFINE_MUTEX(uml_vfio_devices_mtx);
static int uml_vfio_set_container(int group_fd)
{
int err;
guard(mutex)(¨_vfio_container_mtx);
err = uml_vfio_user_set_container(uml_vfio_container.fd, group_fd);
if (err)
return err;
uml_vfio_container.users++;
if (uml_vfio_container.users > 1)
return 0;
err = uml_vfio_user_setup_iommu(uml_vfio_container.fd);
if (err) {
uml_vfio_user_unset_container(uml_vfio_container.fd, group_fd);
uml_vfio_container.users--;
}
return err;
}
static void uml_vfio_unset_container(int group_fd)
{
guard(mutex)(¨_vfio_container_mtx);
uml_vfio_user_unset_container(uml_vfio_container.fd, group_fd);
uml_vfio_container.users--;
}
static int uml_vfio_open_group(int group_id)
{
struct uml_vfio_group *group;
int err;
guard(mutex)(¨_vfio_groups_mtx);
list_for_each_entry(group, ¨_vfio_groups, list) {
if (group->id == group_id) {
group->users++;
return group->fd;
}
}
group = kzalloc_obj(*group);
if (!group)
return -ENOMEM;
group->fd = uml_vfio_user_open_group(group_id);
Annotation
- Immediate include surface: `linux/module.h`, `linux/logic_iomem.h`, `linux/mutex.h`, `linux/list.h`, `linux/string.h`, `linux/unaligned.h`, `irq_kern.h`, `init.h`.
- Detected declarations: `struct uml_vfio_intr_ctx`, `struct uml_vfio_device`, `struct uml_vfio_group`, `function uml_vfio_set_container`, `function uml_vfio_unset_container`, `function uml_vfio_open_group`, `function list_for_each_entry`, `function uml_vfio_release_group`, `function list_for_each_entry`, `function uml_vfio_interrupt`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
- 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.