kvm-irqchip: Only do explicit IRQ routing commit when IRQCHIP is in use
PATCH 1/1 kvm-irqchip: Only do explicit IRQ routing commit when IRQCHIP is in use
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.
---
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 <vfio_msi_interrupt>) 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 <memory_region_write_accessor>, 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 <address_space_memory>, 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 <address_space_memory>, 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 <address_space_memory>, 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(+)
kvm-all.c +4 -0
@@ -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 );
Signature · 1 line
2.5.0.rc3
Quoted 65 lines · 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 supportKVM_CAP_IRQCHIP(KVM_CAP_IRQ_XICSis there instead). At the result,KVMState::irq_routesis NULL when VFIO callskvm_irqchip_commit_routes.This makes the routing update conditional.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
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 Thread0x3fffb663ec90(LWP 11852)]0x0000000010091fa4inkvm_irqchip_commit_routes(s=0x10eff3b0) at/home/aik/p/qemu-ddw/kvm-all.c:1050
1050s->irq_routes->flags= 0;
(gdb) p s
$2 = (KVMState *)0x10eff3b0
(gdb) ps->irq_routes
$3 = (structkvm_irq_routing*)0x0
(gdb) bt
#00x0000000010091fa4inkvm_irqchip_commit_routes(s=0x10eff3b0) at/home/aik/p/qemu-ddw/kvm-all.c:1050#10x000000001010fcd4invfio_update_kvm_msi_virq(vector=0x3fffa8006a10, msg=..., pdev=0x1101f300) at /home/aik/p/qemu-ddw/hw/vfio/pci.c:461
#20x000000001010fe58invfio_msix_vector_do_use(pdev=0x1101f300, nr=0x0, msg=0x3fffb663dd00, handler=0x1010f5e8<vfio_msi_interrupt>) at/home/aik/p/qemu-ddw/hw/vfio/pci.c:496
#30x000000001011010cinvfio_msix_vector_use(pdev=0x1101f300, nr=0x0, msg=...) at/home/aik/p/qemu-ddw/hw/vfio/pci.c:557
#40x00000000103f64c4inmsix_fire_vector_notifier(dev=0x1101f300, vector=0x0, is_masked=0x0) at/home/aik/p/qemu-ddw/hw/pci/msix.c:111
#50x00000000103f6594inmsix_handle_mask_update(dev=0x1101f300, vector=0x0, was_masked=0x1) at/home/aik/p/qemu-ddw/hw/pci/msix.c:124
#60x00000000103f6928inmsix_table_mmio_write(opaque=0x1101f300, addr=0xc, val=0x0, size=0x4) at/home/aik/p/qemu-ddw/hw/pci/msix.c:186
#70x0000000010099738inmemory_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
#80x0000000010099a94inaccess_with_adjusted_size(addr=0xc, value=0x3fffb663df50, size=0x4,access_size_min=0x1, access_size_max=0x4, access=0x100995f8 <memory_region_write_accessor>, mr=0x1101f838, attrs=...)
at/home/aik/p/qemu-ddw/memory.c:591
#90x000000001009cb0cinmemory_region_dispatch_write(mr=0x1101f838, addr=0xc, data=0x0, size=0x4, attrs =...) at/home/aik/p/qemu-ddw/memory.c:1262
#100x0000000010015300inaddress_space_write_continue(as=0x109b3958 <address_space_memory>, addr=0x10120 00200c, attrs=..., buf=0x3fffb5e20028 "", len=0x4, addr1=0xc, l=0x4, mr=0x1101f838) at/home/aik/p/qemu-ddw/exec.c:2580
#110x0000000010015558inaddress_space_write(as=0x109b3958 <address_space_memory>, addr=0x1012000200c, a ttrs=..., buf=0x3fffb5e20028 "", len=0x4) at/home/aik/p/qemu-ddw/exec.c:2637
#120x00000000100159e4inaddress_space_rw(as=0x109b3958 <address_space_memory>, addr=0x1012000200c, attr s=..., buf=0x3fffb5e20028 "", len=0x4, is_write=0x1) at/home/aik/p/qemu-ddw/exec.c:2739#130x0000000010094cb8inkvm_cpu_exec(cpu=0x3fffb6e76db0) at/home/aik/p/qemu-ddw/kvm-all.c:1952#140x0000000010072764inqemu_kvm_cpu_thread_fn(arg=0x3fffb6e76db0) at/home/aik/p/qemu-ddw/cpus.c:1078#150x00003fffb7a184a0instart_thread(arg=0x3fffb663ec90) at pthread_create.c:335
#160x00003fffb7957e74in clone () at../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:96(gdb)--- kvm-all.c | 4 ++++ 1 file changed, 4 insertions(+)kvm-all.c +0
-0
kvm-all.c void kvm_irqchip_commit_routes(KVMState *s) · line 1056
Quoted 10 lines
kvm-all.c +4
-0@@ -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:
kvm-all.c +4 -0
@@ -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
Quoted 95 lines · Peter Xu
Quoted 65 lines · 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 supportKVM_CAP_IRQCHIP(KVM_CAP_IRQ_XICSis there instead). At the result,KVMState::irq_routesis NULL when VFIO callskvm_irqchip_commit_routes.This makes the routing update conditional.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
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 Thread0x3fffb663ec90(LWP 11852)]0x0000000010091fa4inkvm_irqchip_commit_routes(s=0x10eff3b0) at/home/aik/p/qemu-ddw/kvm-all.c:1050
1050s->irq_routes->flags= 0;
(gdb) p s
$2 = (KVMState *)0x10eff3b0
(gdb) ps->irq_routes
$3 = (structkvm_irq_routing*)0x0
(gdb) bt
#00x0000000010091fa4inkvm_irqchip_commit_routes(s=0x10eff3b0) at/home/aik/p/qemu-ddw/kvm-all.c:1050#10x000000001010fcd4invfio_update_kvm_msi_virq(vector=0x3fffa8006a10, msg=..., pdev=0x1101f300) at /home/aik/p/qemu-ddw/hw/vfio/pci.c:461
#20x000000001010fe58invfio_msix_vector_do_use(pdev=0x1101f300, nr=0x0, msg=0x3fffb663dd00, handler=0x1010f5e8<vfio_msi_interrupt>) at/home/aik/p/qemu-ddw/hw/vfio/pci.c:496
#30x000000001011010cinvfio_msix_vector_use(pdev=0x1101f300, nr=0x0, msg=...) at/home/aik/p/qemu-ddw/hw/vfio/pci.c:557
#40x00000000103f64c4inmsix_fire_vector_notifier(dev=0x1101f300, vector=0x0, is_masked=0x0) at/home/aik/p/qemu-ddw/hw/pci/msix.c:111
#50x00000000103f6594inmsix_handle_mask_update(dev=0x1101f300, vector=0x0, was_masked=0x1) at/home/aik/p/qemu-ddw/hw/pci/msix.c:124
#60x00000000103f6928inmsix_table_mmio_write(opaque=0x1101f300, addr=0xc, val=0x0, size=0x4) at/home/aik/p/qemu-ddw/hw/pci/msix.c:186
#70x0000000010099738inmemory_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
#80x0000000010099a94inaccess_with_adjusted_size(addr=0xc, value=0x3fffb663df50, size=0x4,access_size_min=0x1, access_size_max=0x4, access=0x100995f8 <memory_region_write_accessor>, mr=0x1101f838, attrs=...)
at/home/aik/p/qemu-ddw/memory.c:591
#90x000000001009cb0cinmemory_region_dispatch_write(mr=0x1101f838, addr=0xc, data=0x0, size=0x4, attrs =...) at/home/aik/p/qemu-ddw/memory.c:1262
#100x0000000010015300inaddress_space_write_continue(as=0x109b3958 <address_space_memory>, addr=0x10120 00200c, attrs=..., buf=0x3fffb5e20028 "", len=0x4, addr1=0xc, l=0x4, mr=0x1101f838) at/home/aik/p/qemu-ddw/exec.c:2580
#110x0000000010015558inaddress_space_write(as=0x109b3958 <address_space_memory>, addr=0x1012000200c, a ttrs=..., buf=0x3fffb5e20028 "", len=0x4) at/home/aik/p/qemu-ddw/exec.c:2637
#120x00000000100159e4inaddress_space_rw(as=0x109b3958 <address_space_memory>, addr=0x1012000200c, attr s=..., buf=0x3fffb5e20028 "", len=0x4, is_write=0x1) at/home/aik/p/qemu-ddw/exec.c:2739#130x0000000010094cb8inkvm_cpu_exec(cpu=0x3fffb6e76db0) at/home/aik/p/qemu-ddw/kvm-all.c:1952#140x0000000010072764inqemu_kvm_cpu_thread_fn(arg=0x3fffb6e76db0) at/home/aik/p/qemu-ddw/cpus.c:1078#150x00003fffb7a184a0instart_thread(arg=0x3fffb663ec90) at pthread_create.c:335
#160x00003fffb7957e74in clone () at../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:96(gdb)--- kvm-all.c | 4 ++++ 1 file changed, 4 insertions(+)kvm-all.c +0
-0kvm-all.c void kvm_irqchip_commit_routes(KVMState *s) · line 1056
Quoted 10 lines
kvm-all.c +4
-0@@ -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:
kvm-all.c +4
-0@@ -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);
Quoted 3 lines
I don't know whether
irq_routeswill be NULL for all GSI direct mapping case... at least this can have kvm_irqchip_*() APIs got aligned.
This works too.
You may also want to copy if(!kvm_gsi_routing_enabled()) from kvm_irqchip_add_msi_route() to align API (not needed in my case though). Or just check the result of these checks by if(!s->irq_routes) :) Thanks.
Signature · 1 line
Alexey
Quoted 1 line · Alexey Kardashevskiy
On 27/07/16 18:53, Peter Xu wrote:
[...]
Quoted 25 lines
Quoted 18 lines
Sorry for the trouble. How about this one:
kvm-all.c +4
-0@@ -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);Quoted 3 lines
I don't know whether
irq_routeswill be NULL for all GSI direct mapping case... at least this can have kvm_irqchip_*() APIs got aligned.This works too.
Quoted 4 lines
You may also want to copy if(!kvm_gsi_routing_enabled()) from
kvm_irqchip_add_msi_route()to align API (not needed in my case though). Or just check the result of these checks byif(!s->irq_routes):) Thanks.
Right. Do you like to post a v2 for this one? (since of course honor is yours and fault is mine :) Please let me know if you want me to do this for you. It'll be nice we have this fix asap so that less people suffers.
Thanks!
-- peterx
On Wed, Jul 27, 2016 at 09:29:07PM +0800, Peter Xu wrote:
[...]
Quoted 11 lines
Quoted 6 lines
This works too.
You may also want to copy if(!kvm_gsi_routing_enabled()) from
kvm_irqchip_add_msi_route()to align API (not needed in my case though). Or just check the result of these checks byif(!s->irq_routes):) Thanks.Right. Do you like to post a v2 for this one? (since of course honor is yours and fault is mine :) Please let me know if you want me to do this for you. It'll be nice we have this fix asap so that less people suffers.
Btw, please ignore above message if you still prefer v1 and sure that it works in all cases. :)
-- peterx
Quoted 11 lines · Peter Xu
On Wed, Jul 27, 2016 at 09:29:07PM +0800, Peter Xu wrote:
[...]
Quoted 7 lines
Quoted 6 lines
This works too.
You may also want to copy if(!kvm_gsi_routing_enabled()) from
kvm_irqchip_add_msi_route()to align API (not needed in my case though). Or just check the result of these checks byif(!s->irq_routes):) Thanks.
Quoted 7 lines
Quoted 4 lines
Right. Do you like to post a v2 for this one? (since of course honor is yours and fault is mine :) Please let me know if you want me to do this for you. It'll be nice we have this fix asap so that less people suffers.
Btw, please ignore above message if you still prefer v1 and sure that it works in all cases. :)
I am totally fine with either fix (others may have opinions though), if you really want your fix, please do so (and you can quote me as "Reported-by"/"Tested-by" if you feel guilt which I do not think you should) :)
Signature · 1 line
Alexey
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
This works too.
You may also want to copy if(!kvm_gsi_routing_enabled()) from
kvm_irqchip_add_msi_route()to align API (not needed in my case though). Or
just check the result of these checks byif(!s->irq_routes):) Thanks.
Quoted 7 lines
Quoted 4 lines
Right. Do you like to post a v2 for this one? (since of course honor is yours and fault is mine :) Please let me know if you want me to do this for you. It'll be nice we have this fix asap so that less people suffers.
Btw, please ignore above message if you still prefer v1 and sure that it works in all cases. :)
Peter, please post v2 according to your patch and Alexey's suggestion. David, can you handle it?
Thanks!
Paolo
Quoted 13 lines · Paolo Bonzini
Quoted 13 lines
Quoted 12 lines
Quoted 7 lines
This works too.
You may also want to copy if(!kvm_gsi_routing_enabled()) from
kvm_irqchip_add_msi_route()to align API (not needed in my case though). Or
just check the result of these checks byif(!s->irq_routes):) Thanks.Right. Do you like to post a v2 for this one? (since of course honor is yours and fault is mine :) Please let me know if you want me to do this for you. It'll be nice we have this fix asap so that less people suffers.
Quoted 5 lines
Quoted 2 lines
Btw, please ignore above message if you still prefer v1 and sure that it works in all cases. :)
Peter, please post v2 according to your patch and Alexey's suggestion. David, can you handle it?
Sure, then let me send a v2 later. Will CC David. Thanks!
-- peterx