Skip to content

Commit e06670c

Browse files
Tony Krowiakborntraeger
authored andcommitted
s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl
Adds support for the VFIO_DEVICE_GET_INFO ioctl to the VFIO AP Matrix device driver. This is a minimal implementation, as vfio-ap does not use I/O regions. Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Acked-by: Halil Pasic <pasic@linux.ibm.com> Tested-by: Michael Mueller <mimu@linux.ibm.com> Tested-by: Farhan Ali <alifm@linux.ibm.com> Tested-by: Pierre Morel <pmorel@linux.ibm.com> Message-Id: <20180925231641.4954-13-akrowiak@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent 258287c commit e06670c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,43 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev)
855855
module_put(THIS_MODULE);
856856
}
857857

858+
static int vfio_ap_mdev_get_device_info(unsigned long arg)
859+
{
860+
unsigned long minsz;
861+
struct vfio_device_info info;
862+
863+
minsz = offsetofend(struct vfio_device_info, num_irqs);
864+
865+
if (copy_from_user(&info, (void __user *)arg, minsz))
866+
return -EFAULT;
867+
868+
if (info.argsz < minsz)
869+
return -EINVAL;
870+
871+
info.flags = VFIO_DEVICE_FLAGS_AP;
872+
info.num_regions = 0;
873+
info.num_irqs = 0;
874+
875+
return copy_to_user((void __user *)arg, &info, minsz);
876+
}
877+
878+
static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,
879+
unsigned int cmd, unsigned long arg)
880+
{
881+
int ret;
882+
883+
switch (cmd) {
884+
case VFIO_DEVICE_GET_INFO:
885+
ret = vfio_ap_mdev_get_device_info(arg);
886+
break;
887+
default:
888+
ret = -EOPNOTSUPP;
889+
break;
890+
}
891+
892+
return ret;
893+
}
894+
858895
static const struct mdev_parent_ops vfio_ap_matrix_ops = {
859896
.owner = THIS_MODULE,
860897
.supported_type_groups = vfio_ap_mdev_type_groups,
@@ -863,6 +900,7 @@ static const struct mdev_parent_ops vfio_ap_matrix_ops = {
863900
.remove = vfio_ap_mdev_remove,
864901
.open = vfio_ap_mdev_open,
865902
.release = vfio_ap_mdev_release,
903+
.ioctl = vfio_ap_mdev_ioctl,
866904
};
867905

868906
int vfio_ap_mdev_register(void)

include/uapi/linux/vfio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ struct vfio_device_info {
200200
#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) /* vfio-platform device */
201201
#define VFIO_DEVICE_FLAGS_AMBA (1 << 3) /* vfio-amba device */
202202
#define VFIO_DEVICE_FLAGS_CCW (1 << 4) /* vfio-ccw device */
203+
#define VFIO_DEVICE_FLAGS_AP (1 << 5) /* vfio-ap device */
203204
__u32 num_regions; /* Max region index + 1 */
204205
__u32 num_irqs; /* Max IRQ index + 1 */
205206
};

0 commit comments

Comments
 (0)