Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux Add support for Linux SA_RESTORER on amd64.



details:   https://anonhg.NetBSD.org/src/rev/60ec05559f47
branches:  trunk
changeset: 581001:60ec05559f47
user:      manu <manu%NetBSD.org@localhost>
date:      Thu May 19 21:16:29 2005 +0000

description:
Add support for Linux SA_RESTORER on amd64.

diffstat:

 sys/compat/linux/arch/alpha/linux_signal.h   |    5 +-
 sys/compat/linux/arch/amd64/linux_machdep.c  |   14 ++-
 sys/compat/linux/arch/amd64/linux_sigarray.c |  101 +++++++++++++++++++++++++++
 sys/compat/linux/arch/amd64/linux_signal.h   |    5 +-
 sys/compat/linux/arch/arm/linux_signal.h     |    5 +-
 sys/compat/linux/arch/powerpc/linux_signal.h |    5 +-
 sys/compat/linux/common/linux_signal.c       |   42 ++++++----
 sys/compat/linux/common/linux_signo.c        |    6 +-
 8 files changed, 152 insertions(+), 31 deletions(-)

diffs (truncated from 378 to 300 lines):

diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/alpha/linux_signal.h
--- a/sys/compat/linux/arch/alpha/linux_signal.h        Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/arch/alpha/linux_signal.h        Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_signal.h,v 1.4 2002/11/26 18:43:20 christos Exp $        */
+/*     $NetBSD: linux_signal.h,v 1.5 2005/05/19 21:16:29 manu Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -97,12 +97,13 @@
 #define LINUX_SA_RESETHAND     0x00000010
 #define LINUX_SA_NOCLDWAIT     0x00000020
 #define LINUX_SA_SIGINFO       0x00000040
+#define LINUX_SA_RESTORER      0x04000000
 
 #define LINUX_SA_NOMASK                LINUX_SA_NODEFER
 #define LINUX_SA_ONESHOT       LINUX_SA_RESETHAND
 #define LINUX_SA_INTERRUPT     0x20000000      /* Ignore this */
 
-#define LINUX_SA_ALLBITS       0x2000007f
+#define LINUX_SA_ALLBITS       0x2400007f
 
 #define LINUX_SIG_BLOCK                1
 #define LINUX_SIG_UNBLOCK      2
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/amd64/linux_machdep.c
--- a/sys/compat/linux/arch/amd64/linux_machdep.c       Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/arch/amd64/linux_machdep.c       Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_machdep.c,v 1.2 2005/05/15 21:43:08 fvdl Exp $ */
+/*     $NetBSD: linux_machdep.c,v 1.3 2005/05/19 21:16:29 manu Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.2 2005/05/15 21:43:08 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.3 2005/05/19 21:16:29 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -184,7 +184,10 @@
        sfp = (struct linux_rt_sigframe *)sp;
 
        bzero(&sigframe, sizeof(sigframe));
-       sigframe.pretcode = (char *)ps->sa_sigdesc[sig].sd_tramp;
+       if (ps->sa_sigdesc[sig].sd_vers != 0)
+               sigframe.pretcode = (char *)ps->sa_sigdesc[sig].sd_tramp;
+       else
+               sigframe.pretcode = NULL;
 
        /* 
         * The user context 
@@ -272,8 +275,11 @@
 
        /* 
         * Setup registers 
+        * XXX for an unknown reason, the stack is shifted of 24 bytes 
+        * when the signal handler is called. The +24 below is a dirty
+        * workaround, and the real problem should be fixed.
         */
