Skip to contentSkip to conversation

s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl

PATCH Pierre Morel 1 participant 1 message Jul 30, 2018 1 message not in the archive s390

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 46 lines · Cornelia Huck
Quoted 27 lines · On Fri, 27 Jul 2018 17:29:07 +0200 Thomas Huth <[email protected]> wrote:
Quoted 26 lines · Christian Borntraeger

From: Tony Krowiak <[email protected]>

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.

---
  drivers/s390/crypto/vfio_ap_ops.c | 43 +++++++++++++++++++++++++++++++
  1 file changed, 43 insertions(+)
drivers/s390/crypto/vfio_ap_ops.c +0 -0
index d06067a23000..01c429cb51d5 100644
@@ -867,6 +867,48 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev)
  	module_put(THIS_MODULE);
  }
 
Quoted 16 lines

drivers/s390/crypto/vfio_ap_ops.c static void vfio_ap_mdev_release(struct mdev_device *mdev) · line 882

Quoted 13 lines
drivers/s390/crypto/vfio_ap_ops.c +13 -0
+static int vfio_ap_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_warn("%s: Argument size %u less than min size %li\n",
+			VFIO_AP_MODULE_NAME, info.argsz, minsz);

Do you really need this pr_warn here? The -EINVAL should give a clear indication about the problem already. (and in the worst case, a malicious userspace program could use it to flood the kernel log)

Quoted 2 lines

Agreed, that pr_warn should be dropped. FWIW, the other vfio drivers don't do this, either.

yes, done,

Thanks

Pierre

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/s390/crypto/vfio_ap_ops.c +9 -0
+		return -EINVAL;
+	}
+
+	info.flags = VFIO_DEVICE_FLAGS_AP;
+	info.num_regions = 0;
+	info.num_irqs = 0;
+
+	return copy_to_user((void __user *)arg, &info, minsz);
+}
Signature · 2 lines
Pierre Morel
Linux/KVM/QEMU in B�blingen - Germany