From nobody Sat Apr 18 06:54:42 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07FCE33D4F5 for ; Tue, 10 Feb 2026 08:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711972; cv=none; b=UZU5yywUPK0I+BWQdWaApmsLriMDp2ZLRvWEls41fFKJnqNoq7s4qtKKrVMpwyj5ZPrZbqXlQKIOfpZYqla8AyCWJ0iyp1QNqVyqht0IxHDjEwdxxANkoPAYED0SLF+daHWRmxCjV97QSYF591rPANx/YLMWaEdcz3PboMeTXsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711972; c=relaxed/simple; bh=3mS3+X9vmE7OTqs95H53lzU4UWMzZeS/2AcTH4YfG/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pmG9XCtzqB9e9ZGLEGMZwdNX8B1BMcAKAZKKydoTXwJjLlMhd+ufgjqJnnsdKfvpm99QQRwLoLHFLglN18qPznOvLo2sFtaKoAxRPw/OLSbTRx1ySEOH4vpSmNovPQ987kWWK6+xlhuZLZJFh3wPTG4DxSMvDZ0WF7wL+LgkJnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XYilMIOJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XYilMIOJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770711970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+OGNrV7q92SEw+n+ligigLv3apRvr4chwlhOB9DrX4=; b=XYilMIOJB8yyHqBW374Za5JmuhaB8FNbqjlfR0KlICbLBu2QCn++F+Mv8uAgZd3y9D4P4f mw3q8fr8xj5cw11FipI7fQHl9kjxaNPldYy/jZF3vpnomrRYposQD8JFRz2OhCfm0F8VbE gDnPRrLclKhtS2tbirWtuO3QTql5XVw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-JkV4_cS7MC6xoH4kX6KjtA-1; Tue, 10 Feb 2026 03:26:06 -0500 X-MC-Unique: JkV4_cS7MC6xoH4kX6KjtA-1 X-Mimecast-MFC-AGG-ID: JkV4_cS7MC6xoH4kX6KjtA_1770711965 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C6A219560AD; Tue, 10 Feb 2026 08:26:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.173]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B306A1956056; Tue, 10 Feb 2026 08:26:01 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Jason Wang , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH v2 1/5] vduse: store control device pointer Date: Tue, 10 Feb 2026 09:25:50 +0100 Message-ID: <20260210082554.1582553-2-eperezma@redhat.com> In-Reply-To: <20260210082554.1582553-1-eperezma@redhat.com> References: <20260210082554.1582553-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 This helps log the errors in next patches. The alternative is to perform a linear search for it with class_find_device_by_devt(class, devt), as device_destroy do for cleaning. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 405d59610f76..d1da7c15d98b 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -164,6 +164,7 @@ static DEFINE_IDR(vduse_idr); =20 static dev_t vduse_major; static struct cdev vduse_ctrl_cdev; +static const struct device *vduse_ctrl_dev; static struct cdev vduse_cdev; static struct workqueue_struct *vduse_irq_wq; static struct workqueue_struct *vduse_irq_bound_wq; @@ -2396,7 +2397,6 @@ static void vduse_mgmtdev_exit(void) static int vduse_init(void) { int ret; - struct device *dev; =20 ret =3D class_register(&vduse_class); if (ret) @@ -2413,9 +2413,9 @@ static int vduse_init(void) if (ret) goto err_ctrl_cdev; =20 - dev =3D device_create(&vduse_class, NULL, vduse_major, NULL, "control"); - if (IS_ERR(dev)) { - ret =3D PTR_ERR(dev); + vduse_ctrl_dev =3D device_create(&vduse_class, NULL, vduse_major, NULL, "= control"); + if (IS_ERR(vduse_ctrl_dev)) { + ret =3D PTR_ERR(vduse_ctrl_dev); goto err_device; } =20 --=20 2.53.0 From nobody Sat Apr 18 06:54:42 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2E5733CEA2 for ; Tue, 10 Feb 2026 08:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711975; cv=none; b=BhaHB07Qw3CqHD3A/C391q7ncG0o1diXUVwKvEBo2ZkP5GOpmsP6XC0K87eR/q0ELwuAkjupjYddu6xgY0XVDB3TvaHdzfhVZJkGf3u/td8awYMffnr3Lo33Vd+VwGoNhx+4b1TOxZTsRJ2kw9Ob3AoeMz5u+cB3zLc3pJ5nQCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711975; c=relaxed/simple; bh=uFpL5eRW8+htLVAVbGFETpVE+6W1D2CxV0yn7T6mBEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O58niRsaCz/38npNSFMILyjzkd4wIDjF2No+btS4L14UNfh/SK/O0MQj3F74OgTTTofeqw/iqjP7cmdfQysCMhxE0JGMACbfnwTbe5QYTgpSny7XgRRekzDtdfibYta3bHGa9XhmnL9U1XvYr13W5QUYnB9VXNkiho8U4m3dmkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EXx+ATOM; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EXx+ATOM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770711973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ukQsl7MiUaGkU01iV0sC+F/eoBfXFXSkK4DaVtbp3Yw=; b=EXx+ATOM5d1Xu01o9Y0sYbb3+QZwDX8KPv5syVtipJSrdZpXJ7LysigoRGjqbqWED3KAcu Zze+QNkvixWhbe9CiKvzxphkjQ0H3wtDnt0PwVXYoDMz1kFCP6TJhmI1DjJiKSoRJwPjND pNv7ZGtLy5f1Pvc/5sxaEnPwkxNEKE4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-VTgWqw49PEqIwa33Z1R_LQ-1; Tue, 10 Feb 2026 03:26:10 -0500 X-MC-Unique: VTgWqw49PEqIwa33Z1R_LQ-1 X-Mimecast-MFC-AGG-ID: VTgWqw49PEqIwa33Z1R_LQ_1770711969 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8196A19560AA; Tue, 10 Feb 2026 08:26:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.173]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5B491956053; Tue, 10 Feb 2026 08:26:05 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Jason Wang , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH v2 2/5] vduse: Add API v2 definition Date: Tue, 10 Feb 2026 09:25:51 +0100 Message-ID: <20260210082554.1582553-3-eperezma@redhat.com> In-Reply-To: <20260210082554.1582553-1-eperezma@redhat.com> References: <20260210082554.1582553-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Introduce the definition for VDUSE API V2. This version serves as a gateway for feature negotiation. The kernel uses this version to determine if the userspace device supports feature flags. Devices that do not explicitly negotiate API V2 will be blocked from querying available VDUSE features, ensuring backward compatibility. The next patches implement the new feature incrementally, only enabling the VDUSE device to set the V2 API version by the end of the series. Signed-off-by: Eugenio P=C3=A9rez --- include/uapi/linux/vduse.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 361eea511c21..27832d46084c 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -14,6 +14,10 @@ =20 #define VDUSE_API_VERSION_1 1 =20 +/* Features support */ + +#define VDUSE_API_VERSION_2 2 + /* * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). * This is used for future extension. --=20 2.53.0 From nobody Sat Apr 18 06:54:42 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21BCF33D4F0 for ; Tue, 10 Feb 2026 08:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711980; cv=none; b=tVaRJgL+FDX7N6ecbOOhdo5RmIwS6hY6yNSY2omJQ44WeIyf79s7uzwm5RvwUB12UfZYSmwh2KQcVsnOV0cczLs2Z5APqf3o5WAl2JZjDTsuGNISw7RqIGPbX/DQepBWYkuh1WxhJ0XzBLTIxQOkLs8ExWGF1OGghGwhCkCbIdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711980; c=relaxed/simple; bh=74MZVn7IxdvrPRI+5RAG0362lJCruAXzOxMjv+8PuFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iAwbxnouvp+/y1R+vDZRW/Hjm6qtLPa7AnmBMrrPZaz1g+3geL86tAhzAmDztdTwJeQ9ROumiVBjqfF1L8W1JtTB38+WwMpKh4jdksNXY1KxLOF5/sqjgVLzl9STHJWCR/QqZ1DIbryfRawzqDUIxsrB8MjEVphST0/bcwvICdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MmIsZfKJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MmIsZfKJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770711978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HXkbIk+MRQpozZHZOxnmkVlermPLHnywx/svL09mSpM=; b=MmIsZfKJyrjsAEe6zk1HKoBO1LGW4Q6K0Y64dXAKJVPWXZY1h9lBzTxIY1DNZk+jlaUJnB IHdP1zpBv4NpvLoPeAnXHMe5qL/kZVZXB3XMZmp9JNWF4pgtqvAOPY4S1JpXG9Ig5LFyol GoK3K7FkvrGbUaJzcqPGT3xWvFLR5og= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-DdA4cB3WMzmlkC4ACyfiOQ-1; Tue, 10 Feb 2026 03:26:15 -0500 X-MC-Unique: DdA4cB3WMzmlkC4ACyfiOQ-1 X-Mimecast-MFC-AGG-ID: DdA4cB3WMzmlkC4ACyfiOQ_1770711974 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9FFD51955DC3; Tue, 10 Feb 2026 08:26:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.173]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07AF41956053; Tue, 10 Feb 2026 08:26:09 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Jason Wang , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH v2 3/5] vduse: add VDUSE_GET_FEATURES ioctl Date: Tue, 10 Feb 2026 09:25:52 +0100 Message-ID: <20260210082554.1582553-4-eperezma@redhat.com> In-Reply-To: <20260210082554.1582553-1-eperezma@redhat.com> References: <20260210082554.1582553-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Add an ioctl to allow VDUSE instances to query the available features supported by the kernel module. Signed-off-by: Eugenio P=C3=A9rez --- 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. --- v2: * return -EINVAL if ioctl called with version < 2, so userland visible reply is kept (Jason). --- 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/vd= use_dev.c index d1da7c15d98b..7458cbaed4c7 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -52,6 +52,9 @@ =20 #define IRQ_UNBOUND -1 =20 +/* Supported VDUSE features */ +static const uint64_t vduse_features; + /* * VDUSE instance have not asked the vduse API version, so assume 0. * @@ -1947,6 +1950,19 @@ static bool vduse_validate_config(struct vduse_dev_c= onfig *config, sizeof(config->reserved))) return false; =20 + 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; @@ -2207,6 +2223,18 @@ static long vduse_ioctl(struct file *file, unsigned = int cmd, ret =3D 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 =3D -EINVAL; + break; + } + + ret =3D put_user(vduse_features, (u64 __user *)argp); + break; + default: ret =3D -EINVAL; break; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 27832d46084c..8898d9daa777 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 >=3D 1 */ __u32 nas; /* if VDUSE_API_VERSION >=3D 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]) =20 +/* Get the VDUSE supported features */ +#define VDUSE_GET_FEATURES _IOR(VDUSE_BASE, 0x04, __u64) + /* The ioctls for VDUSE device (/dev/vduse/$NAME) */ =20 /** --=20 2.53.0 From nobody Sat Apr 18 06:54:42 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 253E933D4F0 for ; Tue, 10 Feb 2026 08:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711984; cv=none; b=E9ndD31LSkNdk4pGgqOYQW6TZsOaTpVYSP/4dMqtCvF3zZ1TAAleVU0bf6xZdRVsTkLZYRSsck4xVnuJqSvqqBbxOP2sz6v9rSD+heZcN1cRYMoaoCntV0szcmgIivW1U6UeFk5n31305QMhhZrxp6Loma1BLxqXBa84Yo1t6Qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711984; c=relaxed/simple; bh=unqhqVHp7bZXZEdJI4VwNyUYZjmIkrfqvaHxOJZwfYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YreyZ1yIO4XqUfNs+XhCjnfNtxO4J3eYO0fIgOh/j+jtjcgHKofw+bJIz4TkIQDXH3gdATIgkcud4c6FBMNYCak7F+d0RpI0hCzEHYW7oRzsKSFbEdKQl+rmHfK8Nrmy03Xh7QHprhDIidBIUzYxaPemlQ5N2Xsqc259+ScRFUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LoFsUK4t; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LoFsUK4t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770711982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuzb/x/zpg3bCMsL7dSGMWU2Krr95sWPDBHBtOin3lU=; b=LoFsUK4tVmVfgtvKnCznX51hDPnIrUGbjOtw6/z3lySfEShupWpCXhhYvWPqr1Z8sDiC0e rF5Jt27YsKv7o7JKpUUlQCBlL5u147zaPJYAuB/7Be4XwET+d9MBwxtGYxlWK9yGJqEpY4 cKg27ijZYX0uJFyMBAtW6cvjPLLpk9I= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-ywtaJkyyN7mN6DVkZKkhug-1; Tue, 10 Feb 2026 03:26:19 -0500 X-MC-Unique: ywtaJkyyN7mN6DVkZKkhug-1 X-Mimecast-MFC-AGG-ID: ywtaJkyyN7mN6DVkZKkhug_1770711978 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1FCE11955F23; Tue, 10 Feb 2026 08:26:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.173]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 568121956053; Tue, 10 Feb 2026 08:26:13 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Jason Wang , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH v2 4/5] vduse: advertise API V2 support Date: Tue, 10 Feb 2026 09:25:53 +0100 Message-ID: <20260210082554.1582553-5-eperezma@redhat.com> In-Reply-To: <20260210082554.1582553-1-eperezma@redhat.com> References: <20260210082554.1582553-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Advertise VDUSE API V2 support to userspace. With the necessary infrastructure and feature flags in place, VDUSE devices can now opt-in to the new API and utilize the VDUSE_F_QUEUE_READY feature. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 7458cbaed4c7..39e115b8bf44 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -2168,7 +2168,7 @@ static long vduse_ioctl(struct file *file, unsigned i= nt cmd, switch (cmd) { case VDUSE_GET_API_VERSION: if (control->api_version =3D=3D VDUSE_API_VERSION_NOT_ASKED) - control->api_version =3D VDUSE_API_VERSION_1; + control->api_version =3D VDUSE_API_VERSION_2; ret =3D put_user(control->api_version, (u64 __user *)argp); break; case VDUSE_SET_API_VERSION: { @@ -2179,7 +2179,7 @@ static long vduse_ioctl(struct file *file, unsigned i= nt cmd, break; =20 ret =3D -EINVAL; - if (api_version > VDUSE_API_VERSION_1) + if (api_version > VDUSE_API_VERSION_2) break; =20 ret =3D 0; --=20 2.53.0 From nobody Sat Apr 18 06:54:42 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4451833CEA2 for ; Tue, 10 Feb 2026 08:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711988; cv=none; b=hR7Nvy0ym/UgRzhZoH0iBsR4F8clBRQMMPRfmXl/GNn8bdMz6FR09l3Qu+UKzD8vphOLBWIxswYctfV53b3kLhn/xJHSO3DpfSUv8yS/nSErcqCFoe2+ql2bJmyLCsdGQBe8GCRCMDq4KiM91tU6/XwiqhXD71opxRsLp5a5T04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770711988; c=relaxed/simple; bh=G2r8WqiREUW+2jJzyeP9wUiTiglWnV0YXunzqZmXlj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okYdKryFAnm7Xwi9Jw0zCk1A8RL51nkCtOnBxVTrPmIrx4FevIM9wN5IpZQDHZPGkxJA0AZuaYFyYDzSNNcqUNoqjhS41A3iWwMutJii8Tbvqwux0NtjaSZF/0FzUMZ48gAVSHhI+mJsfh7Vg5YZEAu5V+oe1rII+hGw6XHK9MM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FyR5Ae8R; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FyR5Ae8R" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770711986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQ85lh3hgGge5muoa+9ltiWnErqCfrrQ6Voxp1y4QXw=; b=FyR5Ae8RCnhI5GoEjuJLVr9BRfULH7dV9ONvud1DLSKTrfz9H1Hmnqez4w3+JhXVTRy4Kd /wYMlfhbBFonRNsENsAhFfdkVzoQVPM7D0ZSfRvNRhDHo4XnQmvAa2kBogo8cGDvou7mbL xOtj2o8kzEMH1sFWGpisMMNXPeehPHs= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-JW9wPPa2PCWprVqSV22T4g-1; Tue, 10 Feb 2026 03:26:23 -0500 X-MC-Unique: JW9wPPa2PCWprVqSV22T4g-1 X-Mimecast-MFC-AGG-ID: JW9wPPa2PCWprVqSV22T4g_1770711982 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 548A91800370; Tue, 10 Feb 2026 08:26:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.173]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9AB8C1956053; Tue, 10 Feb 2026 08:26:18 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin" Cc: Cindy Lu , Jason Wang , Laurent Vivier , Xuan Zhuo , Maxime Coquelin , linux-kernel@vger.kernel.org, Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , virtualization@lists.linux.dev Subject: [PATCH v2 5/5] vduse: add F_QUEUE_READY feature Date: Tue, 10 Feb 2026 09:25:54 +0100 Message-ID: <20260210082554.1582553-6-eperezma@redhat.com> In-Reply-To: <20260210082554.1582553-1-eperezma@redhat.com> References: <20260210082554.1582553-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Add the VDUSE_F_QUEUE_READY feature flag. This allows the kernel module to explicitly signal userspace when a specific virtqueue has been enabled. In scenarios like Live Migration of VirtIO net devices, the dataplane starts after the control virtqueue allowing QEMU to apply configuration in the destination device. Signed-off-by: Eugenio P=C3=A9rez --- v2: * Fix comment of vduse_dev_request.vq_ready * Set vq_ready before sending the message to the VDUSE userland instance, avoiding the need for SMP sync after receiving the message. --- drivers/vdpa/vdpa_user/vduse_dev.c | 28 +++++++++++++++++++++++++++- include/uapi/linux/vduse.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 39e115b8bf44..59d9c4718d86 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -9,6 +9,7 @@ */ =20 #include "linux/virtio_net.h" +#include #include #include #include @@ -53,7 +54,7 @@ #define IRQ_UNBOUND -1 =20 /* Supported VDUSE features */ -static const uint64_t vduse_features; +static const uint64_t vduse_features =3D BIT_U64(VDUSE_F_QUEUE_READY); =20 /* * VDUSE instance have not asked the vduse API version, so assume 0. @@ -120,6 +121,7 @@ struct vduse_dev { char *name; struct mutex lock; spinlock_t msg_lock; + u64 vduse_features; u64 msg_unique; u32 msg_timeout; wait_queue_head_t waitq; @@ -601,8 +603,29 @@ static void vduse_vdpa_set_vq_ready(struct vdpa_device= *vdpa, { struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); struct vduse_virtqueue *vq =3D dev->vqs[idx]; + struct vduse_dev_msg msg =3D { 0 }; + int r; =20 vq->ready =3D ready; + + if (!(dev->vduse_features & BIT_U64(VDUSE_F_QUEUE_READY))) + return; + + msg.req.type =3D VDUSE_SET_VQ_READY; + msg.req.vq_ready.num =3D idx; + msg.req.vq_ready.ready =3D !!ready; + + r =3D vduse_dev_msg_sync(dev, &msg); + + if (r < 0) { + dev_dbg(&vdpa->dev, "device refuses to set vq %u ready %u", + idx, ready); + + /* We can't do better than break the device in this case */ + spin_lock(&dev->msg_lock); + vduse_dev_broken(dev); + spin_unlock(&dev->msg_lock); + } } =20 static bool vduse_vdpa_get_vq_ready(struct vdpa_device *vdpa, u16 idx) @@ -2091,6 +2114,9 @@ static int vduse_create_dev(struct vduse_dev_config *= config, dev->device_features =3D config->features; dev->device_id =3D config->device_id; dev->vendor_id =3D config->vendor_id; + dev->vduse_features =3D config->vduse_features; + dev_dbg(vduse_ctrl_dev, "Creating device %s with features 0x%llx", + config->name, config->vduse_features); =20 dev->nas =3D (dev->api_version < VDUSE_API_VERSION_1) ? 1 : config->nas; dev->as =3D kcalloc(dev->nas, sizeof(dev->as[0]), GFP_KERNEL); diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 8898d9daa777..d39734cef6d3 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -18,6 +18,9 @@ =20 #define VDUSE_API_VERSION_2 2 =20 +/* The VDUSE instance expects a request for vq ready */ +#define VDUSE_F_QUEUE_READY 0 + /* * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). * This is used for future extension. @@ -334,6 +337,7 @@ enum vduse_req_type { VDUSE_SET_STATUS, VDUSE_UPDATE_IOTLB, VDUSE_SET_VQ_GROUP_ASID, + VDUSE_SET_VQ_READY, }; =20 /** @@ -381,6 +385,15 @@ struct vduse_iova_range_v2 { __u32 padding; }; =20 +/** + * struct vduse_vq_ready - Virtqueue ready request message + * @num: Virtqueue number + */ +struct vduse_vq_ready { + __u32 num; + __u32 ready; +}; + /** * struct vduse_dev_request - control request * @type: request type @@ -391,6 +404,7 @@ struct vduse_iova_range_v2 { * @iova: IOVA range for updating * @iova_v2: IOVA range for updating if API_VERSION >=3D 1 * @vq_group_asid: ASID of a virtqueue group + * @vq_ready: Virtqueue ready request * @padding: padding * * Structure used by read(2) on /dev/vduse/$NAME. @@ -408,6 +422,10 @@ struct vduse_dev_request { */ struct vduse_iova_range_v2 iova_v2; struct vduse_vq_group_asid vq_group_asid; + + /* Only if VDUSE_F_QUEUE_READY is negotiated */ + struct vduse_vq_ready vq_ready; + __u32 padding[32]; }; }; --=20 2.53.0