From patchwork Mon Jan 12 10:04:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 427654 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 3238D14016A for ; Mon, 12 Jan 2015 21:11:21 +1100 (AEDT) Received: from localhost ([::1]:32998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAbxu-0003n0-Px for incoming@patchwork.ozlabs.org; Mon, 12 Jan 2015 05:11:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAbs2-000397-O4 for qemu-devel@nongnu.org; Mon, 12 Jan 2015 05:05:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAbrw-00061v-At for qemu-devel@nongnu.org; Mon, 12 Jan 2015 05:05:14 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:45996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAbrw-000611-2y for qemu-devel@nongnu.org; Mon, 12 Jan 2015 05:05:08 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Jan 2015 10:05:06 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Jan 2015 10:05:04 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id A174517D8056 for ; Mon, 12 Jan 2015 10:05:41 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0CA549q40370274 for ; Mon, 12 Jan 2015 10:05:04 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0C51Eue006753 for ; Mon, 12 Jan 2015 00:01:15 -0500 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-150.boeblingen.de.ibm.com [9.152.224.150]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t0C515wZ006112; Mon, 12 Jan 2015 00:01:14 -0500 From: Cornelia Huck To: peter.maydell@linaro.org Date: Mon, 12 Jan 2015 11:04:52 +0100 Message-Id: <1421057092-8415-8-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1421057092-8415-1-git-send-email-cornelia.huck@de.ibm.com> References: <1421057092-8415-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15011210-0029-0000-0000-000002B5C6A0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.113 Cc: Frank Blaschka , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck Subject: [Qemu-devel] [PULL v3 7/7] kvm: extend kvm_irqchip_add_msi_route to work on s390 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 From: Frank Blaschka on s390 MSI-X irqs are presented as thin or adapter interrupts for this we have to reorganize the routing entry to contain valid information for the adapter interrupt code on s390. To minimize impact on existing code we introduce an architecture function to fixup the routing entry. Signed-off-by: Frank Blaschka Signed-off-by: Cornelia Huck --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 7 +++++++ target-arm/kvm.c | 6 ++++++ target-i386/kvm.c | 6 ++++++ target-mips/kvm.c | 6 ++++++ target-ppc/kvm.c | 6 ++++++ target-s390x/kvm.c | 26 ++++++++++++++++++++++++++ 7 files changed, 61 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 104cf35..30cb84d 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -158,6 +158,7 @@ extern bool kvm_readonly_mem_allowed; struct kvm_run; struct kvm_lapic_state; +struct kvm_irq_routing_entry; typedef struct KVMCapabilityInfo { const char *name; @@ -270,6 +271,9 @@ int kvm_arch_on_sigbus(int code, void *addr); void kvm_arch_init_irq_routing(KVMState *s); +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data); + int kvm_set_irq(KVMState *s, int irq, int level); int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg); diff --git a/kvm-all.c b/kvm-all.c index 18cc6b4..2f21a4e 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1225,6 +1225,10 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg) kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); + if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data)) { + kvm_irqchip_release_virq(s, virq); + return -EINVAL; + } kvm_add_routing_entry(s, &kroute); kvm_irqchip_commit_routes(s); @@ -1250,6 +1254,9 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) kroute.u.msi.address_lo = (uint32_t)msg.address; kroute.u.msi.address_hi = msg.address >> 32; kroute.u.msi.data = le32_to_cpu(msg.data); + if (kvm_arch_fixup_msi_route(&kroute, msg.address, msg.data)) { + return -EINVAL; + } return kvm_update_routing_entry(s, &kroute); } diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 4d81f3d..23cefe9 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -548,3 +548,9 @@ int kvm_arch_irqchip_create(KVMState *s) return 0; } + +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data) +{ + return 0; +} diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f92edfe..54ccb89 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2733,3 +2733,9 @@ int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id) return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSIX | KVM_DEV_IRQ_HOST_MSIX); } + +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data) +{ + return 0; +} diff --git a/target-mips/kvm.c b/target-mips/kvm.c index a761ea5..b68191c 100644 --- a/target-mips/kvm.c +++ b/target-mips/kvm.c @@ -688,3 +688,9 @@ int kvm_arch_get_registers(CPUState *cs) return ret; } + +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data) +{ + return 0; +} diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 911f912..1edf2b5 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -2402,3 +2402,9 @@ out_close: error_out: return; } + +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data) +{ + return 0; +} diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 09c2483..dcd7505 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -41,6 +41,7 @@ #include "trace.h" #include "qapi-event.h" #include "hw/s390x/s390-pci-inst.h" +#include "hw/s390x/s390-pci-bus.h" /* #define DEBUG_KVM */ @@ -1544,3 +1545,28 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) return ret; } + +int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, + uint64_t address, uint32_t data) +{ + S390PCIBusDevice *pbdev; + uint32_t fid = data >> ZPCI_MSI_VEC_BITS; + uint32_t vec = data & ZPCI_MSI_VEC_MASK; + + pbdev = s390_pci_find_dev_by_fid(fid); + if (!pbdev) { + DPRINTF("add_msi_route no dev\n"); + return -ENODEV; + } + + pbdev->routes.adapter.ind_offset = vec; + + route->type = KVM_IRQ_ROUTING_S390_ADAPTER; + route->flags = 0; + route->u.adapter.summary_addr = pbdev->routes.adapter.summary_addr; + route->u.adapter.ind_addr = pbdev->routes.adapter.ind_addr; + route->u.adapter.summary_offset = pbdev->routes.adapter.summary_offset; + route->u.adapter.ind_offset = pbdev->routes.adapter.ind_offset; + route->u.adapter.adapter_id = pbdev->routes.adapter.adapter_id; + return 0; +}