aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/signal_32.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-03-07 21:24:22 -0500
committerPaul Mackerras <paulus@samba.org>2006-03-07 21:24:22 -0500
commit1bd79336a426c5e4f3bab142407059ceb12cadf9 (patch)
treedd8767b0ab3ce310c7df049822100e3838b37a97 /arch/powerpc/kernel/signal_32.c
parentab1b55e21f6977e420341727e9f4a50691057b5e (diff)
powerpc: Fix various syscall/signal/swapcontext bugs
A careful reading of the recent changes to the system call entry/exit paths revealed several problems, plus some things that could be simplified and improved: * 32-bit wasn't testing the _TIF_NOERROR bit in the syscall fast exit path, so it was only doing anything with it once it saw some other bit being set. In other words, the noerror behaviour would apply to the next system call where we had to reschedule or deliver a signal, which is not necessarily the current system call. * 32-bit wasn't doing the call to ptrace_notify in the syscall exit path when the _TIF_SINGLESTEP bit was set. * _TIF_RESTOREALL was in both _TIF_USER_WORK_MASK and _TIF_PERSYSCALL_MASK, which is odd since _TIF_RESTOREALL is only set by system calls. I took it out of _TIF_USER_WORK_MASK. * On 64-bit, _TIF_RESTOREALL wasn't causing the non-volatile registers to be restored (unless perhaps a signal was delivered or the syscall was traced or single-stepped). Thus the non-volatile registers weren't restored on exit from a signal handler. We probably got away with it mostly because signal handlers written in C wouldn't alter the non-volatile registers. * On 32-bit I simplified the code and made it more like 64-bit by making the syscall exit path jump to ret_from_except to handle preemption and signal delivery. * 32-bit was calling do_signal unnecessarily when _TIF_RESTOREALL was set - but I think because of that 32-bit was actually restoring the non-volatile registers on exit from a signal handler. * I changed the order of enabling interrupts and saving the non-volatile registers before calling do_syscall_trace_leave; now we enable interrupts first. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/signal_32.c')
-rw-r--r--arch/powerpc/kernel/signal_32.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index bd837b5dbf06..d7a4e814974d 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -151,10 +151,7 @@ static inline int save_general_regs(struct pt_regs *regs,
151 elf_greg_t64 *gregs = (elf_greg_t64 *)regs; 151 elf_greg_t64 *gregs = (elf_greg_t64 *)regs;
152 int i; 152 int i;
153 153
154 if (!FULL_REGS(regs)) { 154 WARN_ON(!FULL_REGS(regs));
155 set_thread_flag(TIF_SAVE_NVGPRS);
156 current_thread_info()->nvgprs_frame = frame->mc_gregs;
157 }
158 155
159 for (i = 0; i <= PT_RESULT; i ++) { 156 for (i = 0; i <= PT_RESULT; i ++) {
160 if (i == 14 && !FULL_REGS(regs)) 157 if (i == 14 && !FULL_REGS(regs))
@@ -215,15 +212,7 @@ static inline int get_old_sigaction(struct k_sigaction *new_ka,
215static inline int save_general_regs(struct pt_regs *regs, 212static inline int save_general_regs(struct pt_regs *regs,
216 struct mcontext __user *frame) 213 struct mcontext __user *frame)
217{ 214{
218 if (!FULL_REGS(regs)) { 215 WARN_ON(!FULL_REGS(regs));
219 /* Zero out the unsaved GPRs to avoid information
220 leak, and set TIF_SAVE_NVGPRS to ensure that the
221 registers do actually get saved later. */
222 memset(&regs->gpr[14], 0, 18 * sizeof(unsigned long));
223 current_thread_info()->nvgprs_frame = &frame->mc_gregs;
224 set_thread_flag(TIF_SAVE_NVGPRS);
225 }
226
227 return __copy_to_user(&frame->mc_gregs, regs, GP_REGS_SIZE); 216 return __copy_to_user(&frame->mc_gregs, regs, GP_REGS_SIZE);
228} 217}
229 218
@@ -826,8 +815,8 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
826} 815}
827 816
828long sys_swapcontext(struct ucontext __user *old_ctx, 817long sys_swapcontext(struct ucontext __user *old_ctx,
829 struct ucontext __user *new_ctx, 818 struct ucontext __user *new_ctx,
830 int ctx_size, int r6, int r7, int r8, struct pt_regs *regs) 819 int ctx_size, int r6, int r7, int r8, struct pt_regs *regs)
831{ 820{
832 unsigned char tmp; 821 unsigned char tmp;
833 822