From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzMM0-0002kW-CX for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:22:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzMLv-0007Fs-8O for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:22:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzMLv-0007Fn-16 for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:22:07 -0500 References: <1447884913-8011-1-git-send-email-glaubitz@physik.fu-berlin.de> <1447884913-8011-2-git-send-email-glaubitz@physik.fu-berlin.de> <564D965A.2020205@physik.fu-berlin.de> From: Laurent Vivier Message-ID: <564DA2CB.5090901@redhat.com> Date: Thu, 19 Nov 2015 11:22:03 +0100 MIME-Version: 1.0 In-Reply-To: <564D965A.2020205@physik.fu-berlin.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Paul Adrian Glaubitz , Peter Maydell Cc: Michael Karcher , QEMU Developers Hi, On 19/11/2015 10:28, John Paul Adrian Glaubitz wrote: > On 11/19/2015 10:17 AM, Peter Maydell wrote: >> Unfortunately this isn't sufficient. You also need to add >> the code to the sh4-specific functions in linux-user/signal.c >> which honours the requested sigaltstack when taking and returning >> from signal handlers. it seems all needed functions for sh4 signal handling are already written in linux-user/signal.c, I thing about setup_frame(), setup_rt_frame(), do_sigreturn() and do_rt_sigreturn(). Do we need more ? > My supplied test case shows that sigaltstack works unless I am > overseeing anything? Laurent Vivier (CC'ed) who has done some > extensive qemu development thinks that my change should be enough. > > Here's the output of my test case (CC'ing Michael Karcher who > suggested the test case): > > (sid-sh4-sbuild)root@jessie32:/tmp# cat stackoverflow.c > > #include > #include > #include > #include > > jmp_buf exit_jmp; > > void handler(int x) > { > longjmp(exit_jmp, 1); > } > > int f(void) > { > return f(); > } > > int main(void) > { > stack_t sigstack; > sigstack.ss_sp = malloc(1024*1024); > sigstack.ss_size = 1024*1024; > sigstack.ss_flags = 0; > sigaltstack(&sigstack, NULL); > struct sigaction sa; > sa.sa_handler = handler; > sigemptyset(&sa.sa_mask); > sa.sa_flags = SA_ONSTACK; > sigaction(SIGSEGV, &sa, NULL); > if (setjmp(exit_jmp) == 0) > { > return f(); > } > puts("recovered"); > return 0; > } > (sid-sh4-sbuild)root@jessie32:/tmp# gcc stackoverflow.c -o stackoverflow > (sid-sh4-sbuild)root@jessie32:/tmp# ./stackoverflow > recovered > (sid-sh4-sbuild)root@jessie32:/tmp# > > Now commenting "sigaltstack" out: > > (sid-sh4-sbuild)root@jessie32:/tmp# cat stackoverflow.c > > #include > #include > #include > #include > > jmp_buf exit_jmp; > > void handler(int x) > { > longjmp(exit_jmp, 1); > } > > int f(void) > { > return f(); > } > > int main(void) > { > stack_t sigstack; > sigstack.ss_sp = malloc(1024*1024); > sigstack.ss_size = 1024*1024; > sigstack.ss_flags = 0; > // sigaltstack(&sigstack, NULL); > struct sigaction sa; > sa.sa_handler = handler; > sigemptyset(&sa.sa_mask); > sa.sa_flags = SA_ONSTACK; > sigaction(SIGSEGV, &sa, NULL); > if (setjmp(exit_jmp) == 0) > { > return f(); > } > puts("recovered"); > return 0; > } > (sid-sh4-sbuild)root@jessie32:/tmp# gcc stackoverflow.c -o stackoverflow > (sid-sh4-sbuild)root@jessie32:/tmp# ./stackoverflow > qemu: uncaught target signal 11 (Segmentation fault) - core dumped > Segmentation fault > (sid-sh4-sbuild)root@jessie32:/tmp# > > Thus, for me it seems sigaltstack behaves as expected with the patch > applied. > > Am I missing something obvious? > > Cheers, > Adrian >