Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4214961rwr; Sun, 23 Apr 2023 00:26:35 -0700 (PDT) X-Google-Smtp-Source: AKy350YloALDLGcFpLN/i581DWaCudTxChLas3fgJ/qC01EBEYXK3AHJn+FJuagOnSLq7GztuNZ4 X-Received: by 2002:a17:902:e743:b0:19a:7217:32af with SMTP id p3-20020a170902e74300b0019a721732afmr12900454plf.5.1682234794992; Sun, 23 Apr 2023 00:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682234794; cv=none; d=google.com; s=arc-20160816; b=Zx8XMI2C7uT4gx4bqX8oJZh1MM0MGmPMUpT8CYrMV92gqnVyWChnIJYEMQGjftKWYZ 3xm0yRZCSOJEOGQLcb8nk3yBa9eCLAGo1dO+X+QXENSLj2UsMe8P0qraO7DYMElqSX3R QlUuqOHAyPpq1tuvH4Xp8nKFFX8AblCWSWP12YCg2mgWKgJiv+dvxaFUYX/zqTiON0pY 3oZmUggsgP8+Z+8zcarnFmX0WwsToLb2j3te+haOizu2oAl1+lLMavKOQJA5DT5Xjc9t LWnm1f2pLQlb1xR3NgGIz0r9aJ+VmbisfVlA6GDJp7ga/qJU/dMAYZMxH4/NBcHU3HO7 dqAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nOfk5KVt03Kw/nxPJuFXIUc7M+oFb5UuYNKx4WZp95g=; b=qWLZDPZCQR3HZLCD6VQWbKhedvG06XXROKLv7+Es12RRKhXRxGrEM3L4Wac+Sg0Jt7 6Q6MYWpoB2n3/Gep11odPxj7x4IXWNoaT9kFqa4b/c8ZFilZMPSknJquaSxonjWBXJni Ouqmr6Bg467XLj10lPQGX64b1vQtcGeyav/55pMgV7gbwAcwJcYqpfGfIyhH8v1QRt1q 1MjbpqpVk1ZGq+hrSgr/Qo7uyVeJ+EOHqe89/rbilBMjZ8BU+GhJLAHsWJje+h9KHmlj 3VQagg5BQR8NzQ4NZuS6Wtep/5ZH841AXVRpnE2dh3CFXeBu3rXKAFtNgD663LpPK8eZ FIdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BayY7Jgw; 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 j4-20020a170902758400b001a1f70cc7dbsi7975972pll.562.2023.04.23.00.26.05; Sun, 23 Apr 2023 00:26:34 -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=BayY7Jgw; 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 S229614AbjDWHUM (ORCPT + 99 others); Sun, 23 Apr 2023 03:20:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjDWHUK (ORCPT ); Sun, 23 Apr 2023 03:20: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 46CF4173B for ; Sun, 23 Apr 2023 00:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682234362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nOfk5KVt03Kw/nxPJuFXIUc7M+oFb5UuYNKx4WZp95g=; b=BayY7JgwPUKoTnFHruRBrkOD49yx/0BNTo5kuPOwnef+ecOQI7Zs18AxRe4q+X9RCNDWwe P1+ObnC6vjR6TW9xRzAVABEoJJzCoE45iIKtSZaxwxBs62LqHQVrMj5kw3KoJ6X1mBU3cF 2aeQJ0bfBNv/pRyV/gUPR+NtXwoHkFw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-fhhj5bzhNESaxQtJmVwDGA-1; Sun, 23 Apr 2023 03:19:20 -0400 X-MC-Unique: fhhj5bzhNESaxQtJmVwDGA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f19517536eso6552135e9.2 for ; Sun, 23 Apr 2023 00:19:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682234359; x=1684826359; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nOfk5KVt03Kw/nxPJuFXIUc7M+oFb5UuYNKx4WZp95g=; b=FnsU8Gjk5IH1vNfRqkd79FF/Rlw6pMvKbnGrBRKhfNsvWPCXb5TTEED3MbDlaG0ORl RPJ9LInSJl5GgcZ5QJh/+InX1vGxvisW2sDpsxGc+gBeOejfcdQ34fpBW2fe5tPA25vZ vqTAw/FqXi/EYgeGVpfmY0kBJQsnae6+dCHBuP+6PX+Jvi50nxiO6vZruc4dbvNBlKgP TVHLK9rbS3y+ETp3z4XRJIGE7Wi/cDPRayBc8oCWDoqMBD8vGf7id9PdzAcBgZS5vQcJ ehA4IYTEVwWDKFkYtTHUPRhnXBknVpe+yyO3Z05UW7UHQBK8r34VoPgzu/kvxpo6uhN6 Zh7A== X-Gm-Message-State: AAQBX9cWaPkP7TJ71q9r9fBgBA4UJesH1224EHllFP8ijnL1DThsp//y a+exwLQHGQMKDwUunHmUvnvxZJjfMZiSWvV6SqfB+Noo5BWvSG305e2WLAuQc08ern3mLFFV5Ld Y+PWbKRiFbFt9MVxxi7Cwz3Eo X-Received: by 2002:a1c:790e:0:b0:3f1:7288:1912 with SMTP id l14-20020a1c790e000000b003f172881912mr5053871wme.33.1682234359573; Sun, 23 Apr 2023 00:19:19 -0700 (PDT) X-Received: by 2002:a1c:790e:0:b0:3f1:7288:1912 with SMTP id l14-20020a1c790e000000b003f172881912mr5053855wme.33.1682234359214; Sun, 23 Apr 2023 00:19:19 -0700 (PDT) Received: from redhat.com ([2.55.61.39]) by smtp.gmail.com with ESMTPSA id z4-20020a05600c0a0400b003ef4cd057f5sm12633650wmp.4.2023.04.23.00.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 00:19:18 -0700 (PDT) Date: Sun, 23 Apr 2023 03:19:15 -0400 From: "Michael S. Tsirkin" To: Alvaro Karsz Cc: Jason Wang , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net] virtio-net: reject small vring sizes Message-ID: <20230423031308-mutt-send-email-mst@kernel.org> References: <20230417023911-mutt-send-email-mst@kernel.org> <20230417030713-mutt-send-email-mst@kernel.org> <20230417051816-mutt-send-email-mst@kernel.org> <20230417073830-mutt-send-email-mst@kernel.org> <20230417075645-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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_H2,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 On Sun, Apr 23, 2023 at 06:51:46AM +0000, Alvaro Karsz wrote: > > Yes that makes sense, it's architetural. We can disable ctrl vq though. > > The problem here is that we know the vring size after calling virtnet_find_vqs, so the number of VQs already includes the control VQ. > > Actually, many variables/settings that are initialized before we call virtnet_find_vqs may need modifications if we use small vrings. > For example has_rss_hash_report, has_rss, hdr_len etc.. > > We could have a fixup function to fix everything after we discover that we are using small vrings, but, honestly, I think that this will be hard to maintain in the future, and I don't like this approach much. > > The ideal thing will be to discover if we use small vrings in probe's beginning. > > I'm looking for a way at the moment. Hmm. I was wrong. There is no way to disable CVQ feature bit. 1. Reset the device. 2. Set the ACKNOWLEDGE status bit: the guest OS has notice the device. 3. Set the DRIVER status bit: the guest OS knows how to drive the device. 4. Read device feature bits, and write the subset of feature bits understood by the OS and driver to the device. During this step the driver MAY read (but MUST NOT write) the device-specific configuration fields to check that it can support the device before accepting it. 5. Set the FEATURES_OK status bit. The driver MUST NOT accept new feature bits after this step. 6. Re-read device status to ensure the FEATURES_OK bit is still set: otherwise, the device does not support our subset of features and the device is unusable. 7. Perform device-specific setup, including discovery of virtqueues for the device, optional per-bus setup, reading and possibly writing the device’s virtio configuration space, and population of virtqueues. 8. Set the DRIVER_OK status bit. At this point the device is “live”. So features are confirmed before find vqs. The rest of stuff can probably just be moved to after find_vqs without much pain. So if cvq is too small we can either - probe but avoid using cvq or - fail probe -- MST