Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3133604ybg; Mon, 28 Oct 2019 08:01:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjndx9ebpT8k0L03zJVIVwpfiXkD0L9KqEagnpOiNwVRKD0ITYhgHlVM3S07cXhAwG0df7 X-Received: by 2002:aa7:db88:: with SMTP id u8mr20407918edt.278.1572274903420; Mon, 28 Oct 2019 08:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572274903; cv=none; d=google.com; s=arc-20160816; b=uF2iNQ8Ln9gfAYja/e8Fs4765MPlnE2LJNlB/zwS0vzfvDFORgZNecg3c4X3uuelSv BvDWKWfn3lfRD95XorTLyT2JJ1VpXweLIGfglRNckt/QelQqWa95YHMm/iRbG8xxjLSf f3dQDmsT590NF08y8tbE0nbHLPd8Igm5i9mp44Q0HJj+vfGw92U69fgDJ6VYIJB6op7c zPVvuwOTQIcy7s9rRDGBM4oqTNdQPcXFnIgQBTI/M13qIyvetLOTZrBQ9BAiANdFpvEn u5U70JTD275vGGlNCGii2D+PfReWvLTww7VzbBNO1epFr+6a1pzSUHLT7w5z01mRhrvr d8sQ== 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=c3g4UjEb9DWKqjphn6WUlg8TodMgT3MFxKe3D2APMzQ=; b=gRPxUpKVoASnRM/zXFyAYk2PtpjwPaH0kbh+LRjG6wxxeaz/q+YRX5W+AT3uueBa1c xg/LF/IXhdM1py71wUg8gn4su45+vInQkVmVvkNDVRLnWEliZgYWpdNG6L8Mswr8WpHY CcQYn88f6qaiilZ0K3uRndxD9wjXZj9ui5sD0X5yvH+vqgxh8k2Q4v4Ladfj8Krl3V2A yvC5hVdch0N1+QdIY2DWgLEZ/NHxoO9O4jKbtPSj/NzJIJ5ZYzxzXjcvk5bGGBB2CVlN BsovuOlf+foRO22tqFTdqnaPMnUpKbWo4MBNvFEvQ8kx5FW2QXkgnSGreJFpTNa+Fw44 rECg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O58oaPqC; 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 o46si7687159edc.124.2019.10.28.08.01.17; Mon, 28 Oct 2019 08:01:43 -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=O58oaPqC; 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 S1731496AbfJ1DvH (ORCPT + 99 others); Sun, 27 Oct 2019 23:51:07 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42719 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731479AbfJ1DvG (ORCPT ); Sun, 27 Oct 2019 23:51:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572234666; 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=c3g4UjEb9DWKqjphn6WUlg8TodMgT3MFxKe3D2APMzQ=; b=O58oaPqCBm2CehB2m7pxkM4bzB0imAOwss6cOANmChQeDoeCTrPTwiZ5U6RX96sVWjjJ4y nPBhsvxi6fn1I8KvNcNKAG63lZa8RQiULW2ewId2F3t5W0ALB8KCS2Pac/5oGmk2n+pBEk r0uzNzFFjOr9AcIFKcv14Ne9osO85c8= 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-193-ZuWQpeT7OoiBddLiSa6f_Q-1; Sun, 27 Oct 2019 23:51:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0C975EC; Mon, 28 Oct 2019 03:51:00 +0000 (UTC) Received: from [10.72.12.246] (ovpn-12-246.pek2.redhat.com [10.72.12.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0AC35C219; Mon, 28 Oct 2019 03:50:51 +0000 (UTC) Subject: Re: [PATCH v2] vhost: introduce mdev based hardware backend To: Tiwei Bie , "Michael S. Tsirkin" Cc: 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: <106834b5-dae5-82b2-0f97-16951709d075@redhat.com> <20191023101135.GA6367@___> <5a7bc5da-d501-2750-90bf-545dd55f85fa@redhat.com> <20191024042155.GA21090@___> <20191024091839.GA17463@___> <20191025080143-mutt-send-email-mst@kernel.org> <20191028015842.GA9005@___> From: Jason Wang Message-ID: <5e8a623d-9d91-607a-1f9e-7a7086ba9a68@redhat.com> Date: Mon, 28 Oct 2019 11:50:49 +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: <20191028015842.GA9005@___> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: ZuWQpeT7OoiBddLiSa6f_Q-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/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, paren= t >>>> should assume addr of ctrl_vq is hva. >>>> >>>> Thanks >>> >>> This works for vhost but not virtio since there's no way for virtio ker= nel >>> driver to differ ctrl_vq with the rest when doing DMA map. One possible >>> solution is to provide DMA domain isolation between virtqueues. Then ct= rl 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 t= hat >>> 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_OFFLO= ADS) >> && (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 will >> 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 commands >> to device. >> >> Some kind of extension to the transport? Ideas? So it's basically an issue of isolating DMA domains. Maybe we can start=20 with transport API for querying per vq DMA domain/ASID? - for vhost-mdev, userspace can query the DMA domain for each specific=20 virtqueue. For control vq, mdev can return id for software domain, for=20 the rest mdev will return id of VFIO domain. Then userspace know that it=20 should use different API for preparing the virtqueue, e.g for vq other=20 than control vq, it should use VFIO DMA API. The control vq it should=20 use hva instead. - for virito-mdev, we can introduce per-vq DMA device, and route DMA=20 mapping request for control vq back to mdev instead of the hardware. (We=20 can wrap them into library or helpers to ease the development of vendor=20 physical drivers). Thanks >> >> >> --=20 >> MST