-       buildcontext(l, catcher, sp);
+       buildcontext(l, catcher, sp + 24);
        tf->tf_rdi = sigframe.info.lsi_signo;
        tf->tf_rax = 0;
        tf->tf_rsi = (long)&sfp->info;
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/amd64/linux_sigarray.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux/arch/amd64/linux_sigarray.c      Thu May 19 21:16:29 2005 +0000
@@ -0,0 +1,101 @@
+/*     $NetBSD: linux_sigarray.c,v 1.1 2005/05/19 21:16:29 manu Exp $  */
+
+/*-
+ * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by Emmanuel Dreyfus
+ * 4. The name of the author may not be used to endorse or promote 
+ *    products derived from this software without specific prior written 
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS'' 
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+__KERNEL_RCSID(1, "$NetBSD: linux_sigarray.c,v 1.1 2005/05/19 21:16:29 manu Exp $");
+
+const int linux_to_native_signo[LINUX__NSIG] = {
+       0,              /* 0 */
+       SIGHUP,         /* 1 */
+       SIGINT,         /* 2 */
+       SIGQUIT,        /* 3 */
+       SIGILL,         /* 4 */
+       SIGTRAP,        /* 5 */
+       SIGABRT,        /* 6 */
+       SIGBUS,         /* 7 */
+       SIGFPE,         /* 8 */
+       SIGKILL,        /* 9 */
+       SIGUSR1,        /* 10 */
+       SIGSEGV,        /* 11 */
+       SIGUSR2,        /* 12 */
+       SIGPIPE,        /* 13 */
+       SIGALRM,        /* 14 */
+       SIGTERM,        /* 15 */
+       0,              /* 16 SIGSTKFLT */
+       SIGCHLD,        /* 17 */
+       SIGCONT,        /* 18 */
+       SIGSTOP,        /* 19 */
+       SIGTSTP,        /* 20 */
+       SIGTTIN,        /* 21 */
+       SIGTTOU,        /* 22 */
+       SIGURG,         /* 23 */
+       SIGXCPU,        /* 24 */
+       SIGXFSZ,        /* 25 */
+       SIGVTALRM,      /* 26 */
+       SIGPROF,        /* 27 */
+       SIGWINCH,       /* 28 */
+       SIGIO,          /* 29 */
+       SIGPWR,         /* 30 */
+       SIGSYS,         /* 31 */
+       SIGRTMIN + 0,   /* 32 */
+       SIGRTMIN + 1,   /* 33 */
+       SIGRTMIN + 2,   /* 34 */
+       SIGRTMIN + 3,   /* 35 */
+       SIGRTMIN + 4,   /* 36 */
+       SIGRTMIN + 5,   /* 37 */
+       SIGRTMIN + 6,   /* 38 */
+       SIGRTMIN + 7,   /* 39 */
+       SIGRTMIN + 8,   /* 40 */
+       SIGRTMIN + 9,   /* 41 */
+       SIGRTMIN + 10,  /* 42 */
+       SIGRTMIN + 11,  /* 43 */
+       SIGRTMIN + 12,  /* 44 */
+       SIGRTMIN + 13,  /* 45 */
+       SIGRTMIN + 14,  /* 46 */
+       SIGRTMIN + 15,  /* 47 */
+       SIGRTMIN + 16,  /* 48 */
+       SIGRTMIN + 17,  /* 49 */
+       SIGRTMIN + 18,  /* 50 */
+       SIGRTMIN + 19,  /* 51 */
+       SIGRTMIN + 20,  /* 52 */
+       SIGRTMIN + 21,  /* 53 */
+       SIGRTMIN + 22,  /* 54 */
+       SIGRTMIN + 23,  /* 55 */
+       SIGRTMIN + 24,  /* 56 */
+       SIGRTMIN + 25,  /* 57 */
+       SIGRTMIN + 26,  /* 58 */
+       SIGRTMIN + 27,  /* 59 */
+       SIGRTMIN + 28,  /* 60 */
+       SIGRTMIN + 29,  /* 61 */
+       SIGRTMIN + 30,  /* 62 */
+       0               /* 63 */
+};
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/amd64/linux_signal.h
--- a/sys/compat/linux/arch/amd64/linux_signal.h        Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/arch/amd64/linux_signal.h        Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_signal.h,v 1.1 2005/05/03 16:26:30 manu Exp $ */
+/*     $NetBSD: linux_signal.h,v 1.2 2005/05/19 21:16:29 manu Exp $ */
 
 /*-
  * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -76,11 +76,12 @@
 #define LINUX_SA_NOCLDSTOP     0x00000001
 #define LINUX_SA_NOCLDWAIT     0x00000002
 #define LINUX_SA_SIGINFO       0x00000004
+#define LINUX_SA_RESTORER      0x04000000
 #define LINUX_SA_ONSTACK       0x08000000
 #define LINUX_SA_RESTART       0x10000000
 #define LINUX_SA_NOMASK                0x40000000
 #define LINUX_SA_ONESHOT       0x80000000
-#define LINUX_SA_ALLBITS       0xd8000007
+#define LINUX_SA_ALLBITS       0xdc000007
 
 #define LINUX_SIG_BLOCK                0
 #define LINUX_SIG_UNBLOCK      1
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/arm/linux_signal.h
--- a/sys/compat/linux/arch/arm/linux_signal.h  Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/arch/arm/linux_signal.h  Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_signal.h,v 1.4 2002/11/26 18:43:21 christos Exp $        */
+/*     $NetBSD: linux_signal.h,v 1.5 2005/05/19 21:16:29 manu Exp $    */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -90,12 +90,13 @@
 #define LINUX_SA_NOCLDSTOP     0x00000001
 #define LINUX_SA_NOCLDWAIT     0x00000002
 #define LINUX_SA_SIGINFO       0x00000004
