]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
alpha: Use Linux generic sigaction implementation
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 11 Dec 2018 18:57:49 +0000 (16:57 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 18 Dec 2018 21:52:21 +0000 (19:52 -0200)
Alpha rt_sigaction syscall uses a slight different kernel ABI than
generic one:

arch/alpha/kernel/signal.c

 90 SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
 91                 struct sigaction __user *, oact,
 92                 size_t, sigsetsize, void __user *, restorer)

Similar as sparc, the syscall expects a restorer function.  However
different than sparc, alpha defines the restorer as the 5th argument
(sparc defines as the 4th).

This patch removes the arch-specific alpha sigaction implementation,
adapt the Linux generic one to different restore placements (through
STUB macro), and make alpha use the Linux generic kernel_sigaction
definition.

Checked on alpha-linux-gnu and x86_64-linux-gnu (for sanity).

* sysdeps/unix/sysv/linux/alpha/Makefile: Update comment about
__syscall_rt_sigaction.
* sysdeps/unix/sysv/linux/alpha/kernel_sigaction.h
(kernel_sigaction): Use Linux generic defintion.
(STUB): Define.
(__syscall_rt_sigreturn, __syscall_sigreturn): Add prototype.
* sysdeps/unix/sysv/linux/alpha/rt_sigaction.S
(__syscall_rt_sigaction): Remove implementation.
(__syscall_sigreturn, __syscall_rt_sigreturn): Define as global and
hidden.
* sysdeps/unix/sysv/linux/alpha/sigaction.c: Remove file.
* sysdeps/unix/sysv/linux/alpha/sysdep.h (INLINE_SYSCALL,
INTERNAL_SYSCALL): Remove definitions.
* sysdeps/unix/sysv/linux/sigaction.c: Define STUB to accept both the
action and signal set size.
* sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c (STUB): Redefine.
* sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c (STUB): Likewise.

ChangeLog
sysdeps/unix/sysv/linux/alpha/Makefile
sysdeps/unix/sysv/linux/alpha/kernel_sigaction.h
sysdeps/unix/sysv/linux/alpha/rt_sigaction.S
sysdeps/unix/sysv/linux/alpha/sigaction.c [deleted file]
sysdeps/unix/sysv/linux/alpha/sysdep.h
sysdeps/unix/sysv/linux/sigaction.c
sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c

index 7891b7ad91a8953f10234a2859e6aab4306ffa11..f304e585968233949940336bb6d78933c9c1b96a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2018-12-18  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       * sysdeps/unix/sysv/linux/alpha/Makefile: Update comment about
+       __syscall_rt_sigaction.
+       * sysdeps/unix/sysv/linux/alpha/kernel_sigaction.h
+       (kernel_sigaction): Use Linux generic defintion.
+       (STUB): Define.
+       (__syscall_rt_sigreturn, __syscall_sigreturn): Add prototype.
+       * sysdeps/unix/sysv/linux/alpha/rt_sigaction.S
+       (__syscall_rt_sigaction): Remove implementation.
+       (__syscall_sigreturn, __syscall_rt_sigreturn): Define as global and
+       hidden.
+       * sysdeps/unix/sysv/linux/alpha/sigaction.c: Remove file.
+       * sysdeps/unix/sysv/linux/alpha/sysdep.h (INLINE_SYSCALL,
+       INTERNAL_SYSCALL): Remove definitions.
+       * sysdeps/unix/sysv/linux/sigaction.c: Define STUB to accept both the
+       action and signal set size.
+       * sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c (STUB): Redefine.
+       * sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c (STUB): Likewise.
+
 2018-12-18  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
            James Clarke  <jrtc27@jrtc27.com>
 
index 50f4fb1183ef5432875d18917cffbb9edaa1d053..fdd089af71f32b988d08262f1aee4228b1d183d4 100644 (file)
@@ -31,7 +31,7 @@ libm-routines += multc3 divtc3
 endif   # math
 
 ifeq ($(subdir),nptl)
