From nobody Tue Sep 2 15:37:27 2025 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 C9DC928850C for ; Fri, 6 Jun 2025 11:50: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=1749210629; cv=none; b=ML5wLa1NLn34/zc69HWXMKmoPSsZEJxrjHTSo6YoFsRXoYAjD0rc5BLPg2GLdQ2mX5YonJXHg3YsqkENdvyZSgiQ01L0ZRUL6FDMNRpSBSa5NhXYT72dhc3uBY7z7XsrmLzOTvvcUi0bT5yz1uPqZhuaB0UEAxhmV87OTWzil4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210629; c=relaxed/simple; bh=SyMEBMqoEegjVXM0Ur3SwKjQpuKBaC3i+d9aIcIqW2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WpuW7AbLNx+xPRJ7oqzlVqrlMWtFkzGHuDN55jUAq3Nu9/l8guZ/w2syORa4JhX/p/BBc09OE6oR0VGP9fITVoRg3d/z9vuDcSeMlQ7c3KSWpdBfkXG5uyuCn8DJUbpofJmRq3NtFCWOCoMY2BlfjGDbfI3Zn52LK98aSKwqv4M= 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=Wh3iZs6x; 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="Wh3iZs6x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210627; 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=vp49S0VL4Jqz0gpimx8bGKhznGhVA0Kv/wGqwICbM2I=; b=Wh3iZs6xnTB+r5aDObmceeYQ7N8tHF4yIziILNcnn+GG1eQGfdGuw0aG84MnO+arh/0SuC 289Keg0O7XqBEGRLA0kUoCD2CXMOMfOXlf/146qqXVvg4MsgAUUeN5cGDpcRC7/hUTZ07K DIpLklmaeVA5wZEzALA9ntdfFC2PGDY= 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-458-uKZZJwjONfurVKoo1DdWMw-1; Fri, 06 Jun 2025 07:50:24 -0400 X-MC-Unique: uKZZJwjONfurVKoo1DdWMw-1 X-Mimecast-MFC-AGG-ID: uKZZJwjONfurVKoo1DdWMw_1749210623 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 80F1019560B4; Fri, 6 Jun 2025 11:50:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 981FA19560B2; Fri, 6 Jun 2025 11:50:18 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 1/6] vduse: add v1 API definition Date: Fri, 6 Jun 2025 13:50:07 +0200 Message-ID: <20250606115012.1331551-2-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 This allows to define all functions checking the API version set by the userland device. 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 68a627d04afa..9a56d0416bfe 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -10,6 +10,10 @@ =20 #define VDUSE_API_VERSION 0 =20 +/* VQ groups and ASID support */ + +#define VDUSE_API_VERSION_1 1 + /* * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). * This is used for future extension. --=20 2.49.0 From nobody Tue Sep 2 15:37:27 2025 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 4F97A2882C2 for ; Fri, 6 Jun 2025 11:50:34 +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=1749210637; cv=none; b=aE0938p+SLLtiV1Hdr1Wb5FzKx4lf4LUlDApgd+Syz7OtnOil0htppDG1iNkgEazPipgaxCl+5QsX2PRXbGRZqnIKFX4hmeWMY+GM5l6aVS/mNo7Il9BBOzQLDO7lOQ5MalDiHF30n/12mHvWik6GjcjKhg1Byz3URecnMjCIvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210637; c=relaxed/simple; bh=UgsieFu3Kz0njZbZT/Zg810et6OCXfsW1n4LV9dgZgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WcRO5Kr9mWjesOucKNSCKwbbOCmCJecfygOO2lS7ZyhvbK1p1m5D+xi+Nq5U0hH74P0WF4uAVT/7/ma9CshwZp5K7L1AugvpH3b9hv80GAV/mEL6YuH0vlvfncQv/3C3QAS9CcGlVya7jS0sUDL3W/n1ZyoqPV108gLNydJ4kJE= 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=i6uoQw/Z; 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="i6uoQw/Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210634; 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=NZUnE9Fp7JTLv3YsV0naKvxGFvbyveDrK723yBnXOgQ=; b=i6uoQw/ZzVbOplaEtATgXAbXfXgobX9wbwe864CbPsSo9wyhVS711CvphK/b6BT/28hHPY RdToYRnlAcxIP/rUT7mIywIUIVq3rIykIxbVq5KMlJd36WNv+z4AzafTPLuxIe+N+Ax65e tft6v6bgiICibQw62ryt3GF0O7Cfigs= Received: from mx-prod-mc-02.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-5-g9yncyHAMdO1cDyUatHMvg-1; Fri, 06 Jun 2025 07:50:29 -0400 X-MC-Unique: g9yncyHAMdO1cDyUatHMvg-1 X-Mimecast-MFC-AGG-ID: g9yncyHAMdO1cDyUatHMvg_1749210628 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED08A195608B; Fri, 6 Jun 2025 11:50:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0B5AC19560B2; Fri, 6 Jun 2025 11:50:23 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 2/6] vduse: add vq group support Date: Fri, 6 Jun 2025 13:50:08 +0200 Message-ID: <20250606115012.1331551-3-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 The virtqueue group is the minimal set of virtqueues that must share an address space. And the address space identifier could only be attached to a specific virtqueue group. The virtqueue is attached to a virtqueue group for all the life of the device. During vDPA device allocation, the VDUSE device needs to report the number of virtqueue groups supported. At this moment only vhost_vdpa is able to do it. This helps to isolate the environments for the virtqueue that will not be assigned directly. E.g in the case of virtio-net, the control virtqueue will not be assigned directly to guest. As we need to back the vq groups with a struct device for the file operations, let's keep this number as low as possible at the moment: 2. We can back one VQ group with the vduse device and the other one with the vdpa device. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 44 +++++++++++++++++++++++++++++- include/uapi/linux/vduse.h | 17 +++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 6a9a37351310..6fa687bc4912 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -46,6 +46,11 @@ #define VDUSE_IOVA_SIZE (VDUSE_MAX_BOUNCE_SIZE + 128 * 1024 * 1024) #define VDUSE_MSG_DEFAULT_TIMEOUT 30 =20 +/* + * Let's make it 2 for simplicity. + */ +#define VDUSE_MAX_VQ_GROUPS 2 + #define IRQ_UNBOUND -1 =20 struct vduse_virtqueue { @@ -114,6 +119,7 @@ struct vduse_dev { u8 status; u32 vq_num; u32 vq_align; + u32 ngroups; struct vduse_umem *umem; struct mutex mem_lock; unsigned int bounce_size; @@ -592,6 +598,25 @@ static int vduse_vdpa_set_vq_state(struct vdpa_device = *vdpa, u16 idx, return 0; } =20 +static u32 vduse_get_vq_group(struct vdpa_device *vdpa, u16 idx) +{ + struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); + struct vduse_dev_msg msg =3D { 0 }; + int ret; + + if (dev->api_version < VDUSE_API_VERSION_1) + return 0; + + msg.req.type =3D VDUSE_GET_VQ_GROUP; + msg.req.vq_group.index =3D idx; + + ret =3D vduse_dev_msg_sync(dev, &msg); + if (ret) + return ret; + + return msg.resp.vq_group.num; +} + static int vduse_vdpa_get_vq_state(struct vdpa_device *vdpa, u16 idx, struct vdpa_vq_state *state) { @@ -789,6 +814,7 @@ static const struct vdpa_config_ops vduse_vdpa_config_o= ps =3D { .set_vq_cb =3D vduse_vdpa_set_vq_cb, .set_vq_num =3D vduse_vdpa_set_vq_num, .get_vq_size =3D vduse_vdpa_get_vq_size, + .get_vq_group =3D vduse_get_vq_group, .set_vq_ready =3D vduse_vdpa_set_vq_ready, .get_vq_ready =3D vduse_vdpa_get_vq_ready, .set_vq_state =3D vduse_vdpa_set_vq_state, @@ -1850,6 +1876,16 @@ 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; + if (dev->api_version >=3D 1) { + if (config->ngroups > VDUSE_MAX_VQ_GROUPS) { + pr_err("Not creating a VDUSE device with %u vq groups. Max: %u", + config->ngroups, VDUSE_MAX_VQ_GROUPS); + goto err_ngroups; + } + dev->ngroups =3D config->ngroups ?: 1; + } else { + dev->ngroups =3D 1; + } dev->name =3D kstrdup(config->name, GFP_KERNEL); if (!dev->name) goto err_str; @@ -1885,6 +1921,7 @@ static int vduse_create_dev(struct vduse_dev_config *= config, idr_remove(&vduse_idr, dev->minor); err_idr: kfree(dev->name); +err_ngroups: err_str: vduse_dev_destroy(dev); err: @@ -2003,13 +2040,18 @@ static struct vduse_mgmt_dev *vduse_mgmt; static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) { struct vduse_vdpa *vdev; + __u32 ngroups =3D 1; int ret; =20 if (dev->vdev) return -EEXIST; =20 + if (vdev->dev->api_version >=3D VDUSE_API_VERSION_1) + ngroups =3D vdev->dev->ngroups; + vdev =3D vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, - &vduse_vdpa_config_ops, 1, 1, name, true); + &vduse_vdpa_config_ops, ngroups, 1, name, + true); if (IS_ERR(vdev)) return PTR_ERR(vdev); =20 diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 9a56d0416bfe..a779bcddac58 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -45,7 +45,8 @@ struct vduse_dev_config { __u64 features; __u32 vq_num; __u32 vq_align; - __u32 reserved[13]; + __u32 ngroups; /* if VDUSE_API_VERSION >=3D 1 */ + __u32 reserved[12]; __u32 config_size; __u8 config[]; }; @@ -160,6 +161,16 @@ struct vduse_vq_state_packed { __u16 last_used_idx; }; =20 +/** + * struct vduse_vq_group - virtqueue group + * @num: Index of the virtqueue group + * @num: Group + */ +struct vduse_vq_group { + __u32 index; + __u32 num; +}; + /** * struct vduse_vq_info - information of a virtqueue * @index: virtqueue index @@ -182,6 +193,7 @@ struct vduse_vq_info { union { struct vduse_vq_state_split split; struct vduse_vq_state_packed packed; + struct vduse_vq_group group; }; __u8 ready; }; @@ -274,6 +286,7 @@ enum vduse_req_type { VDUSE_GET_VQ_STATE, VDUSE_SET_STATUS, VDUSE_UPDATE_IOTLB, + VDUSE_GET_VQ_GROUP, }; =20 /** @@ -328,6 +341,7 @@ struct vduse_dev_request { struct vduse_vq_state vq_state; struct vduse_dev_status s; struct vduse_iova_range iova; + struct vduse_vq_group vq_group; /* Only if vduse api version >=3D 1 */ __u32 padding[32]; }; }; @@ -350,6 +364,7 @@ struct vduse_dev_response { __u32 reserved[4]; union { struct vduse_vq_state vq_state; + struct vduse_vq_group vq_group; /* Only if vduse api version >=3D 1 */ __u32 padding[32]; }; }; --=20 2.49.0 From nobody Tue Sep 2 15:37:27 2025 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 A8E1C2882CD for ; Fri, 6 Jun 2025 11:50:37 +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=1749210639; cv=none; b=mbBq+vsHLToyV9I//7itQ70Ik86n6hWfwOpSwBNRht1EIwICMJxX6dGG4vgiXVpGcHRJTpInnNtBknMM0kHFc24ghIi13OyqtcC1LeIVkPr3zaZ3ibA9nk20YkkH2qaIiEvhPaXfto797Pw92HULSdh6Om1Y7AakUOR68QkOY9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210639; c=relaxed/simple; bh=JjnV/cMKZ21bR+kkecYTjDSU7m/Vn38S16UYMsTJD2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SgxjXeUe8SWI2UkM49RrIz3RRCEwCzgBF3kpjcPq7+GG7/F4jDC9uPZLLqUD40tJ3K8GT7M1Ql8lRyvhOJARTAkjYdmQ6JON7cAmTr8FH9okyUF9QK++lGWgehMMXen/7hOJ6SB27+tLib02vLYG5uB+GPa4vT/lIGIHk+/yueY= 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=PU+EfHpr; 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="PU+EfHpr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210636; 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=jKyGoqk8vynqsNeQjiRI+TmiQQKqLOuQiBp+LnnxBGc=; b=PU+EfHprpMMvio+TF53MV2XjYwN4wN/+FiFFcZU5tDQfvf7wttuO4djaOQ62+UTmCN2+DT JHL7vX/0KhpnQ58JBUWAO6mA4x39LJ6JxPiOqCx373wtll5vOn6w9dY4HZAszWCRW643pF 3txsUVjh6SWcxOl/I8kFRDokEt0ouOw= 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-49-70eA9zMkO6yJunHjYlTCow-1; Fri, 06 Jun 2025 07:50:33 -0400 X-MC-Unique: 70eA9zMkO6yJunHjYlTCow-1 X-Mimecast-MFC-AGG-ID: 70eA9zMkO6yJunHjYlTCow_1749210632 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 8890B1956046; Fri, 6 Jun 2025 11:50:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7768719560B2; Fri, 6 Jun 2025 11:50:28 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 3/6] vduse: add vq group asid support Date: Fri, 6 Jun 2025 13:50:09 +0200 Message-ID: <20250606115012.1331551-4-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 Make one IOTLB domain per address space, and allow the driver to assign each ASID to a vq group. Each address space via an dedicated identifier (ASID). During vDPA device allocation, the VDUSE device needs to report the number of address spaces supported. Then the vdpa driver is able to configure them. At this moment only vhost_vdpa is able to do it. This helps to isolate the environments for the virtqueue that will not be assigned directly. E.g in the case of virtio-net, the control virtqueue will not be assigned directly to guest. TODO: Ideally, umem should not be duplicated. But it is hard or impossible to refactor everything around one single umem. So should we continue with device specifying umem per vq group? Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 250 +++++++++++++++++++++-------- include/uapi/linux/vduse.h | 38 ++++- 2 files changed, 216 insertions(+), 72 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 6fa687bc4912..d51e4f26fe72 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -51,6 +51,11 @@ */ #define VDUSE_MAX_VQ_GROUPS 2 =20 +/* + * Let's make it 2 for simplicity. + */ +#define VDUSE_MAX_ASID 2 + #define IRQ_UNBOUND -1 =20 struct vduse_virtqueue { @@ -92,7 +97,7 @@ struct vduse_dev { struct vduse_vdpa *vdev; struct device *dev; struct vduse_virtqueue **vqs; - struct vduse_iova_domain *domain; + struct vduse_iova_domain *domain[VDUSE_MAX_ASID]; char *name; struct mutex lock; spinlock_t msg_lock; @@ -120,7 +125,8 @@ struct vduse_dev { u32 vq_num; u32 vq_align; u32 ngroups; - struct vduse_umem *umem; + u32 nas; + struct vduse_umem *umem[VDUSE_MAX_ASID]; struct mutex mem_lock; unsigned int bounce_size; struct mutex domain_lock; @@ -436,11 +442,14 @@ static __poll_t vduse_dev_poll(struct file *file, pol= l_table *wait) static void vduse_dev_reset(struct vduse_dev *dev) { int i; - struct vduse_iova_domain *domain =3D dev->domain; =20 /* The coherent mappings are handled in vduse_dev_free_coherent() */ - if (domain && domain->bounce_map) - vduse_domain_reset_bounce_map(domain); + for (i =3D 0; i < dev->nas; i++) { + struct vduse_iova_domain *domain =3D dev->domain[i]; + + if (domain && domain->bounce_map) + vduse_domain_reset_bounce_map(domain); + } =20 down_write(&dev->rwsem); =20 @@ -617,6 +626,23 @@ static u32 vduse_get_vq_group(struct vdpa_device *vdpa= , u16 idx) return msg.resp.vq_group.num; } =20 +static int vduse_set_group_asid(struct vdpa_device *vdpa, unsigned int gro= up, + unsigned int asid) +{ + struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); + struct vduse_dev_msg msg =3D { 0 }; + + if (dev->api_version < VDUSE_API_VERSION_1 || + group >=3D dev->ngroups || asid >=3D dev->nas) + return -EINVAL; + + msg.req.type =3D VDUSE_SET_VQ_GROUP_ASID; + msg.req.vq_group_asid.group =3D group; + msg.req.vq_group_asid.asid =3D asid; + + return vduse_dev_msg_sync(dev, &msg); +} + static int vduse_vdpa_get_vq_state(struct vdpa_device *vdpa, u16 idx, struct vdpa_vq_state *state) { @@ -788,13 +814,13 @@ static int vduse_vdpa_set_map(struct vdpa_device *vdp= a, struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); int ret; =20 - ret =3D vduse_domain_set_map(dev->domain, iotlb); + ret =3D vduse_domain_set_map(dev->domain[asid], iotlb); if (ret) return ret; =20 ret =3D vduse_dev_update_iotlb(dev, 0ULL, ULLONG_MAX); if (ret) { - vduse_domain_clear_map(dev->domain, iotlb); + vduse_domain_clear_map(dev->domain[asid], iotlb); return ret; } =20 @@ -837,6 +863,7 @@ static const struct vdpa_config_ops vduse_vdpa_config_o= ps =3D { .get_vq_affinity =3D vduse_vdpa_get_vq_affinity, .reset =3D vduse_vdpa_reset, .set_map =3D vduse_vdpa_set_map, + .set_group_asid =3D vduse_set_group_asid, .free =3D vduse_vdpa_free, }; =20 @@ -845,9 +872,12 @@ static void vduse_dev_sync_single_for_device(struct de= vice *dev, enum dma_data_direction dir) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; =20 - vduse_domain_sync_single_for_device(domain, dma_addr, size, dir); + for (int i =3D 0; i < vdev->nas; i++) { + struct vduse_iova_domain *domain =3D vdev->domain[i]; + + vduse_domain_sync_single_for_device(domain, dma_addr, size, dir); + } } =20 static void vduse_dev_sync_single_for_cpu(struct device *dev, @@ -855,9 +885,12 @@ static void vduse_dev_sync_single_for_cpu(struct devic= e *dev, enum dma_data_direction dir) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; =20 - vduse_domain_sync_single_for_cpu(domain, dma_addr, size, dir); + for (int i =3D 0; i < vdev->nas; i++) { + struct vduse_iova_domain *domain =3D vdev->domain[i]; + + vduse_domain_sync_single_for_cpu(domain, dma_addr, size, dir); + } } =20 static dma_addr_t vduse_dev_map_page(struct device *dev, struct page *page, @@ -866,7 +899,7 @@ static dma_addr_t vduse_dev_map_page(struct device *dev= , struct page *page, unsigned long attrs) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; + struct vduse_iova_domain *domain =3D vdev->domain[0]; =20 return vduse_domain_map_page(domain, page, offset, size, dir, attrs); } @@ -876,7 +909,7 @@ static void vduse_dev_unmap_page(struct device *dev, dm= a_addr_t dma_addr, unsigned long attrs) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; + struct vduse_iova_domain *domain =3D vdev->domain[0]; =20 return vduse_domain_unmap_page(domain, dma_addr, size, dir, attrs); } @@ -886,7 +919,7 @@ static void *vduse_dev_alloc_coherent(struct device *de= v, size_t size, unsigned long attrs) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; + struct vduse_iova_domain *domain =3D vdev->domain[0]; unsigned long iova; void *addr; =20 @@ -906,17 +939,25 @@ static void vduse_dev_free_coherent(struct device *de= v, size_t size, unsigned long attrs) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; + struct vduse_iova_domain *domain =3D vdev->domain[0]; =20 vduse_domain_free_coherent(domain, size, vaddr, dma_addr, attrs); } =20 +/* TODO check if this is correct */ static size_t vduse_dev_max_mapping_size(struct device *dev) { struct vduse_dev *vdev =3D dev_to_vduse(dev); - struct vduse_iova_domain *domain =3D vdev->domain; + size_t max_mapping_size =3D 0; + + for (int i =3D 0; i < vdev->nas; i++) { + struct vduse_iova_domain *domain =3D vdev->domain[i]; =20 - return domain->bounce_size; + if (domain->bounce_size > max_mapping_size) + max_mapping_size =3D domain->bounce_size; + } + + return max_mapping_size; } =20 static const struct dma_map_ops vduse_dev_dma_ops =3D { @@ -1054,31 +1095,32 @@ static int vduse_dev_queue_irq_work(struct vduse_de= v *dev, return ret; } =20 -static int vduse_dev_dereg_umem(struct vduse_dev *dev, +static int vduse_dev_dereg_umem(struct vduse_dev *dev, u32 asid, u64 iova, u64 size) { int ret; =20 mutex_lock(&dev->mem_lock); ret =3D -ENOENT; - if (!dev->umem) + if (!dev->umem[asid]) goto unlock; =20 ret =3D -EINVAL; - if (!dev->domain) + if (!dev->domain[asid]) goto unlock; =20 - if (dev->umem->iova !=3D iova || size !=3D dev->domain->bounce_size) + if (dev->umem[asid]->iova !=3D iova || + size !=3D dev->domain[asid]->bounce_size) goto unlock; =20 - vduse_domain_remove_user_bounce_pages(dev->domain); - unpin_user_pages_dirty_lock(dev->umem->pages, - dev->umem->npages, true); - atomic64_sub(dev->umem->npages, &dev->umem->mm->pinned_vm); - mmdrop(dev->umem->mm); - vfree(dev->umem->pages); - kfree(dev->umem); - dev->umem =3D NULL; + vduse_domain_remove_user_bounce_pages(dev->domain[asid]); + unpin_user_pages_dirty_lock(dev->umem[asid]->pages, + dev->umem[asid]->npages, true); + atomic64_sub(dev->umem[asid]->npages, &dev->umem[asid]->mm->pinned_vm); + mmdrop(dev->umem[asid]->mm); + vfree(dev->umem[asid]->pages); + kfree(dev->umem[asid]); + dev->umem[asid] =3D NULL; ret =3D 0; unlock: mutex_unlock(&dev->mem_lock); @@ -1086,7 +1128,7 @@ static int vduse_dev_dereg_umem(struct vduse_dev *dev, } =20 static int vduse_dev_reg_umem(struct vduse_dev *dev, - u64 iova, u64 uaddr, u64 size) + u32 asid, u64 iova, u64 uaddr, u64 size) { struct page **page_list =3D NULL; struct vduse_umem *umem =3D NULL; @@ -1094,14 +1136,14 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev, unsigned long npages, lock_limit; int ret; =20 - if (!dev->domain || !dev->domain->bounce_map || - size !=3D dev->domain->bounce_size || + if (!dev->domain[asid] || !dev->domain[asid]->bounce_map || + size !=3D dev->domain[asid]->bounce_size || iova !=3D 0 || uaddr & ~PAGE_MASK) return -EINVAL; =20 mutex_lock(&dev->mem_lock); ret =3D -EEXIST; - if (dev->umem) + if (dev->umem[asid]) goto unlock; =20 ret =3D -ENOMEM; @@ -1125,7 +1167,7 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev, goto out; } =20 - ret =3D vduse_domain_add_user_bounce_pages(dev->domain, + ret =3D vduse_domain_add_user_bounce_pages(dev->domain[asid], page_list, pinned); if (ret) goto out; @@ -1138,7 +1180,7 @@ static int vduse_dev_reg_umem(struct vduse_dev *dev, umem->mm =3D current->mm; mmgrab(current->mm); =20 - dev->umem =3D umem; + dev->umem[asid] =3D umem; out: if (ret && pinned > 0) unpin_user_pages(page_list, pinned); @@ -1181,26 +1223,42 @@ static long vduse_dev_ioctl(struct file *file, unsi= gned int cmd, =20 switch (cmd) { case VDUSE_IOTLB_GET_FD: { - struct vduse_iotlb_entry entry; + struct vduse_iotlb_entry_v2 entry =3D {}; + struct vduse_iotlb_entry entry_old; struct vhost_iotlb_map *map; struct vdpa_map_file *map_file; struct file *f =3D NULL; =20 ret =3D -EFAULT; - if (copy_from_user(&entry, argp, sizeof(entry))) - break; + if (dev->api_version >=3D VDUSE_API_VERSION_1) { + if (copy_from_user(&entry, argp, sizeof(entry))) + break; + } else { + if (copy_from_user(&entry_old, argp, + sizeof(entry_old))) + break; + + entry.offset =3D entry_old.offset; + entry.start =3D entry_old.start; + entry.last =3D entry_old.last; + entry.perm =3D entry_old.perm; + } =20 ret =3D -EINVAL; if (entry.start > entry.last) break; =20 + if (entry.asid >=3D dev->nas) + break; + mutex_lock(&dev->domain_lock); - if (!dev->domain) { + /* TODO accessing an array with idx from userspace, mitigations? */ + if (!dev->domain[entry.asid]) { mutex_unlock(&dev->domain_lock); break; } - spin_lock(&dev->domain->iotlb_lock); - map =3D vhost_iotlb_itree_first(dev->domain->iotlb, + spin_lock(&dev->domain[entry.asid]->iotlb_lock); + map =3D vhost_iotlb_itree_first(dev->domain[entry.asid]->iotlb, entry.start, entry.last); if (map) { map_file =3D (struct vdpa_map_file *)map->opaque; @@ -1210,7 +1268,7 @@ static long vduse_dev_ioctl(struct file *file, unsign= ed int cmd, entry.last =3D map->last; entry.perm =3D map->perm; } - spin_unlock(&dev->domain->iotlb_lock); + spin_unlock(&dev->domain[entry.asid]->iotlb_lock); mutex_unlock(&dev->domain_lock); ret =3D -EINVAL; if (!f) @@ -1360,12 +1418,18 @@ static long vduse_dev_ioctl(struct file *file, unsi= gned int cmd, break; =20 ret =3D -EINVAL; + /* TODO: Using asid from userspace, need to mitigate? */ if (!is_mem_zero((const char *)umem.reserved, - sizeof(umem.reserved))) + sizeof(umem.reserved)) || + !is_mem_zero((const char *)umem.reserved2, + sizeof(umem.reserved2)) || + (dev->api_version < VDUSE_API_VERSION_1 && + umem.asid !=3D 0) || + umem.asid >=3D dev->nas) break; =20 mutex_lock(&dev->domain_lock); - ret =3D vduse_dev_reg_umem(dev, umem.iova, + ret =3D vduse_dev_reg_umem(dev, umem.asid, umem.iova, umem.uaddr, umem.size); mutex_unlock(&dev->domain_lock); break; @@ -1378,15 +1442,23 @@ static long vduse_dev_ioctl(struct file *file, unsi= gned int cmd, break; =20 ret =3D -EINVAL; + /* TODO: Using asid from userspace, need to mitigate? */ if (!is_mem_zero((const char *)umem.reserved, - sizeof(umem.reserved))) + sizeof(umem.reserved)) || + !is_mem_zero((const char *)umem.reserved2, + sizeof(umem.reserved2)) || + (dev->api_version < VDUSE_API_VERSION_1 && + umem.asid !=3D 0) || + umem.asid >=3D dev->nas) break; + mutex_lock(&dev->domain_lock); - ret =3D vduse_dev_dereg_umem(dev, umem.iova, + ret =3D vduse_dev_dereg_umem(dev, umem.asid, umem.iova, umem.size); mutex_unlock(&dev->domain_lock); break; } + /* TODO can we merge this with GET_FD? */ case VDUSE_IOTLB_GET_INFO: { struct vduse_iova_info info; struct vhost_iotlb_map *map; @@ -1399,27 +1471,32 @@ static long vduse_dev_ioctl(struct file *file, unsi= gned int cmd, if (info.start > info.last) break; =20 + if (info.asid >=3D dev->nas) + break; + if (!is_mem_zero((const char *)info.reserved, sizeof(info.reserved))) break; =20 mutex_lock(&dev->domain_lock); - if (!dev->domain) { + /* TODO asid comes from userspace. mitigations? */ + if (!dev->domain[info.asid]) { mutex_unlock(&dev->domain_lock); break; } - spin_lock(&dev->domain->iotlb_lock); - map =3D vhost_iotlb_itree_first(dev->domain->iotlb, + spin_lock(&dev->domain[info.asid]->iotlb_lock); + map =3D vhost_iotlb_itree_first(dev->domain[info.asid]->iotlb, info.start, info.last); if (map) { info.start =3D map->start; info.last =3D map->last; info.capability =3D 0; - if (dev->domain->bounce_map && map->start =3D=3D 0 && - map->last =3D=3D dev->domain->bounce_size - 1) + if (dev->domain[info.asid]->bounce_map && + map->start =3D=3D 0 && + map->last =3D=3D dev->domain[info.asid]->bounce_size - 1) info.capability |=3D VDUSE_IOVA_CAP_UMEM; } - spin_unlock(&dev->domain->iotlb_lock); + spin_unlock(&dev->domain[info.asid]->iotlb_lock); mutex_unlock(&dev->domain_lock); if (!map) break; @@ -1444,8 +1521,13 @@ static int vduse_dev_release(struct inode *inode, st= ruct file *file) struct vduse_dev *dev =3D file->private_data; =20 mutex_lock(&dev->domain_lock); - if (dev->domain) - vduse_dev_dereg_umem(dev, 0, dev->domain->bounce_size); + for (int i =3D 0; i < dev->nas; i++) { + if (dev->domain[i]) { + vduse_dev_dereg_umem(dev, i, 0, + dev->domain[i]->bounce_size); + dev->domain[i] =3D NULL; + } + } mutex_unlock(&dev->domain_lock); spin_lock(&dev->msg_lock); /* Make sure the inflight messages can processed after reconncection */ @@ -1715,8 +1797,10 @@ static int vduse_destroy_dev(char *name) idr_remove(&vduse_idr, dev->minor); kvfree(dev->config); vduse_dev_deinit_vqs(dev); - if (dev->domain) - vduse_domain_destroy(dev->domain); + for (int i =3D 0; i < dev->nas; i++) { + if (dev->domain[i]) + vduse_domain_destroy(dev->domain[i]); + } kfree(dev->name); vduse_dev_destroy(dev); module_put(THIS_MODULE); @@ -1824,7 +1908,7 @@ static ssize_t bounce_size_store(struct device *devic= e, =20 ret =3D -EPERM; mutex_lock(&dev->domain_lock); - if (dev->domain) + if (dev->domain[0] && dev->domain[1]) goto unlock; =20 ret =3D kstrtouint(buf, 10, &bounce_size); @@ -1882,9 +1966,18 @@ static int vduse_create_dev(struct vduse_dev_config = *config, config->ngroups, VDUSE_MAX_VQ_GROUPS); goto err_ngroups; } + + if (config->nas > VDUSE_MAX_ASID) { + pr_err("Not creating a VDUSE device with %u asid. Max: %u", + config->nas, VDUSE_MAX_ASID); + goto err_nas; + } + dev->ngroups =3D config->ngroups ?: 1; + dev->nas =3D config->nas ?: 1; } else { dev->ngroups =3D 1; + dev->nas =3D 1; } dev->name =3D kstrdup(config->name, GFP_KERNEL); if (!dev->name) @@ -1923,6 +2016,7 @@ static int vduse_create_dev(struct vduse_dev_config *= config, kfree(dev->name); err_ngroups: err_str: +err_nas: vduse_dev_destroy(dev); err: return ret; @@ -2015,7 +2109,6 @@ static int vduse_open(struct inode *inode, struct fil= e *file) if (!control) return -ENOMEM; =20 - control->api_version =3D VDUSE_API_VERSION; file->private_data =3D control; =20 return 0; @@ -2040,17 +2133,15 @@ static struct vduse_mgmt_dev *vduse_mgmt; static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) { struct vduse_vdpa *vdev; - __u32 ngroups =3D 1; + __u32 ngroups =3D dev->ngroups; int ret; =20 if (dev->vdev) return -EEXIST; =20 - if (vdev->dev->api_version >=3D VDUSE_API_VERSION_1) - ngroups =3D vdev->dev->ngroups; - + /* TODO do we need to store ngroups and nas? vdpa device already store it= for us */ vdev =3D vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, - &vduse_vdpa_config_ops, ngroups, 1, name, + &vduse_vdpa_config_ops, ngroups, dev->nas, name, true); if (IS_ERR(vdev)) return PTR_ERR(vdev); @@ -2088,11 +2179,23 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev,= const char *name, return ret; =20 mutex_lock(&dev->domain_lock); - if (!dev->domain) - dev->domain =3D vduse_domain_create(VDUSE_IOVA_SIZE - 1, - dev->bounce_size); + ret =3D 0; + + /* TODO we could delay the creation of the domain */ + for (int i =3D 0; i < dev->nas; ++i) { + if (!dev->domain[i]) + dev->domain[i] =3D vduse_domain_create(VDUSE_IOVA_SIZE - 1, + dev->bounce_size); + if (!dev->domain[i]) { + ret =3D -ENOMEM; + for (int j =3D 0; j < i; ++j) + vduse_domain_destroy(dev->domain[j]); + goto err_domain; + } + } + mutex_unlock(&dev->domain_lock); - if (!dev->domain) { + if (ret =3D=3D -ENOMEM) { put_device(&dev->vdev->vdpa.dev); return -ENOMEM; } @@ -2101,13 +2204,22 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev,= const char *name, if (ret) { put_device(&dev->vdev->vdpa.dev); mutex_lock(&dev->domain_lock); - vduse_domain_destroy(dev->domain); - dev->domain =3D NULL; + for (int i =3D 0; i < dev->nas; i++) { + if (dev->domain[i]) { + vduse_domain_destroy(dev->domain[i]); + dev->domain[i] =3D NULL; + } + } mutex_unlock(&dev->domain_lock); return ret; } =20 return 0; + +err_domain: + /* TODO do I need to call put_device? */ + mutex_unlock(&dev->domain_lock); + return ret; } =20 static void vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *d= ev) diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index a779bcddac58..3a17a0b4e938 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -46,7 +46,8 @@ struct vduse_dev_config { __u32 vq_num; __u32 vq_align; __u32 ngroups; /* if VDUSE_API_VERSION >=3D 1 */ - __u32 reserved[12]; + __u32 nas; /* if VDUSE_API_VERSION >=3D 1 */ + __u32 reserved[11]; __u32 config_size; __u8 config[]; }; @@ -81,6 +82,17 @@ struct vduse_iotlb_entry { __u8 perm; }; =20 +struct vduse_iotlb_entry_v2 { + __u64 offset; + __u64 start; + __u64 last; + __u32 asid; +#define VDUSE_ACCESS_RO 0x1 +#define VDUSE_ACCESS_WO 0x2 +#define VDUSE_ACCESS_RW 0x3 + __u8 perm; +}; + /* * Find the first IOVA region that overlaps with the range [start, last] * and return the corresponding file descriptor. Return -EINVAL means the @@ -171,6 +183,16 @@ struct vduse_vq_group { __u32 num; }; =20 +/** + * struct vduse_vq_group - virtqueue group + @ @group: Index of the virtqueue group + * @asid: Address space ID of the group + */ +struct vduse_vq_group_asid { + __u32 group; + __u32 asid; +}; + /** * struct vduse_vq_info - information of a virtqueue * @index: virtqueue index @@ -231,7 +253,9 @@ struct vduse_vq_eventfd { * @uaddr: start address of userspace memory, it must be aligned to page s= ize * @iova: start of the IOVA region * @size: size of the IOVA region + * @asid: Address space ID of the IOVA region * @reserved: for future use, needs to be initialized to zero + * @reserved2: for future use, needs to be initialized to zero * * Structure used by VDUSE_IOTLB_REG_UMEM and VDUSE_IOTLB_DEREG_UMEM * ioctls to register/de-register userspace memory for IOVA regions @@ -240,7 +264,9 @@ struct vduse_iova_umem { __u64 uaddr; __u64 iova; __u64 size; - __u64 reserved[3]; + __u32 asid; + __u32 reserved[1]; + __u64 reserved2[2]; }; =20 /* Register userspace memory for IOVA regions */ @@ -264,7 +290,8 @@ struct vduse_iova_info { __u64 last; #define VDUSE_IOVA_CAP_UMEM (1 << 0) __u64 capability; - __u64 reserved[3]; + __u64 asid; /* Only if device API version >=3D 1 */ + __u64 reserved[2]; }; =20 /* @@ -287,6 +314,7 @@ enum vduse_req_type { VDUSE_SET_STATUS, VDUSE_UPDATE_IOTLB, VDUSE_GET_VQ_GROUP, + VDUSE_SET_VQ_GROUP_ASID, }; =20 /** @@ -342,6 +370,8 @@ struct vduse_dev_request { struct vduse_dev_status s; struct vduse_iova_range iova; struct vduse_vq_group vq_group; /* Only if vduse api version >=3D 1 */ + /* Only if vduse api version >=3D 1 */ + struct vduse_vq_group_asid vq_group_asid; __u32 padding[32]; }; }; @@ -365,6 +395,8 @@ struct vduse_dev_response { union { struct vduse_vq_state vq_state; struct vduse_vq_group vq_group; /* Only if vduse api version >=3D 1 */ + /* Only if vduse api version >=3D 1 */ + struct vduse_vq_group_asid vq_group_asid; __u32 padding[32]; }; }; --=20 2.49.0 From nobody Tue Sep 2 15:37:27 2025 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 02D83288C0C for ; Fri, 6 Jun 2025 11:50:41 +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=1749210643; cv=none; b=KLWokj9py66DAyVr1nO2D/fSGOr2b2KutxJ7bWPykWXkfCltMqVch/ei+vpaiAC8DKittqbCDNQWKdh912fdXKexMOoHKTenpR8Nsr3ufhX71smBJM1uPKmXNh6DoFz3ckmDQlWWzhzfjgN+hP+tH366Y5aDvQFeDHq+ud+w1DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210643; c=relaxed/simple; bh=89wxZ3oO4ZH6cCK6mN0JW+yXN+Rr112wSDrBDCPMLAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pqnghTORDRIhLBeSEWuv0NzLQq3nE8xcrKTtFAeI0U4hvGFlBEualC4B22rCIUIAis/8qcBzukv/uwD6EYoDxCaihQGUFWgGups4/euKMj1Jr15xJqxpszH5gyVNxQ5FFJdAclXTDnI+Ee8kAgbOGnG53WNgU+uOsAD2eTedD5c= 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=gq0GpwSs; 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="gq0GpwSs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210641; 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=iretUVp3t9mkYjP8n+n5q4o6QbDi952+SZy4PuCS9O8=; b=gq0GpwSs0q3CnYywnp1WrT2bbxjMscAbJ4S6EJJyX8LhIjNUuxlFJ4P7DZFL/RA4sNvcmW xxBanp3lI1yxYmRVrONCNdLEQHRbwQpz/xrzg9O04X1YwvZe4g67w0Moez0SCYPZCfK2Kh vq4M1/TVrDyxpeQbptE/WSq0ORUQwRg= Received: from mx-prod-mc-01.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-544-UV_7ViRdPh6HGemABi3etQ-1; Fri, 06 Jun 2025 07:50:38 -0400 X-MC-Unique: UV_7ViRdPh6HGemABi3etQ-1 X-Mimecast-MFC-AGG-ID: UV_7ViRdPh6HGemABi3etQ_1749210637 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD9E5195608E; Fri, 6 Jun 2025 11:50:36 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DA36C195E74A; Fri, 6 Jun 2025 11:50:32 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 4/6] vduse: send update_iotlb_v2 message Date: Fri, 6 Jun 2025 13:50:10 +0200 Message-ID: <20250606115012.1331551-5-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 This new version reports the translation ASID. Needed so the device can support it. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 14 ++++++++++---- include/uapi/linux/vduse.h | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index d51e4f26fe72..151c6d133e76 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -317,7 +317,7 @@ static int vduse_dev_set_status(struct vduse_dev *dev, = u8 status) return vduse_dev_msg_sync(dev, &msg); } =20 -static int vduse_dev_update_iotlb(struct vduse_dev *dev, +static int vduse_dev_update_iotlb(struct vduse_dev *dev, u32 asid, u64 start, u64 last) { struct vduse_dev_msg msg =3D { 0 }; @@ -326,8 +326,14 @@ static int vduse_dev_update_iotlb(struct vduse_dev *de= v, return -EINVAL; =20 msg.req.type =3D VDUSE_UPDATE_IOTLB; - msg.req.iova.start =3D start; - msg.req.iova.last =3D last; + if (dev->api_version < VDUSE_API_VERSION_1) { + msg.req.iova.start =3D start; + msg.req.iova.last =3D last; + } else { + msg.req.iova_v2.start =3D start; + msg.req.iova_v2.last =3D last; + msg.req.iova_v2.asid =3D asid; + } =20 return vduse_dev_msg_sync(dev, &msg); } @@ -818,7 +824,7 @@ static int vduse_vdpa_set_map(struct vdpa_device *vdpa, if (ret) return ret; =20 - ret =3D vduse_dev_update_iotlb(dev, 0ULL, ULLONG_MAX); + ret =3D vduse_dev_update_iotlb(dev, asid, 0ULL, ULLONG_MAX); if (ret) { vduse_domain_clear_map(dev->domain[asid], iotlb); return ret; diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h index 3a17a0b4e938..a7c979591b2e 100644 --- a/include/uapi/linux/vduse.h +++ b/include/uapi/linux/vduse.h @@ -349,6 +349,12 @@ struct vduse_iova_range { __u64 last; }; =20 +struct vduse_iova_range_v2 { + __u64 start; + __u64 last; + __u32 asid; +}; + /** * struct vduse_dev_request - control request * @type: request type @@ -369,6 +375,7 @@ struct vduse_dev_request { struct vduse_vq_state vq_state; struct vduse_dev_status s; struct vduse_iova_range iova; + struct vduse_iova_range_v2 iova_v2; struct vduse_vq_group vq_group; /* Only if vduse api version >=3D 1 */ /* Only if vduse api version >=3D 1 */ struct vduse_vq_group_asid vq_group_asid; --=20 2.49.0 From nobody Tue Sep 2 15:37:27 2025 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 77D4D288525 for ; Fri, 6 Jun 2025 11:50:45 +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=1749210648; cv=none; b=UkBkodnGcIHE7g/8AVBaEUGYTQFqS6i2Jq4MhfT9vrZLKkVm/gpGi1hpGlTFK6kXit+wo6EXcR5YjPURI4cvDAyOk738crqZebSu6z3/TeLsXd4p387jBie3TH3k1M6Vik49mI9ERqzYhk6/CBRi0NpW9UVGxzNFpxkxjVleSmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210648; c=relaxed/simple; bh=rnfH/LG4SOFZzUgJOleYnhArYVI1bRk/qn39vRK7QZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rrH9D84cnqlBGrY9UOe7RfVESv/mHc9G7WCHIg23GAXIhk6dFhkV9hjbDRBMjs8tvjyid1nzRlN/TbRBqhfdfJBLcTUu4+rmkiDd49XTujRu2HferZT5lzMpujTonV66QheIg/okRGdbKGtAeegz/iSVdCr/yq3NXV1sAK2BaUQ= 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=Bjcbq0BS; 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="Bjcbq0BS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210644; 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=WqxHAv8IthusYfEbserIn/Muun9xU0nuRy3hl8B74K8=; b=Bjcbq0BSt44u5XYbHaWsoONDdl4f8HFlFle2yueVY8qpWa0zbfh1H+S8aNkFgmPNhksOaT rH3pxuMxzmGrM6qsn5wxmKN0h1VKIWL8/McRxsFeOKSFolSRsVAn9zlc0hyXm4PVYRr24f t2rzK1hoPoFmXBA6uW7a76iuu+VjZbA= Received: from mx-prod-mc-02.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-689-_pxwGeO9Pl6BItm5ke8y2Q-1; Fri, 06 Jun 2025 07:50:43 -0400 X-MC-Unique: _pxwGeO9Pl6BItm5ke8y2Q-1 X-Mimecast-MFC-AGG-ID: _pxwGeO9Pl6BItm5ke8y2Q_1749210642 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C85371956086; Fri, 6 Jun 2025 11:50:41 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E363B19560B2; Fri, 6 Jun 2025 11:50:37 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 5/6] vduse: reset group asid in reset Date: Fri, 6 Jun 2025 13:50:11 +0200 Message-ID: <20250606115012.1331551-6-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 Is the expected behavior with vdpa_sim and mlx. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 151c6d133e76..5f0032df43b8 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -445,6 +445,9 @@ static __poll_t vduse_dev_poll(struct file *file, poll_= table *wait) return mask; } =20 +static int vduse_set_group_asid(struct vdpa_device *vdpa, unsigned int gro= up, + unsigned int asid); + static void vduse_dev_reset(struct vduse_dev *dev) { int i; @@ -457,6 +460,9 @@ static void vduse_dev_reset(struct vduse_dev *dev) vduse_domain_reset_bounce_map(domain); } =20 + for (i =3D 0; i < dev->ngroups; i++) + vduse_set_group_asid(&dev->vdev->vdpa, i, 0); + down_write(&dev->rwsem); =20 dev->status =3D 0; --=20 2.49.0 From nobody Tue Sep 2 15:37:27 2025 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 67B1A288525 for ; Fri, 6 Jun 2025 11:50:51 +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=1749210652; cv=none; b=OBCEt9w9WatgPby4UeYRsm3A+1udoyKXF+1JY3+NY7aM3a8oQ02x4IhUAm6beNH2NdWxAW9nlraTxCfaPpS2l0DPRIEm/HsfrSZE0nu9psSa/I1ei0lMJPnSPFK7BXUhq+Th7KjxmD53+Q3tHCruyavu4sWsATGvEEStDsmjNow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749210652; c=relaxed/simple; bh=0jY8Ix2Pgzh4AnL8c2nW59L0ilTMJI8ols79dNPFWFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eGVzCWfHlcpOY7qlA5pwN29tMG3vqEoJHRmLIQ5tG0DyjqtBSIKufThbzafyPI+R5FsCrAFzjsMYiRlpOV2f5POMXkX/mhP6DzrF6XAN8pJpDvocd6kbcSXxSqJ6nYVKv9sI1XTao1YhJeypLoTi28YZOMCopRFl9exUzqSUHHM= 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=Eayl0aW7; 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="Eayl0aW7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749210650; 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=47KURE2uwvmeWrjGi3t/o6J482tK7X78iwNAEhTsM28=; b=Eayl0aW7NSER+Q+oZDwBwqTkbqLaHO200EKwFKs0zZoeWArrp8vpX7Jzw0Ku7tTYG5n9fF kJnPgOnRaISBYor+WkfeNrhDZC1NK8OgFCyhs2Gz9AYFCaoCuawp421B8H80/gD9rqrRpN 39PvwS5mzBt9TcCKumfYyh9y3OxhSgc= Received: from mx-prod-mc-06.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-102-tUGiYcpJNWaGjGguxhJ0HQ-1; Fri, 06 Jun 2025 07:50:47 -0400 X-MC-Unique: tUGiYcpJNWaGjGguxhJ0HQ-1 X-Mimecast-MFC-AGG-ID: tUGiYcpJNWaGjGguxhJ0HQ_1749210646 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A7E818009B3; Fri, 6 Jun 2025 11:50:46 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.33.72]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 51CFE19560B2; Fri, 6 Jun 2025 11:50:42 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: jasowang@redhat.com Cc: Yongji Xie , Cindy Lu , linux-kernel@vger.kernel.org, =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stefano Garzarella , Stefan Hajnoczi , Maxime Coquelin , "Michael S. Tsirkin" , virtualization@lists.linux.dev, Xuan Zhuo , Laurent Vivier Subject: [RFC 6/6] vduse: bump version number Date: Fri, 6 Jun 2025 13:50:12 +0200 Message-ID: <20250606115012.1331551-7-eperezma@redhat.com> In-Reply-To: <20250606115012.1331551-1-eperezma@redhat.com> References: <20250606115012.1331551-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.12 So VDUSE devices can use the new features Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 5f0032df43b8..aa2d25caa933 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -2054,7 +2054,7 @@ static long vduse_ioctl(struct file *file, unsigned i= nt cmd, break; =20 ret =3D -EINVAL; - if (api_version > VDUSE_API_VERSION) + if (api_version > VDUSE_API_VERSION_1) break; =20 ret =3D 0; @@ -2121,6 +2121,7 @@ static int vduse_open(struct inode *inode, struct fil= e *file) if (!control) return -ENOMEM; =20 + control->api_version =3D VDUSE_API_VERSION_1; file->private_data =3D control; =20 return 0; --=20 2.49.0