Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1991, 1992 Linus Torvalds |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson |
| 6 | * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 7 | * 2000-2002 x86-64 support by Andi Kleen |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 9 | #include <linux/sched.h> |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 10 | #include <linux/mm.h> |
Hiroshi Shimamoto | 5c9b3a0 | 2008-11-21 17:36:41 -0800 | [diff] [blame] | 11 | #include <linux/smp.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/signal.h> |
| 14 | #include <linux/errno.h> |
| 15 | #include <linux/wait.h> |
| 16 | #include <linux/ptrace.h> |
| 17 | #include <linux/tracehook.h> |
| 18 | #include <linux/unistd.h> |
| 19 | #include <linux/stddef.h> |
| 20 | #include <linux/personality.h> |
| 21 | #include <linux/uaccess.h> |
Avi Kivity | 7c68af6 | 2009-09-19 09:40:22 +0300 | [diff] [blame] | 22 | #include <linux/user-return-notifier.h> |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <asm/processor.h> |
| 25 | #include <asm/ucontext.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/i387.h> |
Linus Torvalds | 1361b83 | 2012-02-21 13:19:22 -0800 | [diff] [blame] | 27 | #include <asm/fpu-internal.h> |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 28 | #include <asm/vdso.h> |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 29 | #include <asm/mce.h> |
Hiroshi Shimamoto | 5c9b3a0 | 2008-11-21 17:36:41 -0800 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_X86_64 |
| 32 | #include <asm/proto.h> |
| 33 | #include <asm/ia32_unistd.h> |
Hiroshi Shimamoto | 5c9b3a0 | 2008-11-21 17:36:41 -0800 | [diff] [blame] | 34 | #endif /* CONFIG_X86_64 */ |
| 35 | |
Hiroshi Shimamoto | bb57925 | 2008-09-05 16:26:55 -0700 | [diff] [blame] | 36 | #include <asm/syscall.h> |
Jaswinder Singh | bbc1f69 | 2008-07-21 21:34:13 +0530 | [diff] [blame] | 37 | #include <asm/syscalls.h> |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 38 | |
Hiroshi Shimamoto | 41af86f | 2008-12-17 18:50:32 -0800 | [diff] [blame] | 39 | #include <asm/sigframe.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
| 42 | |
Harvey Harrison | 1a17680 | 2008-02-08 12:09:59 -0800 | [diff] [blame] | 43 | #define __FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | \ |
| 44 | X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \ |
| 45 | X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \ |
| 46 | X86_EFLAGS_CF) |
| 47 | |
| 48 | #ifdef CONFIG_X86_32 |
| 49 | # define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF) |
| 50 | #else |
| 51 | # define FIX_EFLAGS __FIX_EFLAGS |
| 52 | #endif |
| 53 | |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 54 | #define COPY(x) do { \ |
| 55 | get_user_ex(regs->x, &sc->x); \ |
| 56 | } while (0) |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 57 | |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 58 | #define GET_SEG(seg) ({ \ |
| 59 | unsigned short tmp; \ |
| 60 | get_user_ex(tmp, &sc->seg); \ |
| 61 | tmp; \ |
| 62 | }) |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 63 | |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 64 | #define COPY_SEG(seg) do { \ |
| 65 | regs->seg = GET_SEG(seg); \ |
| 66 | } while (0) |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 67 | |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 68 | #define COPY_SEG_CPL3(seg) do { \ |
| 69 | regs->seg = GET_SEG(seg) | 3; \ |
| 70 | } while (0) |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 71 | |
| 72 | static int |
| 73 | restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, |
| 74 | unsigned long *pax) |
| 75 | { |
| 76 | void __user *buf; |
| 77 | unsigned int tmpflags; |
| 78 | unsigned int err = 0; |
| 79 | |
| 80 | /* Always make any pending restarted system calls return -EINTR */ |
| 81 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
| 82 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 83 | get_user_try { |
| 84 | |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 85 | #ifdef CONFIG_X86_32 |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 86 | set_user_gs(regs, GET_SEG(gs)); |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 87 | COPY_SEG(fs); |
| 88 | COPY_SEG(es); |
| 89 | COPY_SEG(ds); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 90 | #endif /* CONFIG_X86_32 */ |
| 91 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 92 | COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); |
| 93 | COPY(dx); COPY(cx); COPY(ip); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 94 | |
| 95 | #ifdef CONFIG_X86_64 |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 96 | COPY(r8); |
| 97 | COPY(r9); |
| 98 | COPY(r10); |
| 99 | COPY(r11); |
| 100 | COPY(r12); |
| 101 | COPY(r13); |
| 102 | COPY(r14); |
| 103 | COPY(r15); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 104 | #endif /* CONFIG_X86_64 */ |
| 105 | |
| 106 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 107 | COPY_SEG_CPL3(cs); |
| 108 | COPY_SEG_CPL3(ss); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 109 | #else /* !CONFIG_X86_32 */ |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 110 | /* Kernel saves and restores only the CS segment register on signals, |
| 111 | * which is the bare minimum needed to allow mixed 32/64-bit code. |
| 112 | * App's signal handler can save/restore other segments if needed. */ |
| 113 | COPY_SEG_CPL3(cs); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 114 | #endif /* CONFIG_X86_32 */ |
| 115 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 116 | get_user_ex(tmpflags, &sc->flags); |
| 117 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); |
| 118 | regs->orig_ax = -1; /* disable syscall checks */ |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 119 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 120 | get_user_ex(buf, &sc->fpstate); |
| 121 | err |= restore_i387_xstate(buf); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 122 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 123 | get_user_ex(*pax, &sc->ax); |
| 124 | } get_user_catch(err); |
| 125 | |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 126 | return err; |
| 127 | } |
| 128 | |
| 129 | static int |
| 130 | setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, |
| 131 | struct pt_regs *regs, unsigned long mask) |
| 132 | { |
| 133 | int err = 0; |
| 134 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 135 | put_user_try { |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 136 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 137 | #ifdef CONFIG_X86_32 |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 138 | put_user_ex(get_user_gs(regs), (unsigned int __user *)&sc->gs); |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 139 | put_user_ex(regs->fs, (unsigned int __user *)&sc->fs); |
| 140 | put_user_ex(regs->es, (unsigned int __user *)&sc->es); |
| 141 | put_user_ex(regs->ds, (unsigned int __user *)&sc->ds); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 142 | #endif /* CONFIG_X86_32 */ |
| 143 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 144 | put_user_ex(regs->di, &sc->di); |
| 145 | put_user_ex(regs->si, &sc->si); |
| 146 | put_user_ex(regs->bp, &sc->bp); |
| 147 | put_user_ex(regs->sp, &sc->sp); |
| 148 | put_user_ex(regs->bx, &sc->bx); |
| 149 | put_user_ex(regs->dx, &sc->dx); |
| 150 | put_user_ex(regs->cx, &sc->cx); |
| 151 | put_user_ex(regs->ax, &sc->ax); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 152 | #ifdef CONFIG_X86_64 |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 153 | put_user_ex(regs->r8, &sc->r8); |
| 154 | put_user_ex(regs->r9, &sc->r9); |
| 155 | put_user_ex(regs->r10, &sc->r10); |
| 156 | put_user_ex(regs->r11, &sc->r11); |
| 157 | put_user_ex(regs->r12, &sc->r12); |
| 158 | put_user_ex(regs->r13, &sc->r13); |
| 159 | put_user_ex(regs->r14, &sc->r14); |
| 160 | put_user_ex(regs->r15, &sc->r15); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 161 | #endif /* CONFIG_X86_64 */ |
| 162 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 163 | put_user_ex(current->thread.trap_no, &sc->trapno); |
| 164 | put_user_ex(current->thread.error_code, &sc->err); |
| 165 | put_user_ex(regs->ip, &sc->ip); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 166 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 167 | put_user_ex(regs->cs, (unsigned int __user *)&sc->cs); |
| 168 | put_user_ex(regs->flags, &sc->flags); |
| 169 | put_user_ex(regs->sp, &sc->sp_at_signal); |
| 170 | put_user_ex(regs->ss, (unsigned int __user *)&sc->ss); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 171 | #else /* !CONFIG_X86_32 */ |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 172 | put_user_ex(regs->flags, &sc->flags); |
| 173 | put_user_ex(regs->cs, &sc->cs); |
| 174 | put_user_ex(0, &sc->gs); |
| 175 | put_user_ex(0, &sc->fs); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 176 | #endif /* CONFIG_X86_32 */ |
| 177 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 178 | put_user_ex(fpstate, &sc->fpstate); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 179 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 180 | /* non-iBCS2 extensions.. */ |
| 181 | put_user_ex(mask, &sc->oldmask); |
| 182 | put_user_ex(current->thread.cr2, &sc->cr2); |
| 183 | } put_user_catch(err); |
Hiroshi Shimamoto | 2601657 | 2008-11-24 18:21:37 -0800 | [diff] [blame] | 184 | |
| 185 | return err; |
| 186 | } |
| 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | * Set up a signal frame. |
| 190 | */ |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 191 | |
| 192 | /* |
| 193 | * Determine which stack to use.. |
| 194 | */ |
Hiroshi Shimamoto | 1fae027 | 2009-02-27 10:30:32 -0800 | [diff] [blame] | 195 | static unsigned long align_sigframe(unsigned long sp) |
| 196 | { |
| 197 | #ifdef CONFIG_X86_32 |
| 198 | /* |
| 199 | * Align the stack pointer according to the i386 ABI, |
| 200 | * i.e. so that on function entry ((sp + 4) & 15) == 0. |
| 201 | */ |
| 202 | sp = ((sp + 4) & -16ul) - 4; |
| 203 | #else /* !CONFIG_X86_32 */ |
| 204 | sp = round_down(sp, 16) - 8; |
| 205 | #endif |
| 206 | return sp; |
| 207 | } |
| 208 | |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 209 | static inline void __user * |
| 210 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size, |
| 211 | void __user **fpstate) |
| 212 | { |
| 213 | /* Default to using normal stack */ |
| 214 | unsigned long sp = regs->sp; |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 215 | int onsigstack = on_sig_stack(sp); |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 216 | |
| 217 | #ifdef CONFIG_X86_64 |
| 218 | /* redzone */ |
| 219 | sp -= 128; |
| 220 | #endif /* CONFIG_X86_64 */ |
| 221 | |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 222 | if (!onsigstack) { |
| 223 | /* This is the X/Open sanctioned signal stack switching. */ |
| 224 | if (ka->sa.sa_flags & SA_ONSTACK) { |
Hiroshi Shimamoto | 0f8f308 | 2009-03-26 10:03:08 -0700 | [diff] [blame] | 225 | if (current->sas_ss_size) |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 226 | sp = current->sas_ss_sp + current->sas_ss_size; |
| 227 | } else { |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 228 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 229 | /* This is the legacy signal stack switching. */ |
| 230 | if ((regs->ss & 0xffff) != __USER_DS && |
| 231 | !(ka->sa.sa_flags & SA_RESTORER) && |
| 232 | ka->sa.sa_restorer) |
| 233 | sp = (unsigned long) ka->sa.sa_restorer; |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 234 | #endif /* CONFIG_X86_32 */ |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 235 | } |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | if (used_math()) { |
| 239 | sp -= sig_xstate_size; |
Hiroshi Shimamoto | 2505170 | 2009-03-02 17:20:01 -0800 | [diff] [blame] | 240 | #ifdef CONFIG_X86_64 |
| 241 | sp = round_down(sp, 64); |
| 242 | #endif /* CONFIG_X86_64 */ |
| 243 | *fpstate = (void __user *)sp; |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Hiroshi Shimamoto | 14fc9fb | 2009-03-19 10:56:29 -0700 | [diff] [blame] | 246 | sp = align_sigframe(sp - frame_size); |
| 247 | |
| 248 | /* |
| 249 | * If we are on the alternate signal stack and would overflow it, don't. |
| 250 | * Return an always-bogus address instead so we will die with SIGSEGV. |
| 251 | */ |
| 252 | if (onsigstack && !likely(on_sig_stack(sp))) |
| 253 | return (void __user *)-1L; |
| 254 | |
| 255 | /* save i387 state */ |
| 256 | if (used_math() && save_i387_xstate(*fpstate) < 0) |
| 257 | return (void __user *)-1L; |
| 258 | |
| 259 | return (void __user *)sp; |
Hiroshi Shimamoto | 75779f0 | 2009-02-27 10:29:57 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 262 | #ifdef CONFIG_X86_32 |
| 263 | static const struct { |
| 264 | u16 poplmovl; |
| 265 | u32 val; |
| 266 | u16 int80; |
| 267 | } __attribute__((packed)) retcode = { |
| 268 | 0xb858, /* popl %eax; movl $..., %eax */ |
| 269 | __NR_sigreturn, |
| 270 | 0x80cd, /* int $0x80 */ |
| 271 | }; |
| 272 | |
| 273 | static const struct { |
| 274 | u8 movl; |
| 275 | u32 val; |
| 276 | u16 int80; |
| 277 | u8 pad; |
| 278 | } __attribute__((packed)) rt_retcode = { |
| 279 | 0xb8, /* movl $..., %eax */ |
| 280 | __NR_rt_sigreturn, |
| 281 | 0x80cd, /* int $0x80 */ |
| 282 | 0 |
| 283 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 285 | static int |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 286 | __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, |
| 287 | struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | struct sigframe __user *frame; |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 290 | void __user *restorer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | int err = 0; |
Suresh Siddha | ab51370 | 2008-07-29 10:29:22 -0700 | [diff] [blame] | 292 | void __user *fpstate = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
Suresh Siddha | 3c1c7f1 | 2008-07-29 10:29:21 -0700 | [diff] [blame] | 294 | frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
| 296 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 297 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
Hiroshi Shimamoto | 2ba48e1 | 2008-09-12 17:02:53 -0700 | [diff] [blame] | 299 | if (__put_user(sig, &frame->sig)) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 300 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
Hiroshi Shimamoto | 2ba48e1 | 2008-09-12 17:02:53 -0700 | [diff] [blame] | 302 | if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0])) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 303 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
| 305 | if (_NSIG_WORDS > 1) { |
Hiroshi Shimamoto | 2ba48e1 | 2008-09-12 17:02:53 -0700 | [diff] [blame] | 306 | if (__copy_to_user(&frame->extramask, &set->sig[1], |
| 307 | sizeof(frame->extramask))) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 308 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Roland McGrath | 1a3e4ca | 2008-04-09 01:29:27 -0700 | [diff] [blame] | 311 | if (current->mm->context.vdso) |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 312 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn); |
Andi Kleen | 9fbbd4d | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 313 | else |
Jan Engelhardt | ade1af7 | 2008-01-30 13:33:23 +0100 | [diff] [blame] | 314 | restorer = &frame->retcode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | if (ka->sa.sa_flags & SA_RESTORER) |
| 316 | restorer = ka->sa.sa_restorer; |
| 317 | |
| 318 | /* Set up to return from userspace. */ |
| 319 | err |= __put_user(restorer, &frame->pretcode); |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | /* |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 322 | * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | * |
| 324 | * WE DO NOT USE IT ANY MORE! It's only left here for historical |
| 325 | * reasons and because gdb uses it as a signature to notice |
| 326 | * signal handler stack frames. |
| 327 | */ |
Hiroshi Shimamoto | 4a61204 | 2008-11-11 19:09:29 -0800 | [diff] [blame] | 328 | err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
| 330 | if (err) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 331 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | /* Set up registers for signal handler */ |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 334 | regs->sp = (unsigned long)frame; |
| 335 | regs->ip = (unsigned long)ka->sa.sa_handler; |
| 336 | regs->ax = (unsigned long)sig; |
Harvey Harrison | 92bc205 | 2008-02-08 12:09:56 -0800 | [diff] [blame] | 337 | regs->dx = 0; |
| 338 | regs->cx = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 340 | regs->ds = __USER_DS; |
| 341 | regs->es = __USER_DS; |
| 342 | regs->ss = __USER_DS; |
| 343 | regs->cs = __USER_CS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 345 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 348 | static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
| 349 | sigset_t *set, struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | struct rt_sigframe __user *frame; |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 352 | void __user *restorer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | int err = 0; |
Suresh Siddha | ab51370 | 2008-07-29 10:29:22 -0700 | [diff] [blame] | 354 | void __user *fpstate = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Suresh Siddha | 3c1c7f1 | 2008-07-29 10:29:21 -0700 | [diff] [blame] | 356 | frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
| 358 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 359 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 361 | put_user_try { |
| 362 | put_user_ex(sig, &frame->sig); |
| 363 | put_user_ex(&frame->info, &frame->pinfo); |
| 364 | put_user_ex(&frame->uc, &frame->puc); |
| 365 | err |= copy_siginfo_to_user(&frame->info, info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 367 | /* Create the ucontext. */ |
| 368 | if (cpu_has_xsave) |
| 369 | put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags); |
| 370 | else |
| 371 | put_user_ex(0, &frame->uc.uc_flags); |
| 372 | put_user_ex(0, &frame->uc.uc_link); |
| 373 | put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
| 374 | put_user_ex(sas_ss_flags(regs->sp), |
| 375 | &frame->uc.uc_stack.ss_flags); |
| 376 | put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size); |
| 377 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate, |
| 378 | regs, set->sig[0]); |
| 379 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 381 | /* Set up to return from userspace. */ |
| 382 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); |
| 383 | if (ka->sa.sa_flags & SA_RESTORER) |
| 384 | restorer = ka->sa.sa_restorer; |
| 385 | put_user_ex(restorer, &frame->pretcode); |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 386 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 387 | /* |
| 388 | * This is movl $__NR_rt_sigreturn, %ax ; int $0x80 |
| 389 | * |
| 390 | * WE DO NOT USE IT ANY MORE! It's only left here for historical |
| 391 | * reasons and because gdb uses it as a signature to notice |
| 392 | * signal handler stack frames. |
| 393 | */ |
| 394 | put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode); |
| 395 | } put_user_catch(err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
| 397 | if (err) |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 398 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
| 400 | /* Set up registers for signal handler */ |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 401 | regs->sp = (unsigned long)frame; |
| 402 | regs->ip = (unsigned long)ka->sa.sa_handler; |
Hiroshi Shimamoto | 13ad772 | 2008-09-05 16:28:38 -0700 | [diff] [blame] | 403 | regs->ax = (unsigned long)sig; |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 404 | regs->dx = (unsigned long)&frame->info; |
| 405 | regs->cx = (unsigned long)&frame->uc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 407 | regs->ds = __USER_DS; |
| 408 | regs->es = __USER_DS; |
| 409 | regs->ss = __USER_DS; |
| 410 | regs->cs = __USER_CS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 412 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 414 | #else /* !CONFIG_X86_32 */ |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 415 | static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
| 416 | sigset_t *set, struct pt_regs *regs) |
| 417 | { |
| 418 | struct rt_sigframe __user *frame; |
| 419 | void __user *fp = NULL; |
| 420 | int err = 0; |
| 421 | struct task_struct *me = current; |
| 422 | |
Hiroshi Shimamoto | 97286a2 | 2009-02-27 10:28:48 -0800 | [diff] [blame] | 423 | frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 424 | |
| 425 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
| 426 | return -EFAULT; |
| 427 | |
| 428 | if (ka->sa.sa_flags & SA_SIGINFO) { |
| 429 | if (copy_siginfo_to_user(&frame->info, info)) |
| 430 | return -EFAULT; |
| 431 | } |
| 432 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 433 | put_user_try { |
| 434 | /* Create the ucontext. */ |
| 435 | if (cpu_has_xsave) |
| 436 | put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags); |
| 437 | else |
| 438 | put_user_ex(0, &frame->uc.uc_flags); |
| 439 | put_user_ex(0, &frame->uc.uc_link); |
| 440 | put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
| 441 | put_user_ex(sas_ss_flags(regs->sp), |
| 442 | &frame->uc.uc_stack.ss_flags); |
| 443 | put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size); |
| 444 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]); |
| 445 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 446 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 447 | /* Set up to return from userspace. If provided, use a stub |
| 448 | already in userspace. */ |
| 449 | /* x86-64 should always use SA_RESTORER. */ |
| 450 | if (ka->sa.sa_flags & SA_RESTORER) { |
| 451 | put_user_ex(ka->sa.sa_restorer, &frame->pretcode); |
| 452 | } else { |
| 453 | /* could use a vstub here */ |
| 454 | err |= -EFAULT; |
| 455 | } |
| 456 | } put_user_catch(err); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 457 | |
| 458 | if (err) |
| 459 | return -EFAULT; |
| 460 | |
| 461 | /* Set up registers for signal handler */ |
| 462 | regs->di = sig; |
| 463 | /* In case the signal handler was declared without prototypes */ |
| 464 | regs->ax = 0; |
| 465 | |
| 466 | /* This also works for non SA_SIGINFO handlers because they expect the |
| 467 | next argument after the signal number on the stack. */ |
| 468 | regs->si = (unsigned long)&frame->info; |
| 469 | regs->dx = (unsigned long)&frame->uc; |
| 470 | regs->ip = (unsigned long) ka->sa.sa_handler; |
| 471 | |
| 472 | regs->sp = (unsigned long)frame; |
| 473 | |
| 474 | /* Set up the CS register to run signal handlers in 64-bit mode, |
| 475 | even if the handler happens to be interrupting 32-bit code. */ |
| 476 | regs->cs = __USER_CS; |
| 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | #endif /* CONFIG_X86_32 */ |
| 481 | |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 482 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 483 | /* |
| 484 | * Atomically swap in the new signal mask, and wait for a signal. |
| 485 | */ |
| 486 | asmlinkage int |
| 487 | sys_sigsuspend(int history0, int history1, old_sigset_t mask) |
| 488 | { |
Oleg Nesterov | 3982294 | 2011-07-10 21:27:27 +0200 | [diff] [blame] | 489 | sigset_t blocked; |
| 490 | |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 491 | current->saved_sigmask = current->blocked; |
Oleg Nesterov | 3982294 | 2011-07-10 21:27:27 +0200 | [diff] [blame] | 492 | |
| 493 | mask &= _BLOCKABLE; |
| 494 | siginitset(&blocked, mask); |
| 495 | set_current_blocked(&blocked); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 496 | |
| 497 | current->state = TASK_INTERRUPTIBLE; |
| 498 | schedule(); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 499 | |
Oleg Nesterov | 3982294 | 2011-07-10 21:27:27 +0200 | [diff] [blame] | 500 | set_restore_sigmask(); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 501 | return -ERESTARTNOHAND; |
| 502 | } |
| 503 | |
| 504 | asmlinkage int |
| 505 | sys_sigaction(int sig, const struct old_sigaction __user *act, |
| 506 | struct old_sigaction __user *oact) |
| 507 | { |
| 508 | struct k_sigaction new_ka, old_ka; |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 509 | int ret = 0; |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 510 | |
| 511 | if (act) { |
| 512 | old_sigset_t mask; |
| 513 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 514 | if (!access_ok(VERIFY_READ, act, sizeof(*act))) |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 515 | return -EFAULT; |
| 516 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 517 | get_user_try { |
| 518 | get_user_ex(new_ka.sa.sa_handler, &act->sa_handler); |
| 519 | get_user_ex(new_ka.sa.sa_flags, &act->sa_flags); |
| 520 | get_user_ex(mask, &act->sa_mask); |
| 521 | get_user_ex(new_ka.sa.sa_restorer, &act->sa_restorer); |
| 522 | } get_user_catch(ret); |
| 523 | |
| 524 | if (ret) |
| 525 | return -EFAULT; |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 526 | siginitset(&new_ka.sa.sa_mask, mask); |
| 527 | } |
| 528 | |
| 529 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
| 530 | |
| 531 | if (!ret && oact) { |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 532 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact))) |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 533 | return -EFAULT; |
| 534 | |
Hiroshi Shimamoto | 98e3d45 | 2009-01-23 15:50:10 -0800 | [diff] [blame] | 535 | put_user_try { |
| 536 | put_user_ex(old_ka.sa.sa_handler, &oact->sa_handler); |
| 537 | put_user_ex(old_ka.sa.sa_flags, &oact->sa_flags); |
| 538 | put_user_ex(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); |
| 539 | put_user_ex(old_ka.sa.sa_restorer, &oact->sa_restorer); |
| 540 | } put_user_catch(ret); |
| 541 | |
| 542 | if (ret) |
| 543 | return -EFAULT; |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | return ret; |
| 547 | } |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 548 | #endif /* CONFIG_X86_32 */ |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 549 | |
Brian Gerst | 052acad | 2009-12-09 19:01:54 -0500 | [diff] [blame] | 550 | long |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 551 | sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, |
| 552 | struct pt_regs *regs) |
| 553 | { |
| 554 | return do_sigaltstack(uss, uoss, regs->sp); |
| 555 | } |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 556 | |
| 557 | /* |
| 558 | * Do a signal return; undo the signal stack. |
| 559 | */ |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 560 | #ifdef CONFIG_X86_32 |
Brian Gerst | b12bdaf | 2009-02-11 16:43:58 -0500 | [diff] [blame] | 561 | unsigned long sys_sigreturn(struct pt_regs *regs) |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 562 | { |
| 563 | struct sigframe __user *frame; |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 564 | unsigned long ax; |
| 565 | sigset_t set; |
| 566 | |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 567 | frame = (struct sigframe __user *)(regs->sp - 8); |
| 568 | |
| 569 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
| 570 | goto badframe; |
| 571 | if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1 |
| 572 | && __copy_from_user(&set.sig[1], &frame->extramask, |
| 573 | sizeof(frame->extramask)))) |
| 574 | goto badframe; |
| 575 | |
| 576 | sigdelsetmask(&set, ~_BLOCKABLE); |
Oleg Nesterov | 3982294 | 2011-07-10 21:27:27 +0200 | [diff] [blame] | 577 | set_current_blocked(&set); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 578 | |
| 579 | if (restore_sigcontext(regs, &frame->sc, &ax)) |
| 580 | goto badframe; |
| 581 | return ax; |
| 582 | |
| 583 | badframe: |
Hiroshi Shimamoto | ae417bb | 2008-12-16 14:02:16 -0800 | [diff] [blame] | 584 | signal_fault(regs, frame, "sigreturn"); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 585 | |
| 586 | return 0; |
| 587 | } |
Hiroshi Shimamoto | e5fa2d0 | 2008-11-24 18:24:11 -0800 | [diff] [blame] | 588 | #endif /* CONFIG_X86_32 */ |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 589 | |
H. Peter Anvin | 7445250 | 2009-02-11 16:31:40 -0800 | [diff] [blame] | 590 | long sys_rt_sigreturn(struct pt_regs *regs) |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 591 | { |
| 592 | struct rt_sigframe __user *frame; |
| 593 | unsigned long ax; |
| 594 | sigset_t set; |
| 595 | |
| 596 | frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long)); |
| 597 | if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) |
| 598 | goto badframe; |
| 599 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) |
| 600 | goto badframe; |
| 601 | |
| 602 | sigdelsetmask(&set, ~_BLOCKABLE); |
Oleg Nesterov | e9bd3f0 | 2011-04-27 21:09:39 +0200 | [diff] [blame] | 603 | set_current_blocked(&set); |
Hiroshi Shimamoto | bfeb91a | 2008-11-24 18:23:12 -0800 | [diff] [blame] | 604 | |
| 605 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) |
| 606 | goto badframe; |
| 607 | |
| 608 | if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT) |
| 609 | goto badframe; |
| 610 | |
| 611 | return ax; |
| 612 | |
| 613 | badframe: |
| 614 | signal_fault(regs, frame, "rt_sigreturn"); |
| 615 | return 0; |
| 616 | } |
| 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | /* |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 619 | * OK, we're invoking a handler: |
| 620 | */ |
Hiroshi Shimamoto | 8d8c13b | 2008-09-24 19:10:29 -0700 | [diff] [blame] | 621 | static int signr_convert(int sig) |
| 622 | { |
Hiroshi Shimamoto | 96bf84b | 2008-10-29 18:44:08 -0700 | [diff] [blame] | 623 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | 8d8c13b | 2008-09-24 19:10:29 -0700 | [diff] [blame] | 624 | struct thread_info *info = current_thread_info(); |
| 625 | |
| 626 | if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32) |
| 627 | return info->exec_domain->signal_invmap[sig]; |
Hiroshi Shimamoto | 96bf84b | 2008-10-29 18:44:08 -0700 | [diff] [blame] | 628 | #endif /* CONFIG_X86_32 */ |
Hiroshi Shimamoto | 8d8c13b | 2008-09-24 19:10:29 -0700 | [diff] [blame] | 629 | return sig; |
| 630 | } |
| 631 | |
Hiroshi Shimamoto | cabf503 | 2008-10-29 18:46:07 -0700 | [diff] [blame] | 632 | #ifdef CONFIG_X86_32 |
| 633 | |
Hiroshi Shimamoto | 455edbc | 2008-09-24 19:13:11 -0700 | [diff] [blame] | 634 | #define is_ia32 1 |
Hiroshi Shimamoto | 4694d23 | 2008-09-24 19:13:29 -0700 | [diff] [blame] | 635 | #define ia32_setup_frame __setup_frame |
| 636 | #define ia32_setup_rt_frame __setup_rt_frame |
Hiroshi Shimamoto | 455edbc | 2008-09-24 19:13:11 -0700 | [diff] [blame] | 637 | |
Hiroshi Shimamoto | cabf503 | 2008-10-29 18:46:07 -0700 | [diff] [blame] | 638 | #else /* !CONFIG_X86_32 */ |
| 639 | |
| 640 | #ifdef CONFIG_IA32_EMULATION |
| 641 | #define is_ia32 test_thread_flag(TIF_IA32) |
| 642 | #else /* !CONFIG_IA32_EMULATION */ |
| 643 | #define is_ia32 0 |
| 644 | #endif /* CONFIG_IA32_EMULATION */ |
| 645 | |
Hiroshi Shimamoto | f522376 | 2008-12-17 18:47:17 -0800 | [diff] [blame] | 646 | int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
| 647 | sigset_t *set, struct pt_regs *regs); |
| 648 | int ia32_setup_frame(int sig, struct k_sigaction *ka, |
| 649 | sigset_t *set, struct pt_regs *regs); |
| 650 | |
Hiroshi Shimamoto | cabf503 | 2008-10-29 18:46:07 -0700 | [diff] [blame] | 651 | #endif /* CONFIG_X86_32 */ |
| 652 | |
Roland McGrath | 7c1def1 | 2005-06-23 00:08:21 -0700 | [diff] [blame] | 653 | static int |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 654 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 655 | struct pt_regs *regs) |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 656 | { |
Hiroshi Shimamoto | 8d8c13b | 2008-09-24 19:10:29 -0700 | [diff] [blame] | 657 | int usig = signr_convert(sig); |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 658 | sigset_t *set = ¤t->blocked; |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 659 | int ret; |
| 660 | |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 661 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) |
| 662 | set = ¤t->saved_sigmask; |
| 663 | |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 664 | /* Set up the stack frame */ |
Hiroshi Shimamoto | 455edbc | 2008-09-24 19:13:11 -0700 | [diff] [blame] | 665 | if (is_ia32) { |
| 666 | if (ka->sa.sa_flags & SA_SIGINFO) |
Hiroshi Shimamoto | 4694d23 | 2008-09-24 19:13:29 -0700 | [diff] [blame] | 667 | ret = ia32_setup_rt_frame(usig, ka, info, set, regs); |
Hiroshi Shimamoto | 455edbc | 2008-09-24 19:13:11 -0700 | [diff] [blame] | 668 | else |
Hiroshi Shimamoto | 4694d23 | 2008-09-24 19:13:29 -0700 | [diff] [blame] | 669 | ret = ia32_setup_frame(usig, ka, set, regs); |
Hiroshi Shimamoto | 455edbc | 2008-09-24 19:13:11 -0700 | [diff] [blame] | 670 | } else |
| 671 | ret = __setup_rt_frame(sig, ka, info, set, regs); |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 672 | |
Hiroshi Shimamoto | 3d0aedd | 2008-09-12 17:01:09 -0700 | [diff] [blame] | 673 | if (ret) { |
| 674 | force_sigsegv(sig, current); |
| 675 | return -EFAULT; |
| 676 | } |
| 677 | |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 678 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
Hiroshi Shimamoto | 1d13024 | 2008-09-05 16:28:06 -0700 | [diff] [blame] | 679 | return ret; |
| 680 | } |
| 681 | |
| 682 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 684 | struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | { |
Roland McGrath | 7c1def1 | 2005-06-23 00:08:21 -0700 | [diff] [blame] | 686 | int ret; |
| 687 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | /* Are we from a system call? */ |
Hiroshi Shimamoto | bb57925 | 2008-09-05 16:26:55 -0700 | [diff] [blame] | 689 | if (syscall_get_nr(current, regs) >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | /* If so, check system call restarting.. */ |
Hiroshi Shimamoto | bb57925 | 2008-09-05 16:26:55 -0700 | [diff] [blame] | 691 | switch (syscall_get_error(current, regs)) { |
Harvey Harrison | ac66f3f | 2008-02-08 12:09:58 -0800 | [diff] [blame] | 692 | case -ERESTART_RESTARTBLOCK: |
| 693 | case -ERESTARTNOHAND: |
| 694 | regs->ax = -EINTR; |
| 695 | break; |
| 696 | |
| 697 | case -ERESTARTSYS: |
| 698 | if (!(ka->sa.sa_flags & SA_RESTART)) { |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 699 | regs->ax = -EINTR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | break; |
Harvey Harrison | ac66f3f | 2008-02-08 12:09:58 -0800 | [diff] [blame] | 701 | } |
| 702 | /* fallthrough */ |
| 703 | case -ERESTARTNOINTR: |
| 704 | regs->ax = regs->orig_ax; |
| 705 | regs->ip -= 2; |
| 706 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
| 710 | /* |
Roland McGrath | e1f2877 | 2008-01-30 13:30:50 +0100 | [diff] [blame] | 711 | * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF |
| 712 | * flag so that register information in the sigcontext is correct. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | */ |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 714 | if (unlikely(regs->flags & X86_EFLAGS_TF) && |
Roland McGrath | e1f2877 | 2008-01-30 13:30:50 +0100 | [diff] [blame] | 715 | likely(test_and_clear_thread_flag(TIF_FORCED_TF))) |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 716 | regs->flags &= ~X86_EFLAGS_TF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 718 | ret = setup_rt_frame(sig, ka, info, regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 720 | if (ret) |
| 721 | return ret; |
Roland McGrath | 7c1def1 | 2005-06-23 00:08:21 -0700 | [diff] [blame] | 722 | |
Roland McGrath | 8b9c5ff | 2008-04-19 14:26:54 -0700 | [diff] [blame] | 723 | /* |
| 724 | * Clear the direction flag as per the ABI for function entry. |
| 725 | */ |
| 726 | regs->flags &= ~X86_EFLAGS_DF; |
| 727 | |
| 728 | /* |
| 729 | * Clear TF when entering the signal handler, but |
| 730 | * notify any tracer that was single-stepping it. |
| 731 | * The tracer may want to single-step inside the |
| 732 | * handler too. |
| 733 | */ |
| 734 | regs->flags &= ~X86_EFLAGS_TF; |
Roland McGrath | 8b9c5ff | 2008-04-19 14:26:54 -0700 | [diff] [blame] | 735 | |
Matt Fleming | 5e6292c | 2012-01-10 15:11:17 -0800 | [diff] [blame] | 736 | block_sigmask(ka, sig); |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 737 | |
Roland McGrath | 36a0330 | 2008-03-14 17:46:38 -0700 | [diff] [blame] | 738 | tracehook_signal_handler(sig, info, ka, regs, |
| 739 | test_thread_flag(TIF_SINGLESTEP)); |
| 740 | |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 741 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | } |
| 743 | |
Hiroshi Shimamoto | 5791775 | 2008-10-29 18:46:40 -0700 | [diff] [blame] | 744 | #ifdef CONFIG_X86_32 |
Hiroshi Shimamoto | 8fcd8e2 | 2008-09-05 16:27:39 -0700 | [diff] [blame] | 745 | #define NR_restart_syscall __NR_restart_syscall |
Hiroshi Shimamoto | 5791775 | 2008-10-29 18:46:40 -0700 | [diff] [blame] | 746 | #else /* !CONFIG_X86_32 */ |
| 747 | #define NR_restart_syscall \ |
| 748 | test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall |
| 749 | #endif /* CONFIG_X86_32 */ |
| 750 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | /* |
| 752 | * Note that 'init' is a special process: it doesn't get signals it doesn't |
| 753 | * want to handle. Thus you cannot kill init even with a SIGKILL even by |
| 754 | * mistake. |
| 755 | */ |
Harvey Harrison | 75604d7 | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 756 | static void do_signal(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | { |
Harvey Harrison | ac66f3f | 2008-02-08 12:09:58 -0800 | [diff] [blame] | 758 | struct k_sigaction ka; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | siginfo_t info; |
| 760 | int signr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | |
| 762 | /* |
Harvey Harrison | ac66f3f | 2008-02-08 12:09:58 -0800 | [diff] [blame] | 763 | * We want the common case to go fast, which is why we may in certain |
| 764 | * cases get here from kernel mode. Just return without doing anything |
| 765 | * if so. |
| 766 | * X86_32: vm86 regs switched out by assembly code before reaching |
| 767 | * here, so testing against kernel CS suffices. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | */ |
Vincent Hanquez | 717b594 | 2005-06-23 00:08:45 -0700 | [diff] [blame] | 769 | if (!user_mode(regs)) |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 770 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
| 773 | if (signr > 0) { |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 774 | /* Whee! Actually deliver the signal. */ |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 775 | handle_signal(signr, &info, &ka, regs); |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 776 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | } |
| 778 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | /* Did we come from a system call? */ |
Hiroshi Shimamoto | bb57925 | 2008-09-05 16:26:55 -0700 | [diff] [blame] | 780 | if (syscall_get_nr(current, regs) >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | /* Restart the system call - no handlers present */ |
Hiroshi Shimamoto | bb57925 | 2008-09-05 16:26:55 -0700 | [diff] [blame] | 782 | switch (syscall_get_error(current, regs)) { |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 783 | case -ERESTARTNOHAND: |
| 784 | case -ERESTARTSYS: |
| 785 | case -ERESTARTNOINTR: |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 786 | regs->ax = regs->orig_ax; |
| 787 | regs->ip -= 2; |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 788 | break; |
| 789 | |
| 790 | case -ERESTART_RESTARTBLOCK: |
Hiroshi Shimamoto | 8fcd8e2 | 2008-09-05 16:27:39 -0700 | [diff] [blame] | 791 | regs->ax = NR_restart_syscall; |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 792 | regs->ip -= 2; |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 793 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | } |
| 795 | } |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 796 | |
Harvey Harrison | ac66f3f | 2008-02-08 12:09:58 -0800 | [diff] [blame] | 797 | /* |
| 798 | * If there's no signal to deliver, we just put the saved sigmask |
| 799 | * back. |
| 800 | */ |
Roland McGrath | 5a8da0e | 2008-04-30 00:53:10 -0700 | [diff] [blame] | 801 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { |
| 802 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; |
Oleg Nesterov | 9b42962 | 2011-07-10 20:22:03 +0200 | [diff] [blame] | 803 | set_current_blocked(¤t->saved_sigmask); |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 804 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /* |
| 808 | * notification of userspace execution resumption |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 809 | * - triggered by the TIF_WORK_MASK flags |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | */ |
Ingo Molnar | 7e907f4 | 2008-03-06 10:33:08 +0100 | [diff] [blame] | 811 | void |
| 812 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | { |
Andi Kleen | c1ebf83 | 2009-07-09 00:31:41 +0200 | [diff] [blame] | 814 | #ifdef CONFIG_X86_MCE |
Hiroshi Shimamoto | ee847c5 | 2008-09-23 17:21:45 -0700 | [diff] [blame] | 815 | /* notify userspace of pending MCEs */ |
| 816 | if (thread_info_flags & _TIF_MCE_NOTIFY) |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 817 | mce_notify_process(); |
Hiroshi Shimamoto | ee847c5 | 2008-09-23 17:21:45 -0700 | [diff] [blame] | 818 | #endif /* CONFIG_X86_64 && CONFIG_X86_MCE */ |
| 819 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | /* deal with pending signal delivery */ |
Roland McGrath | 5a8da0e | 2008-04-30 00:53:10 -0700 | [diff] [blame] | 821 | if (thread_info_flags & _TIF_SIGPENDING) |
David Howells | 283828f | 2006-01-18 17:44:00 -0800 | [diff] [blame] | 822 | do_signal(regs); |
Peter Zijlstra | 8f4d37e | 2008-01-25 21:08:29 +0100 | [diff] [blame] | 823 | |
Roland McGrath | 59e5213 | 2008-04-19 19:10:57 -0700 | [diff] [blame] | 824 | if (thread_info_flags & _TIF_NOTIFY_RESUME) { |
| 825 | clear_thread_flag(TIF_NOTIFY_RESUME); |
| 826 | tracehook_notify_resume(regs); |
David Howells | ee18d64 | 2009-09-02 09:14:21 +0100 | [diff] [blame] | 827 | if (current->replacement_session_keyring) |
| 828 | key_replace_session_keyring(); |
Roland McGrath | 59e5213 | 2008-04-19 19:10:57 -0700 | [diff] [blame] | 829 | } |
Avi Kivity | 7c68af6 | 2009-09-19 09:40:22 +0300 | [diff] [blame] | 830 | if (thread_info_flags & _TIF_USER_RETURN_NOTIFY) |
| 831 | fire_user_return_notifiers(); |
Roland McGrath | 59e5213 | 2008-04-19 19:10:57 -0700 | [diff] [blame] | 832 | |
Hiroshi Shimamoto | ee847c5 | 2008-09-23 17:21:45 -0700 | [diff] [blame] | 833 | #ifdef CONFIG_X86_32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | clear_thread_flag(TIF_IRET); |
Hiroshi Shimamoto | ee847c5 | 2008-09-23 17:21:45 -0700 | [diff] [blame] | 835 | #endif /* CONFIG_X86_32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | } |
Hiroshi Shimamoto | 72fa50f | 2008-09-05 16:27:11 -0700 | [diff] [blame] | 837 | |
| 838 | void signal_fault(struct pt_regs *regs, void __user *frame, char *where) |
| 839 | { |
| 840 | struct task_struct *me = current; |
| 841 | |
| 842 | if (show_unhandled_signals && printk_ratelimit()) { |
Hiroshi Shimamoto | ae417bb | 2008-12-16 14:02:16 -0800 | [diff] [blame] | 843 | printk("%s" |
Hiroshi Shimamoto | 72fa50f | 2008-09-05 16:27:11 -0700 | [diff] [blame] | 844 | "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx", |
Hiroshi Shimamoto | ae417bb | 2008-12-16 14:02:16 -0800 | [diff] [blame] | 845 | task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG, |
Hiroshi Shimamoto | 72fa50f | 2008-09-05 16:27:11 -0700 | [diff] [blame] | 846 | me->comm, me->pid, where, frame, |
| 847 | regs->ip, regs->sp, regs->orig_ax); |
| 848 | print_vma_addr(" in ", regs->ip); |
| 849 | printk(KERN_CONT "\n"); |
| 850 | } |
| 851 | |
| 852 | force_sig(SIGSEGV, me); |
| 853 | } |