Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1121996rdb; Fri, 20 Oct 2023 09:01:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyNO+dDOO5eaZTWtRKsjC8ErGqMC6nVv4MdQW5w7y/Aip6j2PZtZ4tHYIuMV5oaKQHE+F/ X-Received: by 2002:a17:90a:130c:b0:274:7db1:f50f with SMTP id h12-20020a17090a130c00b002747db1f50fmr3111091pja.15.1697817669551; Fri, 20 Oct 2023 09:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697817669; cv=none; d=google.com; s=arc-20160816; b=J1CEj7KmtIyI13IcdnSWDEvOa5CUVNsMLWFbNu/Zye4+lBPyrtcPyojroCJ/55yJUL l/qLwg4baJdDxwCBR6Gm3J6oRVoBEcQgbSmSXY8DLy2RE7CnDt2cIvu2mnHWPSDUW6kd UA0Jzgk7oSRfKyLkRf6x6STnGqopOak3UA0u08VcaDpMEetJDcDtxIP23MroxQfyLeNz qFA2yMVTtpWBe/haWVBn6ZbHJRQBcklN9F791zu0T3xowmqjxYBz4dD/92rJBPlHx+2l 15ISAQbL/Juqp6LRaH6G2owmpIlinWamexcnFnZ6GSWvXjiF0NA6iXJRR5hYt/apsq1/ 5G2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PrVd5hNLS1wjnMKJG4uMD0VRG9l+SsuhqjwmjWwDMM4=; fh=DW2mHD/f0kRN+01V+Z9as8p7OnC0swQlfBH91pgf6/A=; b=aDOv2MgbVOH4oZAbZopBmbm4le3gcNtRCh5NhWZdG1jyhlfKg2hzeW0emkjDSJ1B04 bQsg6MUosDSOEfO/L6iTFgrFtKyWwPzcmItnzCkNFlHFsk/aUUH7xAjq5rkHM9JBTKCl oaImCn0uI7BcXJ/DHohMcs8Rrpk6JSuTEapc44vJL1PSg5IWwwBowOhEdYYp7JAC98p9 rxizdrm1IEJzxpQ0Jl208pv310kk/u+iEPOy4k99n85QYQst4iRjfMDZzPJVl1wW0qB9 70Mhl+fQrx4tcWQr/fJB9ajon/JSHPn9mY34xNsMFmtV0IvJdGOSCAqy0XvDzI/DjwAz nFqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gde7rFo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id gd22-20020a17090b0fd600b0027d61342674si2284994pjb.70.2023.10.20.09.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:01:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gde7rFo1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E0267809B706; Fri, 20 Oct 2023 09:00:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377850AbjJTQAL (ORCPT + 99 others); Fri, 20 Oct 2023 12:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377835AbjJTQAK (ORCPT ); Fri, 20 Oct 2023 12:00:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170DED73 for ; Fri, 20 Oct 2023 08:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697817529; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PrVd5hNLS1wjnMKJG4uMD0VRG9l+SsuhqjwmjWwDMM4=; b=Gde7rFo1I77vKSXaaT6sCNbmBUeBnF5lf95Jkywj5jC6D1SlATsHPnTjL4lp+0sMSR5Tml qdLn/I8vvxMrnuaVAkDfHSy4Oi/BZIB3m3ffB8iinLglApo/cyylBG5sn1LteW62naksYL H/geAOVcthe7iHqEEZc5InodH8V8V/0= 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-609-oJ_RXLPwNCCswWlW3aS1YA-1; Fri, 20 Oct 2023 11:58:33 -0400 X-MC-Unique: oJ_RXLPwNCCswWlW3aS1YA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 6CED2857D07; Fri, 20 Oct 2023 15:58:32 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61637503B; Fri, 20 Oct 2023 15:58:29 +0000 (UTC) From: Maxime Coquelin To: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, xieyongji@bytedance.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, david.marchand@redhat.com, lulu@redhat.com Cc: Maxime Coquelin Subject: [PATCH v4 1/4] vduse: validate block features only with block devices Date: Fri, 20 Oct 2023 17:58:16 +0200 Message-ID: <20231020155819.24000-2-maxime.coquelin@redhat.com> In-Reply-To: <20231020155819.24000-1-maxime.coquelin@redhat.com> References: <20231020155819.24000-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 09:00:20 -0700 (PDT) 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 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 df7869537ef1..5b3879976b3d 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1662,13 +1662,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 & (1ULL << 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 & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))) return false; return true; @@ -1695,7 +1696,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.41.0