Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1122449rdb; Fri, 20 Oct 2023 09:01:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+VDg+EvuSMr2tHpYDDePugaICpVs0Y1EfXd2fyn9t90hdH54InYm/avQzgACzXoOC0K+O X-Received: by 2002:a05:6a00:b8e:b0:6be:4789:97ba with SMTP id g14-20020a056a000b8e00b006be478997bamr2306800pfj.3.1697817702689; Fri, 20 Oct 2023 09:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697817702; cv=none; d=google.com; s=arc-20160816; b=gxjEljI+BPDp5b1edPAc5YcTjYqc5HvrHRvBpZkBaWOoZ1fEy7QmU3XZ7ZCer4zU+l lEq+reZpbbYNCW0D+sO0rqocs2BFj3bHhBCM7KW525lTT6/nu8cqJueuQGx8ENmXQTDd RTztTA137QZ0TtwZHJ02UtFNMNh46yXdKRJ+51leD2MnfB0XNFpWfI5xf0VplnrVcsn9 9KBqdJqs17mq3wwyImaDCG3sQ2UI+dmyQTbKk/zGXMaHdiiUJN3W7R+Oc9ikv9DmUxWg JrlapDihDlH1PYn9Fgx78scsrrwSCHNCE+g7ZMjSzEAYdbNqN3lwWEO4MQ3xzgYbWzeQ jeCA== 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=/YaH8GqSCmsbSQK65aeluJxBiMUQ9PtkPz8wZaXPjys=; fh=DW2mHD/f0kRN+01V+Z9as8p7OnC0swQlfBH91pgf6/A=; b=n+FPDFlo7QA6Z21YIXsWYm81aeff6XyyWCS7gccT7TIk1PI08OLyoDkGeVastcC2BB Kc8gFIQNm8WcPD2zQ83ZVcmKaPFxX39fp7Q7AYTJT4Jef08+c7qUnBmBAzk5YkcJzWSj pPtBmIL16xDXlaFGWIwT6fzIlWfTyR8Js9oLI5oUWzv9/sNZea1LWOZsbroCXP6JV/8X q5Ve6JGu4N4Za2LrO9L7ZU0o5jLo9atd97y4y7AVWLfmow3kw5fkEJmQHsTqKH5Q6sDH U760C7pmxkIDkV11UWzoVCKrYaDFxLk73zBx/73rzBaopUZcfl/y0GZ2B76XGsAQKfT9 sTyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c/Gnpb2q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e9-20020a056a001a8900b006bdd721a84asi2316161pfv.299.2023.10.20.09.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:01:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c/Gnpb2q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9E9DA80C0A65; Fri, 20 Oct 2023 09:00:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377848AbjJTQAP (ORCPT + 99 others); Fri, 20 Oct 2023 12:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377839AbjJTQAK (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.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265C0D65 for ; Fri, 20 Oct 2023 08:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697817523; 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=/YaH8GqSCmsbSQK65aeluJxBiMUQ9PtkPz8wZaXPjys=; b=c/Gnpb2qABMhWmGPOGNosn8CVEAMwcDUV5f0c4OPYCuVZBcRWz5Pn4LfcXyngQC/E42twk PtOnKBpKaTTxlVvizWsgOOx0aNM5T6YGKWA68PGaAyFuH8mn+bYkJicKroisXFfg/R3niC zAhHcM9+Dd3+cubLQVIGk2p4b1mgSj0= Received: from mimecast-mx02.redhat.com (mx-ext.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-648-GcMYqtHEOs6LTSLRuNoADw-1; Fri, 20 Oct 2023 11:58:39 -0400 X-MC-Unique: GcMYqtHEOs6LTSLRuNoADw-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 2F7E33C28647; Fri, 20 Oct 2023 15:58:39 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 219DB10828; Fri, 20 Oct 2023 15:58:35 +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 3/4] vduse: Temporarily disable control queue features Date: Fri, 20 Oct 2023 17:58:18 +0200 Message-ID: <20231020155819.24000-4-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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 09:00:24 -0700 (PDT) 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 disable control virtqueue and features that depend on it. Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 73ad3b7efd8e..0243dee9cf0e 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "iova_domain.h" @@ -46,6 +47,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_RING_F_EVENT_IDX) | \ + BIT_ULL(VIRTIO_F_VERSION_1) | \ + BIT_ULL(VIRTIO_F_ACCESS_PLATFORM) | \ + BIT_ULL(VIRTIO_F_RING_PACKED) | \ + BIT_ULL(VIRTIO_F_IN_ORDER)) + struct vduse_virtqueue { u16 index; u16 num_max; @@ -1778,6 +1803,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 +1828,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; -- 2.41.0