From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 032BF1BE863; Tue, 2 Jul 2024 17:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719941348; cv=none; b=ajGEuY4l/85pyR0xpdWU6KxwqL/IX4e84sWDPOswdDHP163bSOI8VeIKPT7y8ohPEfmeUzkj+vq/6sabxdFisjAgkPbLej0l1kx7yyLXpmtRIQhqcZrVsKHCo0hBBkSwBX6r1+3Dl3GyLoCLDLq3g5tujQntqfRwRyRVr+DtXyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719941348; c=relaxed/simple; bh=qM2hZh2pShhVp4P/fF14ttdlHU2OcZ9Xxw8vqg+Hl0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WaWcPctw21fxaCCY73hnHyFIO7OM80VDpKa/am3iWhlXRfMH1WUKhHYAtcwMVUFn1d7APhNsbsISlzWL0WXlLciSrF/a57h2swFT6PiPdMcI0LvdsQqdDk6c3bsFY/scfEVY/e+29LQdqpsKo2Bo+Lx/lloevHhUAkXd1//1GA0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0IeYGNP1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0IeYGNP1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BACDC116B1; Tue, 2 Jul 2024 17:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719941347; bh=qM2hZh2pShhVp4P/fF14ttdlHU2OcZ9Xxw8vqg+Hl0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0IeYGNP1KSquMqQTf3ZKs9gvwXJhpsDgMOOsUpF55VNqZcUXQ0hS5gGOJwMAqOr75 NhrMXsKCdLusJbR8HJ1lWR82AqWze58bfIWiMyRFdJvW7ShGrgg7VvaEwctUP/+qlI PSfmHZ6Kmts2QPQprJ1BBq2yLRRV+hzWjNDp17mY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jason Wang , Xie Yongji , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Maxime Coquelin , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 6.1 038/128] vduse: validate block features only with block devices Date: Tue, 2 Jul 2024 19:03:59 +0200 Message-ID: <20240702170227.673758243@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240702170226.231899085@linuxfoundation.org> References: <20240702170226.231899085@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maxime Coquelin [ Upstream commit a115b5716fc9a64652aa9cb332070087178ffafa ] 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 Message-Id: <20240109111025.1320976-2-maxime.coquelin@redhat.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- 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 edcd74cc4c0f7..cb35a76146b39 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1416,13 +1416,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; @@ -1449,7 +1450,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