Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/kernel/signal.c |
| 3 | * |
| 4 | * Copyright (C) 1995-2002 Russell King |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/errno.h> |
| 11 | #include <linux/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/personality.h> |
Nigel Cunningham | 7dfb710 | 2006-12-06 20:34:23 -0800 | [diff] [blame] | 13 | #include <linux/freezer.h> |
Russell King | 33fa9b1 | 2008-09-06 11:35:55 +0100 | [diff] [blame] | 14 | #include <linux/uaccess.h> |
David Howells | 733e5e4 | 2009-09-09 08:30:21 +0100 | [diff] [blame^] | 15 | #include <linux/tracehook.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Russell King | ee90dab | 2006-11-09 14:20:47 +0000 | [diff] [blame] | 17 | #include <asm/elf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/cacheflush.h> |
| 19 | #include <asm/ucontext.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/unistd.h> |
| 21 | |
| 22 | #include "ptrace.h" |
Russell King | e00d349 | 2005-06-22 20:26:05 +0100 | [diff] [blame] | 23 | #include "signal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
| 26 | |
| 27 | /* |
| 28 | * For ARM syscalls, we encode the syscall number into the instruction. |
| 29 | */ |
janboe | ee4cd58 | 2008-03-19 03:34:23 +0100 | [diff] [blame] | 30 | #define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE)) |
| 31 | #define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | /* |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 34 | * With EABI, the syscall number has to be loaded into r7. |
| 35 | */ |
| 36 | #define MOV_R7_NR_SIGRETURN (0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE)) |
| 37 | #define MOV_R7_NR_RT_SIGRETURN (0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)) |
| 38 | |
| 39 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | * For Thumb syscalls, we pass the syscall number via r7. We therefore |
| 41 | * need two 16-bit instructions. |
| 42 | */ |
| 43 | #define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE)) |
| 44 | #define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE)) |
| 45 | |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 46 | const unsigned long sigreturn_codes[7] = { |
| 47 | MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, |
| 48 | MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static int do_signal(sigset_t *oldset, struct pt_regs * regs, int syscall); |
| 52 | |
| 53 | /* |
| 54 | * atomically swap in the new signal mask, and wait for a signal. |
| 55 | */ |
| 56 | asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask, struct pt_regs *regs) |
| 57 | { |
| 58 | sigset_t saveset; |
| 59 | |
| 60 | mask &= _BLOCKABLE; |
| 61 | spin_lock_irq(¤t->sighand->siglock); |
| 62 | saveset = current->blocked; |
| 63 | siginitset(¤t->blocked, mask); |
| 64 | recalc_sigpending(); |
| 65 | spin_unlock_irq(¤t->sighand->siglock); |
| 66 | regs->ARM_r0 = -EINTR; |
| 67 | |
| 68 | while (1) { |
| 69 | current->state = TASK_INTERRUPTIBLE; |
| 70 | schedule(); |
| 71 | if (do_signal(&saveset, regs, 0)) |
| 72 | return regs->ARM_r0; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | asmlinkage int |
| 77 | sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *regs) |
| 78 | { |
| 79 | sigset_t saveset, newset; |
| 80 | |
| 81 | /* XXX: Don't preclude handling different sized sigset_t's. */ |
| 82 | if (sigsetsize != sizeof(sigset_t)) |
| 83 | return -EINVAL; |
| 84 | |
| 85 | if (copy_from_user(&newset, unewset, sizeof(newset))) |
| 86 | return -EFAULT; |
| 87 | sigdelsetmask(&newset, ~_BLOCKABLE); |
| 88 | |
| 89 | spin_lock_irq(¤t->sighand->siglock); |
| 90 | saveset = current->blocked; |
| 91 | current->blocked = newset; |
| 92 | recalc_sigpending(); |
| 93 | spin_unlock_irq(¤t->sighand->siglock); |
| 94 | regs->ARM_r0 = -EINTR; |
| 95 | |
| 96 | while (1) { |
| 97 | current->state = TASK_INTERRUPTIBLE; |
| 98 | schedule(); |
| 99 | if (do_signal(&saveset, regs, 0)) |
| 100 | return regs->ARM_r0; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | asmlinkage int |
| 105 | sys_sigaction(int sig, const struct old_sigaction __user *act, |
| 106 | struct old_sigaction __user *oact) |
| 107 | { |
| 108 | struct k_sigaction new_ka, old_ka; |
| 109 | int ret; |
| 110 | |
| 111 | if (act) { |
| 112 | old_sigset_t mask; |
| 113 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || |
| 114 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || |
| 115 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) |
| 116 | return -EFAULT; |
| 117 | __get_user(new_ka.sa.sa_flags, &act->sa_flags); |
| 118 | __get_user(mask, &act->sa_mask); |
| 119 | siginitset(&new_ka.sa.sa_mask, mask); |
| 120 | } |
| 121 | |
| 122 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
| 123 | |
| 124 | if (!ret && oact) { |
| 125 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || |
| 126 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || |
| 127 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) |
| 128 | return -EFAULT; |
| 129 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags); |
| 130 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); |
| 131 | } |
| 132 | |
| 133 | return ret; |
| 134 | } |
| 135 | |
Lennert Buytenhek | 3bec6ded | 2006-06-27 22:56:18 +0100 | [diff] [blame] | 136 | #ifdef CONFIG_CRUNCH |
Hartley Sweeten | 65a5053 | 2009-08-04 23:20:45 +0100 | [diff] [blame] | 137 | static int preserve_crunch_context(struct crunch_sigframe __user *frame) |
Lennert Buytenhek | 3bec6ded | 2006-06-27 22:56:18 +0100 | [diff] [blame] | 138 | { |
| 139 | char kbuf[sizeof(*frame) + 8]; |
| 140 | struct crunch_sigframe *kframe; |
| 141 | |
| 142 | /* the crunch context must be 64 bit aligned */ |
| 143 | kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
| 144 | kframe->magic = CRUNCH_MAGIC; |
| 145 | kframe->size = CRUNCH_STORAGE_SIZE; |
| 146 | crunch_task_copy(current_thread_info(), &kframe->storage); |
| 147 | return __copy_to_user(frame, kframe, sizeof(*frame)); |
| 148 | } |
| 149 | |
Hartley Sweeten | 65a5053 | 2009-08-04 23:20:45 +0100 | [diff] [blame] | 150 | static int restore_crunch_context(struct crunch_sigframe __user *frame) |
Lennert Buytenhek | 3bec6ded | 2006-06-27 22:56:18 +0100 | [diff] [blame] | 151 | { |
| 152 | char kbuf[sizeof(*frame) + 8]; |
| 153 | struct crunch_sigframe *kframe; |
| 154 | |
| 155 | /* the crunch context must be 64 bit aligned */ |
| 156 | kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
| 157 | if (__copy_from_user(kframe, frame, sizeof(*frame))) |
| 158 | return -1; |
| 159 | if (kframe->magic != CRUNCH_MAGIC || |
| 160 | kframe->size != CRUNCH_STORAGE_SIZE) |
| 161 | return -1; |
| 162 | crunch_task_restore(current_thread_info(), &kframe->storage); |
| 163 | return 0; |
| 164 | } |
| 165 | #endif |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | #ifdef CONFIG_IWMMXT |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame) |
| 170 | { |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 171 | char kbuf[sizeof(*frame) + 8]; |
| 172 | struct iwmmxt_sigframe *kframe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | /* the iWMMXt context must be 64 bit aligned */ |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 175 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 176 | kframe->magic = IWMMXT_MAGIC; |
| 177 | kframe->size = IWMMXT_STORAGE_SIZE; |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 178 | iwmmxt_task_copy(current_thread_info(), &kframe->storage); |
| 179 | return __copy_to_user(frame, kframe, sizeof(*frame)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) |
| 183 | { |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 184 | char kbuf[sizeof(*frame) + 8]; |
| 185 | struct iwmmxt_sigframe *kframe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 187 | /* the iWMMXt context must be 64 bit aligned */ |
| 188 | kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7); |
| 189 | if (__copy_from_user(kframe, frame, sizeof(*frame))) |
| 190 | return -1; |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 191 | if (kframe->magic != IWMMXT_MAGIC || |
| 192 | kframe->size != IWMMXT_STORAGE_SIZE) |
Hugh Dickins | 69b0475 | 2005-10-29 18:16:36 -0700 | [diff] [blame] | 193 | return -1; |
| 194 | iwmmxt_task_restore(current_thread_info(), &kframe->storage); |
| 195 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | #endif |
| 199 | |
| 200 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | * Do a signal return; undo the signal stack. These are aligned to 64-bit. |
| 202 | */ |
| 203 | struct sigframe { |
Russell King | 7d4fdc1 | 2006-06-15 20:13:25 +0100 | [diff] [blame] | 204 | struct ucontext uc; |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 205 | unsigned long retcode[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | struct rt_sigframe { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | struct siginfo info; |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 210 | struct sigframe sig; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | }; |
| 212 | |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 213 | static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | { |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 215 | struct aux_sigframe __user *aux; |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 216 | sigset_t set; |
| 217 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 219 | err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); |
| 220 | if (err == 0) { |
| 221 | sigdelsetmask(&set, ~_BLOCKABLE); |
| 222 | spin_lock_irq(¤t->sighand->siglock); |
| 223 | current->blocked = set; |
| 224 | recalc_sigpending(); |
| 225 | spin_unlock_irq(¤t->sighand->siglock); |
| 226 | } |
| 227 | |
| 228 | __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); |
| 229 | __get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); |
| 230 | __get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); |
| 231 | __get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); |
| 232 | __get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); |
| 233 | __get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); |
| 234 | __get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); |
| 235 | __get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); |
| 236 | __get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); |
| 237 | __get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); |
| 238 | __get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); |
| 239 | __get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); |
| 240 | __get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); |
| 241 | __get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); |
| 242 | __get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); |
| 243 | __get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); |
| 244 | __get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
| 246 | err |= !valid_user_regs(regs); |
| 247 | |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 248 | aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; |
Lennert Buytenhek | 3bec6ded | 2006-06-27 22:56:18 +0100 | [diff] [blame] | 249 | #ifdef CONFIG_CRUNCH |
| 250 | if (err == 0) |
| 251 | err |= restore_crunch_context(&aux->crunch); |
| 252 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | #ifdef CONFIG_IWMMXT |
| 254 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) |
| 255 | err |= restore_iwmmxt_context(&aux->iwmmxt); |
| 256 | #endif |
| 257 | #ifdef CONFIG_VFP |
| 258 | // if (err == 0) |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 259 | // err |= vfp_restore_state(&sf->aux.vfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | #endif |
| 261 | |
| 262 | return err; |
| 263 | } |
| 264 | |
| 265 | asmlinkage int sys_sigreturn(struct pt_regs *regs) |
| 266 | { |
| 267 | struct sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
| 269 | /* Always make any pending restarted system calls return -EINTR */ |
| 270 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| 271 | |
| 272 | /* |
| 273 | * Since we stacked the signal on a 64-bit boundary, |
| 274 | * then 'sp' should be word aligned here. If it's |
| 275 | * not, then the user is trying to mess with us. |
| 276 | */ |
| 277 | if (regs->ARM_sp & 7) |
| 278 | goto badframe; |
| 279 | |
| 280 | frame = (struct sigframe __user *)regs->ARM_sp; |
| 281 | |
| 282 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) |
| 283 | goto badframe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 285 | if (restore_sigframe(regs, frame)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | goto badframe; |
| 287 | |
Russell King | b2a0d36 | 2007-03-04 09:50:28 +0000 | [diff] [blame] | 288 | single_step_trap(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | return regs->ARM_r0; |
| 291 | |
| 292 | badframe: |
| 293 | force_sig(SIGSEGV, current); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) |
| 298 | { |
| 299 | struct rt_sigframe __user *frame; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | /* Always make any pending restarted system calls return -EINTR */ |
| 302 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| 303 | |
| 304 | /* |
| 305 | * Since we stacked the signal on a 64-bit boundary, |
| 306 | * then 'sp' should be word aligned here. If it's |
| 307 | * not, then the user is trying to mess with us. |
| 308 | */ |
| 309 | if (regs->ARM_sp & 7) |
| 310 | goto badframe; |
| 311 | |
| 312 | frame = (struct rt_sigframe __user *)regs->ARM_sp; |
| 313 | |
| 314 | if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) |
| 315 | goto badframe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
Russell King | 6807148 | 2006-06-15 20:23:02 +0100 | [diff] [blame] | 317 | if (restore_sigframe(regs, &frame->sig)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | goto badframe; |
| 319 | |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 320 | if (do_sigaltstack(&frame->sig.uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | goto badframe; |
| 322 | |
Russell King | b2a0d36 | 2007-03-04 09:50:28 +0000 | [diff] [blame] | 323 | single_step_trap(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
| 325 | return regs->ARM_r0; |
| 326 | |
| 327 | badframe: |
| 328 | force_sig(SIGSEGV, current); |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | static int |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 333 | setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | { |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 335 | struct aux_sigframe __user *aux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | int err = 0; |
| 337 | |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 338 | __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); |
| 339 | __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); |
| 340 | __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); |
| 341 | __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); |
| 342 | __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); |
| 343 | __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); |
| 344 | __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); |
| 345 | __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); |
| 346 | __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); |
| 347 | __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); |
| 348 | __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); |
| 349 | __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); |
| 350 | __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); |
| 351 | __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); |
| 352 | __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); |
| 353 | __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); |
| 354 | __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 356 | __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err); |
| 357 | __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err); |
| 358 | __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err); |
| 359 | __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 361 | err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 363 | aux = (struct aux_sigframe __user *) sf->uc.uc_regspace; |
Lennert Buytenhek | 3bec6ded | 2006-06-27 22:56:18 +0100 | [diff] [blame] | 364 | #ifdef CONFIG_CRUNCH |
| 365 | if (err == 0) |
| 366 | err |= preserve_crunch_context(&aux->crunch); |
| 367 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | #ifdef CONFIG_IWMMXT |
| 369 | if (err == 0 && test_thread_flag(TIF_USING_IWMMXT)) |
| 370 | err |= preserve_iwmmxt_context(&aux->iwmmxt); |
| 371 | #endif |
| 372 | #ifdef CONFIG_VFP |
| 373 | // if (err == 0) |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 374 | // err |= vfp_save_state(&sf->aux.vfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | #endif |
Daniel Jacobowitz | 85fe068 | 2006-06-24 23:46:21 +0100 | [diff] [blame] | 376 | __put_user_error(0, &aux->end_magic, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
| 378 | return err; |
| 379 | } |
| 380 | |
| 381 | static inline void __user * |
| 382 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize) |
| 383 | { |
| 384 | unsigned long sp = regs->ARM_sp; |
| 385 | void __user *frame; |
| 386 | |
| 387 | /* |
| 388 | * This is the X/Open sanctioned signal stack switching. |
| 389 | */ |
| 390 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) |
| 391 | sp = current->sas_ss_sp + current->sas_ss_size; |
| 392 | |
| 393 | /* |
| 394 | * ATPCS B01 mandates 8-byte alignment |
| 395 | */ |
| 396 | frame = (void __user *)((sp - framesize) & ~7); |
| 397 | |
| 398 | /* |
| 399 | * Check that we can actually write to the signal frame. |
| 400 | */ |
| 401 | if (!access_ok(VERIFY_WRITE, frame, framesize)) |
| 402 | frame = NULL; |
| 403 | |
| 404 | return frame; |
| 405 | } |
| 406 | |
| 407 | static int |
| 408 | setup_return(struct pt_regs *regs, struct k_sigaction *ka, |
| 409 | unsigned long __user *rc, void __user *frame, int usig) |
| 410 | { |
| 411 | unsigned long handler = (unsigned long)ka->sa.sa_handler; |
| 412 | unsigned long retcode; |
| 413 | int thumb = 0; |
| 414 | unsigned long cpsr = regs->ARM_cpsr & ~PSR_f; |
| 415 | |
| 416 | /* |
| 417 | * Maybe we need to deliver a 32-bit signal to a 26-bit task. |
| 418 | */ |
| 419 | if (ka->sa.sa_flags & SA_THIRTYTWO) |
| 420 | cpsr = (cpsr & ~MODE_MASK) | USR_MODE; |
| 421 | |
| 422 | #ifdef CONFIG_ARM_THUMB |
| 423 | if (elf_hwcap & HWCAP_THUMB) { |
| 424 | /* |
| 425 | * The LSB of the handler determines if we're going to |
| 426 | * be using THUMB or ARM mode for this signal handler. |
| 427 | */ |
| 428 | thumb = handler & 1; |
| 429 | |
Catalin Marinas | d71e135 | 2009-05-30 14:00:15 +0100 | [diff] [blame] | 430 | if (thumb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | cpsr |= PSR_T_BIT; |
Catalin Marinas | d71e135 | 2009-05-30 14:00:15 +0100 | [diff] [blame] | 432 | #if __LINUX_ARM_ARCH__ >= 7 |
| 433 | /* clear the If-Then Thumb-2 execution state */ |
| 434 | cpsr &= ~PSR_IT_MASK; |
| 435 | #endif |
| 436 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | cpsr &= ~PSR_T_BIT; |
| 438 | } |
| 439 | #endif |
| 440 | |
| 441 | if (ka->sa.sa_flags & SA_RESTORER) { |
| 442 | retcode = (unsigned long)ka->sa.sa_restorer; |
| 443 | } else { |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 444 | unsigned int idx = thumb << 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
| 446 | if (ka->sa.sa_flags & SA_SIGINFO) |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 447 | idx += 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 449 | if (__put_user(sigreturn_codes[idx], rc) || |
| 450 | __put_user(sigreturn_codes[idx+1], rc+1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | return 1; |
| 452 | |
Russell King | e00d349 | 2005-06-22 20:26:05 +0100 | [diff] [blame] | 453 | if (cpsr & MODE32_BIT) { |
| 454 | /* |
| 455 | * 32-bit code can use the new high-page |
| 456 | * signal return code support. |
| 457 | */ |
| 458 | retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb; |
| 459 | } else { |
| 460 | /* |
| 461 | * Ensure that the instruction cache sees |
| 462 | * the return code written onto the stack. |
| 463 | */ |
| 464 | flush_icache_range((unsigned long)rc, |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 465 | (unsigned long)(rc + 2)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Russell King | e00d349 | 2005-06-22 20:26:05 +0100 | [diff] [blame] | 467 | retcode = ((unsigned long)rc) + thumb; |
| 468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | regs->ARM_r0 = usig; |
| 472 | regs->ARM_sp = (unsigned long)frame; |
| 473 | regs->ARM_lr = retcode; |
| 474 | regs->ARM_pc = handler; |
| 475 | regs->ARM_cpsr = cpsr; |
| 476 | |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | static int |
| 481 | setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *regs) |
| 482 | { |
| 483 | struct sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame)); |
| 484 | int err = 0; |
| 485 | |
| 486 | if (!frame) |
| 487 | return 1; |
| 488 | |
Russell King | ca195cf | 2006-06-24 22:41:09 +0100 | [diff] [blame] | 489 | /* |
| 490 | * Set uc.uc_flags to a value which sc.trap_no would never have. |
| 491 | */ |
| 492 | __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 494 | err |= setup_sigframe(frame, regs, set); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | if (err == 0) |
Nicolas Pitre | fcca538 | 2006-01-18 22:38:47 +0000 | [diff] [blame] | 496 | err = setup_return(regs, ka, frame->retcode, frame, usig); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
| 498 | return err; |
| 499 | } |
| 500 | |
| 501 | static int |
| 502 | setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, |
| 503 | sigset_t *set, struct pt_regs *regs) |
| 504 | { |
| 505 | struct rt_sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame)); |
| 506 | stack_t stack; |
| 507 | int err = 0; |
| 508 | |
| 509 | if (!frame) |
| 510 | return 1; |
| 511 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | err |= copy_siginfo_to_user(&frame->info, info); |
| 513 | |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 514 | __put_user_error(0, &frame->sig.uc.uc_flags, err); |
| 515 | __put_user_error(NULL, &frame->sig.uc.uc_link, err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
| 517 | memset(&stack, 0, sizeof(stack)); |
| 518 | stack.ss_sp = (void __user *)current->sas_ss_sp; |
| 519 | stack.ss_flags = sas_ss_flags(regs->ARM_sp); |
| 520 | stack.ss_size = current->sas_ss_size; |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 521 | err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
Russell King | aca6ca1 | 2006-06-15 20:28:03 +0100 | [diff] [blame] | 523 | err |= setup_sigframe(&frame->sig, regs, set); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | if (err == 0) |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 525 | err = setup_return(regs, ka, frame->sig.retcode, frame, usig); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | |
| 527 | if (err == 0) { |
| 528 | /* |
| 529 | * For realtime signals we must also set the second and third |
| 530 | * arguments for the signal handler. |
| 531 | * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06 |
| 532 | */ |
| 533 | regs->ARM_r1 = (unsigned long)&frame->info; |
Russell King | cb3504e | 2006-06-15 20:18:25 +0100 | [diff] [blame] | 534 | regs->ARM_r2 = (unsigned long)&frame->sig.uc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | return err; |
| 538 | } |
| 539 | |
Eric W. Biederman | 288ddad | 2009-05-20 15:52:40 -0700 | [diff] [blame] | 540 | static inline void setup_syscall_restart(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | { |
| 542 | regs->ARM_r0 = regs->ARM_ORIG_r0; |
| 543 | regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; |
| 544 | } |
| 545 | |
| 546 | /* |
| 547 | * OK, we're invoking a handler |
| 548 | */ |
| 549 | static void |
| 550 | handle_signal(unsigned long sig, struct k_sigaction *ka, |
| 551 | siginfo_t *info, sigset_t *oldset, |
| 552 | struct pt_regs * regs, int syscall) |
| 553 | { |
| 554 | struct thread_info *thread = current_thread_info(); |
| 555 | struct task_struct *tsk = current; |
| 556 | int usig = sig; |
| 557 | int ret; |
| 558 | |
| 559 | /* |
| 560 | * If we were from a system call, check for system call restarting... |
| 561 | */ |
| 562 | if (syscall) { |
| 563 | switch (regs->ARM_r0) { |
| 564 | case -ERESTART_RESTARTBLOCK: |
| 565 | case -ERESTARTNOHAND: |
| 566 | regs->ARM_r0 = -EINTR; |
| 567 | break; |
| 568 | case -ERESTARTSYS: |
| 569 | if (!(ka->sa.sa_flags & SA_RESTART)) { |
| 570 | regs->ARM_r0 = -EINTR; |
| 571 | break; |
| 572 | } |
| 573 | /* fallthrough */ |
| 574 | case -ERESTARTNOINTR: |
Eric W. Biederman | 288ddad | 2009-05-20 15:52:40 -0700 | [diff] [blame] | 575 | setup_syscall_restart(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | } |
| 577 | } |
| 578 | |
| 579 | /* |
| 580 | * translate the signal |
| 581 | */ |
| 582 | if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap) |
| 583 | usig = thread->exec_domain->signal_invmap[usig]; |
| 584 | |
| 585 | /* |
| 586 | * Set up the stack frame |
| 587 | */ |
| 588 | if (ka->sa.sa_flags & SA_SIGINFO) |
| 589 | ret = setup_rt_frame(usig, ka, info, oldset, regs); |
| 590 | else |
| 591 | ret = setup_frame(usig, ka, oldset, regs); |
| 592 | |
| 593 | /* |
| 594 | * Check that the resulting registers are actually sane. |
| 595 | */ |
| 596 | ret |= !valid_user_regs(regs); |
| 597 | |
Steven Rostedt | 69be8f1 | 2005-08-29 11:44:09 -0400 | [diff] [blame] | 598 | if (ret != 0) { |
Daniel Jacobowitz | a6c61e9 | 2005-11-19 10:01:07 +0000 | [diff] [blame] | 599 | force_sigsegv(sig, tsk); |
| 600 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Daniel Jacobowitz | a6c61e9 | 2005-11-19 10:01:07 +0000 | [diff] [blame] | 603 | /* |
| 604 | * Block the signal if we were successful. |
| 605 | */ |
| 606 | spin_lock_irq(&tsk->sighand->siglock); |
| 607 | sigorsets(&tsk->blocked, &tsk->blocked, |
| 608 | &ka->sa.sa_mask); |
| 609 | if (!(ka->sa.sa_flags & SA_NODEFER)) |
| 610 | sigaddset(&tsk->blocked, sig); |
| 611 | recalc_sigpending(); |
| 612 | spin_unlock_irq(&tsk->sighand->siglock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | /* |
| 617 | * Note that 'init' is a special process: it doesn't get signals it doesn't |
| 618 | * want to handle. Thus you cannot kill init even with a SIGKILL even by |
| 619 | * mistake. |
| 620 | * |
| 621 | * Note that we go through the signals twice: once to check the signals that |
| 622 | * the kernel can handle, and then we build all the user-level signal handling |
| 623 | * stack-frames in one go after that. |
| 624 | */ |
| 625 | static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall) |
| 626 | { |
| 627 | struct k_sigaction ka; |
| 628 | siginfo_t info; |
| 629 | int signr; |
| 630 | |
| 631 | /* |
| 632 | * We want the common case to go fast, which |
| 633 | * is why we may in certain cases get here from |
| 634 | * kernel mode. Just return without doing anything |
| 635 | * if so. |
| 636 | */ |
| 637 | if (!user_mode(regs)) |
| 638 | return 0; |
| 639 | |
Andrew Morton | bdb94f3 | 2005-06-26 03:27:21 -0700 | [diff] [blame] | 640 | if (try_to_freeze()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | goto no_signal; |
| 642 | |
Russell King | b2a0d36 | 2007-03-04 09:50:28 +0000 | [diff] [blame] | 643 | single_step_clear(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
| 645 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
| 646 | if (signr > 0) { |
| 647 | handle_signal(signr, &ka, &info, oldset, regs, syscall); |
Russell King | b2a0d36 | 2007-03-04 09:50:28 +0000 | [diff] [blame] | 648 | single_step_set(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | return 1; |
| 650 | } |
| 651 | |
| 652 | no_signal: |
| 653 | /* |
| 654 | * No signal to deliver to the process - restart the syscall. |
| 655 | */ |
| 656 | if (syscall) { |
| 657 | if (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) { |
| 658 | if (thumb_mode(regs)) { |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 659 | regs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | regs->ARM_pc -= 2; |
| 661 | } else { |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 662 | #if defined(CONFIG_AEABI) && !defined(CONFIG_OABI_COMPAT) |
| 663 | regs->ARM_r7 = __NR_restart_syscall; |
| 664 | regs->ARM_pc -= 4; |
| 665 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | u32 __user *usp; |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 667 | u32 swival = __NR_restart_syscall; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | |
| 669 | regs->ARM_sp -= 12; |
| 670 | usp = (u32 __user *)regs->ARM_sp; |
| 671 | |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 672 | /* |
| 673 | * Either we supports OABI only, or we have |
| 674 | * EABI with the OABI compat layer enabled. |
| 675 | * In the later case we don't know if user |
| 676 | * space is EABI or not, and if not we must |
| 677 | * not clobber r7. Always using the OABI |
| 678 | * syscall solves that issue and works for |
| 679 | * all those cases. |
| 680 | */ |
Nicolas Pitre | 95eaa5f | 2006-06-23 11:40:53 -0400 | [diff] [blame] | 681 | swival = swival - __NR_SYSCALL_BASE + __NR_OABI_SYSCALL_BASE; |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 682 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | put_user(regs->ARM_pc, &usp[0]); |
| 684 | /* swi __NR_restart_syscall */ |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 685 | put_user(0xef000000 | swival, &usp[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | /* ldr pc, [sp], #12 */ |
| 687 | put_user(0xe49df00c, &usp[2]); |
| 688 | |
| 689 | flush_icache_range((unsigned long)usp, |
| 690 | (unsigned long)(usp + 3)); |
| 691 | |
| 692 | regs->ARM_pc = regs->ARM_sp + 4; |
Nicolas Pitre | f606a6f | 2006-06-22 22:18:45 +0100 | [diff] [blame] | 693 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | } |
| 695 | } |
| 696 | if (regs->ARM_r0 == -ERESTARTNOHAND || |
| 697 | regs->ARM_r0 == -ERESTARTSYS || |
| 698 | regs->ARM_r0 == -ERESTARTNOINTR) { |
Eric W. Biederman | 288ddad | 2009-05-20 15:52:40 -0700 | [diff] [blame] | 699 | setup_syscall_restart(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | } |
Russell King | b2a0d36 | 2007-03-04 09:50:28 +0000 | [diff] [blame] | 702 | single_step_set(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | asmlinkage void |
| 707 | do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall) |
| 708 | { |
| 709 | if (thread_flags & _TIF_SIGPENDING) |
| 710 | do_signal(¤t->blocked, regs, syscall); |
David Howells | d0420c8 | 2009-09-02 09:14:16 +0100 | [diff] [blame] | 711 | |
| 712 | if (thread_flags & _TIF_NOTIFY_RESUME) { |
| 713 | clear_thread_flag(TIF_NOTIFY_RESUME); |
| 714 | tracehook_notify_resume(regs); |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 715 | if (current->replacement_session_keyring) |
| 716 | key_replace_session_keyring(); |
David Howells | d0420c8 | 2009-09-02 09:14:16 +0100 | [diff] [blame] | 717 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | } |