From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CwN2L-0005lE-Oz for qemu-devel@nongnu.org; Wed, 02 Feb 2005 11:07:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CwN2F-0005iX-20 for qemu-devel@nongnu.org; Wed, 02 Feb 2005 11:07:20 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CwN2E-0005g5-Uv for qemu-devel@nongnu.org; Wed, 02 Feb 2005 11:07:19 -0500 Received: from [65.74.133.9] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CwMj2-0003ZK-MJ for qemu-devel@nongnu.org; Wed, 02 Feb 2005 10:47:28 -0500 From: Paul Brook Subject: Re: [Qemu-devel] Armv5 target Date: Wed, 2 Feb 2005 15:47:24 +0000 References: <200501312019.45282.paul@codesourcery.com> <200502020126.38386.paul@codesourcery.com> <20050202120109.GB17294@xi.wantstofly.org> In-Reply-To: <20050202120109.GB17294@xi.wantstofly.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_MYPACuhqEi8KofH" Message-Id: <200502021547.24944.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_MYPACuhqEi8KofH Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wednesday 02 February 2005 12:01, Lennert Buytenhek wrote: > On Wed, Feb 02, 2005 at 01:26:37AM +0000, Paul Brook wrote: > > > > + /* XXX: locking issue */ > > > > + if (is_write && page_unprotect(address, pc, puc)) { > > > > + return 1; > > > > + } > > > > /* XXX: do more */ > > > > return 0; > > > > } > > > > > > Sort of. Self-modifying code (e.g. stack trampolines) are still broken, > > > and the patch above should work. > > > > > > However I just tested it and it doesn't seem to work any more. It seems > > > that the SEGV handler is being passed an address of 0, rather than the > > > actual faulting location. > > > > > > This may be a host kernel/libc bug. > > > > I just tried on a few different machines, and this is a host kernel bug > > specific to one particular kernel (custom 2.6.9). > > Do you have some example code that demonstrates this? I've attached two programs. segv-test.c tests for the kernel bug. nest_test.c tests stack trampolines, which exposes the bug then run inside qemu-user. Note that the proper fix for arm is to remove the ||1 hack on the TARGET_HAS_SMC tests in exec.c. Comments indicate this hack is to work around bugs in the PPC emulation. Paul --Boundary-00=_MYPACuhqEi8KofH Content-Type: text/x-csrc; charset="iso-8859-1"; name="segv_test.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="segv_test.c" /* Test that gatching SIGSEGV gives the correct fault address. */ #include #include #include #include void * volatile p = NULL; void * volatile block; void foo(int n, siginfo_t *info, void *data) { p = info->si_addr; printf ("%p\n", block); mprotect(block, sizeof(int), PROT_READ | PROT_WRITE); } int main() { struct sigaction sa; p = &sa; memset (&sa, 0, sizeof(sa)); sa.sa_sigaction = foo; sa.sa_flags = SA_SIGINFO; sigaction (SIGSEGV, &sa, NULL); block = mmap(NULL, sizeof(int), PROT_READ, MAP_SHARED|MAP_ANONYMOUS, 0, 0); if (block == MAP_FAILED) { printf ("mmap failed\n"); return 1; } *(volatile int *) block = 42; sleep(1); if (p != block) printf ("FAIL: expected %p, got %p\n", block, p); else printf ("OK\n"); return 0; } --Boundary-00=_MYPACuhqEi8KofH Content-Type: text/x-csrc; charset="iso-8859-1"; name="nest_test.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nest_test.c" /* Test stack trampolines (nested functions). */ /* Should print "Hello nested world". */ #include void bar(void (*)()) { f(); } int main() { void f() { printf ("nested "); } printf ("Hello "); bar(f); printf ("world\n"); return 0; } --Boundary-00=_MYPACuhqEi8KofH--