Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20545225ybl; Sun, 5 Jan 2020 05:15:00 -0800 (PST) X-Google-Smtp-Source: APXvYqynHEDCp85nm2n5MLmE9cpk9S1wTWr90OwxSVnxBs8azM1hM03gJMa6AqfpZuyWw6v+FqKe X-Received: by 2002:a9d:65cf:: with SMTP id z15mr113568739oth.238.1578230100798; Sun, 05 Jan 2020 05:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578230100; cv=none; d=google.com; s=arc-20160816; b=M7tDaa6E83lWxUeyEjEn6EFwNtHby4jDALzsy/R6bkZ3Wuhps6SuggfkT8DaJVc992 VKZG/Dzaka57xaApdXFZV1W7tJAUheH8UEfS/TsztDpKnrVK4hiqXuv2lwrEFx1n24n+ fvGwb1mQx2rXoLR05jYTB2dY6hFRAkZH7LshJazsYJvB8VgrgCUM4eFKWozghEcHcOCK 2K2IEyoFWBVdkd6iQtb1W4C+bbc/8DpCImU+d9oaz27FfJTwgbz4NbVGO+2Ci6yFm+6C 7oLLN/dlH/BJ4svNjf3n+OrYomc5t1oYzm12dENX18diB29rCeweeJEsVWR70Ag+LjWK 5ByA== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Fk09R+kHO6037bNMYCslAmNwggGNiJ8jA8PAG3EtmFs=; b=XWs83QHPPZnxjEw8jyXXiHzUDA9B3SvKIJ7MzlVATGzMS8aYnPf78BwYWKryBHQJfd Eporok16ahLPNsSQKi9WHHBKgeouZHk86z7Y1GpAnh+jDhnkFZ3tp1990R+O2dQ3h4lj EgA7M5tQxHPylbISdc7wpY/bCOioZjhD730W84xfOcgZnEK8dM4RjoU1No4A+ILAw8rs dvFMnDXNbOIYKsdAzPnutQfG6a58ltykxwwkDzSJJpqQtsc41U9pyNkUD5LL8XL/Z+IY NJV748J2Z+eERhE96M4hsuNzANUnj38GnqAUuQPq/DxFrwKi2DHhGy/irCfu+dAbxnxi 992A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R7wNr+I7; 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 w7si34554303otq.250.2020.01.05.05.14.48; Sun, 05 Jan 2020 05:15:00 -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=R7wNr+I7; 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 S1726391AbgAENOD (ORCPT + 99 others); Sun, 5 Jan 2020 08:14:03 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28752 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726188AbgAENOC (ORCPT ); Sun, 5 Jan 2020 08:14:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578230040; 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: in-reply-to:in-reply-to:references:references; bh=Fk09R+kHO6037bNMYCslAmNwggGNiJ8jA8PAG3EtmFs=; b=R7wNr+I724MMHWTzLsyA98YshUdJMxO4fTkYS3bFYpbl8rw2ePChvbqfBIlfgn3lEdq4nf 9FP0dQMNB34muCwunWw627XdthjYBHrqh3PFqO3RnHZ67xHnXOELngtCGc8fOuX2yk6Ghb 702XNZfX6EDfAmFgn1pItco7qdqefjQ= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-ERRgaFS8M3in-d5K1EqQxQ-1; Sun, 05 Jan 2020 08:13:58 -0500 X-MC-Unique: ERRgaFS8M3in-d5K1EqQxQ-1 Received: by mail-qt1-f200.google.com with SMTP id c8so32610291qte.22 for ; Sun, 05 Jan 2020 05:13:58 -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:in-reply-to; bh=Fk09R+kHO6037bNMYCslAmNwggGNiJ8jA8PAG3EtmFs=; b=KfVzBoO/gKWdhDyCWplkuTbUWUr1RxmIePMIzPWF7CW9R7NtuYDEJIArxvvCufnf3G GV1ki5DneCHlZfrpVwyN61RwKyiRApp8d5qI6RdkqWsMtH4nGQht0kGTQtTBACRygwAu RYyFS4dhHEH5+eUyR5iT2URnndt64Be6DPqUCn2s5JgXAKNFSF1PKot23pwbAMnm3e/3 fWkLbYsoe2D0CyM8W2He8Pre6jV5hlPcFRqJ5KMFtDvm1ejOiXi+7kLkC6lR+rH4/QD2 /VzM2g84/r/PSbRZBCvU4l+GCCY2Rz3C7Xy5DACjYeSuodJE2wiBW8PWm5JeiSWYMZXe rFaQ== X-Gm-Message-State: APjAAAVPXVZ6YsVW2b758ZPAD6i7X6flMP9O7RVUUCzOrFHX3oKM1g2y Eu2AlN2IoR87CYyXbstkEScCWXdXHtL7J9gpi5CWAG6P3iFjjhM/rbz02dftXS0b5hzM1zBvsQF HusMEDRyYwlv4q9FP4SrFqa36 X-Received: by 2002:ae9:f506:: with SMTP id o6mr78042887qkg.41.1578230038399; Sun, 05 Jan 2020 05:13:58 -0800 (PST) X-Received: by 2002:ae9:f506:: with SMTP id o6mr78042873qkg.41.1578230038128; Sun, 05 Jan 2020 05:13:58 -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 g21sm19193743qkl.116.2020.01.05.05.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 05:13:57 -0800 (PST) Date: Sun, 5 Jan 2020 08:13:52 -0500 From: "Michael S. Tsirkin" To: Alistair Delva Cc: Willem de Bruijn , LKML , Jason Wang , "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: <20200105081312-mutt-send-email-mst@kernel.org> References: <20191223140322.20013-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 23, 2019 at 12:21:56PM -0800, 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; Should this return error here? > @@ -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, This is just my virtio_net: CTRL_GUEST_OFFLOADS depends on CTRL_VQ right?