public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: "Eugenio Pérez" <eperezma@redhat.com>
To: "Michael S . Tsirkin" <mst@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Cindy Lu" <lulu@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Maxime Coquelin" <mcoqueli@redhat.com>,
	"Yongji Xie" <xieyongji@bytedance.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	virtualization@lists.linux.dev
Subject: [PATCH 4/6] vduse: add VDUSE_GET_FEATURES ioctl
Date: Wed, 28 Jan 2026 13:45:22 +0100	[thread overview]
Message-ID: <20260128124524.875271-5-eperezma@redhat.com> (raw)
In-Reply-To: <20260128124524.875271-1-eperezma@redhat.com>

Add an ioctl to allow VDUSE instances to query the available features
supported by the kernel module.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
A simple u64 bitmap is used for feature flags. While a flexible array
could support indefinite expansion, 64 bits is sufficient for the
foreseeable future and simplifies the implementation.

Also, dev_dbg is used for logging rather than dev_err as these can be
triggered from userspace.
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 28 ++++++++++++++++++++++++++++
 include/uapi/linux/vduse.h         |  7 ++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 551ccde0b856..e7da69c2ad71 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -52,6 +52,9 @@
 
 #define IRQ_UNBOUND -1
 
+/* Supported VDUSE features */
+static const uint64_t vduse_features;
+
 /*
  * VDUSE instance have not asked the vduse API version, so assume 0.
  *
@@ -1977,6 +1980,19 @@ static bool vduse_validate_config(struct vduse_dev_config *config,
 			 sizeof(config->reserved)))
 		return false;
 
+	if (api_version < VDUSE_API_VERSION_2) {
+		if (config->vduse_features) {
+			dev_dbg(vduse_ctrl_dev,
+				"config->vduse_features with version %llu",
+				api_version);
+			return false;
+		}
+	} else {
+		if (config->vduse_features & ~vduse_features)
+			return false;
+	}
+
+
 	if (api_version < VDUSE_API_VERSION_1 &&
 	    (config->ngroups || config->nas))
 		return false;
@@ -2237,6 +2253,18 @@ static long vduse_ioctl(struct file *file, unsigned int cmd,
 		ret = vduse_destroy_dev(name);
 		break;
 	}
+	case VDUSE_GET_FEATURES:
+		if (control->api_version < VDUSE_API_VERSION_2) {
+			dev_dbg(vduse_ctrl_dev,
+				"VDUSE_GET_FEATURES ioctl with version %llu",
+				control->api_version);
+			ret = -ENOIOCTLCMD;
+			break;
+		}
+
+		ret = put_user(vduse_features, (u64 __user *)argp);
+		break;
+
 	default:
 		ret = -EINVAL;
 		break;
diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h
index dea89ed281a7..1f68e556cbf2 100644
--- a/include/uapi/linux/vduse.h
+++ b/include/uapi/linux/vduse.h
@@ -37,6 +37,7 @@
  * @vq_align: the allocation alignment of virtqueue's metadata
  * @ngroups: number of vq groups that VDUSE device declares
  * @nas: number of address spaces that VDUSE device declares
+ * @vduse_features: VDUSE features
  * @reserved: for future use, needs to be initialized to zero
  * @config_size: the size of the configuration space
  * @config: the buffer of the configuration space
@@ -53,7 +54,8 @@ struct vduse_dev_config {
 	__u32 vq_align;
 	__u32 ngroups; /* if VDUSE_API_VERSION >= 1 */
 	__u32 nas; /* if VDUSE_API_VERSION >= 1 */
-	__u32 reserved[11];
+	__u64 vduse_features;
+	__u32 reserved[9];
 	__u32 config_size;
 	__u8 config[];
 };
@@ -67,6 +69,9 @@ struct vduse_dev_config {
  */
 #define VDUSE_DESTROY_DEV	_IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX])
 
+/* Get the VDUSE supported features */
+#define VDUSE_GET_FEATURES	_IOR(VDUSE_BASE, 0x04, __u64)
+
 /* The ioctls for VDUSE device (/dev/vduse/$NAME) */
 
 /**
-- 
2.52.0


  parent reply	other threads:[~2026-01-28 12:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:45 [PATCH 0/6] Add queue ready message to VDUSE Eugenio Pérez
2026-01-28 12:45 ` [PATCH 1/6] vduse: ensure vq->ready access is smp safe Eugenio Pérez
2026-01-29  1:16   ` Jason Wang
2026-01-29  6:20     ` Eugenio Perez Martin
2026-01-30  2:18       ` Jason Wang
2026-01-30  7:56         ` Eugenio Perez Martin
2026-02-03  4:05           ` Jason Wang
2026-02-03 10:35             ` Eugenio Perez Martin
2026-02-04  2:48               ` Jason Wang
2026-02-04  8:53                 ` Eugenio Perez Martin
2026-02-05  4:04                   ` Jason Wang
2026-02-05  6:30                     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 2/6] vduse: store control device pointer Eugenio Pérez
2026-01-28 12:45 ` [PATCH 3/6] vduse: Add API v2 definition Eugenio Pérez
2026-01-29  2:00   ` Jason Wang
2026-01-29  8:07     ` Eugenio Perez Martin
2026-01-30  2:17       ` Jason Wang
2026-01-30  8:12         ` Eugenio Perez Martin
2026-01-28 12:45 ` Eugenio Pérez [this message]
2026-01-29  2:10   ` [PATCH 4/6] vduse: add VDUSE_GET_FEATURES ioctl Jason Wang
2026-01-29  8:03     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 5/6] vduse: add F_QUEUE_READY feature Eugenio Pérez
2026-01-29  2:12   ` Jason Wang
2026-01-29  6:26     ` Eugenio Perez Martin
2026-01-30  2:17       ` Jason Wang
2026-01-30  8:14         ` Eugenio Perez Martin
2026-02-03  4:00           ` Jason Wang
2026-02-03  7:27             ` Eugenio Perez Martin
2026-02-04  2:44               ` Jason Wang
2026-02-04  7:34                 ` Eugenio Perez Martin
2026-02-05  4:08                   ` Jason Wang
2026-02-05  6:38                     ` Eugenio Perez Martin
2026-01-28 12:45 ` [PATCH 6/6] vduse: advertise API V2 support Eugenio Pérez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260128124524.875271-5-eperezma@redhat.com \
    --to=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mcoqueli@redhat.com \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xieyongji@bytedance.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox