Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3466423ybi; Fri, 5 Jul 2019 07:50:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjY2eaWEurjQGZHfXApWMC1OJS4eSxz/jqrXMWyubxfmKjsUcUstes9n1BWE77ONt6Kkdy X-Received: by 2002:a17:902:4283:: with SMTP id h3mr5984717pld.15.1562338250093; Fri, 05 Jul 2019 07:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562338250; cv=none; d=google.com; s=arc-20160816; b=lo6/BhaTy6mJcQjZTCzKa2zhKwoN1QPGS5tsdNiWP9QsRvw21ZsJd2vvcFFiiHPTuh AAcOuNP1ebef1nz9L5NA/LJFbES34NwLVbEkJACoshw3+9os9IT5xJNMxJ19w1V9MUN/ 6ZIN8HNoeBAOeb/E30Sy2BFmreDrkmY58+DQhHPKF5Fjq7iiRivH/r/+pHRyqAo9oWR7 qRw4G6x9tORVAftHOklg6hy0QnrfdfCL9llHWtpmw5FRBc6qztoFrLvz7NQPBEVLbskw GTwcVGvV5I+tll5P+OqfzE3Lux+xOj6LOBzdRQ3VFeMdNrPaiq6EDKFvs49x7FD5xBVU afHg== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=tLLiw2QKBYdLKt4h34I1TN+JZmUIdBhz7QlcSkNQpc4=; b=MJu2hwuA2Gex/4XWpqb7ISJro8zYrQ6ZElOCoIMjWLeL42irZfpVNqos0LUM6Otvby iBhoBPxW5NJ1QwSi4lCehWRFm2R/vZeQlO7CXciDQr8JqceBfGSlulqDcZe98YAQHCZo X+7MhX7zf5YiexPHaSKjEoUinYnIK2HpgXkcGjtyQXMCUDIHc1JDTQxDAYLxodJUpM2p DNSM3WzRClan6HKW6erhV1je39GeBOAQMkcILlRkZ+1O2RgITMHZQei4Z20Yrvj+5eTx OSJ3du/beSlffJxAcJDCyNRuCzhLhgtP1+XXtAUGZcFF3YoQjGsYQtkIwnnNKK7bUNxL PvHw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 y12si3916958pfg.260.2019.07.05.07.50.33; Fri, 05 Jul 2019 07:50:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfGEOuI convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Jul 2019 10:50:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46202 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfGEOuI (ORCPT ); Fri, 5 Jul 2019 10:50:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65412308213B; Fri, 5 Jul 2019 14:49:57 +0000 (UTC) Received: from x1.home (ovpn-116-83.phx2.redhat.com [10.3.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id D63269D90A; Fri, 5 Jul 2019 14:49:47 +0000 (UTC) Date: Fri, 5 Jul 2019 08:49:46 -0600 From: Alex Williamson To: Tiwei Bie Cc: Jason Wang , mst@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 Subject: Re: [RFC v2] vhost: introduce mdev based hardware vhost backend Message-ID: <20190705084946.67b8f9f5@x1.home> In-Reply-To: <20190704062134.GA21116@___> References: <20190703091339.1847-1-tiwei.bie@intel.com> <7b8279b2-aa7e-7adc-eeff-20dfaf4400d0@redhat.com> <20190703115245.GA22374@___> <64833f91-02cd-7143-f12e-56ab93b2418d@redhat.com> <20190703130817.GA1978@___> <20190704062134.GA21116@___> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 05 Jul 2019 14:50:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Jul 2019 14:21:34 +0800 Tiwei Bie wrote: > On Thu, Jul 04, 2019 at 12:31:48PM +0800, Jason Wang wrote: > > On 2019/7/3 下午9:08, Tiwei Bie wrote: > > > On Wed, Jul 03, 2019 at 08:16:23PM +0800, Jason Wang wrote: > > > > On 2019/7/3 下午7:52, Tiwei Bie wrote: > > > > > On Wed, Jul 03, 2019 at 06:09:51PM +0800, Jason Wang wrote: > > > > > > On 2019/7/3 下午5:13, Tiwei Bie wrote: > > > > > > > Details about this can be found here: > > > > > > > > > > > > > > https://lwn.net/Articles/750770/ > > > > > > > > > > > > > > What's new in this version > > > > > > > ========================== > > > > > > > > > > > > > > A new VFIO device type is introduced - vfio-vhost. This addressed > > > > > > > some comments from here:https://patchwork.ozlabs.org/cover/984763/ > > > > > > > > > > > > > > Below is the updated device interface: > > > > > > > > > > > > > > Currently, there are two regions of this device: 1) CONFIG_REGION > > > > > > > (VFIO_VHOST_CONFIG_REGION_INDEX), which can be used to setup the > > > > > > > device; 2) NOTIFY_REGION (VFIO_VHOST_NOTIFY_REGION_INDEX), which > > > > > > > can be used to notify the device. > > > > > > > > > > > > > > 1. CONFIG_REGION > > > > > > > > > > > > > > The region described by CONFIG_REGION is the main control interface. > > > > > > > Messages will be written to or read from this region. > > > > > > > > > > > > > > The message type is determined by the `request` field in message > > > > > > > header. The message size is encoded in the message header too. > > > > > > > The message format looks like this: > > > > > > > > > > > > > > struct vhost_vfio_op { > > > > > > > __u64 request; > > > > > > > __u32 flags; > > > > > > > /* Flag values: */ > > > > > > > #define VHOST_VFIO_NEED_REPLY 0x1 /* Whether need reply */ > > > > > > > __u32 size; > > > > > > > union { > > > > > > > __u64 u64; > > > > > > > struct vhost_vring_state state; > > > > > > > struct vhost_vring_addr addr; > > > > > > > } payload; > > > > > > > }; > > > > > > > > > > > > > > The existing vhost-kernel ioctl cmds are reused as the message > > > > > > > requests in above structure. > > > > > > Still a comments like V1. What's the advantage of inventing a new protocol? > > > > > I'm trying to make it work in VFIO's way.. > > > > > > > > > > > I believe either of the following should be better: > > > > > > > > > > > > - using vhost ioctl,  we can start from SET_VRING_KICK/SET_VRING_CALL and > > > > > > extend it with e.g notify region. The advantages is that all exist userspace > > > > > > program could be reused without modification (or minimal modification). And > > > > > > vhost API hides lots of details that is not necessary to be understood by > > > > > > application (e.g in the case of container). > > > > > Do you mean reusing vhost's ioctl on VFIO device fd directly, > > > > > or introducing another mdev driver (i.e. vhost_mdev instead of > > > > > using the existing vfio_mdev) for mdev device? > > > > Can we simply add them into ioctl of mdev_parent_ops? > > > Right, either way, these ioctls have to be and just need to be > > > added in the ioctl of the mdev_parent_ops. But another thing we > > > also need to consider is that which file descriptor the userspace > > > will do the ioctl() on. So I'm wondering do you mean let the > > > userspace do the ioctl() on the VFIO device fd of the mdev > > > device? > > > > > > > Yes. > > Got it! I'm not sure what's Alex opinion on this. If we all > agree with this, I can do it in this way. > > > Is there any other way btw? > > Just a quick thought.. Maybe totally a bad idea. I was thinking > whether it would be odd to do non-VFIO's ioctls on VFIO's device > fd. So I was wondering whether it's possible to allow binding > another mdev driver (e.g. vhost_mdev) to the supported mdev > devices. The new mdev driver, vhost_mdev, can provide similar > ways to let userspace open the mdev device and do the vhost ioctls > on it. To distinguish with the vfio_mdev compatible mdev devices, > the device API of the new vhost_mdev compatible mdev devices > might be e.g. "vhost-net" for net? > > So in VFIO case, the device will be for passthru directly. And > in VHOST case, the device can be used to accelerate the existing > virtualized devices. > > How do you think? VFIO really can't prevent vendor specific ioctls on the device file descriptor for mdevs, but a) we'd want to be sure the ioctl address space can't collide with ioctls we'd use for vfio defined purposes and b) maybe the VFIO user API isn't what you want in the first place if you intend to mostly/entirely ignore the defined ioctl set and replace them with your own. In the case of the latter, you're also not getting the advantages of the existing VFIO userspace code, so why expose a VFIO device at all. The mdev interface does provide a general interface for creating and managing virtual devices, vfio-mdev is just one driver on the mdev bus. Parav (Mellanox) has been doing work on mdev-core to help clean out vfio-isms from the interface, aiui, with the intent of implementing another mdev bus driver for using the devices within the kernel. It seems like this vhost-mdev driver might be similar, using mdev but not necessarily vfio-mdev to expose devices. Thanks, Alex