Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1121119rdb; Fri, 20 Oct 2023 09:00:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtjjRmVF+AacKOqmfpU7V4WGowaHjA4BwzyPIY0UeabCOIHwgTm2eN089f40R9qIOFaldC X-Received: by 2002:a05:6a00:990:b0:690:c887:8cd8 with SMTP id u16-20020a056a00099000b00690c8878cd8mr2411245pfg.32.1697817611476; Fri, 20 Oct 2023 09:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697817611; cv=none; d=google.com; s=arc-20160816; b=M2silIlNVan2od9uiUCuWafLBS6IYzfgsOmVOUhR1FKwlTNUV+/1IG49rrW3WMh/a5 5Rys8dNYdQDtBvgnppZMeHMn0rjQr4HDN6eKB94hwBYdxtv7usmVDMq0ZpZZTubyA4Nw ISVJA+3AiiQ2sQcMjwi2ZEq9HtSRE16M+GRs8dIEyXSLmo24WEX8OVRRH0nwD34Iv/TQ epXtsgacjywp9M3Gf3f3D294P8L5PfUrGuMUSMdnecl6bc0eRfgyXQAZxMFyNs2b+pAR VysYPUZ/UjW8wAZW2QgVOdUGdjDwp62svntH4ulgB6zDnyjDzuZRajUo6qO6fgkLNGon YoxA== 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=sJDKpQQy665XvGZPky5UtXAeHywtQ/JigxzuJqzayEo=; fh=DW2mHD/f0kRN+01V+Z9as8p7OnC0swQlfBH91pgf6/A=; b=gGW/pZ7dEc14s8NgT2ay0Dfgt8f3YwhnNlxlwgPjxyKuUa4bulLo9Kj5piDctaJQbc uh91kyF4Sgl+3G48mXldHtCcHpS73PL4oxbPF9GoaCDG/zQee9AofT1IQXY7BhAfMdt/ 09l5a/qNGitfjGC4hpVsrZDGzkCg8J5dOn9sEvDL6thBh8j5JmGkntl099LI0BrRmbU2 ktYbDByPypo2l5Wv0vGs59y7HJW5KP++eRQs6rsec9JACtgG3BbAF4NtEe5xN7tlT+ky JeIxmZKroyvitQYTWlY3sa3F9uVhKlHWCs/npmTjOCNcfC/ayfP+wraoLQw5RxaeaTZw yTbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5ybDBf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id r31-20020a63205f000000b00565e42df278si2041479pgm.759.2023.10.20.08.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:00:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5ybDBf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id D7427842C68A; Fri, 20 Oct 2023 08:59:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377827AbjJTP71 (ORCPT + 99 others); Fri, 20 Oct 2023 11:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377825AbjJTP7Z (ORCPT ); Fri, 20 Oct 2023 11:59:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B61AB3 for ; Fri, 20 Oct 2023 08:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697817520; 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=sJDKpQQy665XvGZPky5UtXAeHywtQ/JigxzuJqzayEo=; b=h5ybDBf3gXe7Q0eb0xYrkIs5InhwZO5XftGD+RvPnrTJiVJbM7xbD1NMsdGLMDoaTPznQY 2Zqp1Ig0xPMmkvnyDpyh4U2lVF9+UOHIigxw0wov/Ejoud9X2jSrr4aQ2e1oErh58GIEW3 zNhwDrMEee3HD07kVYL0EHrxGm1Km+g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636--OQOfImDP0iRRlu1vp9QdA-1; Fri, 20 Oct 2023 11:58:36 -0400 X-MC-Unique: -OQOfImDP0iRRlu1vp9QdA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C98808C7EC1; Fri, 20 Oct 2023 15:58:35 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAB7D8CF2; Fri, 20 Oct 2023 15:58:32 +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 2/4] vduse: enable Virtio-net device type Date: Fri, 20 Oct 2023 17:58:17 +0200 Message-ID: <20231020155819.24000-3-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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 08:59:47 -0700 (PDT) This patch adds Virtio-net device type to the supported devices types. Initialization fails if the device does not support VIRTIO_F_VERSION_1 feature, in order to guarantee the configuration space is read-only. Acked-by: Jason Wang Reviewed-by: Xie Yongji Signed-off-by: Maxime Coquelin --- 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/vduse_dev.c index 5b3879976b3d..73ad3b7efd8e 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -142,6 +142,7 @@ static struct workqueue_struct *vduse_irq_bound_wq; static u32 allowed_device_id[] = { VIRTIO_ID_BLOCK, + VIRTIO_ID_NET, }; static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa) @@ -1672,6 +1673,10 @@ static bool features_is_valid(struct vduse_dev_config *config) (config->features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))) return false; + if ((config->device_id == VIRTIO_ID_NET) && + !(config->features & (1ULL << VIRTIO_F_VERSION_1))) + return false; + return true; } @@ -2027,6 +2032,7 @@ static const struct vdpa_mgmtdev_ops vdpa_dev_mgmtdev_ops = { static struct virtio_device_id id_table[] = { { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID }, + { VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID }, { 0 }, }; -- 2.41.0