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 80CE1C47089 for ; Thu, 27 May 2021 13:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FC89610FC for ; Thu, 27 May 2021 13:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236412AbhE0NTr (ORCPT ); Thu, 27 May 2021 09:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236378AbhE0NTp (ORCPT ); Thu, 27 May 2021 09:19:45 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF331C061760 for ; Thu, 27 May 2021 06:18:10 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id lz27so7968371ejb.11 for ; Thu, 27 May 2021 06:18:10 -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=nQgFn8dxliqZkV+84EDBr5D6XtzraqZ1JcCt4vcxaEg=; b=U+4BjfZGBFAb1qVG2dykR4pGeBdKBFy1a0gYiCM/bVIvP4FQgP0Rlv2zd+rc7Cb3qV pR+aE2uu9wEZvhgfWfZxsIR/HpvJ2SiNN/uDvKZIKLLr9rQzwjL8rIyIyDU6Qh6tshvo fPVAeH9h6ZTQlSdYq8Z3GN9z4duLY02ZtqKLyiXt4CnpYZLHuHaD5CywUaq9UxR1K9JO RCRP/QniKCl0pELJZt2SJ4/29wuT+lh8Gu/dnTU2TsNSQ7CgvIKF0SytFPqHlZAnOd0g 949d1X4Aehx49vMb6axO60paWMz84o4PHz2KAygA9S9MxJyuPxN+bjMMCpX/d/j0cmuN lQTw== 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=nQgFn8dxliqZkV+84EDBr5D6XtzraqZ1JcCt4vcxaEg=; b=qrO2utc3tvgixATwhoSOQVaZv+HQsX0Re9Y3fyVyE3uKhHvTLYAMthuy/R+wMStoDq /g3C3I7xwvomqOOLD5U4kWwgplIjJu2sAlx4t4o6L7iTdN4yBwyvhJaOVvpoB1YuNpTp K99Sgf7kwTgRbWwq1OKwekMU6rhcL/gAaLe56jC8RdWF6fEC4ZEjYYF/XEqB1+gUgw8l rzunnkKzJ4GswBjGRiShPGsY5nvI3z+4ptmonF805pLhSD1+WtdmzDhN4Yw3oGBu0+GF 1++riuy0Pdt7kSeczEfq/FPLEdR2GPKMwj/AcErqhSLSvNrv8dnvXHySt3CTbWMSd2MU Fj/g== X-Gm-Message-State: AOAM532I+hW6Q02RI+opoZak0zLhBGVKa25MtqCj5tdcOj+s8KX+xkoR 71QS47EUKq4J2+hGoCVXBVEAeokwo1NGqscIYLmA X-Google-Smtp-Source: ABdhPJzONeuUPApTMkYwvFbbcILylmfJeY2yh2SKaw7NmLK0VfeRDhi2UdjgnlJsCGuc2sUrB8OCqSsNbGKNja1zLzI= X-Received: by 2002:a17:907:1b11:: with SMTP id mp17mr3810051ejc.1.1622121484390; Thu, 27 May 2021 06:18:04 -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> <00ded99f-91b6-ba92-5d92-2366b163f129@redhat.com> In-Reply-To: <00ded99f-91b6-ba92-5d92-2366b163f129@redhat.com> From: Yongji Xie Date: Thu, 27 May 2021 21:17:54 +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 4:41 PM Jason Wang wrote: > > > =E5=9C=A8 2021/5/27 =E4=B8=8B=E5=8D=883:34, Yongji Xie =E5=86=99=E9=81=93= : > > 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 wrot= e: > >>>> =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 w= rote: > >>>>>> =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 fo= rever? > >>>>>> > >>>>>> 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 import= ant, > >>>> 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. > > > Probably. > > > > > >> We had NEEDS_RESET but it looks we don't implement it. > >> > > Could it handle the failure of get_feature() and get/set_config()? > > > Looks not: > > " > > The device SHOULD set DEVICE_NEEDS_RESET when it enters an error state > that a reset is needed. If DRIVER_OK is set, after it sets > DEVICE_NEEDS_RESET, the device MUST send a device configuration change > notification to the driver. > > " > > This looks implies that NEEDS_RESET may only work after device is > probed. But in the current design, even the reset() is not reliable. > > > > > >> 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. > > > Good point. > > But set_config() should be rare: > > E.g in the case of virtio-net with VERSION_1, config space is read only, > and it was set via control vq. > > For block, we can > > 1) start from without WCE or > 2) we add a config change notification to userspace or I prefer this way. And I think we also need to do similar things for set/get_vq_state(). Thanks, Yongji