Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1689094ybi; Wed, 3 Jul 2019 21:32:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqysf4IA3IWfpcly0MjdhOIqZ4X3ap7ARjhKjXKXA9pLBx84DAcvTARRpKyvPv8p1k+bdJRX X-Received: by 2002:a17:902:a50d:: with SMTP id s13mr2693955plq.12.1562214764492; Wed, 03 Jul 2019 21:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562214764; cv=none; d=google.com; s=arc-20160816; b=ujL9AfTP04cnl/XjrxZ1CFY9bUGZ63L1Cm4WpK+EscRXwhapfG4gSb/cHkxeEJyGJW yGTjlA3rTYd1noQtDAP2g2AN+sMlOh3B9Hlb5Lawl5eYj+TBmWWpS8OMHsmFVmNiAX1m Cb4D4tRaKEPamSKltayWDHieNBkzflUBZ9BS7NyHIFxmIiBFXP0F73ElN/h+hxvXXSts jkBX5zIQJqcZykPAAGO2a4JajpzoH9ch5BEyfbsko8HXhzHKwKoxuDVxZOKAYMIIpNt1 k+YrX3a8wCGxJKSb4kW8yrM0Civ9bd0ISMu6oJ6w4xYrC9E1G8tLOOxyRGc85mz/NRnC Phfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TePNbnO3/uH4Qn/wim78geiTQrooM5iLlyW3Fxb5pPU=; b=pthqpcWEyOuqiJDT3ATfzQB9MoxwfqFweIACi6hhahI7oAG16UofWJQzIgLvggcMh1 sTRoTq95dc/UVUN8m+F0YKHBN/X1Vnk+QFWQgS1to0cDhvomPnF4UFOzZE8EywwugTSH +ndnl2AmT9k33iYKBBqJlqBzaReSMvgaC5ZhzFcMLntOZanif5aMvrgpihdGoaATd/1y WK8HrojVcYPStGHlP3IroX9007qKQ+yFMgSYSEG76deW5Zrs4LtiFZoPEnE1Bxl1N6cT U2BL7sgBQ8YF4EMr5Rcu7zSDhAOaIhVqJpxywnCLerNKJ4GKM+iwBp+vIpdxcmU8DqQO vb9w== 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 y71si4386054pgd.271.2019.07.03.21.32.27; Wed, 03 Jul 2019 21:32:44 -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 S1726085AbfGDEcG (ORCPT + 99 others); Thu, 4 Jul 2019 00:32:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49668 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfGDEcG (ORCPT ); Thu, 4 Jul 2019 00:32:06 -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 EE19F3082132; Thu, 4 Jul 2019 04:32:00 +0000 (UTC) Received: from [10.72.12.202] (ovpn-12-202.pek2.redhat.com [10.72.12.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id B705F968C7; Thu, 4 Jul 2019 04:31:50 +0000 (UTC) Subject: Re: [RFC v2] vhost: introduce mdev based hardware vhost backend 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 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@___> From: Jason Wang Message-ID: Date: Thu, 4 Jul 2019 12:31:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190703130817.GA1978@___> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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]); Thu, 04 Jul 2019 04:32:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Is there any other way btw? Thanks