Received: from eggs.gnu.org ([2001:4830:134:3::10]:35795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSKbW-0008SV-5r for qemu-devel@nongnu.org; Wed, 27 Jul 2016 04:54:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSKbQ-0001Ps-5H for qemu-devel@nongnu.org; Wed, 27 Jul 2016 04:54:13 -0400 Date: Wed, 27 Jul 2016 16:53:59 +0800 From: Peter Xu Message-ID: <20160727085359.GA18777@pxdev.xzpeter.org> References: <1469605906-20243-1-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1469605906-20243-1-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu] kvm-irqchip: Only do explicit IRQ routing commit when IRQCHIP is in use List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson , Paolo Bonzini , alex.williamson@redhat.com, mst@redhat.com, Thomas Huth On Wed, Jul 27, 2016 at 05:51:46PM +1000, Alexey Kardashevskiy wrote: > 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. > > Signed-off-by: Alexey Kardashevskiy > --- > > Or I am too late and there is the fix? Could not find any. > > This is the backtrace: > > Thread 4 "qemu-system-ppc" received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x3fffb663ec90 (LWP 11852)] > 0x0000000010091fa4 in kvm_irqchip_commit_routes (s=0x10eff3b0) at /home/aik/p/qemu-ddw/kvm-all.c:1050 > 1050 s->irq_routes->flags = 0; > (gdb) p s > $2 = (KVMState *) 0x10eff3b0 > (gdb) p s->irq_routes > $3 = (struct kvm_irq_routing *) 0x0 > (gdb) bt > #0 0x0000000010091fa4 in kvm_irqchip_commit_routes (s=0x10eff3b0) at /home/aik/p/qemu-ddw/kvm-all.c:1050 > #1 0x000000001010fcd4 in vfio_update_kvm_msi_virq (vector=0x3fffa8006a10, msg=..., pdev=0x1101f300) at /h > ome/aik/p/qemu-ddw/hw/vfio/pci.c:461 > #2 0x000000001010fe58 in vfio_msix_vector_do_use (pdev=0x1101f300, nr=0x0, msg=0x3fffb663dd00, handler=0x > 1010f5e8 ) at /home/aik/p/qemu-ddw/hw/vfio/pci.c:496 > #3 0x000000001011010c in vfio_msix_vector_use (pdev=0x1101f300, nr=0x0, msg=...) at /home/aik/p/qemu-ddw/ > hw/vfio/pci.c:557 > #4 0x00000000103f64c4 in msix_fire_vector_notifier (dev=0x1101f300, vector=0x0, is_masked=0x0) at /home/a > ik/p/qemu-ddw/hw/pci/msix.c:111 > #5 0x00000000103f6594 in msix_handle_mask_update (dev=0x1101f300, vector=0x0, was_masked=0x1) at /home/ai > k/p/qemu-ddw/hw/pci/msix.c:124 > #6 0x00000000103f6928 in msix_table_mmio_write (opaque=0x1101f300, addr=0xc, val=0x0, size=0x4) at /home/ > aik/p/qemu-ddw/hw/pci/msix.c:186 > #7 0x0000000010099738 in memory_region_write_accessor (mr=0x1101f838, addr=0xc, value=0x3fffb663df50, siz > e=0x4, shift=0x0, mask=0xffffffff, attrs=...) at /home/aik/p/qemu-ddw/memory.c:525 > #8 0x0000000010099a94 in access_with_adjusted_size (addr=0xc, value=0x3fffb663df50, size=0x4, access_size > _min=0x1, access_size_max=0x4, access=0x100995f8 , mr=0x1101f838, attrs=...) > at /home/aik/p/qemu-ddw/memory.c:591 > #9 0x000000001009cb0c in memory_region_dispatch_write (mr=0x1101f838, addr=0xc, data=0x0, size=0x4, attrs > =...) at /home/aik/p/qemu-ddw/memory.c:1262 > #10 0x0000000010015300 in address_space_write_continue (as=0x109b3958 , addr=0x10120 > 00200c, attrs=..., buf=0x3fffb5e20028 "", len=0x4, addr1=0xc, l=0x4, mr=0x1101f838) at /home/aik/p/qemu-dd > w/exec.c:2580 > #11 0x0000000010015558 in address_space_write (as=0x109b3958 , addr=0x1012000200c, a > ttrs=..., buf=0x3fffb5e20028 "", len=0x4) at /home/aik/p/qemu-ddw/exec.c:2637 > #12 0x00000000100159e4 in address_space_rw (as=0x109b3958 , addr=0x1012000200c, attr > s=..., buf=0x3fffb5e20028 "", len=0x4, is_write=0x1) at /home/aik/p/qemu-ddw/exec.c:2739 > #13 0x0000000010094cb8 in kvm_cpu_exec (cpu=0x3fffb6e76db0) at /home/aik/p/qemu-ddw/kvm-all.c:1952 > #14 0x0000000010072764 in qemu_kvm_cpu_thread_fn (arg=0x3fffb6e76db0) at /home/aik/p/qemu-ddw/cpus.c:1078 > #15 0x00003fffb7a184a0 in start_thread (arg=0x3fffb663ec90) at pthread_create.c:335 > #16 0x00003fffb7957e74 in clone () at ../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:96 > (gdb) > --- > kvm-all.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kvm-all.c b/kvm-all.c > index 3764ba9..028fdcb 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -1047,6 +1047,10 @@ void kvm_irqchip_commit_routes(KVMState *s) > { > int ret; > > + if (!s->irq_routes) { > + return; > + } > + > s->irq_routes->flags = 0; > ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); > assert(ret == 0); Sorry for the trouble. How about this one: diff --git a/kvm-all.c b/kvm-all.c index ef81ca5..4b3e330 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1047,6 +1047,10 @@ void kvm_irqchip_commit_routes(KVMState *s) { int ret; + if (kvm_gsi_direct_mapping()) { + return 0; + } + s->irq_routes->flags = 0; trace_kvm_irqchip_commit_routes(); ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); I don't know whether irq_routes will be NULL for all GSI direct mapping case... at least this can have kvm_irqchip_*() APIs got aligned. Thanks, -- peterx