Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 18 commits
  • 38 files changed
  • 0 comments
  • 2 contributors
Mar 03, 2013
Lars-Peter Clausen lm32: signal: Use restore_altstack()
do_sigaltstack() will be gone in the next upstream release, restore_altstack()
is it's replacement.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
1a70d26
Lars-Peter Clausen lm32: signal: Use flush_icache_range() instead of open-coding it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
75f7d00
Lars-Peter Clausen lm32: signal: Reset restart_block.fn in rt_sigreturn
This is required for proper operation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
ac2205b
Lars-Peter Clausen lm32: signals: Add proper __user annotation for setup_sigcontext()
The sigcontext struct we are working with here is on the userspace stack.

Fixes the following sparse warnings:
	arch/lm32/kernel/signal.c:114:31: warning: incorrect type in argument 1 (different address spaces)
	arch/lm32/kernel/signal.c:114:31:    expected void [noderef] <asn:1>*to
	arch/lm32/kernel/signal.c:114:31:    got struct pt_regs *<noident>
	arch/lm32/kernel/signal.c:115:16: warning: incorrect type in initializer (different address spaces)
	arch/lm32/kernel/signal.c:115:16:    expected unsigned long [noderef] <asn:1>*__pu_addr
	arch/lm32/kernel/signal.c:115:16:    got unsigned long *<noident>
	arch/lm32/kernel/signal.c:148:34: warning: incorrect type in argument 1 (different address spaces)
	arch/lm32/kernel/signal.c:148:34:    expected struct sigcontext *sc
	arch/lm32/kernel/signal.c:148:34:    got struct sigcontext [noderef] <asn:1>*<noident>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
41b08fb
consolidate declarations of k_sigaction
Only alpha and sparc are unusual - they have ka_restorer in it.
And nobody needs that exposed to userland.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
b687889
consolidate kernel-side struct sigaction declarations
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
ca15062
new helper: get_signal()
On success get_signal_to_deliver() fills k_sigaction and siginfo.
_All_ users pass it addresses of the local variables sitting in
the same function.  Then they proceed to pass those addresses
pretty much in tandem to a bunch of helper functions; again, all
callers of those helpers are passing them such a pair, and one that
had been through get_signal_to_deliver() at that.

The obvious cleanup: introduce a new type that would contain a
<k_sigaction,siginfo> pair (struct ksignal) and begin switching to
using it.  Turns out that it's convenient to store the signal number
in the same object.

New helper, taking that sucker is a wrapper for get_signal_to_deliver();
takes struct ksignal * and returns bool.  On success fills ksignal
with the information for signal handler to be invoked.

For now it's a macro (to avoid header ordering headache), but eventually
it'll be a function in kernel/signal.c, with get_signal_to_deliver()
folded into it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9894936
new helper: signal_setup_done()
usual "call force_sigsegv or signal_delivered" logics.  Takes
ksignal instead of separate siginfo/k_sigaction.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
b6df4b0
new helper: sigsp()
Normal logics for altstack handling in sigframe allocation

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
7a5070b
Lars-Peter Clausen lm32: signal: switch to ksignal
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
17412b4
Lars-Peter Clausen lm32: Rework signal handling
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
11b6d4c
Lars-Peter Clausen lm32: entry.S: Use PT_Rxx instead of magic numbers
Use the PT_Rxx defines instead of magic number for accessing the pt_regs fields.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
9df0d4b
Lars-Peter Clausen lm32: processor.h: More cleanups
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
abac1ab
Lars-Peter Clausen lm32: Remove gpio.h
It is unused these days. There is a generic implementation of it now.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
7b96718
Lars-Peter Clausen lm32: timex.h: Remove CLOCK_TICK_RATE
It's unused.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
0bfdb9b
Lars-Peter Clausen lm32: prom.h: Remove #ifdef CONFIG_OF
CONFIG_OF is always defined for lm32.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
ec06e14
Lars-Peter Clausen lm32: Remove r0 from pt_regs
We never use it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
a24553b
Lars-Peter Clausen lm32: process.c: Include linux/pm.h
Fixes the following sparse warning:
	arch/lm32/kernel/process.c:53:6: warning: symbol 'pm_power_off' was not declared. Should it be static?

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
4b72058

Showing 38 changed files with 317 additions and 447 deletions. Show diff stats Hide diff stats

  1. 11  arch/alpha/include/asm/signal.h
  2. 11  arch/arm/include/asm/signal.h
  3. 11  arch/avr32/include/asm/signal.h
  4. 10  arch/cris/include/asm/signal.h
  5. 11  arch/h8300/include/asm/signal.h
  6. 10  arch/ia64/include/asm/signal.h
  7. 1  arch/ia64/include/asm/unistd.h
  8. 16  arch/lm32/include/asm/gpio.h
  9. 13  arch/lm32/include/asm/processor.h
  10. 2  arch/lm32/include/asm/prom.h
  11. 2  arch/lm32/include/asm/ptrace.h
  12. 8  arch/lm32/include/asm/thread_info.h
  13. 8  arch/lm32/include/asm/timex.h
  14. 66  arch/lm32/kernel/asm-offsets.c
  15. 197  arch/lm32/kernel/entry.S
  16. 1  arch/lm32/kernel/process.c
  17. 205  arch/lm32/kernel/signal.c
  18. 11  arch/m32r/include/asm/signal.h
  19. 10  arch/m68k/include/asm/signal.h
  20. 2  arch/mips/include/asm/signal.h
  21. 6  arch/mips/include/uapi/asm/signal.h
  22. 10  arch/mn10300/include/asm/signal.h
  23. 6  arch/parisc/include/asm/signal.h
  24. 1  arch/powerpc/include/asm/signal.h
  25. 1  arch/powerpc/include/asm/syscalls.h
  26. 6  arch/powerpc/include/uapi/asm/signal.h
  27. 12  arch/s390/include/asm/signal.h
  28. 6  arch/sparc/include/asm/signal.h
  29. 2  arch/sparc/include/uapi/asm/signal.h
  30. 2  arch/sparc/kernel/systbls.h
  31. 15  arch/x86/include/asm/signal.h
  32. 8  arch/x86/include/uapi/asm/signal.h
  33. 11  arch/xtensa/include/asm/signal.h
  34. 11  include/linux/sched.h
  35. 40  include/linux/signal.h
  36. 2  include/linux/syscalls.h
  37. 10  include/uapi/asm-generic/signal.h
  38. 9  kernel/signal.c
11  arch/alpha/include/asm/signal.h
@@ -22,15 +22,6 @@ struct osf_sigaction {
22 22
 	int		sa_flags;
23 23
 };
24 24
 
25  
-struct sigaction {
26  
-	__sighandler_t	sa_handler;
27  
-	unsigned long	sa_flags;
28  
-	sigset_t	sa_mask;	/* mask last for extensibility */
29  
-};
30  
-
31  
-struct k_sigaction {
32  
-	struct sigaction sa;
33  
-	__sigrestore_t ka_restorer;
34  
-};
  25
+#define __ARCH_HAS_KA_RESTORER
35 26
 #include <asm/sigcontext.h>
36 27
 #endif
11  arch/arm/include/asm/signal.h
@@ -23,16 +23,7 @@ struct old_sigaction {
23 23
 	__sigrestore_t sa_restorer;
24 24
 };
25 25
 
26  
-struct sigaction {
27  
-	__sighandler_t sa_handler;
28  
-	unsigned long sa_flags;
29  
-	__sigrestore_t sa_restorer;
30  
-	sigset_t sa_mask;		/* mask last for extensibility */
31  
-};
32  
-
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
  26
