Re: [patch] fold struct vcpu_info into CPUState

Hollis Blanchard
2008-10-24T19:11:00Z

On Fri, 2008-10-24 at 17:57 +0200, Jes Sorensen wrote:
> Hi,
>
> Here's an updated version of the patch, which builds against Avi's
> current tree. Please note this is a bit of a work in progress version
> as I am trying to eliminate the need for the vcpu -> env linear
> conversion, but I wanted to send out something before heading off for
> the weekend.
>
> Hollis if you have time to check this out for PPC, I would much
> appreciate it.

Unfortunately qemu segfaults halfway through guest kernel boot:

...
virtio-pci 0000:00:01.0: enabling device (0000 -> 0001)
vda:Segmentation fault

This is 100% repeatable, and it doesn't happen without your patch
applied.

0x10116f1c in kvm_update_interrupt_request (env=0x103d4718)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/qemu-kvm.c:142
142 if (current_env->vcpu_info.created &&
(gdb) bt
#0 0x10116f1c in kvm_update_interrupt_request (env=0x103d4718)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/qemu-kvm.c:142
#1 0x100b4a74 in cpu_interrupt (env=0x103d4718, mask=0x2)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/exec.c:1507
#2 0x10033d04 in ppc_set_irq (env=0x0, n_IRQ=0x2, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/ppc.c:41
#3 0x10033e4c in ppc40x_set_irq (opaque=0x103d4718, pin=0x4, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/ppc.c:400
#4 0x44004084 in ?? ()
#5 0x1007cc40 in qemu_set_irq (irq=0x103d4718, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/irq.c:38
#6 0x1006e408 in ppcuic_trigger_irq (uic=0x103f2c80)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/irq.h:19
#7 0x1007cc40 in qemu_set_irq (irq=0x103d4718, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/irq.c:38
#8 0x1006edf4 in bamboo_pci_set_irq (pic=0x103d4718, irq_num=0x2, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/ppc4xx_devs.c:837
#9 0x100170d4 in pci_set_irq (opaque=0x103d4718, irq_num=0x2, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/pci.c:560
#10 0x1007cc40 in qemu_set_irq (irq=0x103d4718, level=0x1)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/irq.c:38
#11 0x1003194c in virtio_update_irq (vdev=0x103d4718)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/virtio.c:205
#12 0x10032ef4 in virtio_blk_rw_complete (opaque=0x10438008, ret=0x0)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/hw/virtio-blk.c:119
#13 0x100ad680 in qcow_aio_read_cb (opaque=0x10432e58, ret=0x0)
at block-qcow2.c:1205
#14 0x1001c450 in posix_aio_read (opaque=0x103d4718) at block-raw-posix.c:550
#15 0x1000e5d8 in main_loop_wait (timeout=0xbfe5a978)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/vl.c:8352
#16 0x24000082 in ?? ()
#17 0x10117a00 in kvm_main_loop ()
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/qemu-kvm.c:614
#18 0x10011aa0 in main (argc=0x101b0000, argv=0x10380958)
at /home/hollisb/source/kvm-userspace-ppc.hg/qemu/vl.c:8416
(gdb) p current_env
$1 = (struct CPUPPCState *) 0x0
(gdb)

It looks like qemu is actually switching threads when this happens...
I'm not sure what the current state is of qemu/KVM threads... I think we
have 1 thread per vcpu, plus 1 IO thread? If that's right, maybe
current_env isn't being initialized in the IO thread; I only see that
happening inside ap_main_loop(), which is the vcpu thread.

--
Hollis Blanchard
IBM Linux Technology Center