linux: update to 4.4.79, add back required patches
[openadk.git] / target / linux / patches / 4.4.79 / coldfire-sighandler.patch
blobc52a4e22882e5059f41110a1ba653767556faf62
1 From a95517992a37488c0bc8b629c47c570e580e407d Mon Sep 17 00:00:00 2001
2 From: Greg Ungerer <gerg@uclinux.org>
3 Date: Mon, 15 Feb 2016 16:36:29 +1000
4 Subject: m68k: Use conventional function parameters for do_sigreturn
6 Create conventional stack parameters for the calls to do_sigreturn and
7 do_rt_sigreturn. The current C code for do_sigreturn and do_rt_sigreturn
8 dig into the stack to create local pointers to the saved switch stack
9 and the pt_regs structs.
11 The motivation for this change is a problem with non-MMU targets that
12 have broken signal return paths on newer versions of gcc. It appears as
13 though gcc has determined that the pointers into the saved stack structs,
14 and the saved structs themselves, are function parameters and updates to
15 them will be lost on function return, so they are optimized away. This
16 results in large parts of restore_sigcontext() and mangle_kernel_stack()
17 functions being removed. Of course this results in non-functional code
18 causing kernel oops. This problem has been observed with gcc version
19 5.2 and 5.3, and probably exists in earlier versions as well.
21 Using conventional stack parameter pointers passed to these functions has
22 the advantage of the code here not needing to know the exact details of
23 how the underlying entry handler layed these structs out on the stack.
24 So the rather ugly pointer setup casting and arg referencing can be
25 removed.
27 The resulting code after this change is a few bytes larger (due to the
28 overhead of creating the stack args and their tear down). Not being hot
29 paths I don't think this is too much of a problem here.
31 An alternative solution is to put a barrier() in the do_sigreturn() code,
32 but this doesn't feel quite as clean as this solution.
34 This change has been compile tested on all defconfigs, and run tested on
35 Atari (through aranym), ColdFire with MMU (M5407EVB) and ColdFire with
36 no-MMU (QEMU and M5208EVB).
38 Signed-off-by: Greg Ungerer <gerg@uclinux.org>
39 Acked-by: Andreas Schwab <schwab@linux-m68k.org>
40 Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
41 ---
42 arch/m68k/kernel/entry.S | 6 ++++++
43 arch/m68k/kernel/signal.c | 8 ++------
44 2 files changed, 8 insertions(+), 6 deletions(-)
46 diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
47 index b54ac7a..97cd3ea 100644
48 --- a/arch/m68k/kernel/entry.S
49 +++ b/arch/m68k/kernel/entry.S
50 @@ -71,13 +71,19 @@ ENTRY(__sys_vfork)
52 ENTRY(sys_sigreturn)
53 SAVE_SWITCH_STACK
54 + movel %sp,%sp@- | switch_stack pointer
55 + pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
56 jbsr do_sigreturn
57 + addql #8,%sp
58 RESTORE_SWITCH_STACK
59 rts
61 ENTRY(sys_rt_sigreturn)
62 SAVE_SWITCH_STACK
63 + movel %sp,%sp@- | switch_stack pointer
64 + pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
65 jbsr do_rt_sigreturn
66 + addql #8,%sp
67 RESTORE_SWITCH_STACK
68 rts
70 diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
71 index af1c4f3..2dcee3a 100644
72 --- a/arch/m68k/kernel/signal.c
73 +++ b/arch/m68k/kernel/signal.c
74 @@ -737,10 +737,8 @@ badframe:
75 return 1;
78 -asmlinkage int do_sigreturn(unsigned long __unused)
79 +asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
81 - struct switch_stack *sw = (struct switch_stack *) &__unused;
82 - struct pt_regs *regs = (struct pt_regs *) (sw + 1);
83 unsigned long usp = rdusp();
84 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
85 sigset_t set;
86 @@ -764,10 +762,8 @@ badframe:
87 return 0;
90 -asmlinkage int do_rt_sigreturn(unsigned long __unused)
91 +asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
93 - struct switch_stack *sw = (struct switch_stack *) &__unused;
94 - struct pt_regs *regs = (struct pt_regs *) (sw + 1);
95 unsigned long usp = rdusp();
96 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
97 sigset_t set;
98 --
99 cgit v0.12