+#define __ARCH_HAS_SA_RESTORER
36 27
 
37 28
 #include <asm/sigcontext.h>
38 29
 #endif
11  arch/avr32/include/asm/signal.h
@@ -23,16 +23,7 @@ typedef struct {
23 23
 	unsigned long sig[_NSIG_WORDS];
24 24
 } sigset_t;
25 25
 
26  
-struct sigaction {
27  
-	__sighandler_t sa_handler;
28  
-	unsigned long sa_flags;
29  
-	__sigrestore_t sa_restorer;
30  
-	sigset_t sa_mask;		/* mask last for extensibility */
31  
-};
32  
-
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
  26
+#define __ARCH_HAS_SA_RESTORER
36 27
 
37 28
 #include <asm/sigcontext.h>
38 29
 #undef __HAVE_ARCH_SIG_BITOPS
10  arch/cris/include/asm/signal.h
@@ -23,16 +23,8 @@ struct old_sigaction {
23 23
 	void (*sa_restorer)(void);
24 24
 };
25 25
 
26  
-struct sigaction {
27  
-	__sighandler_t sa_handler;
28  
-	unsigned long sa_flags;
29  
-	void (*sa_restorer)(void);
30  
-	sigset_t sa_mask;		/* mask last for extensibility */
31  
-};
  26
+#define __ARCH_HAS_SA_RESTORER
32 27
 
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
36 28
 #include <asm/sigcontext.h>
37 29
 
38 30
 #endif
11  arch/h8300/include/asm/signal.h
@@ -23,16 +23,7 @@ struct old_sigaction {
23 23
 	void (*sa_restorer)(void);
24 24
 };
25 25
 
26  
-struct sigaction {
27  
-	__sighandler_t sa_handler;
28  
-	unsigned long sa_flags;
29  
-	void (*sa_restorer)(void);
30  
-	sigset_t sa_mask;		/* mask last for extensibility */
31  
-};
32  
-
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
  26
+#define __ARCH_HAS_SA_RESTORER
36 27
 
37 28
 #include <asm/sigcontext.h>
38 29
 #undef __HAVE_ARCH_SIG_BITOPS
10  arch/ia64/include/asm/signal.h
@@ -26,16 +26,6 @@ typedef struct {
26 26
 	unsigned long sig[_NSIG_WORDS];
27 27
 } sigset_t;
28 28
 
29  
-struct sigaction {
30  
-	__sighandler_t sa_handler;
31  
-	unsigned long sa_flags;
32  
-	sigset_t sa_mask;		/* mask last for extensibility */
33  
-};
34  
-
35  
-struct k_sigaction {
36  
-	struct sigaction sa;
37  
-};
38  
-
39 29
 #  include <asm/sigcontext.h>
40 30
 
41 31
 # endif /* !__ASSEMBLY__ */
1  arch/ia64/include/asm/unistd.h
@@ -47,7 +47,6 @@ asmlinkage unsigned long sys_mmap2(
47 47
 				int prot, int flags,
48 48
 				int fd, long pgoff);
49 49
 struct pt_regs;
50  
-struct sigaction;
51 50
 asmlinkage long sys_ia64_pipe(void);
