Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 7 | * Copyright (C) 1994 - 2000 Ralf Baechle |
| 8 | * Copyright (C) 1999, 2000 Silicon Graphics, Inc. |
| 9 | */ |
Ralf Baechle | 02416dc | 2005-06-15 13:00:12 +0000 | [diff] [blame] | 10 | #include <linux/cache.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/sched.h> |
| 12 | #include <linux/mm.h> |
| 13 | #include <linux/personality.h> |
| 14 | #include <linux/smp.h> |
| 15 | #include <linux/smp_lock.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/signal.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/wait.h> |
| 20 | #include <linux/ptrace.h> |
| 21 | #include <linux/unistd.h> |
| 22 | #include <linux/compiler.h> |
Atsushi Nemoto | faea623 | 2007-04-16 23:19:44 +0900 | [diff] [blame^] | 23 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Ralf Baechle | e50c0a8 | 2005-05-31 11:49:19 +0000 | [diff] [blame] | 25 | #include <asm/abi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/asm.h> |
| 27 | #include <linux/bitops.h> |
| 28 | #include <asm/cacheflush.h> |
| 29 | #include <asm/fpu.h> |
| 30 | #include <asm/sim.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <asm/ucontext.h> |
| 32 | #include <asm/cpu-features.h> |
Ralf Baechle | 02416dc | 2005-06-15 13:00:12 +0000 | [diff] [blame] | 33 | #include <asm/war.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #include "signal-common.h" |
| 36 | |
Ralf Baechle | 6668058 | 2007-02-13 01:31:48 +0000 | [diff] [blame] | 37 | /* |
| 38 | * Horribly complicated - with the bloody RM9000 workarounds enabled |
| 39 | * the signal trampolines is moving to the end of the structure so we can |
| 40 | * increase the alignment without breaking software compatibility. |
| 41 | */ |
Franck Bui-Huu | c0b9bae | 2007-02-05 15:24:21 +0100 | [diff] [blame] | 42 | #if ICACHE_REFILLS_WORKAROUND_WAR == 0 |
| 43 | |
Ralf Baechle | 6668058 | 2007-02-13 01:31:48 +0000 | [diff] [blame] | 44 | struct sigframe { |
| 45 | u32 sf_ass[4]; /* argument save space for o32 */ |
| 46 | u32 sf_code[2]; /* signal trampoline */ |
| 47 | struct sigcontext sf_sc; |
| 48 | sigset_t sf_mask; |
| 49 | }; |
| 50 | |
Franck Bui-Huu | c0b9bae | 2007-02-05 15:24:21 +0100 | [diff] [blame] | 51 | struct rt_sigframe { |
| 52 | u32 rs_ass[4]; /* argument save space for o32 */ |
| 53 | u32 rs_code[2]; /* signal trampoline */ |
| 54 | struct siginfo rs_info; |
| 55 | struct ucontext rs_uc; |
| 56 | }; |
| 57 | |
| 58 | #else |
| 59 | |
Ralf Baechle | 6668058 | 2007-02-13 01:31:48 +0000 | [diff] [blame] | 60 | struct sigframe { |
| 61 | u32 sf_ass[4]; /* argument save space for o32 */ |
| 62 | u32 sf_pad[2]; |
| 63 | struct sigcontext sf_sc; /* hw context */ |
| 64 | sigset_t sf_mask; |
| 65 | u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */ |
| 66 | }; |
| 67 | |
Franck Bui-Huu | c0b9bae | 2007-02-05 15:24:21 +0100 | [diff] [blame] | 68 | struct rt_sigframe { |
| 69 | u32 rs_ass[4]; /* argument save space for o32 */ |
| 70 | u32 rs_pad[2]; |
| 71 | struct siginfo rs_info; |
| 72 | struct ucontext rs_uc; |
| 73 | u32 rs_code[8] ____cacheline_aligned; /* signal trampoline */ |
| 74 | }; |
| 75 | |
| 76 | #endif |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | /* |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 79 | * Helper routines |
| 80 | */ |
Atsushi Nemoto | faea623 | 2007-04-16 23:19:44 +0900 | [diff] [blame^] | 81 | static int protected_save_fp_context(struct sigcontext __user *sc) |
| 82 | { |
| 83 | int err; |
| 84 | while (1) { |
| 85 | lock_fpu_owner(); |
| 86 | own_fpu_inatomic(1); |
| 87 | err = save_fp_context(sc); /* this might fail */ |
| 88 | unlock_fpu_owner(); |
| 89 | if (likely(!err)) |
| 90 | break; |
| 91 | /* touch the sigcontext and try again */ |
| 92 | err = __put_user(0, &sc->sc_fpregs[0]) | |
| 93 | __put_user(0, &sc->sc_fpregs[31]) | |
| 94 | __put_user(0, &sc->sc_fpc_csr); |
| 95 | if (err) |
| 96 | break; /* really bad sigcontext */ |
| 97 | } |
| 98 | return err; |
| 99 | } |
| 100 | |
| 101 | static int protected_restore_fp_context(struct sigcontext __user *sc) |
| 102 | { |
| 103 | int err, tmp; |
| 104 | while (1) { |
| 105 | lock_fpu_owner(); |
| 106 | own_fpu_inatomic(0); |
| 107 | err = restore_fp_context(sc); /* this might fail */ |
| 108 | unlock_fpu_owner(); |
| 109 | if (likely(!err)) |
| 110 | break; |
| 111 | /* touch the sigcontext and try again */ |
| 112 | err = __get_user(tmp, &sc->sc_fpregs[0]) | |
| 113 | __get_user(tmp, &sc->sc_fpregs[31]) | |
| 114 | __get_user(tmp, &sc->sc_fpc_csr); |
| 115 | if (err) |
| 116 | break; /* really bad sigcontext */ |
| 117 | } |
| 118 | return err; |
| 119 | } |
| 120 | |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 121 | int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) |
| 122 | { |
| 123 | int err = 0; |
| 124 | int i; |
Atsushi Nemoto | 53dc802 | 2007-03-10 01:07:45 +0900 | [diff] [blame] | 125 | unsigned int used_math; |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 126 | |
| 127 | err |= __put_user(regs->cp0_epc, &sc->sc_pc); |
| 128 | |
| 129 | err |= __put_user(0, &sc->sc_regs[0]); |
| 130 | for (i = 1; i < 32; i++) |
| 131 | err |= __put_user(regs->regs[i], &sc->sc_regs[i]); |
| 132 | |
Franck Bui-Huu | 9693a85 | 2007-02-02 17:41:47 +0100 | [diff] [blame] | 133 | #ifdef CONFIG_CPU_HAS_SMARTMIPS |
| 134 | err |= __put_user(regs->acx, &sc->sc_acx); |
| 135 | #endif |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 136 | err |= __put_user(regs->hi, &sc->sc_mdhi); |
| 137 | err |= __put_user(regs->lo, &sc->sc_mdlo); |
| 138 | if (cpu_has_dsp) { |
| 139 | err |= __put_user(mfhi1(), &sc->sc_hi1); |
| 140 | err |= __put_user(mflo1(), &sc->sc_lo1); |
| 141 | err |= __put_user(mfhi2(), &sc->sc_hi2); |
| 142 | err |= __put_user(mflo2(), &sc->sc_lo2); |
| 143 | err |= __put_user(mfhi3(), &sc->sc_hi3); |
| 144 | err |= __put_user(mflo3(), &sc->sc_lo3); |
| 145 | err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp); |
| 146 | } |
| 147 | |
Atsushi Nemoto | 53dc802 | 2007-03-10 01:07:45 +0900 | [diff] [blame] | 148 | used_math = !!used_math(); |
| 149 | err |= __put_user(used_math, &sc->sc_used_math); |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 150 | |
Atsushi Nemoto | 53dc802 | 2007-03-10 01:07:45 +0900 | [diff] [blame] | 151 | if (used_math) { |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 152 | /* |
| 153 | * Save FPU state to signal context. Signal handler |
| 154 | * will "inherit" current FPU state. |
| 155 | */ |
Atsushi Nemoto | faea623 | 2007-04-16 23:19:44 +0900 | [diff] [blame^] | 156 | err |= protected_save_fp_context(sc); |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 157 | } |
| 158 | return err; |
| 159 | } |
| 160 | |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 161 | int fpcsr_pending(unsigned int __user *fpcsr) |
| 162 | { |
| 163 | int err, sig = 0; |
| 164 | unsigned int csr, enabled; |
| 165 | |
| 166 | err = __get_user(csr, fpcsr); |
| 167 | enabled = FPU_CSR_UNI_X | ((csr & FPU_CSR_ALL_E) << 5); |
| 168 | /* |
| 169 | * If the signal handler set some FPU exceptions, clear it and |
| 170 | * send SIGFPE. |
| 171 | */ |
| 172 | if (csr & enabled) { |
| 173 | csr &= ~enabled; |
| 174 | err |= __put_user(csr, fpcsr); |
| 175 | sig = SIGFPE; |
| 176 | } |
| 177 | return err ?: sig; |
| 178 | } |
| 179 | |
| 180 | static int |
| 181 | check_and_restore_fp_context(struct sigcontext __user *sc) |
| 182 | { |
| 183 | int err, sig; |
| 184 | |
| 185 | err = sig = fpcsr_pending(&sc->sc_fpc_csr); |
| 186 | if (err > 0) |
| 187 | err = 0; |
Atsushi Nemoto | faea623 | 2007-04-16 23:19:44 +0900 | [diff] [blame^] | 188 | err |= protected_restore_fp_context(sc); |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 189 | return err ?: sig; |
| 190 | } |
| 191 | |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 192 | int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) |
| 193 | { |
| 194 | unsigned int used_math; |
| 195 | unsigned long treg; |
| 196 | int err = 0; |
| 197 | int i; |
| 198 | |
| 199 | /* Always make any pending restarted system calls return -EINTR */ |
| 200 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| 201 | |
| 202 | err |= __get_user(regs->cp0_epc, &sc->sc_pc); |
Franck Bui-Huu | 9693a85 | 2007-02-02 17:41:47 +0100 | [diff] [blame] | 203 | |
| 204 | #ifdef CONFIG_CPU_HAS_SMARTMIPS |
| 205 | err |= __get_user(regs->acx, &sc->sc_acx); |
| 206 | #endif |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 207 | err |= __get_user(regs->hi, &sc->sc_mdhi); |
| 208 | err |= __get_user(regs->lo, &sc->sc_mdlo); |
| 209 | if (cpu_has_dsp) { |
| 210 | err |= __get_user(treg, &sc->sc_hi1); mthi1(treg); |
| 211 | err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg); |
| 212 | err |= __get_user(treg, &sc->sc_hi2); mthi2(treg); |
| 213 | err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg); |
| 214 | err |= __get_user(treg, &sc->sc_hi3); mthi3(treg); |
| 215 | err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg); |
| 216 | err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK); |
| 217 | } |
| 218 | |
| 219 | for (i = 1; i < 32; i++) |
| 220 | err |= __get_user(regs->regs[i], &sc->sc_regs[i]); |
| 221 | |
| 222 | err |= __get_user(used_math, &sc->sc_used_math); |
| 223 | conditional_used_math(used_math); |
| 224 | |
Atsushi Nemoto | 53dc802 | 2007-03-10 01:07:45 +0900 | [diff] [blame] | 225 | if (used_math) { |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 226 | /* restore fpu context if we have used it before */ |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 227 | if (!err) |
| 228 | err = check_and_restore_fp_context(sc); |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 229 | } else { |
| 230 | /* signal handler may have used FPU. Give it up. */ |
Atsushi Nemoto | 53dc802 | 2007-03-10 01:07:45 +0900 | [diff] [blame] | 231 | lose_fpu(0); |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 232 | } |
| 233 | |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 234 | return err; |
| 235 | } |
| 236 | |
| 237 | void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, |
| 238 | size_t frame_size) |
| 239 | { |
| 240 | unsigned long sp; |
| 241 | |
| 242 | /* Default to using normal stack */ |
| 243 | sp = regs->regs[29]; |
| 244 | |
| 245 | /* |
| 246 | * FPU emulator may have it's own trampoline active just |
| 247 | * above the user stack, 16-bytes before the next lowest |
| 248 | * 16 byte boundary. Try to avoid trashing it. |
| 249 | */ |
| 250 | sp -= 32; |
| 251 | |
| 252 | /* This is the X/Open sanctioned signal stack switching. */ |
| 253 | if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0)) |
| 254 | sp = current->sas_ss_sp + current->sas_ss_size; |
| 255 | |
| 256 | return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size()-1) : ALMASK)); |
| 257 | } |
| 258 | |
| 259 | int install_sigtramp(unsigned int __user *tramp, unsigned int syscall) |
| 260 | { |
| 261 | int err; |
| 262 | |
| 263 | /* |
| 264 | * Set up the return code ... |
| 265 | * |
| 266 | * li v0, __NR__foo_sigreturn |
| 267 | * syscall |
| 268 | */ |
| 269 | |
| 270 | err = __put_user(0x24020000 + syscall, tramp + 0); |
Franck Bui-Huu | 601dde4 | 2007-02-05 15:24:23 +0100 | [diff] [blame] | 271 | err |= __put_user(0x0000000c , tramp + 1); |
Franck Bui-Huu | c3fc4ab | 2007-02-05 15:24:20 +0100 | [diff] [blame] | 272 | if (ICACHE_REFILLS_WORKAROUND_WAR) { |
| 273 | err |= __put_user(0, tramp + 2); |
| 274 | err |= __put_user(0, tramp + 3); |
| 275 | err |= __put_user(0, tramp + 4); |
| 276 | err |= __put_user(0, tramp + 5); |
| 277 | err |= __put_user(0, tramp + 6); |
| 278 | err |= __put_user(0, tramp + 7); |
| 279 | } |
| 280 | flush_cache_sigtramp((unsigned long) tramp); |
| 281 | |
| 282 | return err; |
| 283 | } |
| 284 | |
| 285 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | * Atomically swap in the new signal mask, and wait for a signal. |
| 287 | */ |
| 288 | |
| 289 | #ifdef CONFIG_TRAD_SIGNALS |
Franck Bui-Huu | f90080a | 2007-02-05 15:24:27 +0100 | [diff] [blame] | 290 | asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 292 | sigset_t newset; |
Ralf Baechle | fe00f94 | 2005-03-01 19:22:29 +0000 | [diff] [blame] | 293 | sigset_t __user *uset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Ralf Baechle | fe00f94 | 2005-03-01 19:22:29 +0000 | [diff] [blame] | 295 | uset = (sigset_t __user *) regs.regs[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | if (copy_from_user(&newset, uset, sizeof(sigset_t))) |
| 297 | return -EFAULT; |
| 298 | sigdelsetmask(&newset, ~_BLOCKABLE); |
| 299 | |
| 300 | spin_lock_irq(¤t->sighand->siglock); |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 301 | current->saved_sigmask = current->blocked; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | current->blocked = newset; |
| 303 | recalc_sigpending(); |
| 304 | spin_unlock_irq(¤t->sighand->siglock); |
| 305 | |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 306 | current->state = TASK_INTERRUPTIBLE; |
| 307 | schedule(); |
| 308 | set_thread_flag(TIF_RESTORE_SIGMASK); |
| 309 | return -ERESTARTNOHAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
| 311 | #endif |
| 312 | |
Franck Bui-Huu | f90080a | 2007-02-05 15:24:27 +0100 | [diff] [blame] | 313 | asmlinkage int sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | { |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 315 | sigset_t newset; |
Ralf Baechle | fe00f94 | 2005-03-01 19:22:29 +0000 | [diff] [blame] | 316 | sigset_t __user *unewset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | size_t sigsetsize; |
| 318 | |
| 319 | /* XXX Don't preclude handling different sized sigset_t's. */ |
| 320 | sigsetsize = regs.regs[5]; |
| 321 | if (sigsetsize != sizeof(sigset_t)) |
| 322 | return -EINVAL; |
| 323 | |
Ralf Baechle | fe00f94 | 2005-03-01 19:22:29 +0000 | [diff] [blame] | 324 | unewset = (sigset_t __user *) regs.regs[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | if (copy_from_user(&newset, unewset, sizeof(newset))) |
| 326 | return -EFAULT; |
| 327 | sigdelsetmask(&newset, ~_BLOCKABLE); |
| 328 | |
| 329 | spin_lock_irq(¤t->sighand->siglock); |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 330 | current->saved_sigmask = current->blocked; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | current->blocked = newset; |
Ralf Baechle | e0daad4 | 2007-02-05 00:10:11 +0000 | [diff] [blame] | 332 | recalc_sigpending(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | spin_unlock_irq(¤t->sighand->siglock); |
| 334 | |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 335 | current->state = TASK_INTERRUPTIBLE; |
| 336 | schedule(); |
| 337 | set_thread_flag(TIF_RESTORE_SIGMASK); |
| 338 | return -ERESTARTNOHAND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | #ifdef CONFIG_TRAD_SIGNALS |
Atsushi Nemoto | 9c6031c | 2006-02-19 23:46:44 +0900 | [diff] [blame] | 342 | asmlinkage int sys_sigaction(int sig, const struct sigaction __user *act, |
| 343 | struct sigaction __user *oact) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | { |
| 345 | struct k_sigaction new_ka, old_ka; |
| 346 | int ret; |
| 347 | int err = 0; |
| 348 | |
| 349 | if (act) { |
| 350 | old_sigset_t mask; |
| 351 | |
| 352 | if (!access_ok(VERIFY_READ, act, sizeof(*act))) |
| 353 | return -EFAULT; |
| 354 | err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler); |
| 355 | err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags); |
| 356 | err |= __get_user(mask, &act->sa_mask.sig[0]); |
| 357 | if (err) |
| 358 | return -EFAULT; |
| 359 | |
| 360 | siginitset(&new_ka.sa.sa_mask, mask); |
| 361 | } |
| 362 | |
| 363 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
| 364 | |
| 365 | if (!ret && oact) { |
| 366 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact))) |
Ralf Baechle | e0daad4 | 2007-02-05 00:10:11 +0000 | [diff] [blame] | 367 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); |
| 369 | err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler); |
| 370 | err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig); |
| 371 | err |= __put_user(0, &oact->sa_mask.sig[1]); |
| 372 | err |= __put_user(0, &oact->sa_mask.sig[2]); |
| 373 | err |= __put_user(0, &oact->sa_mask.sig[3]); |
| 374 | if (err) |
| 375 | return -EFAULT; |
| 376 | } |
| 377 | |
| 378 | return ret; |
| 379 | } |
| 380 | #endif |
| 381 | |
| 382 | asmlinkage int sys_sigaltstack(nabi_no_regargs struct pt_regs regs) |
| 383 | { |
Ralf Baechle | fe00f94 | 2005-03-01 19:22:29 +0000 | [diff] [blame] | 384 | const stack_t __user *uss = (const stack_t __user *) regs.regs[4]; |
| 385 | stack_t __user *uoss = (stack_t __user *) regs.regs[5]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | unsigned long usp = regs.regs[29]; |
| 387 | |
| 388 | return do_sigaltstack(uss, uoss, usp); |
| 389 | } |
| 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #ifdef CONFIG_TRAD_SIGNALS |
Franck Bui-Huu | f90080a | 2007-02-05 15:24:27 +0100 | [diff] [blame] | 392 | asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 394 | struct sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | sigset_t blocked; |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 396 | int sig; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 398 | frame = (struct sigframe __user *) regs.regs[29]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
| 400 | goto badframe; |
| 401 | if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked))) |
| 402 | goto badframe; |
| 403 | |
| 404 | sigdelsetmask(&blocked, ~_BLOCKABLE); |
| 405 | spin_lock_irq(¤t->sighand->siglock); |
| 406 | current->blocked = blocked; |
| 407 | recalc_sigpending(); |
| 408 | spin_unlock_irq(¤t->sighand->siglock); |
| 409 | |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 410 | sig = restore_sigcontext(®s, &frame->sf_sc); |
| 411 | if (sig < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | goto badframe; |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 413 | else if (sig) |
| 414 | force_sig(sig, current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
| 416 | /* |
| 417 | * Don't let your children do this ... |
| 418 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | __asm__ __volatile__( |
| 420 | "move\t$29, %0\n\t" |
| 421 | "j\tsyscall_exit" |
| 422 | :/* no outputs */ |
| 423 | :"r" (®s)); |
| 424 | /* Unreached */ |
| 425 | |
| 426 | badframe: |
| 427 | force_sig(SIGSEGV, current); |
| 428 | } |
Ralf Baechle | e50c0a8 | 2005-05-31 11:49:19 +0000 | [diff] [blame] | 429 | #endif /* CONFIG_TRAD_SIGNALS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
Franck Bui-Huu | f90080a | 2007-02-05 15:24:27 +0100 | [diff] [blame] | 431 | asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | { |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 433 | struct rt_sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | sigset_t set; |
| 435 | stack_t st; |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 436 | int sig; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 438 | frame = (struct rt_sigframe __user *) regs.regs[29]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
| 440 | goto badframe; |
| 441 | if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set))) |
| 442 | goto badframe; |
| 443 | |
| 444 | sigdelsetmask(&set, ~_BLOCKABLE); |
| 445 | spin_lock_irq(¤t->sighand->siglock); |
| 446 | current->blocked = set; |
| 447 | recalc_sigpending(); |
| 448 | spin_unlock_irq(¤t->sighand->siglock); |
| 449 | |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 450 | sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext); |
| 451 | if (sig < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | goto badframe; |
Atsushi Nemoto | c6a2f46 | 2007-03-10 01:03:48 +0900 | [diff] [blame] | 453 | else if (sig) |
| 454 | force_sig(sig, current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
| 456 | if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st))) |
| 457 | goto badframe; |
| 458 | /* It is more difficult to avoid calling this function than to |
| 459 | call it and ignore errors. */ |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 460 | do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | /* |
| 463 | * Don't let your children do this ... |
| 464 | */ |
| 465 | __asm__ __volatile__( |
| 466 | "move\t$29, %0\n\t" |
| 467 | "j\tsyscall_exit" |
| 468 | :/* no outputs */ |
| 469 | :"r" (®s)); |
| 470 | /* Unreached */ |
| 471 | |
| 472 | badframe: |
| 473 | force_sig(SIGSEGV, current); |
| 474 | } |
| 475 | |
| 476 | #ifdef CONFIG_TRAD_SIGNALS |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 477 | static int setup_frame(struct k_sigaction * ka, struct pt_regs *regs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | int signr, sigset_t *set) |
| 479 | { |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 480 | struct sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | int err = 0; |
| 482 | |
| 483 | frame = get_sigframe(ka, regs, sizeof(*frame)); |
| 484 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
| 485 | goto give_sigsegv; |
| 486 | |
Franck Bui-Huu | 601dde4 | 2007-02-05 15:24:23 +0100 | [diff] [blame] | 487 | err |= install_sigtramp(frame->sf_code, __NR_sigreturn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | err |= setup_sigcontext(regs, &frame->sf_sc); |
| 490 | err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set)); |
| 491 | if (err) |
| 492 | goto give_sigsegv; |
| 493 | |
| 494 | /* |
| 495 | * Arguments to signal handler: |
| 496 | * |
| 497 | * a0 = signal number |
| 498 | * a1 = 0 (should be cause) |
| 499 | * a2 = pointer to struct sigcontext |
| 500 | * |
| 501 | * $25 and c0_epc point to the signal handler, $29 points to the |
| 502 | * struct sigframe. |
| 503 | */ |
| 504 | regs->regs[ 4] = signr; |
| 505 | regs->regs[ 5] = 0; |
| 506 | regs->regs[ 6] = (unsigned long) &frame->sf_sc; |
| 507 | regs->regs[29] = (unsigned long) frame; |
| 508 | regs->regs[31] = (unsigned long) frame->sf_code; |
| 509 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; |
| 510 | |
Franck Bui-Huu | 722bb63 | 2007-02-05 15:24:24 +0100 | [diff] [blame] | 511 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | current->comm, current->pid, |
Franck Bui-Huu | 722bb63 | 2007-02-05 15:24:24 +0100 | [diff] [blame] | 513 | frame, regs->cp0_epc, regs->regs[31]); |
Ralf Baechle | e0daad4 | 2007-02-05 00:10:11 +0000 | [diff] [blame] | 514 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
| 516 | give_sigsegv: |
| 517 | force_sigsegv(signr, current); |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 518 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | } |
| 520 | #endif |
| 521 | |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 522 | static int setup_rt_frame(struct k_sigaction * ka, struct pt_regs *regs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | int signr, sigset_t *set, siginfo_t *info) |
| 524 | { |
Atsushi Nemoto | 9bbf28a3 | 2006-02-01 01:41:09 +0900 | [diff] [blame] | 525 | struct rt_sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | int err = 0; |
| 527 | |
| 528 | frame = get_sigframe(ka, regs, sizeof(*frame)); |
| 529 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
| 530 | goto give_sigsegv; |
| 531 | |
Franck Bui-Huu | 601dde4 | 2007-02-05 15:24:23 +0100 | [diff] [blame] | 532 | err |= install_sigtramp(frame->rs_code, __NR_rt_sigreturn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
| 534 | /* Create siginfo. */ |
| 535 | err |= copy_siginfo_to_user(&frame->rs_info, info); |
| 536 | |
| 537 | /* Create the ucontext. */ |
| 538 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
Atsushi Nemoto | 5665a0a | 2006-02-02 01:26:34 +0900 | [diff] [blame] | 539 | err |= __put_user(NULL, &frame->rs_uc.uc_link); |
Atsushi Nemoto | 9c6031c | 2006-02-19 23:46:44 +0900 | [diff] [blame] | 540 | err |= __put_user((void __user *)current->sas_ss_sp, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | &frame->rs_uc.uc_stack.ss_sp); |
| 542 | err |= __put_user(sas_ss_flags(regs->regs[29]), |
| 543 | &frame->rs_uc.uc_stack.ss_flags); |
| 544 | err |= __put_user(current->sas_ss_size, |
| 545 | &frame->rs_uc.uc_stack.ss_size); |
| 546 | err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext); |
| 547 | err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); |
| 548 | |
| 549 | if (err) |
| 550 | goto give_sigsegv; |
| 551 | |
| 552 | /* |
| 553 | * Arguments to signal handler: |
| 554 | * |
| 555 | * a0 = signal number |
| 556 | * a1 = 0 (should be cause) |
| 557 | * a2 = pointer to ucontext |
| 558 | * |
| 559 | * $25 and c0_epc point to the signal handler, $29 points to |
| 560 | * the struct rt_sigframe. |
| 561 | */ |
| 562 | regs->regs[ 4] = signr; |
| 563 | regs->regs[ 5] = (unsigned long) &frame->rs_info; |
| 564 | regs->regs[ 6] = (unsigned long) &frame->rs_uc; |
| 565 | regs->regs[29] = (unsigned long) frame; |
| 566 | regs->regs[31] = (unsigned long) frame->rs_code; |
| 567 | regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; |
| 568 | |
Franck Bui-Huu | 722bb63 | 2007-02-05 15:24:24 +0100 | [diff] [blame] | 569 | DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | current->comm, current->pid, |
| 571 | frame, regs->cp0_epc, regs->regs[31]); |
Franck Bui-Huu | 722bb63 | 2007-02-05 15:24:24 +0100 | [diff] [blame] | 572 | |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 573 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
| 575 | give_sigsegv: |
| 576 | force_sigsegv(signr, current); |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 577 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 580 | struct mips_abi mips_abi = { |
| 581 | #ifdef CONFIG_TRAD_SIGNALS |
| 582 | .setup_frame = setup_frame, |
| 583 | #endif |
| 584 | .setup_rt_frame = setup_rt_frame, |
| 585 | .restart = __NR_restart_syscall |
| 586 | }; |
| 587 | |
Franck Bui-Huu | e692eb3 | 2007-02-05 15:24:28 +0100 | [diff] [blame] | 588 | static int handle_signal(unsigned long sig, siginfo_t *info, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs) |
| 590 | { |
Ralf Baechle | 129bc8f | 2005-07-11 20:45:51 +0000 | [diff] [blame] | 591 | int ret; |
| 592 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | switch(regs->regs[0]) { |
| 594 | case ERESTART_RESTARTBLOCK: |
| 595 | case ERESTARTNOHAND: |
| 596 | regs->regs[2] = EINTR; |
| 597 | break; |
| 598 | case ERESTARTSYS: |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 599 | if (!(ka->sa.sa_flags & SA_RESTART)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | regs->regs[2] = EINTR; |
| 601 | break; |
| 602 | } |
| 603 | /* fallthrough */ |
| 604 | case ERESTARTNOINTR: /* Userland will reload $v0. */ |
| 605 | regs->regs[7] = regs->regs[26]; |
| 606 | regs->cp0_epc -= 8; |
| 607 | } |
| 608 | |
| 609 | regs->regs[0] = 0; /* Don't deal with this again. */ |
| 610 | |
Ralf Baechle | e50c0a8 | 2005-05-31 11:49:19 +0000 | [diff] [blame] | 611 | if (sig_uses_siginfo(ka)) |
Ralf Baechle | 129bc8f | 2005-07-11 20:45:51 +0000 | [diff] [blame] | 612 | ret = current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | else |
Ralf Baechle | 129bc8f | 2005-07-11 20:45:51 +0000 | [diff] [blame] | 614 | ret = current->thread.abi->setup_frame(ka, regs, sig, oldset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | |
Steven Rostedt | 69be8f1 | 2005-08-29 11:44:09 -0400 | [diff] [blame] | 616 | spin_lock_irq(¤t->sighand->siglock); |
| 617 | sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); |
| 618 | if (!(ka->sa.sa_flags & SA_NODEFER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | sigaddset(¤t->blocked,sig); |
Steven Rostedt | 69be8f1 | 2005-08-29 11:44:09 -0400 | [diff] [blame] | 620 | recalc_sigpending(); |
| 621 | spin_unlock_irq(¤t->sighand->siglock); |
Ralf Baechle | 129bc8f | 2005-07-11 20:45:51 +0000 | [diff] [blame] | 622 | |
| 623 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | } |
| 625 | |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 626 | static void do_signal(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | { |
| 628 | struct k_sigaction ka; |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 629 | sigset_t *oldset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | siginfo_t info; |
| 631 | int signr; |
| 632 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | /* |
| 634 | * We want the common case to go fast, which is why we may in certain |
| 635 | * cases get here from kernel mode. Just return without doing anything |
| 636 | * if so. |
| 637 | */ |
| 638 | if (!user_mode(regs)) |
Ralf Baechle | 40ac5d4 | 2006-02-08 13:38:18 +0000 | [diff] [blame] | 639 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 641 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
| 642 | oldset = ¤t->saved_sigmask; |
| 643 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | oldset = ¤t->blocked; |
| 645 | |
| 646 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 647 | if (signr > 0) { |
| 648 | /* Whee! Actually deliver the signal. */ |
| 649 | if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { |
| 650 | /* |
| 651 | * A signal was successfully delivered; the saved |
| 652 | * sigmask will have been stored in the signal frame, |
| 653 | * and will be restored by sigreturn, so we can simply |
| 654 | * clear the TIF_RESTORE_SIGMASK flag. |
| 655 | */ |
| 656 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) |
| 657 | clear_thread_flag(TIF_RESTORE_SIGMASK); |
| 658 | } |
Ralf Baechle | 45887e1 | 2006-08-03 21:54:13 +0100 | [diff] [blame] | 659 | |
| 660 | return; |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 661 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | /* |
| 664 | * Who's code doesn't conform to the restartable syscall convention |
| 665 | * dies here!!! The li instruction, a single machine instruction, |
| 666 | * must directly be followed by the syscall instruction. |
| 667 | */ |
| 668 | if (regs->regs[0]) { |
| 669 | if (regs->regs[2] == ERESTARTNOHAND || |
| 670 | regs->regs[2] == ERESTARTSYS || |
| 671 | regs->regs[2] == ERESTARTNOINTR) { |
| 672 | regs->regs[7] = regs->regs[26]; |
| 673 | regs->cp0_epc -= 8; |
| 674 | } |
| 675 | if (regs->regs[2] == ERESTART_RESTARTBLOCK) { |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 676 | regs->regs[2] = current->thread.abi->restart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | regs->regs[7] = regs->regs[26]; |
| 678 | regs->cp0_epc -= 4; |
| 679 | } |
Ralf Baechle | 13fdd31 | 2006-08-08 03:47:01 +0100 | [diff] [blame] | 680 | regs->regs[0] = 0; /* Don't deal with this again. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | } |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 682 | |
| 683 | /* |
| 684 | * If there's no signal to deliver, we just put the saved sigmask |
| 685 | * back |
| 686 | */ |
| 687 | if (test_thread_flag(TIF_RESTORE_SIGMASK)) { |
| 688 | clear_thread_flag(TIF_RESTORE_SIGMASK); |
| 689 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); |
| 690 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | /* |
| 694 | * notification of userspace execution resumption |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 695 | * - triggered by the TIF_WORK_MASK flags |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | */ |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 697 | asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | __u32 thread_info_flags) |
| 699 | { |
| 700 | /* deal with pending signal delivery */ |
Ralf Baechle | 7b3e2fc | 2006-02-08 12:58:41 +0000 | [diff] [blame] | 701 | if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 702 | do_signal(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | } |