Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28823411rwd; Wed, 5 Jul 2023 03:19:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRRn5KP5fll+zyLWjPkxdjaLrxXiirs/fEetDbTaAbg13H7wIYJ/WjWEmGyV23pv8g76Kl X-Received: by 2002:a05:6870:7885:b0:1b0:805:8678 with SMTP id hc5-20020a056870788500b001b008058678mr17950732oab.24.1688552345244; Wed, 05 Jul 2023 03:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552345; cv=none; d=google.com; s=arc-20160816; b=qQDyUEXn3amc26UKQbf9gLJPYXePJx8CK8zp1GritodjLsddvUSipFpxQwEK4NmsGV n75OvsGGLLvI4VGOKH1v5krIhl6RfY7U5FJB4saf3aXdqGXLUVGnw/SKDUQjv0c5/G31 lgyAr9u+3DHlV2PSG2y903YLMkQa09H5dEzMrffjFT0zBgthe6DJ7ucVEBEzANbuGs1j XxtauEG8guoWJ3tgoLEyDh4Ew/IV/HJWmyVBP6kaNldPUN2aHshIwJBRq4UAlPNkgUDx pJTzVfmFcRIt10aGcnjdkl66XXCWgW2qDBfsCkLFmwizpiZHZ9dkw+5RZBUpCJxNpCI2 uGaQ== 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=wmmn0GHuacIslFYpx9xi8H/1mryWYn2Fay5wwTPFsq8=; b=DO8JZdg08ZgGtelmqTcXJis9saIocl+7ViNKULKMBECsTHQmMs+Yl2+fyMGAavyBzx Q6XN63ljh+Y4q8+/nTV/2YZeNMV36QEvcdYkD939WmeHot4mBApKGD3dHdd7UWyQZQCE 3BbCwAqR1fD2R3RItSRTCKdgQZLHH+OuQJMh3mhM412xCCywZ5j5WoRFIbbItH6LpDXl ZTuxPnXuUq/eQLaF5fL1LI1Zp9FXwXpXkFz8OGWXOmSW0gD0w960pbpg2CcBtWxCj36o z2TxUzkf0jjQfpzLxjjkeMN9nJExyTSJtSE0N10I5Z0PV5R96/N8MTaNXuAlkOvo5t36 Cscg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a17090a899800b00262e1adb2c7si1366949pjn.51.2023.07.05.03.18.53; Wed, 05 Jul 2023 03:19:05 -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 S231911AbjGEKFe (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 Content-Transfer-Encoding: 8bit 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 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 --- 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; -- 2.41.0