From patchwork Wed Sep 19 06:28:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 10605367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6ADDA112B for ; Wed, 19 Sep 2018 06:31:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58B7F2B635 for ; Wed, 19 Sep 2018 06:31:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CF662B649; Wed, 19 Sep 2018 06:31:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7AAD2B635 for ; Wed, 19 Sep 2018 06:31:38 +0000 (UTC) Received: from localhost ([::1]:43863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2W1S-0007pV-7e for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Sep 2018 02:31:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2Vzk-0006dJ-Sk for qemu-devel@nongnu.org; Wed, 19 Sep 2018 02:29:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g2Vzf-0002Yd-TM for qemu-devel@nongnu.org; Wed, 19 Sep 2018 02:29:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:1973) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g2Vzf-0002RZ-JN for qemu-devel@nongnu.org; Wed, 19 Sep 2018 02:29:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2018 23:29:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,392,1531810800"; d="scan'208";a="71164008" Received: from btwcube1.sh.intel.com ([10.67.104.151]) by fmsmga007.fm.intel.com with ESMTP; 18 Sep 2018 23:29:40 -0700 From: Tiwei Bie To: mst@redhat.com, alex.williamson@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Date: Wed, 19 Sep 2018 14:28:30 +0800 Message-Id: <20180919062834.30103-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [RFC v2 0/4] Supporting programming IOMMU in QEMU (vDPA/vhost-user) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tiwei.bie@intel.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch set introduces a slave message in vhost-user to allow slave to share its VFIO container fd to master and do the IOMMU programming based on virtio device's DMA address space for the VFIO groups inside this container in QEMU. For the vhost-user backends which support vDPA, they could leverage this message to ask master to do IOMMU programming in QEMU for the vDPA device in backend. This is helpful to support vIOMMU in vDPA. Below are the simple steps to test this function: # Build the QEMU with trace support ./configure --enable-trace-backends=simple --target-list=x86_64-softmmu make # Set the events we want to trace echo vfio_new_container > /tmp/events echo vfio_free_container >> /tmp/events echo vfio_listener_region_add_ram >> /tmp/events echo vfio_listener_region_del >> /tmp/events # Launch vhost-user-bridge with VFIO enabled make tests/vhost-user-bridge ./tests/vhost-user-bridge -G /dev/vfio/$GROUP_NO # Launch QEMU on another terminal ./x86_64-softmmu/qemu-system-x86_64 \ -smp 4 -m 1024M -cpu host -enable-kvm \ -hda "$DISK" \ -object memory-backend-file,id=mem,size=1024M,mem-path=/dev/shm,share=on \ -numa node,memdev=mem -mem-prealloc \ -chardev socket,id=char0,path=/tmp/vubr.sock \ -netdev type=vhost-user,id=net0,chardev=char0 \ -device virtio-net-pci,netdev=net0,page-per-vq=on \ --trace events=/tmp/events # Dump the trace events ./scripts/simpletrace.py ./trace-events-all ./trace-"$QEMU_PID" More details can be found from the patches. Thanks! RFC -> RFC v2: - Share VFIO container fd instead of group fd to QEMU; - Extend libvhost-user and vhost-user-bridge for testing; Tiwei Bie (4): vfio: support creating VFIOContainer directly vhost-user: support programming VFIO container in master libvhost-user: support VFIO container message vhost-user-bridge: support VFIO container message contrib/libvhost-user/libvhost-user.c | 29 ++++- contrib/libvhost-user/libvhost-user.h | 12 ++ docs/interop/vhost-user.txt | 21 ++++ hw/vfio/common.c | 164 +++++++++++++++++++++++++- hw/vfio/trace-events | 2 + hw/virtio/vhost-user.c | 45 +++++++ include/hw/vfio/vfio-common.h | 9 ++ include/hw/virtio/vhost-user.h | 2 + tests/vhost-user-bridge.c | 63 +++++++++- 9 files changed, 343 insertions(+), 4 deletions(-)