From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apY1i-0006ny-US for qemu-devel@nongnu.org; Mon, 11 Apr 2016 05:20:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apY1d-0007Oa-OQ for qemu-devel@nongnu.org; Mon, 11 Apr 2016 05:20:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apY1d-0007OT-Ek for qemu-devel@nongnu.org; Mon, 11 Apr 2016 05:20:53 -0400 From: Peter Xu Date: Mon, 11 Apr 2016 17:19:19 +0800 Message-Id: <1460366363-4589-10-git-send-email-peterx@redhat.com> In-Reply-To: <1460366363-4589-1-git-send-email-peterx@redhat.com> References: <1460366363-4589-1-git-send-email-peterx@redhat.com> Subject: [Qemu-devel] [PATCH v2 09/13] intel_iommu: provide helper function vtd_get_iommu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, marcel@redhat.com, mst@redhat.com, pbonzini@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, peterx@redhat.com Moves acpi_get_iommu() under VT-d to make it a public function. Signed-off-by: Peter Xu --- hw/i386/acpi-build.c | 7 +------ hw/i386/intel_iommu.c | 13 +++++++++++++ include/hw/i386/intel_iommu.h | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 5ad6f9a..213f174 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2673,12 +2673,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) static bool acpi_has_iommu(void) { - bool ambiguous; - Object *intel_iommu; - - intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, - &ambiguous); - return intel_iommu && !ambiguous; + return !!vtd_iommu_get(); } static diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 4d14124..a44289f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2001,6 +2001,19 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) return vtd_dev_as; } +IntelIOMMUState *vtd_iommu_get(void) +{ + bool ambiguous = false; + Object *intel_iommu = NULL; + + intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, + &ambiguous); + if (ambiguous) + intel_iommu = NULL; + + return (IntelIOMMUState *)intel_iommu; +} + /* Do the initialization. It will also be called when reset, so pay * attention when adding new initialization stuff. */ diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 4914fe6..9ee84f7 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -196,5 +196,7 @@ struct IntelIOMMUState { * create a new one if none exists */ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn); +/* Get default IOMMU object */ +IntelIOMMUState *vtd_iommu_get(void); #endif -- 2.4.3