From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MHMmC-0006bS-0f for qemu-devel@nongnu.org; Thu, 18 Jun 2009 14:55:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MHMmB-0006Zn-4E for qemu-devel@nongnu.org; Thu, 18 Jun 2009 14:55:55 -0400 Received: from [199.232.76.173] (port=41274 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MHMmB-0006ZZ-1B for qemu-devel@nongnu.org; Thu, 18 Jun 2009 14:55:55 -0400 Received: from naru.obs2.net ([84.20.150.76]:38701) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MHMmA-0006bd-CX for qemu-devel@nongnu.org; Thu, 18 Jun 2009 14:55:54 -0400 Date: Thu, 18 Jun 2009 21:55:52 +0300 From: Riku Voipio Subject: Re: [Qemu-devel] Re: problems with mmap on qemu-arm Message-ID: <20090618185551.GB24046@kos.to> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kai Backman Cc: qemu-devel@nongnu.org On Wed, Jun 17, 2009 at 11:38:32PM +0300, Kai Backman wrote: > I tracked this down to the code in linux-user/syscall.c. The mmap co= de > seems broken, it assumes arg1 is a pointer to an array where the rea= l > arguments are. Given arg1 =3D 0 the memory access check fails. > The code I'm working on will happily take mmap2 instead so I have a > workaround. Does someone have an opinion on the state of the mmap co= de? > =A0Kai looking at old_mmap() for arm in kernel, qemu seems to the right thing. I= e you are probably calling mmap the wrong way, you are supposed to give it = a array. mmap syscall is depreceated, glibc uses mmap2 since forever. > On Wed, Jun 17, 2009 at 8:54 PM, Kai Backman <[1]kaib@google.com> wr= ote: >=20 > I'm running qemu-arm and see the following output from mmap with '= strace > qemu-arm -strace' (for both host and traget strace output): > mmap(NULL, 32800, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,= -1, > 0) =3D 0x2ad329b46000 > 4023 mmap(0,131072,7,34,-1,0) =3D 0xfffffff2 > When my program later tries to read memory at 0xfffffffe it fails = with a > SIGSEGV: > Program received signal SIGSEGV, Segmentation fault. > 1: x/i $pc =A00xce30: =A0 =A0 ldr =A0 =A0 r1, [r5] > (gdb) i r > r5 =A0 =A0 =A0 =A0 =A0 =A0 0xfffffffe =A0 =A0 =A0 -2 > Why does qemu-arm return such high addresses on a 32 bit platform = and > why is the memory inaccessible? If this doesn't seem like an obvio= us bug > in my code, where in the qemu code should I start looking for how = mmap > works? > =A0Kai > -- > Kai Backman, Software Engineer, [2]kaib@google.com >=20 > -- > Kai Backman, Software Engineer, [3]kaib@google.com >=20 > References >=20 > Visible links > 1. mailto:kaib@google.com > 2. mailto:kaib@google.com > 3. mailto:kaib@google.com