From patchwork Fri Oct 23 09:43:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 534858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 D969B141320 for ; Fri, 23 Oct 2015 20:44:00 +1100 (AEDT) Received: from localhost ([::1]:37217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpYtD-0006sw-0D for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2015 05:43:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpYsT-0005eI-NQ for qemu-devel@nongnu.org; Fri, 23 Oct 2015 05:43:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpYsR-0008SG-S1 for qemu-devel@nongnu.org; Fri, 23 Oct 2015 05:43:13 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:45317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpYsR-0008Qp-Fm; Fri, 23 Oct 2015 05:43:11 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 6E8D8141337; Fri, 23 Oct 2015 20:43:06 +1100 (AEDT) From: David Gibson To: peter.maydell@linaro.org Date: Fri, 23 Oct 2015 20:43:19 +1100 Message-Id: <1445593413-22057-9-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1445593413-22057-1-git-send-email-david@gibson.dropbear.id.au> References: <1445593413-22057-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2401:3900:2:1::2 Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, David Gibson Subject: [Qemu-devel] [PULL 07/21] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The core VFIO infrastructure more or less allows VFIO devices to work on any normal guest PCI host bridge (PHB) without extra logic. However, the "spapr-pci-host-bridge" device (as opposed to the special "spapr-pci-vfio-host-bridge" device) breaks this by using a partially KVM accelerated implementation of the guest kernel IOMMU which won't work with VFIO devices, without additional kernel support. This patch allows VFIO devices to work on the spapr-pci-host-bridge, by having it switch off KVM TCE acceleration when a VFIO device is added to the PHB (either on startup, or by hotplug). Signed-off-by: David Gibson Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier --- hw/ppc/spapr_pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index cb7c351..55fa8db 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1083,6 +1083,12 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, void *fdt = NULL; int fdt_start_offset = 0, fdt_size; + if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { + sPAPRTCETable *tcet = spapr_tce_find_by_liobn(phb->dma_liobn); + + spapr_tce_set_need_vfio(tcet, true); + } + if (dev->hotplugged) { fdt = create_device_tree(&fdt_size); fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);