drivers/s390/cio/vfio_ccw_ops.c
Source file repositories/reference/linux-study-clean/drivers/s390/cio/vfio_ccw_ops.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/cio/vfio_ccw_ops.c- Extension
.c- Size
- 15226 bytes
- Lines
- 615
- Domain
- Driver Families
- Bucket
- drivers/s390
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/vfio.hlinux/nospec.hlinux/slab.hvfio_ccw_private.h
Detected Declarations
function vfio_ccw_mdev_resetfunction vfio_ccw_dma_unmapfunction vfio_ccw_mdev_init_devfunction vfio_ccw_mdev_probefunction vfio_ccw_mdev_release_devfunction list_for_each_entry_safefunction vfio_ccw_mdev_removefunction vfio_ccw_mdev_open_devicefunction vfio_ccw_mdev_close_devicefunction vfio_ccw_mdev_read_io_regionfunction vfio_ccw_mdev_readfunction vfio_ccw_mdev_write_io_regionfunction vfio_ccw_mdev_writefunction vfio_ccw_mdev_get_device_infofunction vfio_ccw_mdev_ioctl_get_region_infofunction vfio_ccw_mdev_get_irq_infofunction vfio_ccw_mdev_set_irqsfunction vfio_ccw_register_dev_regionfunction vfio_ccw_unregister_dev_regionsfunction vfio_ccw_mdev_ioctlfunction vfio_ccw_mdev_request
Annotated Snippet
if (fd == -1) {
if (*ctx)
eventfd_ctx_put(*ctx);
*ctx = NULL;
} else if (fd >= 0) {
struct eventfd_ctx *efdctx;
efdctx = eventfd_ctx_fdget(fd);
if (IS_ERR(efdctx))
return PTR_ERR(efdctx);
if (*ctx)
eventfd_ctx_put(*ctx);
*ctx = efdctx;
} else
return -EINVAL;
return 0;
}
default:
return -EINVAL;
}
}
int vfio_ccw_register_dev_region(struct vfio_ccw_private *private,
unsigned int subtype,
const struct vfio_ccw_regops *ops,
size_t size, u32 flags, void *data)
{
struct vfio_ccw_region *region;
region = krealloc(private->region,
(private->num_regions + 1) * sizeof(*region),
GFP_KERNEL);
if (!region)
return -ENOMEM;
private->region = region;
private->region[private->num_regions].type = VFIO_REGION_TYPE_CCW;
private->region[private->num_regions].subtype = subtype;
private->region[private->num_regions].ops = ops;
private->region[private->num_regions].size = size;
private->region[private->num_regions].flags = flags;
private->region[private->num_regions].data = data;
private->num_regions++;
return 0;
}
void vfio_ccw_unregister_dev_regions(struct vfio_ccw_private *private)
{
int i;
for (i = 0; i < private->num_regions; i++)
private->region[i].ops->release(private, &private->region[i]);
private->num_regions = 0;
kfree(private->region);
private->region = NULL;
}
static ssize_t vfio_ccw_mdev_ioctl(struct vfio_device *vdev,
unsigned int cmd,
unsigned long arg)
{
struct vfio_ccw_private *private =
container_of(vdev, struct vfio_ccw_private, vdev);
int ret = 0;
unsigned long minsz;
switch (cmd) {
case VFIO_DEVICE_GET_INFO:
{
struct vfio_device_info info;
minsz = offsetofend(struct vfio_device_info, num_irqs);
if (copy_from_user(&info, (void __user *)arg, minsz))
return -EFAULT;
if (info.argsz < minsz)
return -EINVAL;
ret = vfio_ccw_mdev_get_device_info(private, &info);
if (ret)
return ret;
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
}
Annotation
- Immediate include surface: `linux/vfio.h`, `linux/nospec.h`, `linux/slab.h`, `vfio_ccw_private.h`.
- Detected declarations: `function vfio_ccw_mdev_reset`, `function vfio_ccw_dma_unmap`, `function vfio_ccw_mdev_init_dev`, `function vfio_ccw_mdev_probe`, `function vfio_ccw_mdev_release_dev`, `function list_for_each_entry_safe`, `function vfio_ccw_mdev_remove`, `function vfio_ccw_mdev_open_device`, `function vfio_ccw_mdev_close_device`, `function vfio_ccw_mdev_read_io_region`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: source 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.