Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20467512ybl; Sun, 5 Jan 2020 03:23:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxOc/eIqaAP5jN1K+SAo2Qr1RSQGQXDRGVWL2B8wSp0EGUBrs4TQ/gvOT7Yg+lJsCyee47m X-Received: by 2002:a9d:6502:: with SMTP id i2mr83395904otl.206.1578223418166; Sun, 05 Jan 2020 03:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578223418; cv=none; d=google.com; s=arc-20160816; b=0EKVlLUpphs1eOkoGQ1G4S0+rfogdB/mfYlD5yTWiAKkczip4489AD0VP5meDUVrWF 1PJx6ssCqY3JOlk6rjkxTmTrDtflGMOflku9/8TiAt/EjfHWo0L9/DU5xGaTu21/l2Ba 3m824kn9oHBkUHLsy4aZbc+IWh8oAmpTeup2ncKBItEZa1aV+9DKI3O8EwD1q1H75gOs SKbfk/k85b4FdtCdYrR7V97emv59WshyWrtri/OES/9J9yrYBP8bjkAptWo4W51aI6kM jdPyC2X7rIzt02EBFzuXbdoz7XoPgYj8icZ75ijUGh0Rn8KboQpSWs+/7Nb0c4WbSZ0N wuZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+GGlSSbeC4Kbhr61r3dRU9qa1eVoeraY/lQ162mo0Jg=; b=yBzOd2RQdHQTNUIpXUo0aibaWoWU8EGqp+5x1Z89HcarMOu+GXKRLuhj4+d0wfQicp r65yERyT03opzvE2xpwEcMmgS8IFGnD40wTNtLYfQKyiCCnpz61vObJsZrSPUsTW2Swv a3XdwsGrqUVOUleAqA4LdAJjQ8BiKuoUrxBvWqaKxjDsSPqmW8o1VPeK94gTOlIWh5/p bpB8ND05UNfT9uGV+qSkxgGZbOXljSKCsDguGeQRd4rgme3ZUiqyZAl2cr0Lfv5j2KOC TmFkEOwEigJrGr1smZ6G+24I5grvc6PLTbFsHBzAY7/nowGFdClR+cPA9A5WhRlWnNgy Ayyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WtHbvrcn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si34157128otr.227.2020.01.05.03.23.12; Sun, 05 Jan 2020 03:23:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WtHbvrcn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726141AbgAELQl (ORCPT + 99 others); Sun, 5 Jan 2020 06:16:41 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49423 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725930AbgAELQl (ORCPT ); Sun, 5 Jan 2020 06:16:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578222999; 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=+GGlSSbeC4Kbhr61r3dRU9qa1eVoeraY/lQ162mo0Jg=; b=WtHbvrcnb7uj/nbsnYYHVHjmVdQ9yrNOKlV0Kq+ZP3LErUs8VCq1UHFdIiQetc5KKxHxgi jWDusYJ0aPYIxL8tsbZnmOwbi2QcMcQLy+6OeVfLRd8x8FLY3FPbxeD8m5DGjL0qghYxKa UUwyRYgGOifxfwJPRoJoeUAUBS0Ry80= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-432-CvbVxVnhOgqn9tn_TJcitg-1; Sun, 05 Jan 2020 06:16:37 -0500 X-MC-Unique: CvbVxVnhOgqn9tn_TJcitg-1 Received: by mail-qt1-f198.google.com with SMTP id c8so32472204qte.22 for ; Sun, 05 Jan 2020 03:16:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=+GGlSSbeC4Kbhr61r3dRU9qa1eVoeraY/lQ162mo0Jg=; b=mHXfkG91ojmxuMFike/m8p2pKCsQRXFM5nDfQbWJNFq/rt1PW2MujGsx3GfI+1+LHo nSNeHHA/3s4AztG8FGjbzhY84oNisZ+qkKkhfhGCzyWvsAML1/kwmbF1jkNnpfwx11Ed +8VhUwsQmZaaX/JhthnDnP5qF87VwLvw7R4PghHgs8DrKkoC/7qVQsuD+GI/9iHodNge V1GjD2RwQZXYA1VJzYpiR3OM8S9GkgTkDg7eMrBKbp+baFoMKV9xkXIRA06/qw55bbnv m2X31v4M3ZYUhHHHHf63/vpV2yztDBe6KtC+dpqCaqDqe0jKr8AUo0WsDpcJy5BKJ9j6 wzpw== X-Gm-Message-State: APjAAAUGlEC1P8n/ndgQnuc/iEbqPLGDW/y6ZIjbRXYoZO8Ho9u0tzzV ZAkNtC0gX+4TLoLJ9AvXLlwFRR8OXGu+nJlUtpuBXfwlUQdZwlpqx+sj0+LRTdn5JOs68WWMhjY 2mDp9yl1tbtGGr1aM7AaFW2AR X-Received: by 2002:a37:68d5:: with SMTP id d204mr78760684qkc.171.1578222997285; Sun, 05 Jan 2020 03:16:37 -0800 (PST) X-Received: by 2002:a37:68d5:: with SMTP id d204mr78760671qkc.171.1578222996963; Sun, 05 Jan 2020 03:16:36 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id t7sm19125131qkm.136.2020.01.05.03.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 03:16:36 -0800 (PST) Date: Sun, 5 Jan 2020 06:16:30 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Alistair Delva , Willem de Bruijn , LKML , "David S. Miller" , virtualization@lists.linux-foundation.org, Network Development Subject: Re: [PATCH net] virtio_net: CTRL_GUEST_OFFLOADS depends on CTRL_VQ Message-ID: <20200105061532-mutt-send-email-mst@kernel.org> References: <20191223140322.20013-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 24, 2019 at 10:49:13AM +0800, Jason Wang wrote: > > On 2019/12/24 上午4:21, Alistair Delva wrote: > > On Mon, Dec 23, 2019 at 12:12 PM Willem de Bruijn > > wrote: > > > On Mon, Dec 23, 2019 at 2:56 PM Willem de Bruijn > > > wrote: > > > > 00fffe0ff0 DR7: 0000000000000400 > > > > > > Call Trace: > > > > > > ? preempt_count_add+0x58/0xb0 > > > > > > ? _raw_spin_lock_irqsave+0x36/0x70 > > > > > > ? _raw_spin_unlock_irqrestore+0x1a/0x40 > > > > > > ? __wake_up+0x70/0x190 > > > > > > virtnet_set_features+0x90/0xf0 [virtio_net] > > > > > > __netdev_update_features+0x271/0x980 > > > > > > ? nlmsg_notify+0x5b/0xa0 > > > > > > dev_disable_lro+0x2b/0x190 > > > > > > ? inet_netconf_notify_devconf+0xe2/0x120 > > > > > > devinet_sysctl_forward+0x176/0x1e0 > > > > > > proc_sys_call_handler+0x1f0/0x250 > > > > > > proc_sys_write+0xf/0x20 > > > > > > __vfs_write+0x3e/0x190 > > > > > > ? __sb_start_write+0x6d/0xd0 > > > > > > vfs_write+0xd3/0x190 > > > > > > ksys_write+0x68/0xd0 > > > > > > __ia32_sys_write+0x14/0x20 > > > > > > do_fast_syscall_32+0x86/0xe0 > > > > > > entry_SYSENTER_compat+0x7c/0x8e > > > > > > > > > > > > A similar crash will likely trigger when enabling XDP. > > > > > > > > > > > > Reported-by: Alistair Delva > > > > > > Reported-by: Willem de Bruijn > > > > > > Fixes: 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set") > > > > > > Signed-off-by: Michael S. Tsirkin > > > > > > --- > > > > > > > > > > > > Lightly tested. > > > > > > > > > > > > Alistair, could you please test and confirm that this resolves the > > > > > > crash for you? > > > > > This patch doesn't work. The reason is that NETIF_F_LRO is also turned > > > > > on by TSO4/TSO6, which your patch didn't check for. So it ends up > > > > > going through the same path and crashing in the same way. > > > > > > > > > > if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || > > > > > virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)) > > > > > dev->features |= NETIF_F_LRO; > > > > > > > > > > It sounds like this patch is fixing something slightly differently to > > > > > my patch fixed. virtnet_set_features() doesn't care about > > > > > GUEST_OFFLOADS, it only tests against NETIF_F_LRO. Even if "offloads" > > > > > is zero, it will call virtnet_set_guest_offloads(), which triggers the > > > > > crash. > > > > > > > > Interesting. It's surprising that it is trying to configure a flag > > > > that is not configurable, i.e., absent from dev->hw_features > > > > after Michael's change. > > > > > > > > > So either we need to ensure NETIF_F_LRO is never set, or > > > > LRO might be available, just not configurable. Indeed this was what I > > > > observed in the past. > > > dev_disable_lro expects that NETIF_F_LRO is always configurable. Which > > > I guess is a reasonable assumption, just not necessarily the case in > > > virtio_net. > > > > > > So I think we need both patches. Correctly mark the feature as fixed > > > by removing from dev->hw_features and also ignore the request from > > > dev_disable_lro, which does not check for this. > > Something like this maybe: > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 4d7d5434cc5d..0556f42b0fb5 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -2560,6 +2560,9 @@ static int virtnet_set_features(struct net_device *dev, > > u64 offloads; > > int err; > > > > + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) > > + return 0; > > + > > if ((dev->features ^ features) & NETIF_F_LRO) { > > if (vi->xdp_queue_pairs) > > return -EBUSY; > > @@ -2971,6 +2974,15 @@ static int virtnet_validate(struct virtio_device *vdev) > > if (!virtnet_validate_features(vdev)) > > return -EINVAL; > > > > + /* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without > > + * VIRTIO_NET_F_CTRL_VQ. However the virtio spec does not > > + * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends > > + * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but > > + * not the former. > > + */ > > + if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) > > + __virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS); > > + > > if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { > > int mtu = virtio_cread16(vdev, > > offsetof(struct virtio_net_config, > > > > We check feature dependency and fail the probe in > virtnet_validate_features(). > > Is it more straightforward to fail the probe there when CTRL_GUEST_OFFLOADS > was set but CTRL_VQ wasn't? > > Thanks Expanding on what the comment above says, we can't fail probe in this configuration without breaking the driver for spec compliant devices. -- MST