[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231205083444.3029239-4-lulu@redhat.com>
Date: Tue, 5 Dec 2023 16:34:40 +0800
From: Cindy Lu <lulu@...hat.com>
To: lulu@...hat.com, jasowang@...hat.com, mst@...hat.com,
xieyongji@...edance.com, linux-kernel@...r.kernel.org,
maxime.coquelin@...hat.com
Subject: [PATCH v3 3/7] vduse: Add new ioctl VDUSE_DEV_GET_CONFIG
The ioctl VDUSE_GET_RECONNECT_INFO is used by the Userspace App
to get the device configuration space.
Signed-off-by: Cindy Lu <lulu@...hat.com>
---
drivers/vdpa/vdpa_user/vduse_dev.c | 21 +++++++++++++++++++++
include/uapi/linux/vduse.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 26b7e29cb900..dd074a7b4bc7 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -1273,6 +1273,27 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
ret = 0;
break;
}
+ case VDUSE_DEV_GET_CONFIG: {
+ struct vduse_config_data config;
+ unsigned long size = offsetof(struct vduse_config_data, buffer);
+
+ ret = -EFAULT;
+ if (copy_from_user(&config, argp, size))
+ break;
+
+ ret = -EINVAL;
+ if (config.offset > dev->config_size || config.length == 0 ||
+ config.length > dev->config_size - config.offset)
+ break;
+
+ if (copy_to_user(argp + size, dev->config + config.offset,
+ config.length)) {
+ ret = -EFAULT;
+ break;
+ }
+ ret = 0;
+ break;
+ }
default:
ret = -ENOIOCTLCMD;
break;
diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h
index c22838247814..5280042ced23 100644
--- a/include/uapi/linux/vduse.h
+++ b/include/uapi/linux/vduse.h
@@ -372,4 +372,7 @@ struct vduse_dev_reconnect_data {
/* the reconnection mmap size for each VQ and dev status */
#define VDUSE_RECONNCT_MMAP_SIZE PAGE_SIZE
+/* get device configuration space */
+#define VDUSE_DEV_GET_CONFIG _IOR(VDUSE_BASE, 0x1b, struct vduse_config_data)
+
#endif /* _UAPI_VDUSE_H_ */
--
2.34.3
Powered by blists - more mailing lists