All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Isaku Yamahata <yamahata@valinux.co.jp>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] pci: add standard bridge device
Date: Thu, 18 Aug 2011 11:22:31 +0800	[thread overview]
Message-ID: <4E4C8577.5000608@cn.fujitsu.com> (raw)
In-Reply-To: <4E4B7DE1.3050405@cn.fujitsu.com>

At 08/17/2011 04:37 PM, Wen Congyang Write:
> At 07/04/2011 05:43 PM, Michael S. Tsirkin Write:
>> This adds support for a standard pci to pci bridge,
>> enabling support for more than 32 PCI devices in the system.
>> To use, specify the device id as a 'bus' option.
>> Example:
>> 	-device pci-bridge,id=bridge1 \
>> 	-netdev user,id=u \
>> 	-device ne2k_pci,id=net2,bus=bridge1,netdev=u
>>
>> TODO: device hotplug support.
> 
> I try this patch, and found that when I use pci bridge, qemu will core dump.
> 
> Here is my command line:
> /usr/local2/bin/qemu-system-x86_64 -M pc-0.14 -enable-kvm -m 512 -name vm1 -drive file=/var/lib/libvirt/images/vm1.img,if=none,id=drive-ide0-0-0,format=qcow2,cache=writethrough -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -vnc 0.0.0.0:1 -device pci-bridge,id=bridge1,bus=pci.0,addr=0x08.0x0 -netdev user,id=u -device ne2k_pci,id=net2,bus=bridge1,netdev=u
> 
> Here is the backtrace:
> Core was generated by `/usr/local2/bin/qemu-system-x86_64 -M pc-0.14 -enable-kvm -m 512 -name vm1 -dri'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x0000000000438e34 in memory_region_add_subregion_common (mr=0x0, offset=49152, subregion=0x1de5d58) at /home/wency/source/qemu/memory.c:1152
> 1152	    QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {
> Missing separate debuginfos, use: debuginfo-install SDL-1.2.14-2.el6.x86_64 celt051-0.5.1.3-0.el6.x86_64 cyrus-sasl-gssapi-2.1.23-8.el6.x86_64 cyrus-sasl-lib-2.1.23-8.el6.x86_64 cyrus-sasl-md5-2.1.23-8.el6.x86_64 cyrus-sasl-plain-2.1.23-8.el6.x86_64 db4-4.7.25-16.el6.x86_64 glib2-2.22.5-6.el6.x86_64 glibc-2.12-1.25.el6.x86_64 keyutils-libs-1.4-1.el6.x86_64 krb5-libs-1.9-9.el6.x86_64 libX11-1.3-2.el6.x86_64 libXau-1.0.5-1.el6.x86_64 libaio-0.3.107-10.el6.x86_64 libattr-2.4.44-4.el6.x86_64 libcom_err-1.41.12-7.el6.x86_64 libcurl-7.19.7-26.el6.x86_64 libgcrypt-1.4.5-5.el6.x86_64 libgpg-error-1.7-3.el6.x86_64 libidn-1.18-2.el6.x86_64 libjpeg-6b-46.el6.x86_64 libpng-1.2.44-1.el6.x86_64 libselinux-2.0.94-5.el6.x86_64 libssh2-1.2.2-7.el6.x86_64 libtasn1-2.3-3.el6.x86_64 libuuid-2.17.2-12.el6.x86_64 libxcb-1.5-1.el6.x86_64 ncurses-libs-5.7-3.20090208.el6.x86_64 nspr-4.8.7-1.el6.x86_64 nss-3.12.9-9.el6.x86_64 nss-softokn-freebl-3.12.9-3.el6.x86_64 nss-util-3.12.9-1.el6.x86_64 openld

ap
> -2.4.23-15.el6.x86_64 openssl-1.0.0-10.el6.x86_64 pixman-0.18.4-1.el6_0.1.x86_64 spice-server-0.8.0-1.el6.x86_64 zlib-1.2.3-25.el6.x86_64
> (gdb) bt
> #0  0x0000000000438e34 in memory_region_add_subregion_common (mr=0x0, offset=49152, subregion=0x1de5d58) at /home/wency/source/qemu/memory.c:1152
> #1  0x0000000000439090 in memory_region_add_subregion_overlap (mr=0x0, offset=49152, subregion=0x1de5d58, priority=1) at /home/wency/source/qemu/memory.c:1194
> #2  0x00000000005c55fe in pci_update_mappings (d=0x1de5900) at /home/wency/source/qemu/hw/pci.c:1063
> #3  0x00000000005c5982 in pci_default_write_config (d=0x1de5900, addr=4, val=0, l=2) at /home/wency/source/qemu/hw/pci.c:1121
> #4  0x00000000005cbfbf in pci_host_config_write_common (pci_dev=0x1de5900, addr=4, limit=256, val=1, len=2) at /home/wency/source/qemu/hw/pci_host.c:54
> #5  0x00000000005cc0d1 in pci_data_write (s=0x1da2b90, addr=2147549188, val=1, len=2) at /home/wency/source/qemu/hw/pci_host.c:75
> #6  0x00000000005cc2b1 in pci_host_data_write (handler=0x1da2b60, addr=3324, val=1, len=2) at /home/wency/source/qemu/hw/pci_host.c:125
> #7  0x000000000042c884 in ioport_simple_writew (opaque=0x1da2b60, addr=3324, value=1) at /home/wency/source/qemu/rwhandler.c:50
> #8  0x0000000000499e85 in ioport_write (index=1, address=3324, data=1) at ioport.c:81
> #9  0x000000000049a8e1 in cpu_outw (addr=3324, val=1) at ioport.c:280
> #10 0x0000000000433c5d in kvm_handle_io (port=3324, data=0x7f0b30f86000, direction=1, size=2, count=1) at /home/wency/source/qemu/kvm-all.c:837
> #11 0x00000000004341c8 in kvm_cpu_exec (env=0x1b7fc70) at /home/wency/source/qemu/kvm-all.c:976
> #12 0x000000000040da99 in cpu_exec_all () at /home/wency/source/qemu/cpus.c:1102
> #13 0x00000000005b60c4 in main_loop () at /home/wency/source/qemu/vl.c:1392
> #14 0x00000000005baa49 in main (argc=20, argv=0x7ffffa6b5a38, envp=0x7ffffa6b5ae0) at /home/wency/source/qemu/vl.c:3356
> 
> If I do not attach any device on bus bridge1, qemu can work nice.
> 
> Thanks
> Wen Congyang
> 

The following patch can fix this problem, but I'm not sure whether it is right.

>From 3ce0000e5a14f0ff7aeac148f9416eac6fa7c6ca Mon Sep 17 00:00:00 2001
From: Wen Congyang <wency@cn.fujitsu.com>
Date: Thu, 18 Aug 2011 09:33:19 +0800
Subject: [PATCH] PCI_Bridge: use parent bus's address space

The pci device may call pci_register_bar() to use PCI bus's address space.
But we forget to init PCI bus's address space if it is not bus 0. It will
cause qemu crashed.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

---
 hw/pci_bridge.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
index 464d897..df16faa 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci_bridge.c
@@ -246,6 +246,8 @@ int pci_bridge_initfn(PCIDevice *dev)
                         br->bus_name);
     sec_bus->parent_dev = dev;
     sec_bus->map_irq = br->map_irq;
+    sec_bus->address_space_mem = parent->address_space_mem;
+    sec_bus->address_space_io = parent->address_space_io;
 
     QLIST_INIT(&sec_bus->child);
     QLIST_INSERT_HEAD(&parent->child, sec_bus, sibling);
-- 
1.7.1

  reply	other threads:[~2011-08-18  3:23 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04  9:43 [Qemu-devel] [PATCH] pci: add standard bridge device Michael S. Tsirkin
2011-07-05 13:29 ` Isaku Yamahata
2011-07-05 13:43   ` Michael S. Tsirkin
2011-08-17  8:37 ` Wen Congyang
2011-08-18  3:22   ` Wen Congyang [this message]
2011-08-18 15:15     ` Avi Kivity
2011-08-19  5:12       ` Wen Congyang
2011-08-19 15:26         ` Avi Kivity
2011-08-22  3:13           ` Wen Congyang
2011-08-22  6:23             ` Avi Kivity
2011-09-02  1:32               ` Wen Congyang
2011-09-02  2:56               ` Wen Congyang
2011-09-04  8:25                 ` Avi Kivity
2011-09-06  3:06                   ` Wen Congyang
2011-09-06  7:45                     ` Avi Kivity
2011-09-07  4:39                       ` Wen Congyang
2011-09-07 11:52                         ` Michael S. Tsirkin
2011-09-08  6:15                           ` Wen Congyang
2011-09-08  7:26                             ` Wen Congyang
2011-09-08  9:43                               ` Gerd Hoffmann
2011-09-08  9:58                                 ` Wen Congyang
2011-09-08 10:42                                   ` Michael S. Tsirkin
2011-09-08 11:03                                     ` Wen Congyang
2011-09-08 11:13                                       ` Michael S. Tsirkin
2011-09-09  6:43           ` Wen Congyang
2011-09-09  7:12             ` Michael S. Tsirkin
2011-09-09  7:24               ` Wen Congyang
2011-09-09  7:34                 ` Michael S. Tsirkin
2011-09-09  7:35                   ` Wen Congyang
2011-08-26  9:43       ` Michael S. Tsirkin
2011-08-28  7:50         ` Avi Kivity
2011-08-28 11:41           ` Michael S. Tsirkin
2011-08-28 13:10             ` Avi Kivity
2011-08-28 13:42               ` Michael S. Tsirkin
2011-08-28 13:53                 ` Avi Kivity
2011-09-04 12:30                   ` Michael S. Tsirkin
2011-09-04 12:40                     ` Avi Kivity
2011-09-04 13:01                       ` Michael S. Tsirkin
2011-09-04 13:05                         ` Avi Kivity
2011-09-04 13:09                           ` Avi Kivity
2011-09-04 13:41                           ` Michael S. Tsirkin
2011-09-04 13:55                             ` Avi Kivity
2011-09-04 14:21                               ` Michael S. Tsirkin
2011-09-04 14:36                                 ` Avi Kivity
2011-09-04 14:54                                   ` Michael S. Tsirkin
2011-09-04 15:14                                     ` Avi Kivity
2011-09-04 15:24                                       ` Michael S. Tsirkin
2011-09-04 15:37                                         ` Avi Kivity
2011-09-04 15:45                                           ` Michael S. Tsirkin
2011-09-04 15:46                                             ` Avi Kivity
2011-09-04 16:19                                               ` Michael S. Tsirkin
2011-09-04 16:22                                                 ` Avi Kivity
2011-09-04 17:03                                                   ` Michael S. Tsirkin
2011-09-05  5:36                                                     ` Avi Kivity
2011-09-04 15:26                                   ` Michael S. Tsirkin
2011-09-04 15:42                                     ` Avi Kivity
2011-09-04 15:46                                       ` Michael S. Tsirkin
2011-09-04 15:49                                         ` Avi Kivity
2011-09-04 16:20                                           ` Michael S. Tsirkin
2011-08-26  9:57     ` Michael S. Tsirkin
2011-09-04 17:11 ` Michael S. Tsirkin
2011-09-05  8:17   ` Markus Armbruster
2011-09-05  9:38     ` Michael S. Tsirkin
2011-09-05  9:53       ` Gerd Hoffmann
2011-09-05 11:40         ` Michael S. Tsirkin
2011-09-06  9:18         ` Markus Armbruster
     [not found] ` <4E801927.8020708@cn.fujitsu.com>
     [not found]   ` <20110926070824.GB5860@redhat.com>
     [not found]     ` <4EAF4AFD.6040102@cn.fujitsu.com>
     [not found]       ` <20111101084439.GA11958@redhat.com>
2011-11-01  8:49         ` Wen Congyang
2011-11-01 11:48           ` Michael S. Tsirkin
2011-11-02  1:00             ` Wen Congyang
2011-11-02  2:15           ` Isaku Yamahata
2011-11-02  2:38             ` Wen Congyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4C8577.5000608@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.