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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 356B2C4707F for ; Thu, 27 May 2021 07:34:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19C8A6128D for ; Thu, 27 May 2021 07:34:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234205AbhE0Hf6 (ORCPT ); Thu, 27 May 2021 03:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233595AbhE0Hfy (ORCPT ); Thu, 27 May 2021 03:35:54 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF382C061763 for ; Thu, 27 May 2021 00:34:21 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id h20so5079859ejg.1 for ; Thu, 27 May 2021 00:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=JpPCkjOAGobfSNtpJxvUsntsk9lsRgQ1IR3+Mq27bcI=; b=uMfYoJuLhl1KdRjAz6yEq3nbDEYIPQGLPOZo1dzv2U1WiTHQwyTUwYCbEPLT8+euBR 88x6YAEk2hBave7+d7G+vz7hvjmmWMj7KtUuw++18w7mDwPL4FmzZsGHehLYCV/JxvWB 0hXKY78gxyqW23n0ICW56b92UcN6Emj4izFb+TMFEGsfxuWSVVmCM7ddoNKpxI/zUDlC kYi91qI7d/gPDmflc8jbzkRfQvBe8r0E9Rl9fmnhOl3WM+9wsfv/3a3WUQk+YAipuc0y sU4BmfNzMxrrzrFXEaeHWUakPY+IGpQWpVBiWhRBKWSdEIGn1O73/meTmJtMab333NDZ 4luA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=JpPCkjOAGobfSNtpJxvUsntsk9lsRgQ1IR3+Mq27bcI=; b=OVAGfK3BmvbyWxFa8wynSMwxxFOO16NjYUw12luoILPNxRpZbjX3+k8KT2Ql/J0pnP +ofEwqVG9eUbhtw/xs4uKPyT4V0FM071YSZhbvwgR5S/e4RAzvH9U46Sr5oOUo04mrd+ kT6PgUPCm+x8mQNgZoKBHZYwWHDLuGjbl7wcfSzzTbkqzhyB/IudjPCTheBJzs9wU8Bn bT/uryUh1Q7Jst9BcoRwRrj1vGWE4HMar9471SHEhbKjWjUoApJ6GiUzzVRJX/09edOW av5OHY03de5MXKlfIx/AzS7cRyO4sFyvfv5cY1A5i6LFdvKHyLMhpbIBa4z7nEsy7y/G s7lQ== X-Gm-Message-State: AOAM531gzvo1F62j6k+OPVis2zqCoZ6F5ol52z07GBxDnKACNNXFgC4j PvKoAF236Lj2HmnfT9wtvXLKuyFjLrC0xZayM85f X-Google-Smtp-Source: ABdhPJx+nv79LV9LGHH2XXyBW6TJ1VbhAhSRhvc0U1UpO3biGSUk5ekbz3VHC3tbBnZ/C+qT8NXNA6kYjMYh4+evHdM= X-Received: by 2002:a17:907:7684:: with SMTP id jv4mr2315095ejc.427.1622100860243; Thu, 27 May 2021 00:34:20 -0700 (PDT) MIME-Version: 1.0 References: <20210517095513.850-1-xieyongji@bytedance.com> <20210517095513.850-12-xieyongji@bytedance.com> <3740c7eb-e457-07f3-5048-917c8606275d@redhat.com> <5a68bb7c-fd05-ce02-cd61-8a601055c604@redhat.com> In-Reply-To: From: Yongji Xie Date: Thu, 27 May 2021 15:34:09 +0800 Message-ID: Subject: Re: Re: [PATCH v7 11/12] vduse: Introduce VDUSE - vDPA Device in Userspace To: Jason Wang Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Christoph Hellwig , Christian Brauner , Randy Dunlap , Matthew Wilcox , Al Viro , Jens Axboe , bcrl@kvack.org, Jonathan Corbet , =?UTF-8?Q?Mika_Penttil=C3=A4?= , Dan Carpenter , joro@8bytes.org, virtualization , netdev@vger.kernel.org, kvm , linux-fsdevel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, May 27, 2021 at 1:40 PM Jason Wang wrote: > > > =E5=9C=A8 2021/5/27 =E4=B8=8B=E5=8D=881:08, Yongji Xie =E5=86=99=E9=81=93= : > > On Thu, May 27, 2021 at 1:00 PM Jason Wang wrote: > >> > >> =E5=9C=A8 2021/5/27 =E4=B8=8B=E5=8D=8812:57, Yongji Xie =E5=86=99=E9= =81=93: > >>> On Thu, May 27, 2021 at 12:13 PM Jason Wang wro= te: > >>>> =E5=9C=A8 2021/5/17 =E4=B8=8B=E5=8D=885:55, Xie Yongji =E5=86=99=E9= =81=93: > >>>>> + > >>>>> +static int vduse_dev_msg_sync(struct vduse_dev *dev, > >>>>> + struct vduse_dev_msg *msg) > >>>>> +{ > >>>>> + init_waitqueue_head(&msg->waitq); > >>>>> + spin_lock(&dev->msg_lock); > >>>>> + vduse_enqueue_msg(&dev->send_list, msg); > >>>>> + wake_up(&dev->waitq); > >>>>> + spin_unlock(&dev->msg_lock); > >>>>> + wait_event_killable(msg->waitq, msg->completed); > >>>> What happens if the userspace(malicous) doesn't give a response fore= ver? > >>>> > >>>> It looks like a DOS. If yes, we need to consider a way to fix that. > >>>> > >>> How about using wait_event_killable_timeout() instead? > >> > >> Probably, and then we need choose a suitable timeout and more importan= t, > >> need to report the failure to virtio. > >> > > Makes sense to me. But it looks like some > > vdpa_config_ops/virtio_config_ops such as set_status() didn't have a > > return value. Now I add a WARN_ON() for the failure. Do you mean we > > need to add some change for virtio core to handle the failure? > > > Maybe, but I'm not sure how hard we can do that. > We need to change all virtio device drivers in this way. > We had NEEDS_RESET but it looks we don't implement it. > Could it handle the failure of get_feature() and get/set_config()? > Or a rough idea is that maybe need some relaxing to be coupled loosely > with userspace. E.g the device (control path) is implemented in the > kernel but the datapath is implemented in the userspace like TUN/TAP. > I think it can work for most cases. One problem is that the set_config might change the behavior of the data path at runtime, e.g. virtnet_set_mac_address() in the virtio-net driver and cache_type_store() in the virtio-blk driver. Not sure if this path is able to return before the datapath is aware of this change. Thanks, Yongji