From nobody Mon Nov 25 18:37:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linuxfoundation.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713102403171301.88375943139533; Sun, 14 Apr 2024 06:46:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rw0B6-0003Rt-9J; Sun, 14 Apr 2024 09:45:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rw0B4-0003Qw-15 for qemu-devel@nongnu.org; Sun, 14 Apr 2024 09:45:50 -0400 Received: from sin.source.kernel.org ([145.40.73.55]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rw0B1-0004xa-AY for qemu-devel@nongnu.org; Sun, 14 Apr 2024 09:45:49 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C3EEACE0925; Sun, 14 Apr 2024 13:45:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6AE0C072AA; Sun, 14 Apr 2024 13:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1713102340; bh=VpnAZmrmIP5/ENO3QKsdOZnFUI49ounKx4tptzFt17g=; h=Subject:To:Cc:From:Date:From; b=mB3oUU9wvM0Ch0Ut+IpGq77l4paRCOsyzzwU6EI4RxrhYZHmD5/0fCZ27LZAgaabG K7qe8IxvUatZpDXDmg70CB7S9rvAW9z0m4FFqWkcoGAmgeyCtpzGEV/fI70TDJYwiX OacrYKrppzz8Te0uflgiTSc2a1HV0ZzyidkRu0RM= Subject: Patch "virtio_net: Do not send RSS key if it is not supported" has been added to the 6.8-stable tree To: davem@davemloft.net, gregkh@linuxfoundation.org, hengqi@linux.alibaba.com, leitao@debian.org, qemu-devel@nongnu.org, xuanzhuo@linux.alibaba.com Cc: From: Date: Sun, 14 Apr 2024 15:43:57 +0200 Message-ID: <2024041456-debrief-crawlers-98b4@gregkh> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-stable: commit X-Patchwork-Hint: ignore Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=145.40.73.55; envelope-from=gregkh@linuxfoundation.org; helo=sin.source.kernel.org X-Spam_score_int: -64 X-Spam_score: -6.5 X-Spam_bar: ------ X-Spam_report: (-6.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.127, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1713102403972100001 Content-Type: text/plain; charset="utf-8" This is a note to let you know that I've just added the patch titled virtio_net: Do not send RSS key if it is not supported to the 6.8-stable tree which can be found at: http://www.kernel.org/git/?p=3Dlinux/kernel/git/stable/stable-queue.git= ;a=3Dsummary The filename of the patch is: virtio_net-do-not-send-rss-key-if-it-is-not-supported.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From 059a49aa2e25c58f90b50151f109dd3c4cdb3a47 Mon Sep 17 00:00:00 2001 From: Breno Leitao Date: Wed, 3 Apr 2024 08:43:12 -0700 Subject: virtio_net: Do not send RSS key if it is not supported From: Breno Leitao commit 059a49aa2e25c58f90b50151f109dd3c4cdb3a47 upstream. There is a bug when setting the RSS options in virtio_net that can break the whole machine, getting the kernel into an infinite loop. Running the following command in any QEMU virtual machine with virtionet will reproduce this problem: # ethtool -X eth0 hfunc toeplitz This is how the problem happens: 1) ethtool_set_rxfh() calls virtnet_set_rxfh() 2) virtnet_set_rxfh() calls virtnet_commit_rss_command() 3) virtnet_commit_rss_command() populates 4 entries for the rss scatter-gather 4) Since the command above does not have a key, then the last scatter-gatter entry will be zeroed, since rss_key_size =3D=3D 0. sg_buf_size =3D vi->rss_key_size; 5) This buffer is passed to qemu, but qemu is not happy with a buffer with zero length, and do the following in virtqueue_map_desc() (QEMU function): if (!sz) { virtio_error(vdev, "virtio: zero sized buffers are not allowed"); 6) virtio_error() (also QEMU function) set the device as broken vdev->broken =3D true; 7) Qemu bails out, and do not repond this crazy kernel. 8) The kernel is waiting for the response to come back (function virtnet_send_command()) 9) The kernel is waiting doing the following : while (!virtqueue_get_buf(vi->cvq, &tmp) && !virtqueue_is_broken(vi->cvq)) cpu_relax(); 10) None of the following functions above is true, thus, the kernel loops here forever. Keeping in mind that virtqueue_is_broken() does not look at the qemu `vdev->broken`, so, it never realizes that the vitio is broken at QEMU side. Fix it by not sending RSS commands if the feature is not available in the device. Fixes: c7114b1249fa ("drivers/net/virtio_net: Added basic RSS support.") Cc: stable@vger.kernel.org Cc: qemu-devel@nongnu.org Signed-off-by: Breno Leitao Reviewed-by: Heng Qi Reviewed-by: Xuan Zhuo Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/virtio_net.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3768,6 +3768,7 @@ static int virtnet_set_rxfh(struct net_d struct netlink_ext_ack *extack) { struct virtnet_info *vi =3D netdev_priv(dev); + bool update =3D false; int i; =20 if (rxfh->hfunc !=3D ETH_RSS_HASH_NO_CHANGE && @@ -3775,13 +3776,28 @@ static int virtnet_set_rxfh(struct net_d return -EOPNOTSUPP; =20 if (rxfh->indir) { + if (!vi->has_rss) + return -EOPNOTSUPP; + for (i =3D 0; i < vi->rss_indir_table_size; ++i) vi->ctrl->rss.indirection_table[i] =3D rxfh->indir[i]; + update =3D true; } - if (rxfh->key) + + if (rxfh->key) { + /* If either _F_HASH_REPORT or _F_RSS are negotiated, the + * device provides hash calculation capabilities, that is, + * hash_key is configured. + */ + if (!vi->has_rss && !vi->has_rss_hash_report) + return -EOPNOTSUPP; + memcpy(vi->ctrl->rss.key, rxfh->key, vi->rss_key_size); + update =3D true; + } =20 - virtnet_commit_rss_command(vi); + if (update) + virtnet_commit_rss_command(vi); =20 return 0; } @@ -4686,13 +4702,15 @@ static int virtnet_probe(struct virtio_d if (virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT)) vi->has_rss_hash_report =3D true; =20 - if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) + if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS)) { vi->has_rss =3D true; =20 - if (vi->has_rss || vi->has_rss_hash_report) { vi->rss_indir_table_size =3D virtio_cread16(vdev, offsetof(struct virtio_net_config, rss_max_indirection_table_length)); + } + + if (vi->has_rss || vi->has_rss_hash_report) { vi->rss_key_size =3D virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size= )); =20 Patches currently in stable-queue which might be from leitao@debian.org are queue-6.8/virtio_net-do-not-send-rss-key-if-it-is-not-supported.patch