52 51
 asmlinkage long sys_rt_sigaction(int sig,
53 52
 				 const struct sigaction __user *act,
16  arch/lm32/include/asm/gpio.h
... ...
@@ -1,16 +0,0 @@
1  
-#ifndef __ASM_GPIO_H__
2  
-#define __ASM_GPIO_H__
3  
-
4  
-#include <linux/errno.h>
5  
-
6  
-#define gpio_get_value	__gpio_get_value
7  
-#define gpio_set_value	__gpio_set_value
8  
-#define gpio_cansleep	__gpio_cansleep
9  
-#define gpio_to_irq		__gpio_to_irq
10  
-
11  
-static inline int irq_to_gpio(unsigned irq) { return -EINVAL; }
12  
-
13  
-
14  
-#include <asm-generic/gpio.h>
15  
-
16  
-#endif
13  arch/lm32/include/asm/processor.h
@@ -42,6 +42,8 @@
42 42
 #include <asm/ptrace.h>
43 43
 #include <asm/current.h>
44 44
 
  45
+struct task_struct;
  46
+
45 47
 /*
46 48
  * User space process size: 3.75GB. This is hardcoded into a few places,
47 49
  * so don't change it unless you know what you are doing.
@@ -57,20 +59,17 @@
57 59
 struct thread_struct {};
58 60
 #define INIT_THREAD   {}
59 61
 
60  
-#define KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
61  
-#define task_pt_regs(tsk) ((struct pt_regs *)KSTK_TOS(tsk) - 1)
62  
-#define KSTK_EIP(tsk) 0
63  
-#define KSTK_ESP(tsk) 0
  62
+#define task_pt_regs(tsk) \
  63
+	((struct pt_regs *)(task_stack_page(tsk) + THREAD_SIZE) - 1)
64 64
 
  65
+#define KSTK_EIP(tsk) (task_pt_regs(tsk)->ea)
  66
+#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
65 67
 
66 68
 /*
67 69
  * Do necessary setup to start up a newly executed thread.
68 70
  */
69 71
 extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
70 72
 
71  
-/* Forward declaration, a strange C thing */
72  
-struct task_struct;
73  
-
74 73
 static inline void release_thread(struct task_struct *dead_task) { }
75 74
 static inline void exit_thread(void) { }
76 75
 
2  arch/lm32/include/asm/prom.h
@@ -9,9 +9,7 @@
9 9
 #ifndef __ASM_LM32_PROM_H
10 10
 #define __ASM_LM32_PROM_H
11 11
 
12  
-#ifdef CONFIG_OF
13 12
 void device_tree_init(void);
14  
-#endif /* CONFIG_OF */
15 13
 
16 14
 #endif /* __ASM_LM32_PROM_H */
17 15
 
2  arch/lm32/include/asm/ptrace.h
@@ -32,7 +32,6 @@
32 32
 typedef unsigned long lm32_reg_t;
33 33
 
34 34
 struct pt_regs {
35  
-	lm32_reg_t r0;
36 35
 	lm32_reg_t r1;
37 36
 	lm32_reg_t r2;
38 37
 	lm32_reg_t r3;
@@ -65,6 +64,7 @@ struct pt_regs {
65 64
 	lm32_reg_t ea;
66 65
 	lm32_reg_t ba;
67 66
 	unsigned int pt_mode;
  67
+	lm32_reg_t orig_r1;
68 68
 };
69 69
 
70 70
 #ifdef __KERNEL__
8  arch/lm32/include/asm/thread_info.h
@@ -109,23 +109,19 @@ static inline struct thread_info *current_thread_info(void)
109 109
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
110 110
 #define TIF_SIGPENDING		1	/* signal pending */
111 111
 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
112  
-#define TIF_POLLING_NRFLAG	3	/* true if poll_idle() is polling
113  
-					   TIF_NEED_RESCHED */
114 112
 #define TIF_MEMDIE		4
115 113
 #define TIF_RESTORE_SIGMASK	5	/* restore signal mask in do_signal() */
116 114
 #define TIF_NOTIFY_RESUME	6	/* callback before returning to user */
117  
-#define TIF_FREEZE		16	/* is freezing for suspend */
118 115
 
119 116
 /* as above, but as bit values */
120 117
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
121 118
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
122 119
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
123  
-#define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
124 120
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
125 121
 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
126  
-#define _TIF_FREEZE		(1<<TIF_FREEZE)
127 122
 
128  
-#define _TIF_WORK_MASK		0x0000FFFE	/* work to do on interrupt/exception return */
  123
+#define _TIF_WORK_MASK \
  124
+    (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED)
129 125
 
130 126
 #endif /* __KERNEL__ */
131 127
 
8  arch/lm32/include/asm/timex.h
@@ -24,14 +24,6 @@
24 24
 #ifndef _ASM_TIMEX_H
25 25
 #define _ASM_TIMEX_H
26 26
 
27  
-#ifdef __KERNEL__
28  
-
29  
-/* cannot use value supplied by bootloader because this value is used in an #if */
30  
-/* 100 MHz works as default value, even for 75 MHz bitstreams */
31  
-#define CLOCK_TICK_RATE		(100*1000*1000)
32  
-
33  
-#endif /* __KERNEL__ */
34  
-
35 27
 typedef unsigned long cycles_t;
36 28
 cycles_t get_cycles(void);
37 29
 
66  arch/lm32/kernel/asm-offsets.c
@@ -27,39 +27,41 @@ int main(void)
27 27
 	DEFINE(TASK_MM, offsetof(struct task_struct, mm));
28 28
 	DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
29 29
 
30  
-	DEFINE(PT_R0, offsetof(struct pt_regs, r0));
31  
-	DEFINE(PT_R1, offsetof(struct pt_regs, r1));
32  
-	DEFINE(PT_R2, offsetof(struct pt_regs, r2));
33  
-	DEFINE(PT_R3, offsetof(struct pt_regs, r3));
34  
-	DEFINE(PT_R4, offsetof(struct pt_regs, r4));
35  
-	DEFINE(PT_R5, offsetof(struct pt_regs, r5));
36  
-	DEFINE(PT_R6, offsetof(struct pt_regs, r6));
37  
-	DEFINE(PT_R7, offsetof(struct pt_regs, r7));
38  
-	DEFINE(PT_R8, offsetof(struct pt_regs, r8));
39  
-	DEFINE(PT_R9, offsetof(struct pt_regs, r9));
40  
-	DEFINE(PT_R10, offsetof(struct pt_regs, r10));
41  
-	DEFINE(PT_R11, offsetof(struct pt_regs, r11));
42  
-	DEFINE(PT_R12, offsetof(struct pt_regs, r12));
43  
-	DEFINE(PT_R13, offsetof(struct pt_regs, r13));
44  
-	DEFINE(PT_R14, offsetof(struct pt_regs, r14));
45  
-	DEFINE(PT_R15, offsetof(struct pt_regs, r15));
46  
-	DEFINE(PT_R16, offsetof(struct pt_regs, r16));
47  
-	DEFINE(PT_R17, offsetof(struct pt_regs, r17));
48  
-	DEFINE(PT_R18, offsetof(struct pt_regs, r18));
49  
-	DEFINE(PT_R19, offsetof(struct pt_regs, r19));
50  
-	DEFINE(PT_R20, offsetof(struct pt_regs, r20));
51  
-	DEFINE(PT_R21, offsetof(struct pt_regs, r21));
52  
-	DEFINE(PT_R22, offsetof(struct pt_regs, r22));
53  
-	DEFINE(PT_R23, offsetof(struct pt_regs, r23));
54  
-	DEFINE(PT_R24, offsetof(struct pt_regs, r24));
55  
-	DEFINE(PT_R25, offsetof(struct pt_regs, r25));
56  
-	DEFINE(PT_GP, offsetof(struct pt_regs, gp));
57  
-	DEFINE(PT_FP, offsetof(struct pt_regs, fp));
58  
-	DEFINE(PT_SP, offsetof(struct pt_regs, sp));
59  
-	DEFINE(PT_RA, offsetof(struct pt_regs, ra));
60  
-	DEFINE(PT_EA, offsetof(struct pt_regs, ea));
61  
-	DEFINE(PT_BA, offsetof(struct pt_regs, ba));
  30
+	/* These are used with sp as the base address, hence the 4 byte offset */
  31
+	DEFINE(PT_R1, offsetof(struct pt_regs, r1) + 4);
  32
+	DEFINE(PT_R2, offsetof(struct pt_regs, r2) + 4);
  33
+	DEFINE(PT_R3, offsetof(struct pt_regs, r3) + 4);
  34
+	DEFINE(PT_R4, offsetof(struct pt_regs, r4) + 4);
  35
+	DEFINE(PT_R5, offsetof(struct pt_regs, r5) + 4);
  36
+	DEFINE(PT_R6, offsetof(struct pt_regs, r6) + 4);
  37
+	DEFINE(PT_R7, offsetof(struct pt_regs, r7) + 4);
  38
+	DEFINE(PT_R8, offsetof(struct pt_regs, r8) + 4);
  39
+	DEFINE(PT_R9, offsetof(struct pt_regs, r9) + 4);
  40
+	DEFINE(PT_R10, offsetof(struct pt_regs, r10) + 4);
  41
+	DEFINE(PT_R11, offsetof(struct pt_regs, r11) + 4);
  42
+	DEFINE(PT_R12, offsetof(struct pt_regs, r12) + 4);
  43
+	DEFINE(PT_R13, offsetof(struct pt_regs, r13) + 4);
  44
+	DEFINE(PT_R14, offsetof(struct pt_regs, r14) + 4);
  45
+	DEFINE(PT_R15, offsetof(struct pt_regs, r15) + 4);
  46
+	DEFINE(PT_R16, offsetof(struct pt_regs, r16) + 4);
  47
+	DEFINE(PT_R17, offsetof(struct pt_regs, r17) + 4);
  48
+	DEFINE(PT_R18, offsetof(struct pt_regs, r18) + 4);
  49
+	DEFINE(PT_R19, offsetof(struct pt_regs, r19) + 4);
  50
+	DEFINE(PT_R20, offsetof(struct pt_regs, r20) + 4);
  51
+	DEFINE(PT_R21, offsetof(struct pt_regs, r21) + 4);
  52
+	DEFINE(PT_R22, offsetof(struct pt_regs, r22) + 4);
  53
+	DEFINE(PT_R23, offsetof(struct pt_regs, r23) + 4);
  54
+	DEFINE(PT_R24, offsetof(struct pt_regs, r24) + 4);
  55
+	DEFINE(PT_R25, offsetof(struct pt_regs, r25) + 4);
  56
+	DEFINE(PT_GP, offsetof(struct pt_regs, gp) + 4);
  57
+	DEFINE(PT_FP, offsetof(struct pt_regs, fp) + 4);
  58
+	DEFINE(PT_SP, offsetof(struct pt_regs, sp) + 4);
  59
+	DEFINE(PT_RA, offsetof(struct pt_regs, ra) + 4);
  60
+	DEFINE(PT_EA, offsetof(struct pt_regs, ea) + 4);
  61
+	DEFINE(PT_BA, offsetof(struct pt_regs, ba) + 4);
62 62
 	DEFINE(PT_MODE, offsetof(struct pt_regs, pt_mode));
  63
+	DEFINE(PT_ORIG_R1, offsetof(struct pt_regs, orig_r1));
  64
+	DEFINE(PT_SIZE, sizeof(struct pt_regs));
63 65
 
64 66
 	DEFINE(TI_TASK, offsetof(struct thread_info, task));
65 67
 	DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
197  arch/lm32/kernel/entry.S
@@ -15,8 +15,8 @@
15 15
 
16 16
 /* exception vector for os-aware gdb and kernel signals */
17 17
 #define KERNEL_EXCEPTION_VECTOR(offset) \
18  
-	addi	sp,sp,-132; \
19  
-	sw		(sp+120), ra; \
  18
+	addi	sp,sp,-PT_SIZE; \
  19
+	sw		(sp+PT_RA), ra; \
20 20
 	calli	_save_syscall_frame; \
21 21
 	mvi		r1, offset; \
22 22
 	addi	r2, sp, 4; \
@@ -62,6 +62,11 @@ ENTRY(interrupt_handler)
62 62
 	nop
63 63
 	nop
64 64
 
  65
+.macro current_thread_info reg
  66
+	xnori \reg, r0, (THREAD_SIZE - 1)
  67
+	and \reg, sp, \reg
  68
+.endm
  69
+
65 70
 .macro switch_to_kernel_mode
66 71
 	/*
67 72
 	 * Store away r9,r10,r11 so that we can use it here. The tricky part is that we
@@ -90,15 +95,15 @@ ENTRY(interrupt_handler)
90 95
 	bne r10, r0, 1f
91 96
 
92 97
 	lw sp, (r9+STATE_CURRENT_THREAD)
93  
-	addi sp, sp, THREAD_SIZE - 36
  98
+	addi sp, sp, THREAD_SIZE - 4
94 99
 1:/* already on kernel stack */
95 100
 
96  
-	addi sp, sp, -132
  101
+	addi sp, sp, -PT_SIZE
97 102
 
98 103
 	/* save pt_mode, stack pointer and ra in current stack frame */
99  
-	sw (sp+132), r10
100  
-	sw (sp+116), r11
101  
-	sw (sp+120), ra
  104
+	sw (sp+PT_MODE), r10
  105
+	sw (sp+PT_SP), r11
  106
+	sw (sp+PT_RA), ra
102 107
 
103 108
 	mvi r10, PT_MODE_KERNEL
104 109
 	sw (r9+STATE_KERNEL_MODE), r10
@@ -109,10 +114,33 @@ ENTRY(interrupt_handler)
109 114
 .endm
110 115
 
111 116
 .macro switch_to_user_mode
112  
-	rcsr r2, IE
113  
-	andi r3, r2, 0xfffe
114  
-	wcsr IE, r3
115  
-	lw r2, (sp+132)
  117
+	rcsr r5, IE
  118
+	andi r6, r5, 0xfffe
  119
+	wcsr IE, r6
  120
+
  121
+	lw r5, (sp+PT_MODE)
  122
+	bne r5, r0, 3f
  123
+1:
  124
+	current_thread_info r3
  125
+	lw r3, (r3+TI_FLAGS)
  126
+
  127
+	andi r4, r3, _TIF_WORK_MASK
  128
+	be r4, r0, 3f
  129
+
  130
+	andi r4, r3, _TIF_NEED_RESCHED
  131
+	be r4, r0, 2f
  132
+	calli schedule
  133
+	bi 1b
  134
+2:
  135
+	addi r1, sp, 4
  136
+	calli do_notify_resume
  137
+	bi 1b
  138
+3:
  139
+	rcsr r5, IE
  140
+	andi r6, r5, 0xfffe
  141
+	wcsr IE, r6
  142
+
  143
+	lw r2, (sp+PT_MODE)
116 144
 	mvhi r1, hi(lm32_state)
117 145
 	ori r1, r1, lo(lm32_state)
118 146
 	sw (r1+STATE_KERNEL_MODE), r2
@@ -139,18 +167,13 @@ ENTRY(system_call)
139 167
 	call r9 /* execute syscall */
140 168
 
141 169
 ENTRY(syscall_tail)
142  
-	/* store pt_regs* in r2 */
143  
-	addi      r2,  sp, 4
144  
-	calli manage_signals
145  
-	sw (sp+8), r1 /* store return value into pt_regs */
146  
-
  170
+	sw (sp+PT_R1), r1 /* store return value into pt_regs */
  171
+	mvi r2, 1 /* In syscall */
147 172
 	bi      _restore_and_return_exception
148 173
 
149 174
 .badsyscall:
150 175
 	mvi r1, -ENOSYS
151  
-	sw (sp+8), r1 /* store return value into pt_regs */
152  
-
153  
-	bi      _restore_and_return_exception
  176
+	bi syscall_tail
154 177
 
155 178
 /**************************/
156 179
 /* exception return paths */
@@ -162,9 +185,9 @@ label: \
162 185
 	/* store pt_regs* in r2 */ \
163 186
 	addi      r2,  sp, 4; \
164 187
 	/* store 0 into r8 (syscall no) in pt_regs */ \
165  
-	sw (sp+36), r0; \
166  
-	calli manage_signals; \
167  
-	sw (sp+8), r1; /* store return value into pt_regs */ \
  188
+	sw (sp+PT_R8), r0; \
  189
+	sw (sp+PT_R1), r1; /* store return value into pt_regs */ \
  190
+	mvi r2, 0; /* Not in syscall */ \
168 191
 	bi branch_to
169 192
 
170 193
 EXCEPTION_RETURN_PATH(_return_from_exception, _restore_and_return_exception)
@@ -188,35 +211,35 @@ ENTRY(ret_from_kernel_thread)
188 211
 	b r11
189 212
 
190 213
 .macro save_irq_frame
191  
-	sw      (sp+8),   r1
192  
-	sw      (sp+12),  r2
193  
-	sw      (sp+16),  r3
194  
-	sw      (sp+20),  r4
195  
-	sw      (sp+24),  r5
196  
-	sw      (sp+28),  r6
197  
-	sw      (sp+32),  r7
198  
-	sw      (sp+36),  r8
199  
-	sw      (sp+40),  r9
200  
-	sw      (sp+44),  r10
201  
-	/* ra (sp + 120) has already been written */
202  
-	sw      (sp+124), ea
  214
+	sw      (sp+PT_R1),  r1
  215
+	sw      (sp+PT_R2),  r2
  216
+	sw      (sp+PT_R3),  r3
  217
+	sw      (sp+PT_R4),  r4
  218
+	sw      (sp+PT_R5),  r5
  219
+	sw      (sp+PT_R6),  r6
  220
+	sw      (sp+PT_R7),  r7
  221
+	sw      (sp+PT_R8),  r8
  222
+	sw      (sp+PT_R9),  r9
  223
+	sw      (sp+PT_R10), r10
  224
+	/* ra (sp + PT_RA) has already been written */
  225
+	sw      (sp+PT_EA),  ea
203 226
 .endm
204 227
 
205 228
 /* restore all caller saved registers saved in save_irq_frame */
206 229
 .macro restore_irq_frame
207  
-	lw      r1,  (sp+8);
208  
-	lw      r2,  (sp+12);
209  
-	lw      r3,  (sp+16);
210  
-	lw      r4,  (sp+20);
211  
-	lw      r5,  (sp+24);
212  
-	lw      r6,  (sp+28);
213  
-	lw      r7,  (sp+32);
214  
-	lw      r8,  (sp+36);
215  
-	lw      r9,  (sp+40);
216  
-	lw      r10, (sp+44);
217  
-	lw      ra,  (sp+120)
218  
-	lw      ea,  (sp+124)
219  
-	lw      sp,  (sp+116)
  230
+	lw      r1,  (sp+PT_R1);
  231
+	lw      r2,  (sp+PT_R2);
  232
+	lw      r3,  (sp+PT_R3);
  233
+	lw      r4,  (sp+PT_R4);
  234
+	lw      r5,  (sp+PT_R5);
  235
+	lw      r6,  (sp+PT_R6);
  236
+	lw      r7,  (sp+PT_R7);
  237
+	lw      r8,  (sp+PT_R8);
  238
+	lw      r9,  (sp+PT_R9);
  239
+	lw      r10, (sp+PT_R10);
  240
+	lw      ra,  (sp+PT_RA)
  241
+	lw      ea,  (sp+PT_EA)
  242
+	lw      sp,  (sp+PT_SP)
220 243
 .endm
221 244
 
222 245
 /* in IRQ we call a function between save and restore */
@@ -265,34 +288,34 @@ _long_interrupt_handler:
265 288
 
266 289
 	addi    r2, sp, 4
267 290
 	calli   asm_do_IRQ
268  
-	addi    r1, sp, 4
269  
-	calli   manage_signals_irq
270 291
 6:
  292
+	mvi r2, 0 /* Not in syscall */
271 293
 	switch_to_user_mode
272 294
 	restore_irq_frame
273 295
 	eret
274 296
 
275 297
 _save_syscall_frame:
276 298
 	save_irq_frame
277  
-	sw      (sp+48),  r11
278  
-	sw      (sp+52),  r12
279  
-	sw      (sp+56),  r13
280  
-	sw      (sp+60),  r14
281  
-	sw      (sp+64),  r15
282  
-	sw      (sp+68),  r16
283  
-	sw      (sp+72),  r17
284  
-	sw      (sp+76),  r18
285  
-	sw      (sp+80),  r19
286  
-	sw      (sp+84),  r20
287  
-	sw      (sp+88),  r21
288  
-	sw      (sp+92),  r22
289  
-	sw      (sp+96),  r23
290  
-	sw      (sp+100), r24
291  
-	sw      (sp+104), r25
292  
-	sw      (sp+108), r26
293  
-	sw      (sp+112), r27
294  
-	/* ra (sp + 120) has already been written */
295  
-	sw      (sp+128), ba
  299
+	sw      (sp+PT_R11), r11
  300
+	sw      (sp+PT_R12), r12
  301
+	sw      (sp+PT_R13), r13
  302
+	sw      (sp+PT_R14), r14
  303
+	sw      (sp+PT_R15), r15
  304
+	sw      (sp+PT_R16), r16
  305
+	sw      (sp+PT_R17), r17
  306
+	sw      (sp+PT_R18), r18
  307
+	sw      (sp+PT_R19), r19
  308
+	sw      (sp+PT_R20), r20
  309
+	sw      (sp+PT_R21), r21
  310
+	sw      (sp+PT_R22), r22
  311
+	sw      (sp+PT_R23), r23
  312
+	sw      (sp+PT_R24), r24
  313
+	sw      (sp+PT_R25), r25
  314
+	sw      (sp+PT_GP), r26
  315
+	sw      (sp+PT_FP), r27
  316
+	/* ra (sp + PT_RA) has already been written */
  317
+	sw      (sp+PT_BA), ba
  318
+	sw      (sp+PT_ORIG_R1),  r1
296 319
 
297 320
 	ret
298 321
 
@@ -310,25 +333,25 @@ label: \
310 333
 	switch_to_user_mode; \
311 334
 	/* restore frame from original kernel stack */ \
312 335
 	/* restore r1 as the return value is stored onto the stack */ \
313  
-	lw      r11, (sp+48); \
314  
-	lw      r12, (sp+52); \
315  
-	lw      r13, (sp+56); \
316  
-	lw      r14, (sp+60); \
317  
-	lw      r15, (sp+64); \
318  
-	lw      r16, (sp+68); \
319  
-	lw      r17, (sp+72); \
320  
-	lw      r18, (sp+76); \
321  
-	lw      r19, (sp+80); \
322  
-	lw      r20, (sp+84); \
323  
-	lw      r21, (sp+88); \
324  
-	lw      r22, (sp+92); \
325  
-	lw      r23, (sp+96); \
326  
-	lw      r24, (sp+100); \
327  
-	lw      r25, (sp+104); \
328  
-	lw      r26, (sp+108); \
329  
-	lw      r27, (sp+112); \
330  
-	lw      ra,  (sp+120); \
331  
-	lw      ba,  (sp+128); \
  336
+	lw      r11, (sp+PT_R11); \
  337
+	lw      r12, (sp+PT_R12); \
  338
+	lw      r13, (sp+PT_R13); \
  339
+	lw      r14, (sp+PT_R14); \
  340
+	lw      r15, (sp+PT_R15); \
  341
+	lw      r16, (sp+PT_R16); \
  342
+	lw      r17, (sp+PT_R17); \
  343
+	lw      r18, (sp+PT_R18); \
  344
+	lw      r19, (sp+PT_R19); \
  345
+	lw      r20, (sp+PT_R20); \
  346
+	lw      r21, (sp+PT_R21); \
  347
+	lw      r22, (sp+PT_R22); \
  348
+	lw      r23, (sp+PT_R23); \
  349
+	lw      r24, (sp+PT_R24); \
  350
+	lw      r25, (sp+PT_R25); \
  351
+	lw      r26, (sp+PT_GP); \
  352
+	lw      r27, (sp+PT_FP); \
  353
+	lw      ra,  (sp+PT_RA); \
  354
+	lw      ba,  (sp+PT_BA); \
332 355
 	restore_irq_frame; \
333 356
 	/* scall stores pc into ea/ba register, not pc+4, so we have to add 4 */ \
334 357
 	addi	addr_register, addr_register, 4; \
1  arch/lm32/kernel/process.c
@@ -40,6 +40,7 @@
40 40
 #include <linux/reboot.h>
41 41
 #include <linux/fs.h>
42 42
 #include <linux/io.h>
  43
+#include <linux/pm.h>
43 44
 
44 45
 #include <asm/uaccess.h>
45 46
 #include <asm/traps.h>
205  arch/lm32/kernel/signal.c
@@ -49,7 +49,7 @@
49 49
 #include <linux/personality.h>
50 50
 #include <linux/tty.h>
51 51
 #include <linux/hardirq.h>
52  
-#include <linux/freezer.h>
  52
+#include <linux/tracehook.h>
53 53
 
54 54
 #include <asm/uaccess.h>
55 55
 #include <asm/ucontext.h>
@@ -60,8 +60,6 @@
60 60
 
61 61
 #define DEBUG_SIG 0
62 62
 
63  
-asmlinkage int manage_signals(int retval, struct pt_regs* regs);
64  
-
65 63
 struct rt_sigframe {
66 64
 	struct siginfo info;
67 65
 	struct ucontext uc;
@@ -79,7 +77,8 @@ asmlinkage int sys_rt_sigreturn(void)
79 77
 	struct pt_regs *regs = current_pt_regs();
80 78
 	struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(regs->sp + 4);
81 79
 	sigset_t set;
82  
-	stack_t st;
  80
+
  81
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
83 82
 
84 83
 	if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
85 84
 		goto badframe;
@@ -92,9 +91,8 @@ asmlinkage int sys_rt_sigreturn(void)
92 91
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
93 92
 		goto badframe;
94 93
 
95  
-	if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
  94
+	if (restore_altstack(&frame->uc.uc_stack))
96 95
 		goto badframe;
97  
-	do_sigaltstack(&st, NULL, regs->sp);
98 96
 
99 97
 	return regs->r1;
100 98
 
@@ -106,7 +104,7 @@ asmlinkage int sys_rt_sigreturn(void)
106 104
 /*
107 105
  * Set up a signal frame.
108 106
  */
109  
-static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
  107
+static int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
110 108
 		 unsigned long mask)
111 109
 {
112 110
 	int err;
@@ -120,28 +118,23 @@ static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
120 118
 /*
121 119
  * Determine which stack to use..
122 120
  */
123  
-static inline void __user *get_sigframe(struct k_sigaction *ka,
  121
+static inline void __user *get_sigframe(struct ksignal *ksig,
124 122
 		struct pt_regs *regs, size_t frame_size)
125 123
 {
126  
-	unsigned long sp = regs->sp;
127  
-
128  
-	if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
129  
-		/* use stack set by sigaltstack */
130  
-		sp = current->sas_ss_sp + current->sas_ss_size;
  124
+	unsigned long sp = sigsp(regs->sp, ksig);
131 125
 
132 126
 	return (void __user *)((sp - frame_size) & ~7UL);
133 127
 }
134 128
 
135  
-static int setup_rt_frame(int sig, struct k_sigaction *ka,
136  
-			sigset_t *set, struct pt_regs *regs)
  129
+static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
137 130
 {
138 131
 	struct rt_sigframe __user *frame;
139 132
 	int err = 0;
140 133
 
141  
-	frame = get_sigframe(ka, regs, sizeof(*frame));
  134
+	frame = get_sigframe(ksig, regs, sizeof(*frame));
142 135
 
143 136
 	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
144  
-		goto give_sigsegv;
  137
+		return 1;
145 138
 
146 139
 	err |= __clear_user(&frame->uc, sizeof(frame->uc));
147 140
 	err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
@@ -157,29 +150,20 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka,
157 150
 	err |= __put_user(0xac000007, &frame->tramp[1]);
158 151
 
159 152
 	if (err)
160  
-		goto give_sigsegv;
161  
-
162  
-	/* flush instruction cache */
163  
-	asm volatile("nop");
164  
-	asm volatile("nop");
165  
-	asm volatile("nop");
166  
-	asm volatile("nop");
167  
-	asm volatile("wcsr ICC, r0");
168  
-	asm volatile("nop");
169  
-	asm volatile("nop");
170  
-	asm volatile("nop");
171  
-	asm volatile("nop");
  153
+		return err;
  154
+
  155
+	flush_icache_range(&frame->tramp, &frame->tramp + 2);
172 156
 
173 157
 	/* set return address for signal handler to trampoline */
174 158
 	regs->ra = (unsigned long)(&frame->tramp[0]);
175 159
 
176 160
 	/* Set up registers for returning to signal handler */
177 161
 	/* entry point */
178  
-	regs->ea = (unsigned long)ka->sa.sa_handler - 4;
  162
+	regs->ea = (unsigned long)ksig->ka.sa.sa_handler - 4;
179 163
 	/* stack pointer */
180 164
 	regs->sp = (unsigned long)frame - 4;
181 165
 	/* Signal handler arguments */
182  
-	regs->r1 = sig;     /* first argument = signum */
  166
+	regs->r1 = ksig->sig;     /* first argument = signum */
183 167
 	regs->r2 = (unsigned long)&frame->info;
184 168
 	regs->r3 = (unsigned long)&frame->uc;
185 169
 
@@ -188,21 +172,16 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka,
188 172
 	       current->comm, current->pid, frame, regs->sp, regs->ra, regs->ea, sig);
189 173
 #endif
190 174
 
191  
-	return regs->r1;
192  
-
193  
-give_sigsegv:
194  
-	force_sigsegv(sig, current);
195  
-
196  
-	return -1;
  175
+	return 0;
197 176
 }
198 177
 
199  
-static void handle_signal(unsigned long sig, siginfo_t *info,
200  
-		struct k_sigaction *ka, struct pt_regs *regs)
  178
+static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
201 179
 {
202 180
 	sigset_t *oldset = sigmask_to_save();
  181
+	int ret;
203 182
 
204  
-	setup_rt_frame(sig, ka, oldset, regs);
205  
-	signal_delivered(sig, info, ka, regs, 0);
  183
+	ret = setup_rt_frame(ksig, oldset, regs);
  184
+	signal_setup_done(ret, ksig, 0);
206 185
 }
207 186
 
208 187
 /*
@@ -214,114 +193,64 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
214 193
  * the kernel can handle, and then we build all the user-level signal handling
215 194
  * stack-frames in one go after that.
216 195
  */
217  
-static int do_signal(int retval, struct pt_regs *regs)
  196
+static void do_signal(struct pt_regs *regs, unsigned int in_syscall)
218 197
 {
219  
-	siginfo_t info;
220  
-	int signr;
221  
-	struct k_sigaction ka;
222  
-
223  
-	/*
224  
-	 * We want the common case to go fast, which
225  
-	 * is why we may in certain cases get here from
226  
-	 * kernel mode. Just return without doing anything
227  
-	 * if so.
228  
-	 */
229  
-	if (!user_mode(regs))
230  
-		return 0;
231  
-
232  
-	if (try_to_freeze())
233  
-		goto no_signal;
234  
-
235  
-	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
236  
-
237  
-	if (signr > 0) {
238  
-		/* Whee!  Actually deliver the signal.  */
239  
-		handle_signal(signr, &info, &ka, regs);
240  
-		return signr;
241  
-	}
  198
+	struct ksignal ksig;
242 199
 
243  
-no_signal:
244 200
 	/* Did we come from a system call? */
245  
-	if (regs->r8) {
246  
-		switch (retval) {
247  
-		case -ERESTART_RESTARTBLOCK:
248  
-			regs->r8 = __NR_restart_syscall;
249  
-		case -ERESTARTNOHAND:
250  
-		case -ERESTARTSYS:
251  
-		case -ERESTARTNOINTR:
252  
-			regs->ea -= 4; /* Size of scall insn.  */
253  
-			break;
254  
-		default:
255  
-			break;
256  
-		}
257  
-	}
258  
-	restore_saved_sigmask();
259  
-
260  
-	return retval;
261  
-}
262  
-
263  
-asmlinkage int manage_signals(int retval, struct pt_regs *regs)
264  
-{
265  
-	unsigned long flags;
266 201
 
267  
-	if (!user_mode(regs))
268  
-		return retval;
269  
-
270  
-	/* disable interrupts for sampling current_thread_info()->flags */
271  
-	local_irq_save(flags);
272  
-	while (current_thread_info()->flags & (_TIF_NEED_RESCHED | _TIF_SIGPENDING)) {
273  
-		if (current_thread_info()->flags & _TIF_NEED_RESCHED) {
274  
-			/* schedule -> enables interrupts */
275  
-			schedule();
276  
-
277  
-			/* disable interrupts for sampling current_thread_info()->flags */
278  
-			local_irq_disable();
279  
-		}
280  
-
281  
-		if (current_thread_info()->flags & _TIF_SIGPENDING) {
282  
-#if DEBUG_SIG
283  
-			/* debugging code */
284  
-			{
285  
-				register unsigned long sp asm("sp");
286  
-				printk("WILL process signal for %s with regs=%lx, ea=%lx, ba=%lx ra=%lx\n",
287  
-						current->comm, regs, regs->ea, regs->ba, *((unsigned long*)(sp+4)));
  202
+	if (get_signal(&ksig)) {
  203
+		if (in_syscall) {
  204
+			switch (regs->r1) {
  205
+			case -ERESTART_RESTARTBLOCK:
  206
+			case -ERESTARTNOHAND:
  207
+				regs->r1 = -EINTR;
  208
+				break;
  209
+			case -ERESTARTSYS:
  210
+				if (!(ksig.ka.sa.sa_flags & SA_RESTART)) {
  211
+					regs->r1 = -EINTR;
  212
+					break;
  213
+				}
  214
+				/* fallthrough */
  215
+			case -ERESTARTNOINTR:
  216
+				regs->ea -= 4; /* Size of scall insn.  */
  217
+				regs->r1 = regs->orig_r1;
  218
+				break;
  219
+			default:
  220
+				break;
288 221
 			}
289  
-#endif
290  
-			retval = do_signal(retval, regs);
291  
-
292  
-			/* signal handling enables interrupts */
293  
-
294  
-			/* disable irqs for sampling current_thread_info()->flags */
295  
-			local_irq_disable();
296  
-#if DEBUG_SIG
297  
-			/* debugging code */
298  
-			{
299  
-				register unsigned long sp asm("sp");
300  
-				printk("Processed Signal for %s with regs=%lx, ea=%lx, ba=%lx ra=%lx\n",
301  
-						current->comm, regs, regs->ea, regs->ba, *((unsigned long*)(sp+4)));
  222
+		}
  223
+		handle_signal(&ksig, regs);
  224
+	} else {
  225
+		/* If there is no handler always restart */
  226
+		if (in_syscall) {
  227
+			switch (regs->r1) {
  228
+			case -ERESTART_RESTARTBLOCK:
  229
+				regs->r8 = __NR_restart_syscall;
  230
+				/* fallthrough */
  231
+			case -ERESTARTNOHAND:
  232
+			case -ERESTARTSYS:
  233
+			case -ERESTARTNOINTR:
  234
+				regs->ea -= 4; /* Size of scall insn.  */
  235
+				regs->r1 = regs->orig_r1;
  236
+				break;
  237
+			default:
  238
+				break;
302 239
 			}
303  
-#endif
304 240
 		}
  241
+		restore_saved_sigmask();
305 242
 	}
306  
-	local_irq_restore(flags);
307  
-
308  
-	return retval;
309 243
 }
310 244
 
311  
-asmlinkage void manage_signals_irq(struct pt_regs *regs)
  245
+asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int in_syscall,
  246
+	unsigned int thread_flags)
312 247
 {
313  
-	unsigned long flags;
  248
+	local_irq_enable();
314 249
 
315  
-	if (!user_mode(regs))
316  
-		return;
317  
-
318  
-	/* disable interrupts for sampling current_thread_info()->flags */
319  
-	local_irq_save(flags);
320  
-
321  
-	if( current_thread_info()->flags & _TIF_NEED_RESCHED ) {
322  
-		/* schedule -> enables interrupts */
323  
-		schedule();
  250
+	if (thread_flags & _TIF_SIGPENDING) {
  251
+		do_signal(regs, in_syscall);
  252
+	} else {
  253
+		clear_thread_flag(TIF_NOTIFY_RESUME);
  254
+		tracehook_notify_resume(regs);
324 255
 	}
325  
-
326  
-	local_irq_restore(flags);
327 256
 }
11  arch/m32r/include/asm/signal.h
@@ -16,16 +16,7 @@ typedef struct {
16 16
 	unsigned long sig[_NSIG_WORDS];
17 17
 } sigset_t;
18 18
 
19  
-struct sigaction {
20  
-	__sighandler_t sa_handler;
21  
-	unsigned long sa_flags;
22  
-	__sigrestore_t sa_restorer;
23  
-	sigset_t sa_mask;		/* mask last for extensibility */
24  
-};
25  
-
26  
-struct k_sigaction {
27  
-	struct sigaction sa;
28  
-};
  19
+#define __ARCH_HAS_SA_RESTORER
29 20
 #include <asm/sigcontext.h>
30 21
 
31 22
 #undef __HAVE_ARCH_SIG_BITOPS
10  arch/m68k/include/asm/signal.h
@@ -23,16 +23,8 @@ struct old_sigaction {
23 23
 	__sigrestore_t sa_restorer;
24 24
 };
25 25
 
26  
-struct sigaction {
27  
-	__sighandler_t sa_handler;
28  
-	unsigned long sa_flags;
29  
-	__sigrestore_t sa_restorer;
30  
-	sigset_t sa_mask;		/* mask last for extensibility */
31  
-};
  26
+#define __ARCH_HAS_SA_RESTORER
32 27
 
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
36 28
 #include <asm/sigcontext.h>
37 29
 
38 30
 #ifndef CONFIG_CPU_HAS_NO_BITFIELDS
2  arch/mips/include/asm/signal.h
@@ -21,4 +21,6 @@
21 21
 #include <asm/sigcontext.h>
22 22
 #include <asm/siginfo.h>
23 23
 
  24
+#define __ARCH_HAS_ODD_SIGACTION
  25
+
24 26
 #endif /* _ASM_SIGNAL_H */
6  arch/mips/include/uapi/asm/signal.h
@@ -96,15 +96,13 @@ typedef unsigned long old_sigset_t;		/* at least 32 bits */
96 96
 
97 97
 #include <asm-generic/signal-defs.h>
98 98
 
  99
+#ifndef __KERNEL__
99 100
 struct sigaction {
100 101
 	unsigned int	sa_flags;
101 102
 	__sighandler_t	sa_handler;
102 103
 	sigset_t	sa_mask;
103 104
 };
104  
-
105  
-struct k_sigaction {
106  
-	struct sigaction sa;
107  
-};
  105
+#endif
108 106
 
109 107
 /* IRIX compatible stack_t  */
110 108
 typedef struct sigaltstack {
10  arch/mn10300/include/asm/signal.h
@@ -33,16 +33,8 @@ struct old_sigaction {
33 33
 	__sigrestore_t sa_restorer;
34 34
 };
35 35
 
36  
-struct sigaction {
37  
-	__sighandler_t sa_handler;
38  
-	unsigned long sa_flags;
39  
-	__sigrestore_t sa_restorer;
40  
-	sigset_t sa_mask;		/* mask last for extensibility */
41  
-};
  36
+#define __ARCH_HAS_SA_RESTORER
42 37
 
43  
-struct k_sigaction {
44  
-	struct sigaction sa;
45  
-};
46 38
 #include <asm/sigcontext.h>
47 39
 
48 40
 #endif /* _ASM_SIGNAL_H */
6  arch/parisc/include/asm/signal.h
@@ -24,15 +24,13 @@ typedef struct {
24 24
 	unsigned long sig[_NSIG_WORDS];
25 25
 } sigset_t;
26 26
 
  27
+#ifndef __KERNEL__
27 28
 struct sigaction {
28 29
 	__sighandler_t sa_handler;
29 30
 	unsigned long sa_flags;
30 31
 	sigset_t sa_mask;		/* mask last for extensibility */
31 32
 };
32  
-
33  
-struct k_sigaction {
34  
-	struct sigaction sa;
35  
-};
  33
+#endif
36 34
 
37 35
 #include <asm/sigcontext.h>
38 36
 
1  arch/powerpc/include/asm/signal.h
... ...
@@ -1,6 +1,7 @@
1 1
 #ifndef _ASM_POWERPC_SIGNAL_H
2 2
 #define _ASM_POWERPC_SIGNAL_H
3 3
 
  4
+#define __ARCH_HAS_SA_RESTORER
4 5
 #include <uapi/asm/signal.h>
5 6
 
6 7
 #endif /* _ASM_POWERPC_SIGNAL_H */
1  arch/powerpc/include/asm/syscalls.h
@@ -9,7 +9,6 @@
9 9
 
10 10
 struct pt_regs;
11 11
 struct rtas_args;
12  
-struct sigaction;
13 12
 
14 13
 asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
15 14
 		unsigned long prot, unsigned long flags,
6  arch/powerpc/include/uapi/asm/signal.h
@@ -97,16 +97,14 @@ struct old_sigaction {
97 97
 	__sigrestore_t sa_restorer;
98 98
 };
99 99
 
  100
+#ifndef __KERNEL__
100 101
 struct sigaction {
101 102
 	__sighandler_t sa_handler;
102 103
 	unsigned long sa_flags;
103 104
 	__sigrestore_t sa_restorer;
104 105
 	sigset_t sa_mask;		/* mask last for extensibility */
105 106
 };
106  
-
107  
-struct k_sigaction {
108  
-	struct sigaction sa;
109  
-};
  107
+#endif
110 108
 
111 109
 typedef struct sigaltstack {
112 110
 	void __user *ss_sp;
12  arch/s390/include/asm/signal.h
@@ -28,15 +28,5 @@ struct old_sigaction {
28 28
         void (*sa_restorer)(void);
29 29
 };
30 30
 
31  
-struct sigaction {
32  
-        __sighandler_t sa_handler;
33  
-        unsigned long sa_flags;
34  
-        void (*sa_restorer)(void);
35  
-        sigset_t sa_mask;               /* mask last for extensibility */
36  
-};
37  
-
38  
-struct k_sigaction {
39  
-        struct sigaction sa;
40  
-};
41  
-
  31
+#define __ARCH_HAS_SA_RESTORER
42 32
 #endif
6  arch/sparc/include/asm/signal.h
@@ -21,10 +21,8 @@
21 21
  */
22 22
 #define SA_STATIC_ALLOC         0x8000
23 23
 
24  
-struct k_sigaction {
25  
-	struct			__new_sigaction sa;
26  
-	void			__user *ka_restorer;
27  
-};
  24
+#define __ARCH_HAS_KA_RESTORER
  25
+#define __ARCH_HAS_SA_RESTORER
28 26
 
29 27
 #endif /* !(__ASSEMBLY__) */
30 28
 #endif /* !(__SPARC_SIGNAL_H) */
2  arch/sparc/include/uapi/asm/signal.h
@@ -153,12 +153,14 @@ struct sigstack {
153 153
 
154 154
 #include <asm-generic/signal-defs.h>
155 155
 
  156
+#ifndef __KERNEL__
156 157
 struct __new_sigaction {
157 158
 	__sighandler_t		sa_handler;
158 159
 	unsigned long		sa_flags;
159 160
 	__sigrestore_t		sa_restorer;  /* not used by Linux/SPARC yet */
160 161
 	__new_sigset_t		sa_mask;
161 162
 };
  163
+#endif
162 164
 
163 165
 struct __old_sigaction {
164 166
 	__sighandler_t		sa_handler;
2  arch/sparc/kernel/systbls.h
@@ -3,8 +3,8 @@
3 3
 
4 4
 #include <linux/kernel.h>
5 5
 #include <linux/types.h>
  6
+#include <linux/signal.h>
6 7
 #include <asm/utrap.h>
7  
-#include <asm/signal.h>
8 8
 
9 9
 extern asmlinkage unsigned long sys_getpagesize(void);
10 10
 extern asmlinkage long sparc_pipe(struct pt_regs *regs);
15  arch/x86/include/asm/signal.h
@@ -31,6 +31,9 @@ typedef sigset_t compat_sigset_t;
31 31
 #include <uapi/asm/signal.h>
32 32
 #ifndef __ASSEMBLY__
33 33
 extern void do_notify_resume(struct pt_regs *, void *, __u32);
  34
+
  35
+#define __ARCH_HAS_SA_RESTORER
  36
+
34 37
 #ifdef __i386__
35 38
 struct old_sigaction {
36 39
 	__sighandler_t sa_handler;
@@ -39,18 +42,6 @@ struct old_sigaction {
39 42
 	__sigrestore_t sa_restorer;
40 43
 };
41 44
 
42  
-struct sigaction {
43  
-	__sighandler_t sa_handler;
44  
-	unsigned long sa_flags;
45  
-	__sigrestore_t sa_restorer;
46  
-	sigset_t sa_mask;		/* mask last for extensibility */
47  
-};
48  
-
49  
-struct k_sigaction {
50  
-	struct sigaction sa;
51  
-};
52  
-
53  
-#else /* __i386__ */
54 45
 #endif /* !__i386__ */
55 46
 #include <asm/sigcontext.h>
56 47
 
8  arch/x86/include/uapi/asm/signal.h
@@ -95,9 +95,9 @@ typedef unsigned long sigset_t;
95 95
 #ifndef __ASSEMBLY__
96 96
 
97 97
 
98  
-#ifdef __i386__
99 98
 # ifndef __KERNEL__
100 99
 /* Here we must cater to libcs that poke about in kernel headers.  */
  100
+#ifdef __i386__
101 101
 
102 102
 struct sigaction {
103 103
 	union {
@@ -112,7 +112,6 @@ struct sigaction {
112 112
 #define sa_handler	_u._sa_handler
113 113
 #define sa_sigaction	_u._sa_sigaction
114 114
 
115  
-# endif /* ! __KERNEL__ */
116 115
 #else /* __i386__ */
117 116
 
118 117
 struct sigaction {
@@ -122,11 +121,8 @@ struct sigaction {
122 121
 	sigset_t sa_mask;		/* mask last for extensibility */
123 122
 };
124 123
 
125  
-struct k_sigaction {
126  
-	struct sigaction sa;
127  
-};
128  
-
129 124
 #endif /* !__i386__ */
  125
+# endif /* ! __KERNEL__ */
130 126
 
131 127
 typedef struct sigaltstack {
132 128
 	void __user *ss_sp;
11  arch/xtensa/include/asm/signal.h
@@ -15,16 +15,7 @@
15 15
 #include <uapi/asm/signal.h>
16 16
 
17 17
 #ifndef __ASSEMBLY__
18  
-struct sigaction {
19  
-	__sighandler_t sa_handler;
20  
-	unsigned long sa_flags;
21  
-	void (*sa_restorer)(void);
22  
-	sigset_t sa_mask;		/* mask last for extensibility */
23  
-};
24  
-
25  
-struct k_sigaction {
26  
-	struct sigaction sa;
27  
-};
  18
+#define __ARCH_HAS_SA_RESTORER
28 19
 
29 20
 #include <asm/sigcontext.h>
30 21
 
11  include/linux/sched.h
@@ -2305,6 +2305,17 @@ static inline int sas_ss_flags(unsigned long sp)
2305 2305
 		: on_sig_stack(sp) ? SS_ONSTACK : 0);
2306 2306
 }
2307 2307
 
  2308
+static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig)
  2309
+{
  2310
+	if (unlikely((ksig->ka.sa.sa_flags & SA_ONSTACK)) && ! sas_ss_flags(sp))
  2311
+#ifdef CONFIG_STACK_GROWSUP
  2312
+		return current->sas_ss_sp;
  2313
+#else
  2314
+		return current->sas_ss_sp + current->sas_ss_size;
  2315
+#endif
  2316
+	return sp;
  2317
+}
  2318
+
2308 2319
 /*
2309 2320
  * Routines for handling mm_structs
2310 2321
  */
40  include/linux/signal.h
@@ -252,10 +252,50 @@ extern void __set_current_blocked(const sigset_t *);
252 252
 extern int show_unhandled_signals;
253 253
 extern int sigsuspend(sigset_t *);
254 254
 
  255
+struct sigaction {
  256
+#ifndef __ARCH_HAS_ODD_SIGACTION
  257
+	__sighandler_t	sa_handler;
  258
+	unsigned long	sa_flags;
  259
+#else
  260
+	unsigned long	sa_flags;
  261
+	__sighandler_t	sa_handler;
  262
+#endif
  263
+#ifdef __ARCH_HAS_SA_RESTORER
  264
+	__sigrestore_t sa_restorer;
  265
+#endif
  266
+	sigset_t	sa_mask;	/* mask last for extensibility */
  267
+};
  268
+
  269
+struct k_sigaction {
  270
+	struct sigaction sa;
  271
+#ifdef __ARCH_HAS_KA_RESTORER
  272
+	__sigrestore_t ka_restorer;
  273
+#endif
  274
+};