Skip to content

Commit

Permalink
microblaze: clean up signal handling
Browse files Browse the repository at this point in the history
When legacy signal handling is disabled, the
arch/microblaze/kernel/signal.c implementation can
be much simpler, as most of it is handled generically
from kernel/signal.c.

This is also a prerequisite for using the generic
asm/unistd.h, which does not provide __NR_sigreturn,
because this macro is referenced by the current signal.c
implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Michal Simek <monstr@monstr.eu>
  • Loading branch information
Arnd Bergmann authored and Michal Simek committed Jul 6, 2009
1 parent 0a58458 commit 3183e06
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 345 deletions.
166 changes: 1 addition & 165 deletions arch/microblaze/include/asm/signal.h
Original file line number Diff line number Diff line change
@@ -1,165 +1 @@
/*
* Copyright (C) 2006 Atmark Techno, Inc.
* Yasushi SHOJI <yashi@atmark-techno.com>
* Tetsuya OHKAWA <tetsuya@atmark-techno.com>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/

#ifndef _ASM_MICROBLAZE_SIGNAL_H
#define _ASM_MICROBLAZE_SIGNAL_H

#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
#define SIGABRT 6
#define SIGIOT 6
#define SIGBUS 7
#define SIGFPE 8
#define SIGKILL 9
#define SIGUSR1 10
#define SIGSEGV 11
#define SIGUSR2 12
#define SIGPIPE 13
#define SIGALRM 14
#define SIGTERM 15
#define SIGSTKFLT 16
#define SIGCHLD 17
#define SIGCONT 18
#define SIGSTOP 19
#define SIGTSTP 20
#define SIGTTIN 21
#define SIGTTOU 22
#define SIGURG 23
#define SIGXCPU 24
#define SIGXFSZ 25
#define SIGVTALRM 26
#define SIGPROF 27
#define SIGWINCH 28
#define SIGIO 29
#define SIGPOLL SIGIO
/*
#define SIGLOST 29
*/
#define SIGPWR 30
#define SIGSYS 31
#define SIGUNUSED 31

/* These should not be considered constants from userland. */
#define SIGRTMIN 32
#define SIGRTMAX _NSIG

/*
* SA_FLAGS values:
*
* SA_ONSTACK indicates that a registered stack_t will be used.
* SA_RESTART flag to get restarting signals (which were the default long ago)
* SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
* SA_RESETHAND clears the handler when the signal is delivered.
* SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
* SA_NODEFER prevents the current signal from being masked in the handler.
*
* SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
* Unix names RESETHAND and NODEFER respectively.
*/
#define SA_NOCLDSTOP 0x00000001
#define SA_NOCLDWAIT 0x00000002
#define SA_SIGINFO 0x00000004
#define SA_ONSTACK 0x08000000
#define SA_RESTART 0x10000000
#define SA_NODEFER 0x40000000
#define SA_RESETHAND 0x80000000

#define SA_NOMASK SA_NODEFER
#define SA_ONESHOT SA_RESETHAND

#define SA_RESTORER 0x04000000

/*
* sigaltstack controls
*/
#define SS_ONSTACK 1
#define SS_DISABLE 2

#define MINSIGSTKSZ 2048
#define SIGSTKSZ 8192

# ifndef __ASSEMBLY__
# include <linux/types.h>
# include <asm-generic/signal-defs.h>

/* Avoid too many header ordering problems. */
struct siginfo;

# ifdef __KERNEL__
/*
* Most things should be clean enough to redefine this at will, if care
* is taken to make libc match.
*/
# define _NSIG 64
# define _NSIG_BPW 32
# define _NSIG_WORDS (_NSIG / _NSIG_BPW)

typedef unsigned long old_sigset_t; /* at least 32 bits */

typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;

struct old_sigaction {
__sighandler_t sa_handler;
old_sigset_t sa_mask;
unsigned long sa_flags;
void (*sa_restorer)(void);
};

struct sigaction {
__sighandler_t sa_handler;
unsigned long sa_flags;
void (*sa_restorer)(void);
sigset_t sa_mask; /* mask last for extensibility */
};

struct k_sigaction {
struct sigaction sa;
};

# include <asm/sigcontext.h>
# undef __HAVE_ARCH_SIG_BITOPS

# define ptrace_signal_deliver(regs, cookie) do { } while (0)

# else /* !__KERNEL__ */

/* Here we must cater to libcs that poke about in kernel headers. */

# define NSIG 32
typedef unsigned long sigset_t;

struct sigaction {
union {
__sighandler_t _sa_handler;
void (*_sa_sigaction)(int, struct siginfo *, void *);
} _u;
sigset_t sa_mask;
unsigned long sa_flags;
void (*sa_restorer)(void);
};

# define sa_handler _u._sa_handler
# define sa_sigaction _u._sa_sigaction

# endif /* __KERNEL__ */

typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
} stack_t;

# endif /* __ASSEMBLY__ */
#endif /* _ASM_MICROBLAZE_SIGNAL_H */
#include <asm-generic/signal.h>
11 changes: 2 additions & 9 deletions arch/microblaze/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,16 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
unsigned long fd, off_t offset);

/* from signal.c */
asmlinkage int sys_sigsuspend(old_sigset_t mask, struct pt_regs *regs);

asmlinkage int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
struct pt_regs *regs);

asmlinkage int sys_sigaction(int sig, const struct old_sigaction *act,
struct old_sigaction *oact);

asmlinkage long sys_rt_sigaction(int sig, const struct sigaction __user *act,
struct sigaction __user *oact, size_t sigsetsize);

asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
struct pt_regs *regs);

asmlinkage int sys_sigreturn(struct pt_regs *regs);

asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
asmlinkage long sys_rt_sigreturn(struct pt_regs *regs);

#endif /* __KERNEL__ */
#endif /* __ASM_MICROBLAZE_SYSCALLS_H */
2 changes: 1 addition & 1 deletion arch/microblaze/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION
/* #define __ARCH_WANT_SYS_RT_SIGSUSPEND */
#define __ARCH_WANT_SYS_RT_SIGSUSPEND

/*
* "Conditional" syscalls
Expand Down
8 changes: 0 additions & 8 deletions arch/microblaze/kernel/entry-nommu.S
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,10 @@ sys_execve_wrapper:
brid sys_execve
addk r8, r1, r0

sys_sigreturn_wrapper:
brid sys_sigreturn
addk r5, r1, r0

sys_rt_sigreturn_wrapper:
brid sys_rt_sigreturn
addk r5, r1, r0

sys_sigsuspend_wrapper:
brid sys_rt_sigsuspend
addk r6, r1, r0

sys_rt_sigsuspend_wrapper:
brid sys_rt_sigsuspend
addk r7, r1, r0
Expand Down
23 changes: 0 additions & 23 deletions arch/microblaze/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,6 @@ C_ENTRY(sys_execve_wrapper):
brid sys_execve; /* Do real work (tail-call).*/
nop;

C_ENTRY(sys_sigsuspend_wrapper):
swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
swi r4, r1, PTO+PT_R4;
la r6, r1, PTO; /* add user context as 2nd arg */
bralid r15, sys_sigsuspend; /* Do real work.*/
nop;
lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
lwi r4, r1, PTO+PT_R4;
bri ret_from_trap /* fall through will not work here due to align */
nop;

C_ENTRY(sys_rt_sigsuspend_wrapper):
swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
swi r4, r1, PTO+PT_R4;
Expand All @@ -471,18 +460,6 @@ C_ENTRY(sys_rt_sigsuspend_wrapper):
bri ret_from_trap /* fall through will not work here due to align */
nop;


C_ENTRY(sys_sigreturn_wrapper):
swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
swi r4, r1, PTO+PT_R4;
la r5, r1, PTO; /* add user context as 1st arg */
brlid r15, sys_sigreturn; /* Do real work.*/
nop;
lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
lwi r4, r1, PTO+PT_R4;
bri ret_from_trap /* fall through will not work here due to align */
nop;

C_ENTRY(sys_rt_sigreturn_wrapper):
swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
swi r4, r1, PTO+PT_R4;
Expand Down
Loading

0 comments on commit 3183e06

Please sign in to comment.