Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4630715rdb; Tue, 12 Dec 2023 05:18:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqKfhkiOSiq1Lgzq17eTeenWORWnccesgjHPgJVoyQeCZouLkk+sYfS5evKcPReT5HcXS0 X-Received: by 2002:a05:6e02:1649:b0:35d:59a2:2b2 with SMTP id v9-20020a056e02164900b0035d59a202b2mr9404920ilu.82.1702387098009; Tue, 12 Dec 2023 05:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702387097; cv=none; d=google.com; s=arc-20160816; b=XG8WUhkiZSJfz0KY7nC7gCMyyImK5UUy6xi/EWxjJPXOSqCXmOkfpcuxrTXxMpj2vw UuKGzgumdTQf0kQvSwpARZECwAQMcy/SrLPx6deyeCPv7UDPM1hOH6+YSg93JgscFHKK O/cWzErxI8F88Mq7lPJpX8L3AXDbt73kkTevGMzCs2LLiB6/58y233XVqJm2yUry3Mo2 mdUM4fFdUzsPq5sFl/dy4CKTpc10jTWtRObQfLeQZQIahmQJOIA5tVNyPdYMvw7UFFnE EBjjgqRncK7oXj/kKvaEYlvDi+LW4RyxBf//AZ9BUKwQ0x1yruPZKEqZ/Q6neJZoHk+5 dHPw== 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=o0LIMgKiGBHNSKD8IIuTa7bPbj2RQDP2uV1SsEiFHOg=; fh=LxmBIMHLWtCjcf7wsP7T1D32SQqzEfF7erhVR43RAg4=; b=tdN28XJkEiMjaV3Inm3O5jprDwQ7TNuJ7roEwQ7ZCDkjcLEkFLxIsi2VzTZJENLD/H Ytk1fXBWUtB93PHRRPlysO3dtZNoChrD6dPjLMiFzKPvWHn+Yu7bCbnDRkeIUH7+wqEm aN0XzP0MzYlj05PmyL1DDgp7IcmgtFA8xfPkvOPodbPOPyu2giR5RvKPuO4vifKzJrua VEyk35huTOZIxnuXqzs4Viajnc2rLn5Gq8Tu2Chmm9QcPNufhiZuJ+iZgXmM/XvImq+L cerp5eSPeR7JPzmz8+aiVnWhYP3KP2tLu84kivd7x+8L1b4Ci7H2b2UlBqVlprb5Rb7/ gReQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SPhjUlnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j7-20020a654287000000b005c69bfbde6dsi7903850pgp.202.2023.12.12.05.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 05:18:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SPhjUlnG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 076F0804C53D; Tue, 12 Dec 2023 05:18:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376700AbjLLNRv (ORCPT + 99 others); Tue, 12 Dec 2023 08:17:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376689AbjLLNRa (ORCPT ); Tue, 12 Dec 2023 08:17:30 -0500 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 844041A8 for ; Tue, 12 Dec 2023 05:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702387054; 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=o0LIMgKiGBHNSKD8IIuTa7bPbj2RQDP2uV1SsEiFHOg=; b=SPhjUlnGPqs5kDa4l/waamJHx4odZztdVWqqSr+hKSIy7FmPAffxUtUr7AnSD0tYOZXg7Y bHEfT/Muz7z2d3XGkRbZ7evl4Zs/A+mXfqhL+6zHPZTHhwaFXYW4zgHde1YIHGaPx03Xiq 92gJRhc2DNAppavSelxALj7MvV0lz0Y= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-Grc6b-i-Ngq40wcOj_AIMg-1; Tue, 12 Dec 2023 08:17:30 -0500 X-MC-Unique: Grc6b-i-Ngq40wcOj_AIMg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 E213D28EC10B; Tue, 12 Dec 2023 13:17:29 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3E4E1121306; Tue, 12 Dec 2023 13:17:26 +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, casey@schaufler-ca.com Cc: Maxime Coquelin Subject: [PATCH v5 3/4] vduse: enable Virtio-net device type Date: Tue, 12 Dec 2023 14:17:11 +0100 Message-ID: <20231212131712.1816324-4-maxime.coquelin@redhat.com> In-Reply-To: <20231212131712.1816324-1-maxime.coquelin@redhat.com> References: <20231212131712.1816324-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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,T_SCC_BODY_TEXT_LINE 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]); Tue, 12 Dec 2023 05:18:15 -0800 (PST) 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 fe4b5c8203fd..fa62825be378 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -166,6 +166,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) @@ -1706,6 +1707,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; } @@ -2068,6 +2073,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.43.0