From patchwork Fri Nov 24 08:52:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Yi L" X-Patchwork-Id: 10073761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4D19D6037F for ; Fri, 24 Nov 2017 09:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B0092A37E for ; Fri, 24 Nov 2017 09:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4011D2A380; Fri, 24 Nov 2017 09:14:03 +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=-6.9 required=2.0 tests=BAYES_00,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 B566C2A37E for ; Fri, 24 Nov 2017 09:14:02 +0000 (UTC) Received: from localhost ([::1]:48117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIA3d-0007G0-UP for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Nov 2017 04:14:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI9zQ-00049a-VK for qemu-devel@nongnu.org; Fri, 24 Nov 2017 04:09:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eI9zM-0000KC-Op for qemu-devel@nongnu.org; Fri, 24 Nov 2017 04:09:40 -0500 Received: from mga09.intel.com ([134.134.136.24]:49873) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eI9zM-0000JB-FV for qemu-devel@nongnu.org; Fri, 24 Nov 2017 04:09:36 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2017 01:09:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,446,1505804400"; d="scan'208";a="177227758" Received: from sky-dev.bj.intel.com ([10.238.144.127]) by orsmga005.jf.intel.com with ESMTP; 24 Nov 2017 01:09:29 -0800 From: "Liu, Yi L" To: qemu-devel@nongnu.org, mst@redhat.com, david@gibson.dropbear.id.au Date: Fri, 24 Nov 2017 16:52:38 +0800 Message-Id: <1511513560-28611-6-git-send-email-yi.l.liu@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1511513560-28611-1-git-send-email-yi.l.liu@linux.intel.com> References: <1511513560-28611-1-git-send-email-yi.l.liu@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Subject: [Qemu-devel] [PATCH v2 5/7] intel_iommu: provide AddressSpaceOps.iommu_get instance 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: tianyu.lan@intel.com, "Liu, Yi L" , kevin.tian@intel.com, yi.l.liu@intel.com, jasowang@redhat.com, peterx@redhat.com, alex.williamson@redhat.com, pbonzini@redhat.com, eric.auger.pro@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Xu Provide AddressSpaceOps.iommu_get() in Intel IOMMU emulator. Signed-off-by: Peter Xu Signed-off-by: Liu, Yi L --- hw/i386/intel_iommu.c | 8 ++++++++ include/hw/i386/intel_iommu.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e81c706..23b13b3 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2687,6 +2687,12 @@ static const MemoryRegionOps vtd_mem_ir_ops = { }, }; +static IOMMUObject *vtd_as_iommu_get(AddressSpace *as) +{ + VTDAddressSpace *vtd_dev_as = container_of(as, VTDAddressSpace, as); + return &vtd_dev_as->iommu_object; +} + VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) { uintptr_t key = (uintptr_t)bus; @@ -2747,7 +2753,9 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) memory_region_add_subregion_overlap(&vtd_dev_as->root, VTD_INTERRUPT_ADDR_FIRST, &vtd_dev_as->iommu_ir, 64); + iommu_object_init(&vtd_dev_as->iommu_object); address_space_init(&vtd_dev_as->as, &vtd_dev_as->root, name); + vtd_dev_as->as.as_ops.iommu_get = vtd_as_iommu_get; memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, &vtd_dev_as->sys_alias, 1); memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index c85f9ff..a3c6d45 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -27,6 +27,7 @@ #include "hw/i386/ioapic.h" #include "hw/pci/msi.h" #include "hw/sysbus.h" +#include "hw/core/iommu.h" #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu" #define INTEL_IOMMU_DEVICE(obj) \ @@ -90,6 +91,7 @@ struct VTDAddressSpace { MemoryRegion sys_alias; MemoryRegion iommu_ir; /* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state; + IOMMUObject iommu_object; VTDContextCacheEntry context_cache_entry; };