Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp253732rdd; Tue, 9 Jan 2024 03:11:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmktIFEX4e/TD2CeY9sQQ1Uzcqi1DpCGA1Rj0rvNRQtSGIpFSxsFodXP+A0D68MvfOyWih X-Received: by 2002:a17:902:b58a:b0:1d4:c445:c705 with SMTP id a10-20020a170902b58a00b001d4c445c705mr4631504pls.26.1704798684192; Tue, 09 Jan 2024 03:11:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704798684; cv=none; d=google.com; s=arc-20160816; b=lLUZhNM7yKkVKUdKEADIFrCoK7e7X18BPFoBGa2pmUn18xxXlO0qj991Y9qMdlUyuz zxo8iF4rs5XiFHXXl7FG2g3A9m3hU75tPXdqxSA8KnzNB4lfrnbNSIGbQ3u7+rc/n1+6 Chf3cs27/OkG3pWFUXU9+JJcaSbUJpYxB7+7YvY2HZJlho5PHot59I5Pnd7uZPPHreQg d+/HsykxEKVKGK6WCQpNWKk//DZunhi9G/dPScPjdG/Ssm3NrzQgTvNf62krckYOq6do 0ieEEZ4kx8O0sY+X9Z36P/rrzQ/zjq1YfPobNhEznGdM+hTe7QqtQ6w1/KzCZZ3K93o4 GTHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BtHMmViNUHkBlyTq+yA+WPFdZXCFstzRWGlzClhIP3k=; fh=PsGcTskB5yyh6wdt5mtIwU0t1QS6fyE7OUFROq1ott8=; b=K8K0t5/QyTh9BfEOZjk/0KHjSg3yoQLr73ukizk6D/b1v0YgonZ5QFGxA1Wa6RWtGR qx91n5tBcuWoOL/oc/3ywmAyX+bW/OyTtd9Y/lJocaA9sj8A4sXhYwikLMNKt3hMWebM 9mYJaETB46GH+h0vDlBj+qKZjuy+HKRUz02fY/StApXKmA94nctokAtX9/vMa+y8Aa+n EGHhzH3aJva07bOiCSFU0DAWZAYpJDiaruqQML5fZ99G3rkNRzBYl/sWx0NyM2EpKfAl dTCgL2nf6utYkPfuXNYXDYqWuGRj3CKUETt/Nt7umV67nDaoCgwMWEy2vwTslETcpFea rIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PQQ+FcLb; spf=pass (google.com: domain of linux-kernel+bounces-20746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20746-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n6-20020a170902e54600b001d4ca3c0f2fsi1326220plf.304.2024.01.09.03.11.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 03:11:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PQQ+FcLb; spf=pass (google.com: domain of linux-kernel+bounces-20746-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20746-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 28696B24265 for ; Tue, 9 Jan 2024 11:11:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7F1C37156; Tue, 9 Jan 2024 11:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PQQ+FcLb" 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 AB4EA36B09 for ; Tue, 9 Jan 2024 11:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704798636; 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=BtHMmViNUHkBlyTq+yA+WPFdZXCFstzRWGlzClhIP3k=; b=PQQ+FcLbHwkJG6CNAgPZ5klHmYh9NWAsoMhD0iY+kxTvzgz31sLMMANCnGJ5MALLydrU9X fAkllvPTa0pEFNigmdBH0y0L+pSNLbM5ciWLlU3mEGDLbgDA8+S+3e/mtVF1ev5Nakzr6r 1xjYFB8SJtHoQUAUTSXbOeOV0TojwzA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-wdiVT_Z_ML2xKOwrFtk9Cw-1; Tue, 09 Jan 2024 06:10:33 -0500 X-MC-Unique: wdiVT_Z_ML2xKOwrFtk9Cw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1AE47106CFF5; Tue, 9 Jan 2024 11:10:33 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 194B4492BE6; Tue, 9 Jan 2024 11:10:30 +0000 (UTC) From: Maxime Coquelin To: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, xieyongji@bytedance.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, david.marchand@redhat.com, lulu@redhat.com Cc: Maxime Coquelin , =?UTF-8?q?Eugenio=20P=C3=A9rez?= Subject: [PATCH v7 1/3] vduse: validate block features only with block devices Date: Tue, 9 Jan 2024 12:10:23 +0100 Message-ID: <20240109111025.1320976-2-maxime.coquelin@redhat.com> In-Reply-To: <20240109111025.1320976-1-maxime.coquelin@redhat.com> References: <20240109111025.1320976-1-maxime.coquelin@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: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 This patch is preliminary work to enable network device type support to VDUSE. As VIRTIO_BLK_F_CONFIG_WCE shares the same value as VIRTIO_NET_F_HOST_TSO4, we need to restrict its check to Virtio-blk device type. Acked-by: Jason Wang Reviewed-by: Xie Yongji Reviewed-by: Eugenio PĂ©rez Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 0ddd4b8abecb..a5af6d4077b8 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1671,13 +1671,14 @@ static bool device_is_allowed(u32 device_id) return false; } -static bool features_is_valid(u64 features) +static bool features_is_valid(struct vduse_dev_config *config) { - if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) + if (!(config->features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM))) return false; /* Now we only support read-only configuration space */ - if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE)) + if ((config->device_id == VIRTIO_ID_BLOCK) && + (config->features & BIT_ULL(VIRTIO_BLK_F_CONFIG_WCE))) return false; return true; @@ -1704,7 +1705,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config) if (!device_is_allowed(config->device_id)) return false; - if (!features_is_valid(config->features)) + if (!features_is_valid(config)) return false; return true; -- 2.43.0