From patchwork Tue Oct 31 05:07:02 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: 832247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yR0J24VMTz9sPm for ; Tue, 31 Oct 2017 16:28:34 +1100 (AEDT) Received: from localhost ([::1]:43774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9P6G-0004sz-Nw for incoming@patchwork.ozlabs.org; Tue, 31 Oct 2017 01:28:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9P1S-00012n-Ms for qemu-devel@nongnu.org; Tue, 31 Oct 2017 01:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9P1R-0004jJ-Tx for qemu-devel@nongnu.org; Tue, 31 Oct 2017 01:23:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:53480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e9P1R-0004cw-Iu for qemu-devel@nongnu.org; Tue, 31 Oct 2017 01:23:33 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 30 Oct 2017 22:23:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,322,1505804400"; d="scan'208";a="169289762" Received: from sky-dev.bj.intel.com ([10.238.144.127]) by fmsmga005.fm.intel.com with ESMTP; 30 Oct 2017 22:23:30 -0700 From: "Liu, Yi L" To: qemu-devel@nongnu.org, mst@redhat.com, david@gibson.dropbear.id.au, pbonzini@redhat.com, alex.williamson@redhat.com Date: Tue, 31 Oct 2017 13:07:02 +0800 Message-Id: <1509426425-23890-4-git-send-email-yi.l.liu@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509426425-23890-1-git-send-email-yi.l.liu@linux.intel.com> References: <1509426425-23890-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.100 Subject: [Qemu-devel] [PATCH 3/6] 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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 7 +++++++ include/hw/i386/intel_iommu.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e81c706..54343e5 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; @@ -2748,6 +2754,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) VTD_INTERRUPT_ADDR_FIRST, &vtd_dev_as->iommu_ir, 64); 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; };