From patchwork Wed Aug 3 03:07:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 655232 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 3s3ygs6Yxtz9t15 for ; Wed, 3 Aug 2016 13:08:25 +1000 (AEST) Received: from localhost ([::1]:59899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUmXf-0004Bq-TS for incoming@patchwork.ozlabs.org; Tue, 02 Aug 2016 23:08:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUmWy-00038i-LZ for qemu-devel@nongnu.org; Tue, 02 Aug 2016 23:07:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUmWt-0006Lj-Iz for qemu-devel@nongnu.org; Tue, 02 Aug 2016 23:07:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUmWt-0006Lf-DC; Tue, 02 Aug 2016 23:07:35 -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 10873821C7; Wed, 3 Aug 2016 03:07:35 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-14-175.nay.redhat.com [10.66.14.175]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7337Sn9009295; Tue, 2 Aug 2016 23:07:29 -0400 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 3 Aug 2016 11:07:21 +0800 Message-Id: <1470193641-26000-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 03 Aug 2016 03:07:35 +0000 (UTC) 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] kvm-irqchip: only commit route when irqchip is used 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: thuth@redhat.com, mst@redhat.com, aik@ozlabs.ru, peterx@redhat.com, alex.williamson@redhat.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Reported from Alexey Kardashevskiy: 3f1fea0fb5bf "kvm-irqchip: do explicit commit when update irq" produces a crash on pseries guest running with VFIO on POWER8 machine as it does not support KVM_CAP_IRQCHIP (KVM_CAP_IRQ_XICS is there instead). At the result, KVMState::irq_routes is NULL when VFIO calls kvm_irqchip_commit_routes. This makes the routing update conditional. Reported-by: Alexey Kardashevskiy Tested-by: Alexey Kardashevskiy Signed-off-by: Peter Xu --- kvm-all.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kvm-all.c b/kvm-all.c index ef81ca5..65608de 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1047,6 +1047,14 @@ void kvm_irqchip_commit_routes(KVMState *s) { int ret; + if (kvm_gsi_direct_mapping()) { + return; + } + + if (!kvm_gsi_routing_enabled()) { + return; + } + s->irq_routes->flags = 0; trace_kvm_irqchip_commit_routes(); ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);