All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	Peter Maydell <peter.maydell@linaro.org>
Cc: Michael Karcher <mkarcher@zedat.fu-berlin.de>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4
Date: Thu, 19 Nov 2015 11:22:03 +0100	[thread overview]
Message-ID: <564DA2CB.5090901@redhat.com> (raw)
In-Reply-To: <564D965A.2020205@physik.fu-berlin.de>

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 <setjmp.h>
> #include <signal.h>
> #include <stdlib.h>
> #include <stdio.h>
> 
> 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 <setjmp.h>
> #include <signal.h>
> #include <stdlib.h>
> #include <stdio.h>
> 
> 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
> 

  reply	other threads:[~2015-11-19 10:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 22:15 [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4 John Paul Adrian Glaubitz
2015-11-18 22:15 ` John Paul Adrian Glaubitz
2015-11-19  9:17   ` Peter Maydell
2015-11-19  9:28     ` John Paul Adrian Glaubitz
2015-11-19 10:22       ` Laurent Vivier [this message]
2015-11-19 11:15         ` Peter Maydell
2015-11-19 12:20           ` Laurent Vivier
2015-11-19 12:28             ` John Paul Adrian Glaubitz
2015-11-19 12:54             ` Peter Maydell

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=564DA2CB.5090901@redhat.com \
    --to=lvivier@redhat.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=mkarcher@zedat.fu-berlin.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.