From patchwork Tue Mar 5 02:34:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 10838859 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 4775E1390 for ; Tue, 5 Mar 2019 02:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C5D02B881 for ; Tue, 5 Mar 2019 02:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F9BC2B8BD; Tue, 5 Mar 2019 02:36:49 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7BEB72B881 for ; Tue, 5 Mar 2019 02:36:48 +0000 (UTC) Received: from localhost ([127.0.0.1]:36260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0zwl-0003S0-1V for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Mar 2019 21:36:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0zvI-0002FW-3x for qemu-devel@nongnu.org; Mon, 04 Mar 2019 21:35:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0zvH-0004eU-10 for qemu-devel@nongnu.org; Mon, 04 Mar 2019 21:35:16 -0500 Received: from mga12.intel.com ([192.55.52.136]:36362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h0zvG-0004NE-Mj for qemu-devel@nongnu.org; Mon, 04 Mar 2019 21:35:14 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 18:35:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,442,1544515200"; d="scan'208";a="148612500" Received: from yisun1-ubuntu2.bj.intel.com ([10.238.144.135]) by fmsmga002.fm.intel.com with ESMTP; 04 Mar 2019 18:35:05 -0800 From: Yi Sun To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 10:34:52 +0800 Message-Id: <1551753295-30167-1-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH v1 0/3] intel_iommu: support scalable mode 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: kevin.tian@intel.com, yi.l.liu@intel.com, Yi Sun , ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, yi.y.sun@intel.com, pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Intel vt-d rev3.0 [1] introduces a new translation mode called 'scalable mode', which enables PASID-granular translations for first level, second level, nested and pass-through modes. The vt-d scalable mode is the key ingredient to enable Scalable I/O Virtualization (Scalable IOV) [2] [3], which allows sharing a device in minimal possible granularity (ADI - Assignable Device Interface). As a result, previous Extended Context (ECS) mode is deprecated (no production ever implements ECS). This patch set emulates a minimal capability set of VT-d scalable mode, equivalent to what is available in VT-d legacy mode today: 1. Scalable mode root entry, context entry and PASID table 2. Seconds level translation under scalable mode 3. Queued invalidation (with 256 bits descriptor) 4. Pass-through mode Corresponding intel-iommu driver support will be included in kernel 5.0: https://www.spinics.net/lists/kernel/msg2985279.html We will add emulation of full scalable mode capability along with guest iommu driver progress later, e.g.: 1. First level translation 2. Nested translation 3. Per-PASID invalidation descriptors 4. Page request services for handling recoverable faults To verify the patches, below cases were tested according to Peter Xu's suggestions. +---------+----------------------------------------------------------------+----------------------------------------------------------------+ | | w/ Device Passthr | w/o Device Passthr | | +-------------------------------+--------------------------------+-------------------------------+--------------------------------+ | | virtio-net-pci, vhost=on | virtio-net-pci, vhost=off | virtio-net-pci, vhost=on | virtio-net-pci, vhost=off | | +-------------------------------+--------------------------------+-------------------------------+--------------------------------+ | | netperf | kernel bld | data cp| netperf | kernel bld | data cp | netperf | kernel bld | data cp| netperf | kernel bld | data cp | +---------+-------------------------------+--------------------------------+-------------------------------+--------------------------------+ | Legacy | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | +---------+-------------------------------+--------------------------------+-------------------------------+--------------------------------+ | Scalable| Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | Pass | +---------+-------------------------------+--------------------------------+-------------------------------+--------------------------------+ References: [1] https://software.intel.com/en-us/download/intel-virtualization-technology-for-directed-io-architecture-specification [2] https://software.intel.com/en-us/download/intel-scalable-io-virtualization-technical-specification [3] https://schd.ws/hosted_files/lc32018/00/LC3-SIOV-final.pdf --- RFC v2->v1 Patch 1: - revert unnecessary rename in 'vtd_ce_present". - use 'ce_size' to judge if it is scalable mode in 'vtd_get_context_entry_from_root'. - remove some 'inline' declarations. - remove unnecessary scalable mode check in 'vtd_ce_type_check' and make corresponding changes in 'vtd_dev_to_context_entry'. - add 'VTD_FR_PASID_TABLE_INV' case in 'vtd_qualified_faults[]'. - create a macro function to handle a repeated pattern about 'is_fpd_set'. - explicitly print 'legacy mode' when calling 'trace_vtd_replay_ce_valid'. Patch 2: - do "(val & VTD_IQT_QT_256_RSV_BIT)" to be clear. Patch 3: - move 's->dma_drain' check from 'vtd_init' to 'vtd_decide_config'. --- Liu, Yi L (2): intel_iommu: scalable mode emulation intel_iommu: add 256 bits qi_desc support Yi Sun (1): intel_iommu: add scalable-mode option to make scalable mode work hw/i386/intel_iommu.c | 559 +++++++++++++++++++++++++++++++++-------- hw/i386/intel_iommu_internal.h | 54 +++- hw/i386/trace-events | 2 +- include/hw/i386/intel_iommu.h | 28 ++- 4 files changed, 533 insertions(+), 110 deletions(-)