From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0BQI-0001FS-3Q for qemu-devel@nongnu.org; Fri, 19 Jul 2013 10:12:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0BQG-00020J-Jd for qemu-devel@nongnu.org; Fri, 19 Jul 2013 10:12:42 -0400 Message-ID: <51E9494F.6050607@suse.de> Date: Fri, 19 Jul 2013 16:12:31 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1373946643-10609-1-git-send-email-qiudayu@linux.vnet.ibm.com> <51E80954.1030708@linux.vnet.ibm.com> <51E82268.3060809@suse.de> <51E8A3C9.7090901@linux.vnet.ibm.com> In-Reply-To: <51E8A3C9.7090901@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Bug Fix:Segmentation fault when use usb-ehci device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mike Qiu Cc: agraf@suse.de, aik@ozlabs.ru, qemu-devel@nongnu.org, xiaoguangrong@linux.vnet.ibm.com, qemu-ppc@nongnu.org, Gerd Hoffmann , Paolo Bonzini Am 19.07.2013 04:26, schrieb Mike Qiu: > =E4=BA=8E 2013/7/19 1:14, Andreas F=C3=A4rber =E5=86=99=E9=81=93: >> There's some typos in the commit message, but the change looks okay to >> me - although there were discussions to catch this on the memory API >> side of things instead. > You mean this patch: see below: >=20 > exec: Support 64-bit operations in address_s No, I don't. There were other segfault avoidance patches like yours over the past months - they're all fixing individual segfault symptoms. Question for Paolo is whether we want to continue to discover them one by one or whether to implement a fallback inside memory code if .read or .write is NULL. Andreas >=20 > BTW, this bug has been opened before? >=20 > Thanks > Mike >> >> Regards, >> Andreas >> >>> Thanks >>> Mike >>> 2013/7/16 11:50, Mike Qiu wrote: >>>> 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=3D0x113e9e78, addr=3D9, value=3D0x3fffa7fce088, >>>> size=3D1, shift=3D0, mask=3D255) 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 =3D {read =3D @0x10716f68: 0x1020699c , write =3D= 0, >>>> endianness =3D DEVICE_LITTLE_ENDIAN, valid =3D {min_access_size =3D= 1, >>>> max_access_size =3D 4, unaligned =3D false, accepts =3D 0}, impl = =3D >>>> {min_access_size =3D 1, max_access_size =3D 1, unaligned =3D fals= e}, >>>> old_mmio =3D {read =3D {0, 0, 0}, write =3D {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 >>>> --- >>>> 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 =3D { >>>> .read =3D ehci_caps_read, >>>> + .write =3D ehci_caps_write, >>>> .valid.min_access_size =3D 1, >>>> .valid.max_access_size =3D 4, >>>> .impl.min_access_size =3D 1, >>> >> >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg