[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [RFC 15/19] s390/zcrypt: introduce ioctl access to VFIO AP
From: |
Tony Krowiak |
Subject: |
[qemu-s390x] [RFC 15/19] s390/zcrypt: introduce ioctl access to VFIO AP Matrix driver |
Date: |
Fri, 13 Oct 2017 13:39:00 -0400 |
Introduces ioctl access to the VFIO AP Matrix device driver
by implementing the VFIO_DEVICE_GET_INFO ioctl. This ioctl
provides the VFIO AP Matrix device driver information to the
guest machine.
Signed-off-by: Tony Krowiak <address@hidden>
---
drivers/s390/crypto/vfio_ap_matrix_ops.c | 43 ++++++++++++++++++++++++++++++
include/uapi/linux/vfio.h | 1 +
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/drivers/s390/crypto/vfio_ap_matrix_ops.c
b/drivers/s390/crypto/vfio_ap_matrix_ops.c
index fd36074..74ea8db 100644
--- a/drivers/s390/crypto/vfio_ap_matrix_ops.c
+++ b/drivers/s390/crypto/vfio_ap_matrix_ops.c
@@ -137,6 +137,48 @@ static void ap_matrix_mdev_release(struct mdev_device
*mdev)
&matrix_mdev->group_notifier);
}
+static int ap_matrix_mdev_get_device_info(unsigned long arg)
+{
+ unsigned long minsz;
+ 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) {
+ pr_err("%s: Argument size %u less than min size %li",
+ VFIO_AP_MATRIX_MODULE_NAME, info.argsz, minsz);
+ return -EINVAL;
+ }
+
+ info.flags = VFIO_DEVICE_FLAGS_AP_MATRIX;
+ info.num_regions = 0;
+ info.num_irqs = 0;
+
+ return copy_to_user((void __user *)arg, &info, minsz);
+}
+
+static ssize_t ap_matrix_mdev_ioctl(struct mdev_device *mdev,
+ unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ switch (cmd) {
+ case VFIO_DEVICE_GET_INFO:
+ ret = ap_matrix_mdev_get_device_info(arg);
+ break;
+ default:
+ pr_err("%s: ioctl command %d is not a supported command",
+ VFIO_AP_MATRIX_MODULE_NAME, cmd);
+ ret = -EOPNOTSUPP;
+ break;
+ }
+
+ return ret;
+}
+
static ssize_t name_show(struct kobject *kobj, struct device *dev, char *buf)
{
return sprintf(buf, "%s\n", AP_MATRIX_MDEV_NAME_HWVIRT);
@@ -651,6 +693,7 @@ static DEVICE_ATTR(control_domains, 0644,
ap_matrix_control_domains_show,
.remove = ap_matrix_mdev_remove,
.open = ap_matrix_mdev_open,
.release = ap_matrix_mdev_release,
+ .ioctl = ap_matrix_mdev_ioctl,
};
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 743456f..08f1ab4 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -199,6 +199,7 @@ struct vfio_device_info {
#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) /* vfio-platform device */
#define VFIO_DEVICE_FLAGS_AMBA (1 << 3) /* vfio-amba device */
#define VFIO_DEVICE_FLAGS_CCW (1 << 4) /* vfio-ccw device */
+#define VFIO_DEVICE_FLAGS_AP_MATRIX (1 << 5) /* vfio-ap-matrix device */
__u32 num_regions; /* Max region index + 1 */
__u32 num_irqs; /* Max IRQ index + 1 */
};
--
1.7.1
- [qemu-s390x] [RFC 00/19] KVM: s390/crypto/vfio: guest dedicated crypto adapters, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 08/19] s390/zcrypt: support for assigning adapters to matrix mdev, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 10/19] s390/zcrypt: sysfs interfaces supporting AP domain assignment, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 07/19] KVM: s390: introduce AP matrix configuration interface, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 13/19] s390/zcrypt: validate control domain assignment, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 18/19] KVM: s390: New ioctl to configure KVM guest's AP matrix, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 15/19] s390/zcrypt: introduce ioctl access to VFIO AP Matrix driver,
Tony Krowiak <=
- [qemu-s390x] [RFC 09/19] s390/zcrypt: validate adapter assignment, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 11/19] s390/zcrypt: validate domain assignment, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 17/19] KVM: s390: validate input to AP matrix config interface, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 19/19] s390/facilities: enable AP facilities needed by guest, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 04/19] s390/zcrypt: create an AP matrix device on the AP matrix bus, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 01/19] KVM: s390: SIE considerations for AP Queue virtualization, Tony Krowiak, 2017/10/13
- [qemu-s390x] [RFC 14/19] KVM: s390: Connect the AP mediated matrix device to KVM, Tony Krowiak, 2017/10/13