+#define LINUX_SA_RESTORER      0x04000000
 #define LINUX_SA_ONSTACK       0x08000000
 #define LINUX_SA_RESTART       0x10000000
 #define LINUX_SA_INTERRUPT     0x20000000
 #define LINUX_SA_NOMASK                0x40000000
 #define LINUX_SA_ONESHOT       0x80000000
-#define LINUX_SA_ALLBITS       0xf8000001
+#define LINUX_SA_ALLBITS       0xfc000007
 
 typedef void   (*linux_handler_t) __P((int));
 
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/arch/powerpc/linux_signal.h
--- a/sys/compat/linux/arch/powerpc/linux_signal.h      Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/arch/powerpc/linux_signal.h      Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_signal.h,v 1.6 2005/02/26 23:10:19 perry Exp $ */
+/* $NetBSD: linux_signal.h,v 1.7 2005/05/19 21:16:29 manu Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 2001 The NetBSD Foundation, Inc.
@@ -95,6 +95,7 @@
 #define LINUX_SA_NOCLDSTOP     0x00000001
 #define LINUX_SA_NOCLDWAIT     0x00000002
 #define LINUX_SA_SIGINFO       0x00000004
+#define LINUX_SA_RESTORER      0x04000000
 #define LINUX_SA_ONSTACK       0x08000000
 #define LINUX_SA_RESTART       0x10000000
 #define LINUX_SA_INTERRUPT     0x20000000
@@ -102,7 +103,7 @@
 #define LINUX_SA_RESETHAND     0x80000000
 #define LINUX_SA_NOMASK                LINUX_SA_NODEFER
 #define LINUX_SA_ONESHOT       LINUX_SA_RESETHAND
-#define LINUX_SA_ALLBITS       0xf8000001 /* XXX from i386, not in ppc. */
+#define LINUX_SA_ALLBITS       0xfc000007
 
 typedef void (*linux_handler_t) __P((int));
 
diff -r e033ebef6c87 -r 60ec05559f47 sys/compat/linux/common/linux_signal.c
--- a/sys/compat/linux/common/linux_signal.c    Thu May 19 20:16:19 2005 +0000
+++ b/sys/compat/linux/common/linux_signal.c    Thu May 19 21:16:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_signal.c,v 1.45 2005/05/16 16:00:31 fvdl Exp $   */
+/*     $NetBSD: linux_signal.c,v 1.46 2005/05/19 21:16:29 manu Exp $   */
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.45 2005/05/16 16:00:31 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.46 2005/05/19 21:16:29 manu Exp $");
 
 #define COMPAT_LINUX 1
 
@@ -219,8 +219,7 @@
 }
 
 /*
- * Convert between Linux and BSD sigaction structures. Linux sometimes
- * has one extra field (sa_restorer) which we don't support.
+ * Convert between Linux and BSD sigaction structures.
  */
 void
 linux_old_to_native_sigaction(bsa, lsa)
@@ -230,14 +229,6 @@
        bsa->sa_handler = lsa->linux_sa_handler;
        linux_old_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
        bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
-#ifndef __alpha__
-/*
- * XXX: On the alpha sa_restorer is elsewhere.
- */
-       if (lsa->linux_sa_restorer != NULL)
-               DPRINTF(("linux_old_to_native_sigaction: "
-                   "sa_restorer ignored\n"));
-#endif /* !__alpha__ */
 }
 
 void
@@ -262,10 +253,6 @@
        bsa->sa_handler = lsa->linux_sa_handler;
        linux_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
        bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
-#ifndef __alpha__
-       if (lsa->linux_sa_restorer != 0)
-               DPRINTF(("linux_to_native_sigaction: sa_restorer ignored\n"));
-#endif
 }
 
 void
@@ -304,6 +291,11 @@



Home | Main Index | Thread Index | Old Index