Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4238794ybg; Tue, 29 Oct 2019 04:19:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqymqco9i84XsKishU9MPhqQ6r9OYklJvWPSsJZT/dtrg6qaCSir9gHUx2TUeKqsr/yNcxlj X-Received: by 2002:a17:906:5f8d:: with SMTP id a13mr2733785eju.11.1572347949464; Tue, 29 Oct 2019 04:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572347949; cv=none; d=google.com; s=arc-20160816; b=pnCyjG/gqWZI7yx281Pfn86ZmNqVf901t9D+tFwMTZlSTHX3yCrYsFYu35ia2hQy8R tH6fTCi2L/U/hPXJowfiouJN9PVMYBM+LUofxktdayoChSiGWaEIBUfmTuiw+06AQ0Fv upNpxooBTXQrSBeLZQiwIfxPGuVI0/Aem127+Iw9BKTh881T/M5lpZHDHJCvpGxE1bGb M1iqSqc0cbkV+3o0NS3FKLz4qWApgAPtvJZ5dsHKO+CQL8E35EyTAxrLwM/En9eFzbZj 7A+NJGqk3amZcNMsxSwsPk8/CxpVF5+KUVMtrTSEwK9+hNARYjvDuXpTlwMSBY5QlGDu ox5w== 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:from:references:cc:to:subject:dkim-signature; bh=ku5QMX1PXe0RMduAjOLbTYKTX3zeaaRJXqe/yt5ek0A=; b=CPuT3oVLsy/PYkbUGdaTfwieRSED9YF65bEVxV58F2Di6fuUlhjMBDJmCa6/meSUAa hDW9i9xlDhzwPeMbFZm1RwD+BgrPK3F5IICLYUgRWBQUGsMJLv0HIIVbKCyFXSb1dqAB N7xjHvyz+8Gpd9K0BfptMjaIQhbkT2wS0trcwcF/OxViyJh98jKOke8/LIbp4U1TpZqs eUdI/DZJrvPSCUtZmJ0SQtNg0sjpSx6mgOLjkPR3Bsf+/9CLTsbjseVkmK45y3LeWEjM hGoTUp9DpW/9YbC7LqTOkrk7kHAwc0dwRNNSk5LOZ+xW1A4AjXdhXb7z6uHnrMuLIBVb ctNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ps3rMyfT; 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 u2si8222727ejj.410.2019.10.29.04.18.46; Tue, 29 Oct 2019 04:19:09 -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=Ps3rMyfT; 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 S1730338AbfJ2KtW (ORCPT + 99 others); Tue, 29 Oct 2019 06:49:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32195 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728189AbfJ2KtV (ORCPT ); Tue, 29 Oct 2019 06:49:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572346160; 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=ku5QMX1PXe0RMduAjOLbTYKTX3zeaaRJXqe/yt5ek0A=; b=Ps3rMyfT85QtyBGghcVd6o8ogKzK9DP4dOTrTVvbT20LY2C0NlVVvFcMNk3dEGTDefCWlM Nz5viSKEr1K7zgG//DL2uJqv/r1xh4OMuhyYJp85W3CVH/X432iKiTDCjdNMBVv0jNHkCx Izzzq1ExcGUcvlyalWIKP7KPGyjMzyg= 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-350-Ojy6gkM5P2myIxO3H-nb5w-1; Tue, 29 Oct 2019 06:49:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 844FC476; Tue, 29 Oct 2019 10:49:15 +0000 (UTC) Received: from [10.72.12.223] (ovpn-12-223.pek2.redhat.com [10.72.12.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1916B600F0; Tue, 29 Oct 2019 10:48:35 +0000 (UTC) Subject: Re: [PATCH v2] vhost: introduce mdev based hardware backend To: Tiwei Bie Cc: "Michael S. Tsirkin" , 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: <5a7bc5da-d501-2750-90bf-545dd55f85fa@redhat.com> <20191024042155.GA21090@___> <20191024091839.GA17463@___> <20191025080143-mutt-send-email-mst@kernel.org> <20191028015842.GA9005@___> <5e8a623d-9d91-607a-1f9e-7a7086ba9a68@redhat.com> <20191029095738.GA7228@___> From: Jason Wang Message-ID: <146752f4-174c-c916-3682-b965b96d7872@redhat.com> Date: Tue, 29 Oct 2019 18:48:27 +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: <20191029095738.GA7228@___> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: Ojy6gkM5P2myIxO3H-nb5w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 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/29 =E4=B8=8B=E5=8D=885:57, Tiwei Bie wrote: > On Mon, Oct 28, 2019 at 11:50:49AM +0800, Jason Wang wrote: >> On 2019/10/28 =E4=B8=8A=E5=8D=889:58, Tiwei Bie wrote: >>> On Fri, Oct 25, 2019 at 08:16:26AM -0400, Michael S. Tsirkin wrote: >>>> On Fri, Oct 25, 2019 at 05:54:55PM +0800, Jason Wang wrote: >>>>> On 2019/10/24 =E4=B8=8B=E5=8D=886:42, Jason Wang wrote: >>>>>> Yes. >>>>>> >>>>>> >>>>>>> =C2=A0 And we should try to avoid >>>>>>> putting ctrl vq and Rx/Tx vqs in the same DMA space to prevent >>>>>>> guests having the chance to bypass the host (e.g. QEMU) to >>>>>>> setup the backend accelerator directly. >>>>>> That's really good point.=C2=A0 So when "vhost" type is created, par= ent >>>>>> should assume addr of ctrl_vq is hva. >>>>>> >>>>>> Thanks >>>>> This works for vhost but not virtio since there's no way for virtio k= ernel >>>>> driver to differ ctrl_vq with the rest when doing DMA map. One possib= le >>>>> solution is to provide DMA domain isolation between virtqueues. Then = ctrl vq >>>>> can use its dedicated DMA domain for the work. >>> It might not be a bad idea to let the parent drivers distinguish >>> between virtio-mdev mdevs and vhost-mdev mdevs in ctrl-vq handling >>> by mdev's class id. >> Yes, that should work, I have something probable better, see below. >> >> >>>>> Anyway, this could be done in the future. We can have a version first= that >>>>> doesn't support ctrl_vq. >>> +1, thanks >>> >>>>> Thanks >>>> Well no ctrl_vq implies either no offloads, or no XDP (since XDP needs >>>> to disable offloads dynamically). >>>> >>>> if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_GUEST_OFF= LOADS) >>>> && (virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4)= || >>>> virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6)= || >>>> virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) = || >>>> virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) = || >>>> virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM)= )) { >>>> NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host = is implementing LRO/CSUM, disable LRO/CSUM first"); >>>> return -EOPNOTSUPP; >>>> } >>>> >>>> neither is very attractive. >>>> >>>> So yes ok just for development but we do need to figure out how it wil= l >>>> work down the road in production. >>> Totally agree. >>> >>>> So really this specific virtio net device does not support control vq, >>>> instead it supports a different transport specific way to send command= s >>>> to device. >>>> >>>> Some kind of extension to the transport? Ideas? >> So it's basically an issue of isolating DMA domains. Maybe we can start = with >> transport API for querying per vq DMA domain/ASID? >> >> - for vhost-mdev, userspace can query the DMA domain for each specific >> virtqueue. For control vq, mdev can return id for software domain, for t= he >> rest mdev will return id of VFIO domain. Then userspace know that it sho= uld >> use different API for preparing the virtqueue, e.g for vq other than con= trol >> vq, it should use VFIO DMA API. The control vq it should use hva instead= . >> >> - for virito-mdev, we can introduce per-vq DMA device, and route DMA map= ping >> request for control vq back to mdev instead of the hardware. (We can wra= p >> them into library or helpers to ease the development of vendor physical >> drivers). > Thanks for this proposal! I'm thinking about it these days. > I think it might be too complicated. I'm wondering whether we > can have something simpler. I will post a RFC patch to show > my idea today. Thanks, will check. Btw, for virtio-mdev, the change should be very minimal, will post an RFC as well. For vhost-mdev, it could be just a helper to return an ID for DMA domain like ID_VFIO or ID_HVA. Or a more straightforward way is to force queues like control vq to use PA. > > Thanks, > Tiwei >