From patchwork Fri Apr 15 03:31:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 8844781 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10FCAC0553 for ; Fri, 15 Apr 2016 03:46:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61A6920379 for ; Fri, 15 Apr 2016 03:46:41 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id E097B202F0 for ; Fri, 15 Apr 2016 03:46:15 +0000 (UTC) Received: from localhost ([::1]:53142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquhy-0005FD-IJ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Apr 2016 23:46:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquXF-0000up-Oe for qemu-devel@nongnu.org; Thu, 14 Apr 2016 23:35:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aquXE-000535-Pb for qemu-devel@nongnu.org; Thu, 14 Apr 2016 23:35:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aquXE-00052y-L5 for qemu-devel@nongnu.org; Thu, 14 Apr 2016 23:35:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 502DBC04B30C; Fri, 15 Apr 2016 03:35:08 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-4-123.pek2.redhat.com [10.72.4.123]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3F3VgWB002504; Thu, 14 Apr 2016 23:35:03 -0400 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 15 Apr 2016 11:31:33 +0800 Message-Id: <1460691099-3024-8-git-send-email-peterx@redhat.com> In-Reply-To: <1460691099-3024-1-git-send-email-peterx@redhat.com> References: <1460691099-3024-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 07/13] intel_iommu: provide helper function vtd_get_iommu 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: ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, rkrcmar@redhat.com, peterx@redhat.com, alex.williamson@redhat.com, jan.kiszka@web.de, wexu@redhat.com, pbonzini@redhat.com, marcel@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 5d2d87b..b064bc2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2677,12 +2677,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