aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@uclinux.org>2016-02-15 01:36:29 -0500
committerGeert Uytterhoeven <geert@linux-m68k.org>2016-02-29 03:51:43 -0500
commita95517992a37488c0bc8b629c47c570e580e407d (patch)
tree5dd5c5c16ef8e1d2eaad798eca1ff3ad2e614e85
parenta9c9d9aca4e7cf75d09faa098785ed991db41c65 (diff)
m68k: Use conventional function parameters for do_sigreturn
Create conventional stack parameters for the calls to do_sigreturn and do_rt_sigreturn. The current C code for do_sigreturn and do_rt_sigreturn dig into the stack to create local pointers to the saved switch stack and the pt_regs structs. The motivation for this change is a problem with non-MMU targets that have broken signal return paths on newer versions of gcc. It appears as though gcc has determined that the pointers into the saved stack structs, and the saved structs themselves, are function parameters and updates to them will be lost on function return, so they are optimized away. This results in large parts of restore_sigcontext() and mangle_kernel_stack() functions being removed. Of course this results in non-functional code causing kernel oops. This problem has been observed with gcc version 5.2 and 5.3, and probably exists in earlier versions as well. Using conventional stack parameter pointers passed to these functions has the advantage of the code here not needing to know the exact details of how the underlying entry handler layed these structs out on the stack. So the rather ugly pointer setup casting and arg referencing can be removed. The resulting code after this change is a few bytes larger (due to the overhead of creating the stack args and their tear down). Not being hot paths I don't think this is too much of a problem here. An alternative solution is to put a barrier() in the do_sigreturn() code, but this doesn't feel quite as clean as this solution. This change has been compile tested on all defconfigs, and run tested on Atari (through aranym), ColdFire with MMU (M5407EVB) and ColdFire with no-MMU (QEMU and M5208EVB). Signed-off-by: Greg Ungerer <gerg@uclinux.org> Acked-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r--arch/m68k/kernel/entry.S6
-rw-r--r--arch/m68k/kernel/signal.c8
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index b54ac7aba850..97cd3ea5f10b 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -71,13 +71,19 @@ ENTRY(__sys_vfork)
71 71
72ENTRY(sys_sigreturn) 72ENTRY(sys_sigreturn)
73 SAVE_SWITCH_STACK 73 SAVE_SWITCH_STACK
74 movel %sp,%sp@- | switch_stack pointer
75 pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
74 jbsr do_sigreturn 76 jbsr do_sigreturn
77 addql #8,%sp
75 RESTORE_SWITCH_STACK 78 RESTORE_SWITCH_STACK
76 rts 79 rts
77 80
78ENTRY(sys_rt_sigreturn) 81ENTRY(sys_rt_sigreturn)
79 SAVE_SWITCH_STACK 82 SAVE_SWITCH_STACK
83 movel %sp,%sp@- | switch_stack pointer
84 pea %sp@(SWITCH_STACK_SIZE+4) | pt_regs pointer
80 jbsr do_rt_sigreturn 85 jbsr do_rt_sigreturn
86 addql #8,%sp
81 RESTORE_SWITCH_STACK 87 RESTORE_SWITCH_STACK
82 rts 88 rts
83 89
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
index af1c4f330aef..2dcee3a88867 100644
--- a/arch/m68k/kernel/signal.c
+++ b/arch/m68k/kernel/signal.c
@@ -737,10 +737,8 @@ badframe:
737 return 1; 737 return 1;
738} 738}
739 739
740asmlinkage int do_sigreturn(unsigned long __unused) 740asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
741{ 741{
742 struct switch_stack *sw = (struct switch_stack *) &__unused;
743 struct pt_regs *regs = (struct pt_regs *) (sw + 1);
744 unsigned long usp = rdusp(); 742 unsigned long usp = rdusp();
745 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4); 743 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
746 sigset_t set; 744 sigset_t set;
@@ -764,10 +762,8 @@ badframe:
764 return 0; 762 return 0;
765} 763}
766 764
767asmlinkage int do_rt_sigreturn(unsigned long __unused) 765asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)
768{ 766{
769 struct switch_stack *sw = (struct switch_stack *) &__unused;
770 struct pt_regs *regs = (struct pt_regs *) (sw + 1);
771 unsigned long usp = rdusp(); 767 unsigned long usp = rdusp();
772 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4); 768 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
773 sigset_t set; 769 sigset_t set;