From patchwork Wed Jul 5 10:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 116057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1763481vqx; Wed, 5 Jul 2023 03:22:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEhViJlBeGSPlgLXMfB+fOdwYEAoxgomZ92b0opayoYa8+b3Dqriy+7vUQzqOKpulGTcBEd X-Received: by 2002:aa7:88d6:0:b0:668:8545:cbeb with SMTP id k22-20020aa788d6000000b006688545cbebmr20538970pff.15.1688552544836; Wed, 05 Jul 2023 03:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552544; cv=none; d=google.com; s=arc-20160816; b=B/lQPSJoBJFyYPM3V5ES3I36VIy+A5erif5xiMMpdVOyAdWk9SOeeGZ0xWqk9Jnhoj boA2CVfOYVZl2owpKQK5rX9QMUyPKhXwGSN5380FFcUPSKkat48Re1gKnJNvIQk3xPEs 2zCGJ0vAMdyoKCR4qNpNHAJJ39L35ZI3MlpzDWjyxRctjzSgePrgyu/WV5vBbI44i92k Y/Yakhv0ZiKyEIc9wY4bUHqMhQuiyUlSfI6pE7Er8WD1ddRtg/sfQoT2DMroF4yZoqXy Lu8FiniAhvl2pVP/G5gn5LNcXIOkR297A42wkSRpYtWdYLZo03lKBYHEwyHRPBmkJBL9 HNJw== 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=ZEEgjTVF9ob0iUf+PbGSGnuQoV1ZTJ330EoiYkZKizQ=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=PMIGwHnvBusWEQbNWzePxT5vZ5olrymiOTtoAb1dHQt6gTCfGpFK9gbJsI+CxNkR/H 3OWYzvXASlF/EFpNFhhgoFzlsuRXF0S+bew942+TXcnsMBU1mzh4zY/P8S8t+0DyJi8w f32V8PDb1AV9x92tpR3X307HUKbFKwyQUBEP5V1AtfMzvtMCznt4/BEkMIT1/8OFHSVZ yOXAGIzaA2oCGzQf0CWbqC0xx9I8llkKckrLv7WgrTluJnlGM4jsXt6x9vCSEo8vyGue TQje4CwwbAgv7ljbh5fxNu4IJqw+phevkPwztwxzxqn145de7V8ym66uUcXjdxuKJBG9 51Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OaLw9Ceg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a635302000000b005538e27e0afsi19779865pgb.750.2023.07.05.03.22.08; Wed, 05 Jul 2023 03:22:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OaLw9Ceg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231608AbjGEKF3 (ORCPT + 99 others); Wed, 5 Jul 2023 06:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGEKFX (ORCPT ); Wed, 5 Jul 2023 06:05:23 -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 E6AB11721 for ; Wed, 5 Jul 2023 03:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688551482; 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=ZEEgjTVF9ob0iUf+PbGSGnuQoV1ZTJ330EoiYkZKizQ=; b=OaLw9Cegd27WGSdL4tcv3Q5sD+RI6Oq9Biakzapibmbe4rA65zlaM0SLRViddcYO+1EjXX roBFx/IKeX7dUl47tWn5Y1oKH3TtwQc6FOh0DwIY/e/Fhu0R0IuJBKQC4GuNRHvonCFYRF fHrGOwgAa0Fd21gHbDiDySMEc838bH0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-6G-zWxspOc2F045WvzciDg-1; Wed, 05 Jul 2023 06:04:38 -0400 X-MC-Unique: 6G-zWxspOc2F045WvzciDg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B73D3380671D; Wed, 5 Jul 2023 10:04:37 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8994F4021523; Wed, 5 Jul 2023 10:04:35 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH v3 1/3] vduse: validate block features only with block devices Date: Wed, 5 Jul 2023 12:04:28 +0200 Message-ID: <20230705100430.61927-2-maxime.coquelin@redhat.com> In-Reply-To: <20230705100430.61927-1-maxime.coquelin@redhat.com> References: <20230705100430.61927-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770575673648332391?= X-GMAIL-MSGID: =?utf-8?q?1770575673648332391?= 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 dc38ed21319d..ff9fdd6783fe 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; From patchwork Wed Jul 5 10:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 116059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1764532vqx; Wed, 5 Jul 2023 03:24:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlGC6sH9qhraYQtmEnw0/kqOojz8eDzI0rSJROd2Ul7YjjRkdnbsER2nTxtZ6jCyouzrL2a7 X-Received: by 2002:a05:6a00:1a87:b0:682:8899:f6e6 with SMTP id e7-20020a056a001a8700b006828899f6e6mr9825660pfv.28.1688552694668; Wed, 05 Jul 2023 03:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552694; cv=none; d=google.com; s=arc-20160816; b=ZEI0VB5dOm0mM5/NOFlN7x/BQyKtDpRXu6qe9t+XqNjrodDp4bq5/w25QQj/JBGJTc 29ewncL2IH+d8Yc6oF2OsARrri06Wyu3OAQb01b2TyBNYHHigOQ4G1JQe/3aOGEY/aKb 1j3y2UYP8c5VSNy6AHxT+qomRvWy/2+uWjmee6F91G6CsM7G9LHS0N38fVVSpMBhciIo yCd+LnNs7gQ+GBFejHoBwpT4AvwI5gOk8eO02jj4/Qu5QYSYwuAWsWoDepNEvHms4SbW /KNpRFjToLni30kIp6LplM9gof7oot/nR9QuJOL8MUcE+7spy9NXCbi0GfySkQwGnFzS EDFQ== 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=Iud4Ecey6anqNBpQug6H+pW6me9r94dCbe9UYyq8Yto=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=NIsO39jKX7ffxFH62zh66XsC1ev6Ag4yFY+Ngvoj31TD9c9ibBrUrmrFZtsooV3fZF NIXzRZs8Tcc+Jbrqz/J/J1YnEpLK3xw2rird0QsXfazYrIBe5jnsPDAjLLE3oTlNATYY 6YA4BBQHXxjQ8M+VP25+3j+DBLTYjKgNUM16lmZKuHC0PTxELD1zjP8Pc+wsdEAO+8lv LybxmmjfwBhF+jBNXCHY1NhomZ+GmJwm01QKcNcnIvI+s1wZkV8WbuQLGP4a/gj+DKtu 2BaWvmY8YxSixdbS9Ttz0cMxZ/wCG3YUVQMk1waymHWjJvEQL3P4AJNoVhiv56OxycIY Hk7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B8AXedT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bt11-20020a056a00438b00b0068207661b64si13726256pfb.137.2023.07.05.03.24.39; Wed, 05 Jul 2023 03:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B8AXedT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbjGEKFh (ORCPT + 99 others); Wed, 5 Jul 2023 06:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjGEKFc (ORCPT ); Wed, 5 Jul 2023 06:05:32 -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 44B8F171C for ; Wed, 5 Jul 2023 03:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688551483; 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=Iud4Ecey6anqNBpQug6H+pW6me9r94dCbe9UYyq8Yto=; b=B8AXedT2FhAn9fTu4danjXDYDK8/nU+Ww7maoB+f4r+KBiderbs/1EqqP0VeNeiRclCnrk KQYd4ZOglhWedmt1cd2y2ZTORdWQFRoRt19pYoKknWIUhDJWOrQvuwDZ2GKSHelVkFGkA2 dJj4lfSMpti1uRudEA3mwuec+BW7O7A= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-gWa3ah60PhGhuzMFrxk5RQ-1; Wed, 05 Jul 2023 06:04:40 -0400 X-MC-Unique: gWa3ah60PhGhuzMFrxk5RQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A45F2A5957D; Wed, 5 Jul 2023 10:04:40 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BE904021523; Wed, 5 Jul 2023 10:04:37 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH v3 2/3] vduse: enable Virtio-net device type Date: Wed, 5 Jul 2023 12:04:29 +0200 Message-ID: <20230705100430.61927-3-maxime.coquelin@redhat.com> In-Reply-To: <20230705100430.61927-1-maxime.coquelin@redhat.com> References: <20230705100430.61927-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770575829952264143?= X-GMAIL-MSGID: =?utf-8?q?1770575829952264143?= 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 ff9fdd6783fe..1271c9796517 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 }, }; From patchwork Wed Jul 5 10:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 116062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1772774vqx; Wed, 5 Jul 2023 03:44:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYw75hAvMmsYbZuoAXn+0l2BHCLeLxcjvmpewK8GhWo0v8Iym31OEExd+N7n92lBDIfytY X-Received: by 2002:a05:6358:c60a:b0:134:d026:42d2 with SMTP id fd10-20020a056358c60a00b00134d02642d2mr9593864rwb.24.1688553858609; Wed, 05 Jul 2023 03:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688553858; cv=none; d=google.com; s=arc-20160816; b=ao5/SdeWAGShXsCFHVl/kTDPQsgzXYgc0CIwjGo4gaIxjwbnsXKZzf61ky85c7Xfq1 Vklex359UqOAx16D4XvPf+Is62pJ0gma/7f0nY8TBk8QzdvMaz0eGPH1donOBpByQBFs RZR/aALdQUUlV/6ZkzxYBpjb74+yHayNPUyS8UQrjZNXnRQu/Z4zOk0VYTXDgHvXpHyo ItuAnOq3NCV5gh3D9ZS5BlPy2ONisJv70dj6sOErBP1OMrzVU/o5nNZEZfI+RxGFNb53 7Vfkwj/uYwVTMvkrJqDmu9a64amN+ElfS+pZ7fbtMX16DQgHq9licylLq4iLRCb5eVTz npSQ== 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=0hwC5y47T6/UzpMniXD0dlaNgSU/p+1EVDrFsA80r7Q=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=ojpN6xh2JXvuZGyPYX3yYQRx+a+vTclTfTtJmUgp+GV7pwlQ8nV4mhM8GvI7w8f0XS TH8B5a3tZtAtxi1afH7UmmaUBu0v/QcFC5/+K0MXLfuHsnSLYxeL9gEvoLw/ane4cPMz K/4Rn7BkyZ7KcuWZNaOIazd8FDsxrnJ9/6Uh4iorY+yp1lzX2Z2XzR1w1OqdhRSKqvnw Wa+daywCPMAVHKjWndCnCzjqvBuyLQqj+qOsGytdMBdurW4aYpoCdHmViv2XdpgtJ5QW AWvFRfAZWS6npobGzzSSfsxn8ZO81YW03D9PJxxTkEZi0D52RVPSuW/0LsnRcGEHhdFq Q9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cm1VStD+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y26-20020a62b51a000000b006824cda542fsi11983715pfe.395.2023.07.05.03.44.03; Wed, 05 Jul 2023 03:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cm1VStD+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231923AbjGEKFe (ORCPT + 99 others); Wed, 5 Jul 2023 06:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGEKFc (ORCPT ); Wed, 5 Jul 2023 06:05:32 -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 2382E1725 for ; Wed, 5 Jul 2023 03:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688551485; 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=0hwC5y47T6/UzpMniXD0dlaNgSU/p+1EVDrFsA80r7Q=; b=Cm1VStD+j15RTDvkgVkv3JRf/oNaoEfRGMcagTLCtfqphhoBnxIF30b6OXiHyPHWhtPBtx bmHFFwUoAE+LpQ0pyMWl1P1n6m1aYWHpqd17WX9QjKHoZmkG4gaX9BliMm/eJUxdkNy0C8 CdecCZobMvJf0DR6UWbxctEDAmpcNDU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-cO98A2tqP06Uvdywyz-xNQ-1; Wed, 05 Jul 2023 06:04:43 -0400 X-MC-Unique: cO98A2tqP06Uvdywyz-xNQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D85BF1C172AB; Wed, 5 Jul 2023 10:04:42 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 813FE4021523; Wed, 5 Jul 2023 10:04:40 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH v3 3/3] vduse: Temporarily disable control queue features Date: Wed, 5 Jul 2023 12:04:30 +0200 Message-ID: <20230705100430.61927-4-maxime.coquelin@redhat.com> In-Reply-To: <20230705100430.61927-1-maxime.coquelin@redhat.com> References: <20230705100430.61927-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770577050978727686?= X-GMAIL-MSGID: =?utf-8?q?1770577050978727686?= Virtio-net driver control queue implementation is not safe when used with VDUSE. If the VDUSE application does not reply to control queue messages, it currently ends up hanging the kernel thread sending this command. Some work is on-going to make the control queue implementation robust with VDUSE. Until it is completed, let's filter out control virtqueue and features that depend on it by keeping only features known to be supported. Signed-off-by: Maxime Coquelin Acked-by: Jason Wang --- drivers/vdpa/vdpa_user/vduse_dev.c | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 1271c9796517..7345071db0a8 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -46,6 +46,30 @@ #define IRQ_UNBOUND -1 +#define VDUSE_NET_VALID_FEATURES_MASK \ + (BIT_ULL(VIRTIO_NET_F_CSUM) | \ + BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ + BIT_ULL(VIRTIO_NET_F_MTU) | \ + BIT_ULL(VIRTIO_NET_F_MAC) | \ + BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) | \ + BIT_ULL(VIRTIO_NET_F_GUEST_TSO6) | \ + BIT_ULL(VIRTIO_NET_F_GUEST_ECN) | \ + BIT_ULL(VIRTIO_NET_F_GUEST_UFO) | \ + BIT_ULL(VIRTIO_NET_F_HOST_TSO4) | \ + BIT_ULL(VIRTIO_NET_F_HOST_TSO6) | \ + BIT_ULL(VIRTIO_NET_F_HOST_ECN) | \ + BIT_ULL(VIRTIO_NET_F_HOST_UFO) | \ + BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | \ + BIT_ULL(VIRTIO_NET_F_STATUS) | \ + BIT_ULL(VIRTIO_NET_F_HOST_USO) | \ + BIT_ULL(VIRTIO_F_ANY_LAYOUT) | \ + BIT_ULL(VIRTIO_RING_F_INDIRECT_DESC) | \ + BIT_ULL(VIRTIO_F_EVENT_IDX) | \ + BIT_ULL(VIRTIO_F_VERSION_1) | \ + BIT_ULL(VIRTIO_F_IOMMU_PLATFORM) | \ + BIT_ULL(VIRTIO_F_RING_PACKED) | \ + BIT_ULL(VIRTIO_F_IN_ORDER)) + struct vduse_virtqueue { u16 index; u16 num_max; @@ -1778,6 +1802,16 @@ static struct attribute *vduse_dev_attrs[] = { ATTRIBUTE_GROUPS(vduse_dev); +static void vduse_dev_features_filter(struct vduse_dev_config *config) +{ + /* + * Temporarily filter out virtio-net's control virtqueue and features + * that depend on it while CVQ is being made more robust for VDUSE. + */ + if (config->device_id == VIRTIO_ID_NET) + config->features &= VDUSE_NET_VALID_FEATURES_MASK; +} + static int vduse_create_dev(struct vduse_dev_config *config, void *config_buf, u64 api_version) { @@ -1793,6 +1827,8 @@ static int vduse_create_dev(struct vduse_dev_config *config, if (!dev) goto err; + vduse_dev_features_filter(config); + dev->api_version = api_version; dev->device_features = config->features; dev->device_id = config->device_id;