qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Enable sigaltstack syscall for sh4
@ 2015-11-18 22:15 John Paul Adrian Glaubitz
  2015-11-18 22:15 ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 9+ messages in thread
From: John Paul Adrian Glaubitz @ 2015-11-18 22:15 UTC (permalink / raw)
  To: qemu-devel

Hello!

I'm the current maintainer for the Debian sh4 port. I maintain several
buildds as well as port packages for the sh4 architecture.

Recently I discovered qemu for building packages in an emulated chroot
environment with qemu-sh4-static. While setting up python, qemu issued
an error message about an unimplemented syscall, 186 which is sigaltstack.

Looking up the sources, I found that linux-user/syscall.c enables
sigaltstack for a limited number of architectures only. In order to fix
the problem with the missing sigaltstack syscall, I added TARGET_SH4
to the list of architectures which seems to work.

The following sample C program tests the functionality of sigaltstack.
Without my patch, the program segfaults on qemu-sh4. With the patch,
it works as expected.

=====================================================================

#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;
}

=====================================================================

Any idea what else I should test to verify my changes? Otherwise, it
would be great if my patch could be applied to add sigaltstack for
sh4.

Thanks,

Adrian

> [1] https://wiki.debian.org/SH4/sbuildQEMU

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-19 12:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).