qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mike Qiu <qiudayu@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aik@ozlabs.ru, Mike Qiu <qiudayu@linux.vnet.ibm.com>,
	qemu-ppc@nongnu.org, agraf@suse.de,
	xiaoguangrong@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH] Bug Fix:Segmentation fault when use usb-ehci device
Date: Mon, 15 Jul 2013 23:50:43 -0400	[thread overview]
Message-ID: <1373946643-10609-1-git-send-email-qiudayu@linux.vnet.ibm.com> (raw)

For usb-ehci in qemu, its caps just has read() operation,
the write() operation does not exist.

This cause a Segmentation fault when use usb-ehci device in ppc64
platform.

here is gdb output:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x3fffa7fcef20 (LWP 6793)]
0x00000000103f5244 in memory_region_oldmmio_write_accessor
(opaque=0x113e9e78, addr=9, value=0x3fffa7fce088,
size=1, shift=0, mask=255) at /home/Mike/qemu-impreza/memory.c:384
384  mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
(gdb) p *mr->ops
$1 = {read = @0x10716f68: 0x1020699c <ehci_caps_read>, write = 0,
   endianness = DEVICE_LITTLE_ENDIAN, valid = {min_access_size = 1,
   max_access_size = 4, unaligned = false, accepts = 0}, impl =
   {min_access_size = 1, max_access_size = 1, unaligned = false},
   old_mmio = {read = {0, 0, 0}, write = {0, 0, 0}}}

Becasue function write() of mr->ops has not been implement, in
function memory_region_dispatch_write(), it call
oldmmio write accessor, but at the same time old_mmio still not
been implement by default.

That is the root cause of the Segmentation fault.

To solve this problem, add empty function: ehci_caps_write()

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
---
 hw/usb/hcd-ehci.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 67e4b24..6c8a439 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1072,6 +1072,12 @@ static void ehci_port_write(void *ptr, hwaddr addr,
     trace_usb_ehci_portsc_change(addr + s->portscbase, addr >> 2, *portsc, old);
 }
 
+static void ehci_caps_write(void *ptr, hwaddr addr, uint64_t val,
+                           unsigned size)
+{
+    /* nothing */
+}
+
 static void ehci_opreg_write(void *ptr, hwaddr addr,
                              uint64_t val, unsigned size)
 {
@@ -2380,6 +2386,7 @@ static void ehci_frame_timer(void *opaque)
 
 static const MemoryRegionOps ehci_mmio_caps_ops = {
     .read = ehci_caps_read,
+    .write = ehci_caps_write,
     .valid.min_access_size = 1,
     .valid.max_access_size = 4,
     .impl.min_access_size = 1,
-- 
1.7.10.1

             reply	other threads:[~2013-07-16  3:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16  3:50 Mike Qiu [this message]
2013-07-18 15:27 ` [Qemu-devel] [PATCH] Bug Fix:Segmentation fault when use usb-ehci device Mike Qiu
2013-07-18 17:14   ` Andreas Färber
2013-07-19  2:26     ` Mike Qiu
2013-07-19 14:12       ` Andreas Färber
2013-07-19 14:32         ` Peter Maydell
2013-07-22  2:17           ` Mike Qiu

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=1373946643-10609-1-git-send-email-qiudayu@linux.vnet.ibm.com \
    --to=qiudayu@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=xiaoguangrong@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).