-# pull in __syscall_error routine, __sigprocmask, __syscall_rt_sigaction
+# pull in __syscall_error routine, __sigprocmask, sigaction stubs.
 libpthread-routines += sysdep sigprocmask rt_sigaction
 libpthread-shared-only-routines += sysdep sigprocmask rt_sigaction
 endif
index 25180ff9c9f0f8c55b9bcf6d21cf222059a87aad..679179b563c4b50971121128a5289feefabbe62f 100644 (file)
@@ -1,12 +1,11 @@
-#ifndef _KERNEL_SIGACTION_H
-# define _KERNEL_SIGACTION_H
+#include <sysdeps/unix/sysv/linux/kernel_sigaction.h>
 
-/* This is the sigaction structure from the Linux 3.2 kernel.  */
-struct kernel_sigaction
-{
-  __sighandler_t k_sa_handler;
-  unsigned int sa_flags;
-  sigset_t sa_mask;
-};
+void __syscall_rt_sigreturn (void) attribute_hidden;
+void __syscall_sigreturn (void) attribute_hidden;
 
-#endif
+#define STUB(act, sigsetsize) \
+  (sigsetsize),                                                \
+  (act) ? ((unsigned long)((act->sa_flags & SA_SIGINFO)        \
+                           ? &__syscall_rt_sigreturn   \
+                           : &__syscall_sigreturn))    \
+       : 0
index ca25eee611d126e2699456ae0d629ee444a8a5ce..17e55239fe526b7af38f8c31644d1507f5e0eee5 100644 (file)
 
 #include <sysdep.h>
 
-/* On Alpha we desparately want to avoid having to issue an imb.  Ordinarily
-   the kernel would have to issue one after setting up the signal return
-   stack, but the Linux rt_sigaction syscall is prepared to accept a pointer
-   to the sigreturn syscall, instead of inlining it on the stack.
-
-   This just about halves signal delivery time.  */
-
-       .text
-
-ENTRY(__syscall_rt_sigaction)
-       cfi_startproc
-       ldgp    gp,0(pv)
-#ifdef PROF
-       .set noat
-       lda     AT, _mcount
-       jsr     AT, (AT), _mcount
-       .set at
-#endif
-       .prologue 1
-
-       beq     a1, 0f
-       ldl     t0, 8(a1)                               # sa_flags
-
-       ldah    a4, __syscall_sigreturn(gp)             !gprelhigh
-       ldah    t1, __syscall_rt_sigreturn(gp)          !gprelhigh
-       lda     a4, __syscall_sigreturn(a4)             !gprellow
-       lda     t1, __syscall_rt_sigreturn(t1)          !gprellow
-       and     t0, 0x40, t0                            # SA_SIGINFO
-       cmovne  t0, t1, a4
-
-0:     ldi     v0, __NR_rt_sigaction
-       callsys
-       bne     a3, SYSCALL_ERROR_LABEL
-       ret
-       cfi_endproc
-PSEUDO_END(__syscall_rt_sigaction)
-
 /* To enable unwinding through the signal frame without special hackery
    elsewhere, describe the entire struct sigcontext with unwind info.
 
@@ -104,6 +67,8 @@ __syscall_sigreturn:
        callsys
        .size   __syscall_sigreturn, .-__syscall_sigreturn
        .type   __syscall_sigreturn, @function
+       .global __syscall_sigreturn;
+       .hidden __syscall_sigreturn;
 
        /* See above wrt including the nop.  */
        cfi_def_cfa_offset (176 + 648)
@@ -116,5 +81,7 @@ __syscall_rt_sigreturn:
        callsys
        .size   __syscall_rt_sigreturn, .-__syscall_rt_sigreturn
        .type   __syscall_rt_sigreturn, @function
+       .global __syscall_rt_sigreturn;
+       .hidden __syscall_rt_sigreturn;
 
        cfi_endproc
