From patchwork Mon Apr 11 09:19:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 8799151 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 26628C0553 for ; Mon, 11 Apr 2016 09:25:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F77F20204 for ; Mon, 11 Apr 2016 09:25:45 +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 8EE60201F5 for ; Mon, 11 Apr 2016 09:25:44 +0000 (UTC) Received: from localhost ([::1]:50943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apY6J-00036D-TL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Apr 2016 05:25:43 -0400 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 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 29FF17D0E5; Mon, 11 Apr 2016 09:20:53 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-4-150.pek2.redhat.com [10.72.4.150]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3B9JTTv007357; Mon, 11 Apr 2016 05:20:46 -0400 From: Peter Xu To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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 v2 09/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, jan.kiszka@web.de, 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 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