Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2960095ybg; Thu, 24 Oct 2019 18:44:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcbnFxeNvbn2UVpYPnHxerdL9VzFwYNdOSXCr+gM2IB3J4IB67PTNv1rEotPVCLUbd2qDg X-Received: by 2002:a17:906:298f:: with SMTP id x15mr1125561eje.50.1571967872001; Thu, 24 Oct 2019 18:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571967871; cv=none; d=google.com; s=arc-20160816; b=CLn8mDfvh1whVnMbf8DvNnhoQd4dPjMQ4DhOBcV4+48996xL1W5HrH6zg6hu4Gn0aV 4DOrL+DcH4iwsd9+au8C5W6uob2a5Rofy6ZPsSr114l5aBZsl5sVclJO8pTMLZU7ibPa Y4nZksgxojnS86I/WMfJ+ggnRo8wxy2hLREvoBAuOf50tHQ1xRaiMVnuYwTqkeJneuIE hwvAFoHTMsCs/lZRvagQUrEe+OHN3n+htmaZ6fLPuQR4T1udFFUWvfMzSJNOiO9/nvf0 jd9zyFquzzLFYltl+pa6zKOea48AYVYUlnNTd+313PePX/IAb0RRWKSR+IRVTZ0PiDv3 wuEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=GP6qD2J1CBmhiVD+sbR/nBuazK8LU9m7yhlITTEQS64=; b=I2UBsVWyTDi3/3somwreHRK2KAenTOgp9QPw5Zce7Jxj9Ay4QOx2pYWSy5/dOmQJv7 ja+ZblF3afutYgw4msrLs/wo9GI+Hd72KFfzYAScOyoK4h2eP+mvrnnfRMg/SzDEJGEG Ej+Fp2FHxUoeiJiAeBbcitSYAcGfFqTY2CBXBWvmwLAI7gaSkwCXR3yI6dCciJMQtkJD AyWLAybvoY+Eiops7iVAcN+0yJD4PHPzf39ZcKD8BfmWUvJ0MMYXLKVcNSOaBw3S6GdW jG4q+hRH+dJNZX6BNuKGsQkhnXRPeDKfWnyCXHRiDeeqEb0XzW9BzFhZ4mdVKoEgIK2p kvOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AOlZgQZO; 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 p21si327304ejx.364.2019.10.24.18.44.08; Thu, 24 Oct 2019 18:44:31 -0700 (PDT) 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=AOlZgQZO; 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 S2438254AbfJXIdI (ORCPT + 99 others); Thu, 24 Oct 2019 04:33:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40220 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2438241AbfJXIdH (ORCPT ); Thu, 24 Oct 2019 04:33:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571905985; 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=GP6qD2J1CBmhiVD+sbR/nBuazK8LU9m7yhlITTEQS64=; b=AOlZgQZOV2vsGc3u91nDFVabCURQZD0C6/X53vifylKMPYENkQwKEiDql68+dxKTLUyj/u 62wNz2SOtwZuyW1uAhWhfx9fKtMKBrnaPeVZCmDU4ELRdrNcovLpzn1lVTpIvlA7AoXpUH bjrD/K/9iWYY79k6M7rGZB/pYIqfMq4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-zHllE4ZJP_6HPNgUQkm_IQ-1; Thu, 24 Oct 2019 04:33:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B751A800D5A; Thu, 24 Oct 2019 08:33:00 +0000 (UTC) Received: from [10.72.13.32] (ovpn-13-32.pek2.redhat.com [10.72.13.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A93A5D717; Thu, 24 Oct 2019 08:32:43 +0000 (UTC) Subject: Re: [PATCH v2] vhost: introduce mdev based hardware backend From: Jason Wang To: Tiwei Bie Cc: mst@redhat.com, alex.williamson@redhat.com, maxime.coquelin@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, dan.daly@intel.com, cunming.liang@intel.com, zhihong.wang@intel.com, lingshan.zhu@intel.com References: <20191022095230.2514-1-tiwei.bie@intel.com> <47a572fd-5597-1972-e177-8ee25ca51247@redhat.com> <20191023030253.GA15401@___> <20191023070747.GA30533@___> <106834b5-dae5-82b2-0f97-16951709d075@redhat.com> <20191023101135.GA6367@___> <5a7bc5da-d501-2750-90bf-545dd55f85fa@redhat.com> <20191024042155.GA21090@___> Message-ID: Date: Thu, 24 Oct 2019 16:32:42 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: zHllE4ZJP_6HPNgUQkm_IQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/24 =E4=B8=8B=E5=8D=884:03, Jason Wang wrote: > > On 2019/10/24 =E4=B8=8B=E5=8D=8812:21, Tiwei Bie wrote: >> On Wed, Oct 23, 2019 at 06:29:21PM +0800, Jason Wang wrote: >>> On 2019/10/23 =E4=B8=8B=E5=8D=886:11, Tiwei Bie wrote: >>>> On Wed, Oct 23, 2019 at 03:25:00PM +0800, Jason Wang wrote: >>>>> On 2019/10/23 =E4=B8=8B=E5=8D=883:07, Tiwei Bie wrote: >>>>>> On Wed, Oct 23, 2019 at 01:46:23PM +0800, Jason Wang wrote: >>>>>>> On 2019/10/23 =E4=B8=8A=E5=8D=8811:02, Tiwei Bie wrote: >>>>>>>> On Tue, Oct 22, 2019 at 09:30:16PM +0800, Jason Wang wrote: >>>>>>>>> On 2019/10/22 =E4=B8=8B=E5=8D=885:52, Tiwei Bie wrote: >>>>>>>>>> This patch introduces a mdev based hardware vhost backend. >>>>>>>>>> This backend is built on top of the same abstraction used >>>>>>>>>> in virtio-mdev and provides a generic vhost interface for >>>>>>>>>> userspace to accelerate the virtio devices in guest. >>>>>>>>>> >>>>>>>>>> This backend is implemented as a mdev device driver on top >>>>>>>>>> of the same mdev device ops used in virtio-mdev but using >>>>>>>>>> a different mdev class id, and it will register the device >>>>>>>>>> as a VFIO device for userspace to use. Userspace can setup >>>>>>>>>> the IOMMU with the existing VFIO container/group APIs and >>>>>>>>>> then get the device fd with the device name. After getting >>>>>>>>>> the device fd of this device, userspace can use vhost ioctls >>>>>>>>>> to setup the backend. >>>>>>>>>> >>>>>>>>>> Signed-off-by: Tiwei Bie >>>>>>>>>> --- >>>>>>>>>> This patch depends on below series: >>>>>>>>>> https://lkml.org/lkml/2019/10/17/286 >>>>>>>>>> >>>>>>>>>> v1 -> v2: >>>>>>>>>> - Replace _SET_STATE with _SET_STATUS (MST); >>>>>>>>>> - Check status bits at each step (MST); >>>>>>>>>> - Report the max ring size and max number of queues (MST); >>>>>>>>>> - Add missing MODULE_DEVICE_TABLE (Jason); >>>>>>>>>> - Only support the network backend w/o multiqueue for now; >>>>>>>>> Any idea on how to extend it to support devices other than=20 >>>>>>>>> net? I think we >>>>>>>>> want a generic API or an API that could be made generic in the=20 >>>>>>>>> future. >>>>>>>>> >>>>>>>>> Do we want to e.g having a generic vhost mdev for all kinds of=20 >>>>>>>>> devices or >>>>>>>>> introducing e.g vhost-net-mdev and vhost-scsi-mdev? >>>>>>>> One possible way is to do what vhost-user does. I.e. Apart from >>>>>>>> the generic ring, features, ... related ioctls, we also introduce >>>>>>>> device specific ioctls when we need them. As vhost-mdev just needs >>>>>>>> to forward configs between parent and userspace and even won't >>>>>>>> cache any info when possible, >>>>>>> So it looks to me this is only possible if we expose e.g=20 >>>>>>> set_config and >>>>>>> get_config to userspace. >>>>>> The set_config and get_config interface isn't really everything >>>>>> of device specific settings. We also have ctrlq in virtio-net. >>>>> Yes, but it could be processed by the exist API. Isn't it? Just=20 >>>>> set ctrl vq >>>>> address and let parent to deal with that. >>>> I mean how to expose ctrlq related settings to userspace? >>> >>> I think it works like: >>> >>> 1) userspace find ctrl_vq is supported >>> >>> 2) then it can allocate memory for ctrl vq and set its address through >>> vhost-mdev >>> >>> 3) userspace can populate ctrl vq itself >> I see. That is to say, userspace e.g. QEMU will program the >> ctrl vq with the existing VHOST_*_VRING_* ioctls, and parent >> drivers should know that the addresses used in ctrl vq are >> host virtual addresses in vhost-mdev's case. > > > That's really good point. And that means parent needs to differ vhost=20 > from virtio. It should work.=20 HVA may only work when we have something similar to VHOST_SET_OWNER=20 which can reuse MM of its owner. > But is there any chance to use DMA address? I'm asking since the API=20 > then tends to be device specific.=20 I wonder whether we can introduce MAP IOMMU notifier and get DMA=20 mappings from that. Thanks