diff --git a/sysdeps/unix/sysv/linux/alpha/sigaction.c b/sysdeps/unix/sysv/linux/alpha/sigaction.c
deleted file mode 100644 (file)
index 8051043..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <sys/cdefs.h>
-#include <stddef.h>
-
-/*
- * In order to get the hidden arguments for rt_sigaction set up
- * properly, we need to call the assembly version.  Detect this in the
- * INLINE_SYSCALL macro, and fail to expand inline in that case.
- */
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)       \
-        (__NR_##name == __NR_rt_sigaction       \
-         ? __syscall_rt_sigaction(args)         \
-         : INLINE_SYSCALL1(name, nr, args))
-
-struct kernel_sigaction;
-extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *,
-                                  struct kernel_sigaction *, size_t);
-
-#include <sysdeps/unix/sysv/linux/sigaction.c>
index 080405021f04a49e621595f6453e9718c83022df..9148b4793bffdbf5d04f74cb94e0d6e20de3bf22 100644 (file)
 
 #define SINGLE_THREAD_BY_GLOBAL 1
 
-/*
- * In order to get the hidden arguments for rt_sigaction set up
- * properly, we need to call the assembly version.  This shouldn't
- * happen except for inside sigaction.c, where we handle this
- * specially.  Catch other uses and error.
- */
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)                              \
-({                                                                     \
-       extern char ChEcK[__NR_##name == __NR_rt_sigaction ? -1 : 1]    \
-         __attribute__((unused));                                      \
-       INLINE_SYSCALL1(name, nr, args);                                \
-})
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err_out, nr, args...)                   \
-({                                                                     \
-       extern char ChEcK[__NR_##name == __NR_rt_sigaction ? -1 : 1]    \
-         __attribute__((unused));                                      \
-       INTERNAL_SYSCALL1(name, err_out, nr, args);                     \
-})
-
 #endif /* _LINUX_ALPHA_SYSDEP_H */
index 0e6851a148a3b931f3f733ce2c1fa304c1c66f7e..233ab1fcb5b869b1344a87eeb6d0cfa179148fdb 100644 (file)
@@ -33,7 +33,7 @@
 
 /* SPARC passes the restore function as an argument to rt_sigaction.  */
 #ifndef STUB
-# define STUB(act)
+# define STUB(act, sigsetsize) (sigsetsize)
 #endif
 
 /* If ACT is not NULL, change the action for SIG to *ACT.
@@ -57,7 +57,7 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
      real size of the user-level sigset_t.  */
   result = INLINE_SYSCALL_CALL (rt_sigaction, sig,
                                act ? &kact : NULL,
-                               oact ? &koact : NULL, STUB(act) _NSIG / 8);
+                               oact ? &koact : NULL, STUB (act, _NSIG / 8));
 
   if (oact && result >= 0)
     {
index 191f58729e4c3b539bb540e63332d357669f8c23..9f1a31a3b380862560f92875f779cf7cb20a48f2 100644 (file)
 static void __rt_sigreturn_stub (void);
 static void __sigreturn_stub (void);
 
-#define STUB(act) \
+#define STUB(act, sigsetsize) \
   (act) ? ((unsigned long)((act->sa_flags & SA_SIGINFO)        \
                            ? &__rt_sigreturn_stub      \
                            : &__sigreturn_stub) - 8)   \
-       : 0,
+       : 0,                                            \
+  (sigsetsize)
 
 #include <sysdeps/unix/sysv/linux/sigaction.c>
 
index cfbbc6e7b40f0aaeb769b0c187d7f7452a1020d9..acc76b1bf93753d4b0a686879f5ad80b2decee33 100644 (file)
@@ -24,8 +24,9 @@
 
 static void __rt_sigreturn_stub (void);
 
-#define STUB(act) \
-  (((unsigned long) &__rt_sigreturn_stub) - 8),
+#define STUB(act, sigsetsize) \
+  (((unsigned long) &__rt_sigreturn_stub) - 8),        \
+  (sigsetsize)
 
 #include <sysdeps/unix/sysv/linux/sigaction.c>