From patchwork Thu Aug 10 11:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hawkins Jiawei X-Patchwork-Id: 134005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp429710vqi; Thu, 10 Aug 2023 06:44:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiQwWefXLkwF/QR7r1Zz5J4tdLiox5cn2TeNosxe9GjICFfpovXliB3F9GJDHSDJr53Z2i X-Received: by 2002:a17:906:1013:b0:99c:6312:73ca with SMTP id 19-20020a170906101300b0099c631273camr1838883ejm.71.1691675091625; Thu, 10 Aug 2023 06:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691675091; cv=none; d=google.com; s=arc-20160816; b=Ew56AuWDFvqST/BvT9vdScjTodcO2112466RBRW4rd1YuiSuy6uHdTTTcqGzxCNfPZ 6oa6bR962dy9duSqAiXbQ8QxYOtf8VNSmYKHdENx6Co/bLJTk4VOENoq+S3lCQwxfVO8 JeewnlOmGr7yAe9A1m7+rPmCGmPHJDfrtdKvAUK+ZEtZFpFsyOyExkzqTGRQDFUnE8BD JKAScNsdBLcWJCYmn792FbthUtIXLsNFWpzK6TDIh5yWcsdovNp6IX0fEeYHYeheMugP TAfOxk4iLLiP8/Z4yUcqy0IqxUqiQiYuA1hKxz4GaLxDM2KrV+x8bnM7kzxJv44pE1dg J0bg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=EZNwX6BX5AQPN+unSBMh2stfRIj6tOKu7CYnBnKpHOo=; fh=s3AQ+ninEAxzp6QsXtwlwcpooyRD1rOJNgR0rl1oZWU=; b=rIwZLaAVQDnR3SRxeyM+jm/ESIPDCjMy6L60NdPGMLyBjL69epopNStXkAnSvij10I V+n6Jv0iKwja6wAhr7DRno+diIAWSYemP/oBA9EcsN3HUrFVEfExOs3NQMljsSWTW+QT Qw6Crq16/E036pZIyM/T2fMlLGojA4SMRxBoQbhTTKIKP/0PSmuO77hY0V0P/ecBADAV 9Cyuz9llfIY21Dc8NhC50yTgXi3rRdo4m+vOoosqO5uQlHH/dmEPBGyiwF8f7lDZ5SLP 8j+fswldhB9UNRGYP+ZYsmjsh13yEiO1ApSsg0IVk3fAzkYXdwGqW8+aD5YZecj4FI/h iBVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fLMH0z09; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gy22-20020a170906f25600b0099bd5a646c2si1424512ejb.271.2023.08.10.06.44.26; Thu, 10 Aug 2023 06:44:51 -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=@gmail.com header.s=20221208 header.b=fLMH0z09; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjHJLFf (ORCPT + 99 others); Thu, 10 Aug 2023 07:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229970AbjHJLFe (ORCPT ); Thu, 10 Aug 2023 07:05:34 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53721994; Thu, 10 Aug 2023 04:05:33 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bb84194bf3so5560955ad.3; Thu, 10 Aug 2023 04:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691665533; x=1692270333; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EZNwX6BX5AQPN+unSBMh2stfRIj6tOKu7CYnBnKpHOo=; b=fLMH0z09jpbIUTMF2PGqdSyku77R0WqQ0sDRGWTzXWXtABt44FcIQtZISOcBQUuOo1 +PniFeXyWmDTvnYz4WKsjUYGQp7CeUB5KB1RgGFTndpT6qOzL8I3jsedxnuxI8234VpW iNYeZpY2E6awMNz5tjEcLTlVhw/7b2NUWybrZchFl5njQ8u0v/TQtohH6nDAz+5WXIro Jv4yUyUj8zOCQMyYATTN+SU+Qz6utCaEcly3Sv+C0w+6fsziQI3F4pZ6lj98uU9dwYAq H7p7QtbBw1UHpuIOhOg7CaFRH8jZsk8la0JEHODRRsWJc7lSK5VonliqARh5nwXombm/ aWnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691665533; x=1692270333; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EZNwX6BX5AQPN+unSBMh2stfRIj6tOKu7CYnBnKpHOo=; b=H5cWjKbUAwBlVohT0xNo2zEW5YBvYUNOTsbwiIKQ1t2uzYvN4gXMstMPhQU9oKA17o vIUU9F9/mfi3mIu7VQLORadUDHryrsg+tmzkVtsYll7KhnqKsxHTpllDQhWh0C9tYkP0 RtJPad534Bgs8NtgeX8MqfXNKgayiWtyMMjnIfHUKCu2InqyevWOGBc2a/FKLmeEPPJC AXKDjNh7/yo5KiTzPhJK0eBbSdM2Uim4lsNe2loOONXDPv+EGnzsamw2otdWcN/kcD6S nixD+xdfVO21jeQLz2bFXBg/wTFwCaRTBhZska28OUJBTt2eqSYz1fPNGN6i0cLt9YQj uxnQ== X-Gm-Message-State: AOJu0YxrQZhpjFzgJ6hfHWjys0sjJ2RRrtAD7+MPrm5yJQh15l3Grndy JHN+vRiSBajQhT/TV0Av0UI= X-Received: by 2002:a17:902:d353:b0:1bc:6845:deb5 with SMTP id l19-20020a170902d35300b001bc6845deb5mr1947971plk.36.1691665533047; Thu, 10 Aug 2023 04:05:33 -0700 (PDT) Received: from localhost ([125.35.86.198]) by smtp.gmail.com with ESMTPSA id l2-20020a170902f68200b001bbdd44bbb6sm1428333plg.136.2023.08.10.04.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 04:05:32 -0700 (PDT) From: Hawkins Jiawei To: yin31149@gmail.com Cc: eperezma@redhat.com, 18801353760@163.com, Andrew Melnychenko , stable@vger.kernel.org, Jason Wang , "Michael S . Tsirkin" , linux-kernel@vger.kernel.org Subject: [PATCH v2] virtio-net: Zero max_tx_vq field for VIRTIO_NET_CTRL_MQ_HASH_CONFIG case Date: Thu, 10 Aug 2023 19:04:05 +0800 Message-Id: <20230810110405.25558-1-yin31149@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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: INBOX X-GMAIL-THRID: 1773841326498533538 X-GMAIL-MSGID: 1773849900721869674 Kernel uses `struct virtio_net_ctrl_rss` to save command-specific-data for both the VIRTIO_NET_CTRL_MQ_HASH_CONFIG and VIRTIO_NET_CTRL_MQ_RSS_CONFIG commands. According to the VirtIO standard, "Field reserved MUST contain zeroes. It is defined to make the structure to match the layout of virtio_net_rss_config structure, defined in 5.1.6.5.7.". Yet for the VIRTIO_NET_CTRL_MQ_HASH_CONFIG command case, the `max_tx_vq` field in struct virtio_net_ctrl_rss, which corresponds to the `reserved` field in struct virtio_net_hash_config, is not zeroed, thereby violating the VirtIO standard. This patch solves this problem by zeroing this field in virtnet_init_default_rss(). Cc: Andrew Melnychenko Cc: stable@vger.kernel.org Fixes: c7114b1249fa ("drivers/net/virtio_net: Added basic RSS support.") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio PĂ©rez Acked-by: Michael S. Tsirkin --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1270c8d23463..8db38634ae82 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2761,7 +2761,7 @@ static void virtnet_init_default_rss(struct virtnet_info *vi) vi->ctrl->rss.indirection_table[i] = indir_val; } - vi->ctrl->rss.max_tx_vq = vi->curr_queue_pairs; + vi->ctrl->rss.max_tx_vq = vi->has_rss ? vi->curr_queue_pairs : 0; vi->ctrl->rss.hash_key_length = vi->rss_key_size; netdev_rss_key_fill(vi->ctrl->rss.key, vi->rss_key_size);