From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0FC8C433FE for ; Tue, 22 Mar 2022 13:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235648AbiCVNhw (ORCPT ); Tue, 22 Mar 2022 09:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235634AbiCVNhv (ORCPT ); Tue, 22 Mar 2022 09:37:51 -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 ESMTP id D3BFF7B137 for ; Tue, 22 Mar 2022 06:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647956181; 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=yEfbx3KDPFlRi9NsR3t9OxuLawKBXpgCccFQfHQvcxA=; b=NiQSgX5t4rKEK6e25+vvVswrgluzj7pQqCaQpFqDv5qqDJ12e6bnSoL8KA1rE8k7Mnew+0 IYannNNRQw+fuKefyrvHxiIQp0q7CwuVZ6btshHbDY78VCjNw2rvVfLpfu4Hy362TMRfhm MAV81cjRudpPPlwaKD7IP9qhIpMhMdQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-2Z3yqIFWON-dm2FFJyrWXQ-1; Tue, 22 Mar 2022 09:36:20 -0400 X-MC-Unique: 2Z3yqIFWON-dm2FFJyrWXQ-1 Received: by mail-wm1-f71.google.com with SMTP id q6-20020a1cf306000000b0038c5726365aso931181wmq.3 for ; Tue, 22 Mar 2022 06:36:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yEfbx3KDPFlRi9NsR3t9OxuLawKBXpgCccFQfHQvcxA=; b=d8DVpiJvmi0eZmy97QPZopNRXrGKhiEQxhpEQy42GC105+b7P/keyT8H02WHOFKg2e Bb03LyRy8HR9YFs3SDCmyHVCp+B8O7OKUY3ScOBVBB08HZfwRYJbwyQYIMhsTJN7NNmS 73yXWem17JvZ52LgUYjRWr9wNIfYjEBGnDjeHRN/aza5aaiUYuqKjIWIpWE4usz34cSZ rZq9jdDfApo243gf5B1gGCaE5DmRtUW44udW4NdYzmL1UGSG1jT5N1rYFLGQdIBlOIF0 6NXIP63NLCG6zGKwGERIBaeHbjgGqEacpRDvRpUZTmJqELjTIEjbNuPVkV6A6AflDkuP v8Ng== X-Gm-Message-State: AOAM533TPTfnv5KlEsUzk+rplIo+UtiK63TqiMQNwFV04/bTHeEcjL/2 f3T4ghSNv+1ceYqMDUy2qHz2a0l6ZgA5X7Gk3Fh8FCsMX1qS6XNh/9gamlfoAgZ0xkaTyI1xfRz THsOzB6/euwD2 X-Received: by 2002:a5d:5982:0:b0:204:1b19:40da with SMTP id n2-20020a5d5982000000b002041b1940damr6150027wri.23.1647956179332; Tue, 22 Mar 2022 06:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt2WiiDuMgW7o4aI8TTeUozv/0SKfKOVFu6npOXGitY0mPpGVzP8XK+kXs7cco7hBpouXLOw== X-Received: by 2002:a5d:5982:0:b0:204:1b19:40da with SMTP id n2-20020a5d5982000000b002041b1940damr6150004wri.23.1647956179070; Tue, 22 Mar 2022 06:36:19 -0700 (PDT) Received: from redhat.com ([2.55.132.0]) by smtp.gmail.com with ESMTPSA id q14-20020a1cf30e000000b0038986a18ec8sm1910031wmq.46.2022.03.22.06.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 06:36:18 -0700 (PDT) Date: Tue, 22 Mar 2022 09:36:14 -0400 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, Asias He , "David S. Miller" , Jakub Kicinski , Stefan Hajnoczi , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Abeni Subject: Re: [PATCH net] vsock/virtio: enable VQs early on probe Message-ID: <20220322092723-mutt-send-email-mst@kernel.org> References: <20220322103823.83411-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220322103823.83411-1-sgarzare@redhat.com> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Mar 22, 2022 at 11:38:23AM +0100, Stefano Garzarella wrote: > virtio spec requires drivers to set DRIVER_OK before using VQs. > This is set automatically after probe returns, but virtio-vsock > driver uses VQs in the probe function to fill rx and event VQs > with new buffers. So this is a spec violation. absolutely. > Let's fix this, calling virtio_device_ready() before using VQs > in the probe function. > > Fixes: 0ea9e1d3a9e3 ("VSOCK: Introduce virtio_transport.ko") > Signed-off-by: Stefano Garzarella > --- > net/vmw_vsock/virtio_transport.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c > index 5afc194a58bb..b1962f8cd502 100644 > --- a/net/vmw_vsock/virtio_transport.c > +++ b/net/vmw_vsock/virtio_transport.c > @@ -622,6 +622,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev) > INIT_WORK(&vsock->event_work, virtio_transport_event_work); > INIT_WORK(&vsock->send_pkt_work, virtio_transport_send_pkt_work); > > + virtio_device_ready(vdev); > + > mutex_lock(&vsock->tx_lock); > vsock->tx_run = true; > mutex_unlock(&vsock->tx_lock); Here's the whole code snippet: mutex_lock(&vsock->tx_lock); vsock->tx_run = true; mutex_unlock(&vsock->tx_lock); mutex_lock(&vsock->rx_lock); virtio_vsock_rx_fill(vsock); vsock->rx_run = true; mutex_unlock(&vsock->rx_lock); mutex_lock(&vsock->event_lock); virtio_vsock_event_fill(vsock); vsock->event_run = true; mutex_unlock(&vsock->event_lock); if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET)) vsock->seqpacket_allow = true; vdev->priv = vsock; rcu_assign_pointer(the_virtio_vsock, vsock); mutex_unlock(&the_virtio_vsock_mutex); I worry that this is not the only problem here: seqpacket_allow and setting of vdev->priv at least after device is active look suspicious. E.g.: static void virtio_vsock_event_done(struct virtqueue *vq) { struct virtio_vsock *vsock = vq->vdev->priv; if (!vsock) return; queue_work(virtio_vsock_workqueue, &vsock->event_work); } looks like it will miss events now they will be reported earlier. One might say that since vq has been kicked it might send interrupts earlier too so not a new problem, but there's a chance device actually waits until DRIVER_OK to start operating. > -- > 2.35.1