From nobody Wed Dec 17 17:41:45 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 455CC15853B for ; Thu, 2 Oct 2025 10:35:58 +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=1759401359; cv=none; b=XdbKYI4s+JlOLz6BPOOtfLQW+wSvFvFDx2KYfMuUqTVlC+0mcELU/0BGXQyPhV4wwYJcPGfmtfQFiyCUiEL0DNbridpK68bnMw0HKUzuiN8TtOyR32VEfzrbweUvtTWolZPULVcLhOuEhZkVO1MS/jW0pgGlbIcMzmU2YBKkWgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759401359; c=relaxed/simple; bh=7+ztxRKxAfTPyADGja6l4vqIG/Vh6uhOBdwDSsoFRzk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GyisNXsFh7PHXdpInV6prwxtatxMoYyIwLF6ucWJd3oKKW69VwxVIRvWbmMwjeTM0MGdVNrec1vMm3RtKvdkXRq2n/VyBMRcLM2hwH7TTASBJzkxEJXliTXIq9KAUK2o1rwfyak+31ZFZjADzMdJZpRQnccLqNJu0jjQZm2E9WU= 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=ABXx8kVL; 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="ABXx8kVL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759401357; 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=d9AeJgoJorYjJ5/QVKVbM47WJUmzhAen8815b/MXP28=; b=ABXx8kVLujuJWuqkCzChe2xFvO/ysIyYD9rOescqx4dUYqA7T6m/tDiLJVKgP6RPKoYdKg 0Yd/j9Jy8hwT1s+SF5JciewLQ6sDf+BzlY20RcNhLmzg9JJyhCL/v7bWOURyajWvQbdv0G KdVl5kohDMB5em6597NzSb4M3ayLJh0= 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-2-kpqWOQIlPgurbQBmK7d8GQ-1; Thu, 02 Oct 2025 06:35:54 -0400 X-MC-Unique: kpqWOQIlPgurbQBmK7d8GQ-1 X-Mimecast-MFC-AGG-ID: kpqWOQIlPgurbQBmK7d8GQ_1759401352 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 79FE319560AE; Thu, 2 Oct 2025 10:35:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.208]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B87E30001B5; Thu, 2 Oct 2025 10:35:46 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com Cc: Laurent Vivier , Stefano Garzarella , Dragos Tatulea DE , Cindy Lu , Maxime Coquelin , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Yongji Xie , jasowang@redhat.com, Xuan Zhuo , linux-kernel@vger.kernel.org, Jonah Palmer , Si-Wei Liu , virtualization@lists.linux.dev, =?UTF-8?q?Be=C3=B1at=20Gartzia=20Arruabarrena?= Subject: [RFC 1/2] vduse: support feature provisioning Date: Thu, 2 Oct 2025 12:35:36 +0200 Message-ID: <20251002103537.308717-2-eperezma@redhat.com> In-Reply-To: <20251002103537.308717-1-eperezma@redhat.com> References: <20251002103537.308717-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.4.1 on 10.30.177.4 This patch implements features provisioning for vduse devices. This allows the device provisioner to clear the features exposed by the userland device, so the driver never see them. The intended use case is to provision more than one different device with the same feature set, allowing live migration between them. The device addition validates the provisioned features to be a subset of the parent features, as the rest of the backends. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/vdpa_user/vduse_dev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 6c74282d5721..ef8fc795cfeb 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -121,6 +121,7 @@ struct vduse_dev { bool connected; u64 api_version; u64 device_features; + u64 supported_features; u64 driver_features; u32 device_id; u32 vendor_id; @@ -698,7 +699,7 @@ static u64 vduse_vdpa_get_device_features(struct vdpa_d= evice *vdpa) { struct vduse_dev *dev =3D vdpa_to_vduse(vdpa); =20 - return dev->device_features; + return dev->supported_features; } =20 static int vduse_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 fe= atures) @@ -2256,13 +2257,22 @@ struct vduse_mgmt_dev { =20 static struct vduse_mgmt_dev *vduse_mgmt; =20 -static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) +static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name, + const struct vdpa_dev_set_config *config) { struct vduse_vdpa *vdev; =20 if (dev->vdev) return -EEXIST; =20 + if (config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) { + if (config->device_features & ~dev->device_features) + return -EINVAL; + dev->supported_features =3D config->device_features; + } else { + dev->supported_features =3D dev->device_features; + } + vdev =3D vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, &vduse_vdpa_config_ops, &vduse_map_ops, dev->ngroups, dev->nas, name, true); @@ -2289,7 +2299,7 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, c= onst char *name, mutex_unlock(&vduse_lock); return -EINVAL; } - ret =3D vduse_dev_init_vdpa(dev, name); + ret =3D vduse_dev_init_vdpa(dev, name, config); mutex_unlock(&vduse_lock); if (ret) return ret; @@ -2376,6 +2386,7 @@ static int vduse_mgmtdev_init(void) vduse_mgmt->mgmt_dev.id_table =3D id_table; vduse_mgmt->mgmt_dev.ops =3D &vdpa_dev_mgmtdev_ops; vduse_mgmt->mgmt_dev.device =3D &vduse_mgmt->dev; + vduse_mgmt->mgmt_dev.config_attr_mask =3D BIT_ULL(VDPA_ATTR_DEV_FEATURES); ret =3D vdpa_mgmtdev_register(&vduse_mgmt->mgmt_dev); if (ret) device_unregister(&vduse_mgmt->dev); --=20 2.51.0