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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 CDCE2CA9EAE for ; Tue, 29 Oct 2019 10:49:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D9A12087F for ; Tue, 29 Oct 2019 10:49:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ps3rMyfT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730432AbfJ2KtW (ORCPT ); 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 >