vfio/platform: return info for bound device

A VFIO userspace driver will start by opening the VFIO device
that corresponds to an IOMMU group, and will use the ioctl interface
to get the basic device info, such as number of memory regions and
interrupts, and their properties. This patch enables the
VFIO_DEVICE_GET_INFO ioctl call.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
[Baptiste Reynal: added include in vfio_platform_common.c]
Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
Reviewed-by: Eric Auger <eric.auger@linaro.org>
Tested-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
Antonios Motakis 2015-03-16 14:08:46 -06:00 committed by Alex Williamson
parent b13329adc2
commit 2e8567bbb5
1 changed files with 21 additions and 3 deletions

View File

@ -18,6 +18,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/vfio.h> #include <linux/vfio.h>
#include "vfio_platform_private.h" #include "vfio_platform_private.h"
@ -38,10 +39,27 @@ static int vfio_platform_open(void *device_data)
static long vfio_platform_ioctl(void *device_data, static long vfio_platform_ioctl(void *device_data,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
if (cmd == VFIO_DEVICE_GET_INFO) struct vfio_platform_device *vdev = device_data;
return -EINVAL; unsigned long minsz;
else if (cmd == VFIO_DEVICE_GET_REGION_INFO) if (cmd == 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;
info.flags = vdev->flags;
info.num_regions = 0;
info.num_irqs = 0;
return copy_to_user((void __user *)arg, &info, minsz);
} else if (cmd == VFIO_DEVICE_GET_REGION_INFO)
return -EINVAL; return -EINVAL;
else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) else if (cmd == VFIO_DEVICE_GET_IRQ_INFO)