From patchwork Fri Sep 19 11:54:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: frank.blaschka@de.ibm.com X-Patchwork-Id: 4937611 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 17537BEEA5 for ; Fri, 19 Sep 2014 11:59:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11545201E4 for ; Fri, 19 Sep 2014 11:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A77FC201EF for ; Fri, 19 Sep 2014 11:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756696AbaISL7t (ORCPT ); Fri, 19 Sep 2014 07:59:49 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:43075 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756673AbaISL7r (ORCPT ); Fri, 19 Sep 2014 07:59:47 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Sep 2014 12:59:45 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Sep 2014 12:59:43 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3336A2190061; Fri, 19 Sep 2014 12:59:22 +0100 (BST) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8JBxglI45875284; Fri, 19 Sep 2014 11:59:42 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8JBxeDK016188; Fri, 19 Sep 2014 05:59:42 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s8JBxeQW016169; Fri, 19 Sep 2014 05:59:40 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 24631) id AB3A2122444C; Fri, 19 Sep 2014 13:59:40 +0200 (CEST) Message-Id: <20140919115940.596533004@de.ibm.com> User-Agent: quilt/0.61-1 Date: Fri, 19 Sep 2014 13:54:35 +0200 From: frank.blaschka@de.ibm.com To: qemu-devel@nongnu.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org Cc: alex.williamson@redhat.com, pbonzini@redhat.com, agraf@suse.de Subject: [RFC patch 6/6] vfio: make vfio run on s390 platform References: <20140919115429.557279920@de.ibm.com> MIME-Version: 1.0 Content-Disposition: inline; filename=104-qemu_vfio.patch X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14091911-0342-0000-0000-0000011FDE8E Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: Frank Blaschka Following changes are made because of platform differences: 1) s390 does not support mmap'ing of PCI BARs so we have to go via slow path 2) no intx support 3) no classic MSIX interrupts. The pci hw understands the concept of requesting MSIX irqs but irqs are delivered as s390 adapter irqs. Introduce s390 specific functions for msix notification (slow path) and msi routes (kvm fast path). 4) Use type1 iommu but register only for iommu address space Signed-off-by: Frank Blaschka --- hw/misc/vfio.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -40,6 +40,9 @@ #include "sysemu/kvm.h" #include "sysemu/sysemu.h" #include "hw/misc/vfio.h" +#ifdef TARGET_S390X +#include "hw/s390x/s390-pci-bus.h" +#endif /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO @@ -51,7 +54,11 @@ #endif /* Extra debugging, trap acceleration paths for more logging */ +#ifdef TARGET_S390X +#define VFIO_ALLOW_MMAP 0 +#else #define VFIO_ALLOW_MMAP 1 +#endif #define VFIO_ALLOW_KVM_INTX 1 #define VFIO_ALLOW_KVM_MSI 1 #define VFIO_ALLOW_KVM_MSIX 1 @@ -554,6 +561,10 @@ static int vfio_enable_intx(VFIODevice * struct vfio_irq_set *irq_set; int32_t *pfd; +#ifdef TARGET_S390X + return 0; +#endif + if (!pin) { return 0; } @@ -664,7 +675,11 @@ static void vfio_msi_interrupt(void *opa #endif if (vdev->interrupt == VFIO_INT_MSIX) { +#ifdef TARGET_S390X + s390_msix_notify(&vdev->pdev, nr); +#else msix_notify(&vdev->pdev, nr); +#endif } else if (vdev->interrupt == VFIO_INT_MSI) { msi_notify(&vdev->pdev, nr); } else { @@ -730,7 +745,11 @@ static void vfio_add_kvm_msi_virq(VFIOMS return; } +#ifdef TARGET_S390X + virq = s390_irqchip_add_msi_route(&vector->vdev->pdev, kvm_state, *msg); +#else virq = kvm_irqchip_add_msi_route(kvm_state, *msg); +#endif if (virq < 0) { event_notifier_cleanup(&vector->kvm_interrupt); return; @@ -3702,8 +3721,13 @@ static int vfio_connect_container(VFIOGr container->iommu_data.type1.listener = vfio_memory_listener; container->iommu_data.release = vfio_listener_release; +#ifdef TARGET_S390X + memory_listener_register(&container->iommu_data.type1.listener, + container->space->as); +#else memory_listener_register(&container->iommu_data.type1.listener, &address_space_memory); +#endif if (container->iommu_data.type1.error) { ret = container->iommu_data.type1.error;