signal_32.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * linux/arch/sh/kernel/signal.c
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. *
  6. * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson
  7. *
  8. * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
  9. *
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/smp.h>
  14. #include <linux/kernel.h>
  15. #include <linux/signal.h>
  16. #include <linux/errno.h>
  17. #include <linux/wait.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/unistd.h>
  20. #include <linux/stddef.h>
  21. #include <linux/tty.h>
  22. #include <linux/elf.h>
  23. #include <linux/personality.h>
  24. #include <linux/binfmts.h>
  25. #include <linux/freezer.h>
  26. #include <linux/io.h>
  27. #include <linux/tracehook.h>
  28. #include <asm/ucontext.h>
  29. #include <asm/uaccess.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/cacheflush.h>
  32. #include <asm/syscalls.h>
  33. #include <asm/fpu.h>
  34. #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
  35. struct fdpic_func_descriptor {
  36. unsigned long text;
  37. unsigned long GOT;
  38. };
  39. /*
  40. * The following define adds a 64 byte gap between the signal
  41. * stack frame and previous contents of the stack. This allows
  42. * frame unwinding in a function epilogue but only if a frame
  43. * pointer is used in the function. This is necessary because
  44. * current gcc compilers (<4.3) do not generate unwind info on
  45. * SH for function epilogues.
  46. */
  47. #define UNWINDGUARD 64
  48. /*
  49. * Atomically swap in the new signal mask, and wait for a signal.
  50. */
  51. asmlinkage int
  52. sys_sigsuspend(old_sigset_t mask,
  53. unsigned long r5, unsigned long r6, unsigned long r7,
  54. struct pt_regs __regs)
  55. {
  56. sigset_t blocked;
  57. current->saved_sigmask = current->blocked;
  58. mask &= _BLOCKABLE;
  59. siginitset(&blocked, mask);
  60. set_current_blocked(&blocked);
  61. current->state = TASK_INTERRUPTIBLE;
  62. schedule();
  63. set_restore_sigmask();
  64. return -ERESTARTNOHAND;
  65. }
  66. asmlinkage int
  67. sys_sigaction(int sig, const struct old_sigaction __user *act,
  68. struct old_sigaction __user *oact)
  69. {
  70. struct k_sigaction new_ka, old_ka;
  71. int ret;
  72. if (act) {
  73. old_sigset_t mask;
  74. if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
  75. __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
  76. __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
  77. return -EFAULT;
  78. __get_user(new_ka.sa.sa_flags, &act->sa_flags);
  79. __get_user(mask, &act->sa_mask);
  80. siginitset(&new_ka.sa.sa_mask, mask);
  81. }
  82. ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
  83. if (!ret && oact) {
  84. if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
  85. __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
  86. __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
  87. return -EFAULT;
  88. __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
  89. __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
  90. }
  91. return ret;
  92. }
  93. asmlinkage int
  94. sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
  95. unsigned long r6, unsigned long r7,
  96. struct pt_regs __regs)
  97. {
  98. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  99. return do_sigaltstack(uss, uoss, regs->regs[15]);
  100. }
  101. /*
  102. * Do a signal return; undo the signal stack.
  103. */
  104. #define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
  105. #if defined(CONFIG_CPU_SH2)
  106. #define TRAP_NOARG 0xc320 /* Syscall w/no args (NR in R3) */
  107. #else
  108. #define TRAP_NOARG 0xc310 /* Syscall w/no args (NR in R3) */
  109. #endif
  110. #define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
  111. struct sigframe
  112. {
  113. struct sigcontext sc;
  114. unsigned long extramask[_NSIG_WORDS-1];
  115. u16 retcode[8];
  116. };
  117. struct rt_sigframe
  118. {
  119. struct siginfo info;
  120. struct ucontext uc;
  121. u16 retcode[8];
  122. };
  123. #ifdef CONFIG_SH_FPU
  124. static inline int restore_sigcontext_fpu(struct sigcontext __user *sc)
  125. {
  126. struct task_struct *tsk = current;
  127. if (!(boot_cpu_data.flags & CPU_HAS_FPU))
  128. return 0;
  129. set_used_math();
  130. return __copy_from_user(&tsk->thread.xstate->hardfpu, &sc->sc_fpregs[0],
  131. sizeof(long)*(16*2+2));
  132. }
  133. static inline int save_sigcontext_fpu(struct sigcontext __user *sc,
  134. struct pt_regs *regs)
  135. {
  136. struct task_struct *tsk = current;
  137. if (!(boot_cpu_data.flags & CPU_HAS_FPU))
  138. return 0;
  139. if (!used_math()) {
  140. __put_user(0, &sc->sc_ownedfp);
  141. return 0;
  142. }
  143. __put_user(1, &sc->sc_ownedfp);
  144. /* This will cause a "finit" to be triggered by the next
  145. attempted FPU operation by the 'current' process.
  146. */
  147. clear_used_math();
  148. unlazy_fpu(tsk, regs);
  149. return __copy_to_user(&sc->sc_fpregs[0], &tsk->thread.xstate->hardfpu,
  150. sizeof(long)*(16*2+2));
  151. }
  152. #endif /* CONFIG_SH_FPU */
  153. static int
  154. restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
  155. {
  156. unsigned int err = 0;
  157. #define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
  158. COPY(regs[1]);
  159. COPY(regs[2]); COPY(regs[3]);
  160. COPY(regs[4]); COPY(regs[5]);
  161. COPY(regs[6]); COPY(regs[7]);
  162. COPY(regs[8]); COPY(regs[9]);
  163. COPY(regs[10]); COPY(regs[11]);
  164. COPY(regs[12]); COPY(regs[13]);
  165. COPY(regs[14]); COPY(regs[15]);
  166. COPY(gbr); COPY(mach);
  167. COPY(macl); COPY(pr);
  168. COPY(sr); COPY(pc);
  169. #undef COPY
  170. #ifdef CONFIG_SH_FPU
  171. if (boot_cpu_data.flags & CPU_HAS_FPU) {
  172. int owned_fp;
  173. struct task_struct *tsk = current;
  174. regs->sr |= SR_FD; /* Release FPU */
  175. clear_fpu(tsk, regs);
  176. clear_used_math();
  177. __get_user (owned_fp, &sc->sc_ownedfp);
  178. if (owned_fp)
  179. err |= restore_sigcontext_fpu(sc);
  180. }
  181. #endif
  182. regs->tra = -1; /* disable syscall checks */
  183. err |= __get_user(*r0_p, &sc->sc_regs[0]);
  184. return err;
  185. }
  186. asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
  187. unsigned long r6, unsigned long r7,
  188. struct pt_regs __regs)
  189. {
  190. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  191. struct sigframe __user *frame = (struct sigframe __user *)regs->regs[15];
  192. sigset_t set;
  193. int r0;
  194. /* Always make any pending restarted system calls return -EINTR */
  195. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  196. if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
  197. goto badframe;
  198. if (__get_user(set.sig[0], &frame->sc.oldmask)
  199. || (_NSIG_WORDS > 1
  200. && __copy_from_user(&set.sig[1], &frame->extramask,
  201. sizeof(frame->extramask))))
  202. goto badframe;
  203. sigdelsetmask(&set, ~_BLOCKABLE);
  204. set_current_blocked(&set);
  205. if (restore_sigcontext(regs, &frame->sc, &r0))
  206. goto badframe;
  207. return r0;
  208. badframe:
  209. force_sig(SIGSEGV, current);
  210. return 0;
  211. }
  212. asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
  213. unsigned long r6, unsigned long r7,
  214. struct pt_regs __regs)
  215. {
  216. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  217. struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs->regs[15];
  218. sigset_t set;
  219. int r0;
  220. /* Always make any pending restarted system calls return -EINTR */
  221. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  222. if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
  223. goto badframe;
  224. if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
  225. goto badframe;
  226. sigdelsetmask(&set, ~_BLOCKABLE);
  227. set_current_blocked(&set);
  228. if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
  229. goto badframe;
  230. if (do_sigaltstack(&frame->uc.uc_stack, NULL,
  231. regs->regs[15]) == -EFAULT)
  232. goto badframe;
  233. return r0;
  234. badframe:
  235. force_sig(SIGSEGV, current);
  236. return 0;
  237. }
  238. /*
  239. * Set up a signal frame.
  240. */
  241. static int
  242. setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
  243. unsigned long mask)
  244. {
  245. int err = 0;
  246. #define COPY(x) err |= __put_user(regs->x, &sc->sc_##x)
  247. COPY(regs[0]); COPY(regs[1]);
  248. COPY(regs[2]); COPY(regs[3]);
  249. COPY(regs[4]); COPY(regs[5]);
  250. COPY(regs[6]); COPY(regs[7]);
  251. COPY(regs[8]); COPY(regs[9]);
  252. COPY(regs[10]); COPY(regs[11]);
  253. COPY(regs[12]); COPY(regs[13]);
  254. COPY(regs[14]); COPY(regs[15]);
  255. COPY(gbr); COPY(mach);
  256. COPY(macl); COPY(pr);
  257. COPY(sr); COPY(pc);
  258. #undef COPY
  259. #ifdef CONFIG_SH_FPU
  260. err |= save_sigcontext_fpu(sc, regs);
  261. #endif
  262. /* non-iBCS2 extensions.. */
  263. err |= __put_user(mask, &sc->oldmask);
  264. return err;
  265. }
  266. /*
  267. * Determine which stack to use..
  268. */
  269. static inline void __user *
  270. get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
  271. {
  272. if (ka->sa.sa_flags & SA_ONSTACK) {
  273. if (sas_ss_flags(sp) == 0)
  274. sp = current->sas_ss_sp + current->sas_ss_size;
  275. }
  276. return (void __user *)((sp - (frame_size+UNWINDGUARD)) & -8ul);
  277. }
  278. /* These symbols are defined with the addresses in the vsyscall page.
  279. See vsyscall-trapa.S. */
  280. extern void __kernel_sigreturn(void);
  281. extern void __kernel_rt_sigreturn(void);
  282. static int setup_frame(int sig, struct k_sigaction *ka,
  283. sigset_t *set, struct pt_regs *regs)
  284. {
  285. struct sigframe __user *frame;
  286. int err = 0;
  287. int signal;
  288. frame = get_sigframe(ka, regs->regs[15], sizeof(*frame));
  289. if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
  290. goto give_sigsegv;
  291. signal = current_thread_info()->exec_domain
  292. && current_thread_info()->exec_domain->signal_invmap
  293. && sig < 32
  294. ? current_thread_info()->exec_domain->signal_invmap[sig]
  295. : sig;
  296. err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
  297. if (_NSIG_WORDS > 1)
  298. err |= __copy_to_user(frame->extramask, &set->sig[1],
  299. sizeof(frame->extramask));
  300. /* Set up to return from userspace. If provided, use a stub
  301. already in userspace. */
  302. if (ka->sa.sa_flags & SA_RESTORER) {
  303. regs->pr = (unsigned long) ka->sa.sa_restorer;
  304. #ifdef CONFIG_VSYSCALL
  305. } else if (likely(current->mm->context.vdso)) {
  306. regs->pr = VDSO_SYM(&__kernel_sigreturn);
  307. #endif
  308. } else {
  309. /* Generate return code (system call to sigreturn) */
  310. err |= __put_user(MOVW(7), &frame->retcode[0]);
  311. err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
  312. err |= __put_user(OR_R0_R0, &frame->retcode[2]);
  313. err |= __put_user(OR_R0_R0, &frame->retcode[3]);
  314. err |= __put_user(OR_R0_R0, &frame->retcode[4]);
  315. err |= __put_user(OR_R0_R0, &frame->retcode[5]);
  316. err |= __put_user(OR_R0_R0, &frame->retcode[6]);
  317. err |= __put_user((__NR_sigreturn), &frame->retcode[7]);
  318. regs->pr = (unsigned long) frame->retcode;
  319. flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
  320. }
  321. if (err)
  322. goto give_sigsegv;
  323. /* Set up registers for signal handler */
  324. regs->regs[15] = (unsigned long) frame;
  325. regs->regs[4] = signal; /* Arg for signal handler */
  326. regs->regs[5] = 0;
  327. regs->regs[6] = (unsigned long) &frame->sc;
  328. if (current->personality & FDPIC_FUNCPTRS) {
  329. struct fdpic_func_descriptor __user *funcptr =
  330. (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
  331. __get_user(regs->pc, &funcptr->text);
  332. __get_user(regs->regs[12], &funcptr->GOT);
  333. } else
  334. regs->pc = (unsigned long)ka->sa.sa_handler;
  335. set_fs(USER_DS);
  336. pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
  337. current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
  338. return 0;
  339. give_sigsegv:
  340. force_sigsegv(sig, current);
  341. return -EFAULT;
  342. }
  343. static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
  344. sigset_t *set, struct pt_regs *regs)
  345. {
  346. struct rt_sigframe __user *frame;
  347. int err = 0;
  348. int signal;
  349. frame = get_sigframe(ka, regs->regs[15], sizeof(*frame));
  350. if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
  351. goto give_sigsegv;
  352. signal = current_thread_info()->exec_domain
  353. && current_thread_info()->exec_domain->signal_invmap
  354. && sig < 32
  355. ? current_thread_info()->exec_domain->signal_invmap[sig]
  356. : sig;
  357. err |= copy_siginfo_to_user(&frame->info, info);
  358. /* Create the ucontext. */
  359. err |= __put_user(0, &frame->uc.uc_flags);
  360. err |= __put_user(NULL, &frame->uc.uc_link);
  361. err |= __put_user((void *)current->sas_ss_sp,
  362. &frame->uc.uc_stack.ss_sp);
  363. err |= __put_user(sas_ss_flags(regs->regs[15]),
  364. &frame->uc.uc_stack.ss_flags);
  365. err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
  366. err |= setup_sigcontext(&frame->uc.uc_mcontext,
  367. regs, set->sig[0]);
  368. err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
  369. /* Set up to return from userspace. If provided, use a stub
  370. already in userspace. */
  371. if (ka->sa.sa_flags & SA_RESTORER) {
  372. regs->pr = (unsigned long) ka->sa.sa_restorer;
  373. #ifdef CONFIG_VSYSCALL
  374. } else if (likely(current->mm->context.vdso)) {
  375. regs->pr = VDSO_SYM(&__kernel_rt_sigreturn);
  376. #endif
  377. } else {
  378. /* Generate return code (system call to rt_sigreturn) */
  379. err |= __put_user(MOVW(7), &frame->retcode[0]);
  380. err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
  381. err |= __put_user(OR_R0_R0, &frame->retcode[2]);
  382. err |= __put_user(OR_R0_R0, &frame->retcode[3]);
  383. err |= __put_user(OR_R0_R0, &frame->retcode[4]);
  384. err |= __put_user(OR_R0_R0, &frame->retcode[5]);
  385. err |= __put_user(OR_R0_R0, &frame->retcode[6]);
  386. err |= __put_user((__NR_rt_sigreturn), &frame->retcode[7]);
  387. regs->pr = (unsigned long) frame->retcode;
  388. flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
  389. }
  390. if (err)
  391. goto give_sigsegv;
  392. /* Set up registers for signal handler */
  393. regs->regs[15] = (unsigned long) frame;
  394. regs->regs[4] = signal; /* Arg for signal handler */
  395. regs->regs[5] = (unsigned long) &frame->info;
  396. regs->regs[6] = (unsigned long) &frame->uc;
  397. if (current->personality & FDPIC_FUNCPTRS) {
  398. struct fdpic_func_descriptor __user *funcptr =
  399. (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
  400. __get_user(regs->pc, &funcptr->text);
  401. __get_user(regs->regs[12], &funcptr->GOT);
  402. } else
  403. regs->pc = (unsigned long)ka->sa.sa_handler;
  404. set_fs(USER_DS);
  405. pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
  406. current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
  407. return 0;
  408. give_sigsegv:
  409. force_sigsegv(sig, current);
  410. return -EFAULT;
  411. }
  412. static inline void
  413. handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
  414. struct sigaction *sa)
  415. {
  416. /* If we're not from a syscall, bail out */
  417. if (regs->tra < 0)
  418. return;
  419. /* check for system call restart.. */
  420. switch (regs->regs[0]) {
  421. case -ERESTART_RESTARTBLOCK:
  422. case -ERESTARTNOHAND:
  423. no_system_call_restart:
  424. regs->regs[0] = -EINTR;
  425. break;
  426. case -ERESTARTSYS:
  427. if (!(sa->sa_flags & SA_RESTART))
  428. goto no_system_call_restart;
  429. /* fallthrough */
  430. case -ERESTARTNOINTR:
  431. regs->regs[0] = save_r0;
  432. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  433. break;
  434. }
  435. }
  436. /*
  437. * OK, we're invoking a handler
  438. */
  439. static int
  440. handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
  441. sigset_t *oldset, struct pt_regs *regs, unsigned int save_r0)
  442. {
  443. int ret;
  444. /* Set up the stack frame */
  445. if (ka->sa.sa_flags & SA_SIGINFO)
  446. ret = setup_rt_frame(sig, ka, info, oldset, regs);
  447. else
  448. ret = setup_frame(sig, ka, oldset, regs);
  449. if (ret == 0)
  450. block_sigmask(ka, sig);
  451. return ret;
  452. }
  453. /*
  454. * Note that 'init' is a special process: it doesn't get signals it doesn't
  455. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  456. * mistake.
  457. *
  458. * Note that we go through the signals twice: once to check the signals that
  459. * the kernel can handle, and then we build all the user-level signal handling
  460. * stack-frames in one go after that.
  461. */
  462. static void do_signal(struct pt_regs *regs, unsigned int save_r0)
  463. {
  464. siginfo_t info;
  465. int signr;
  466. struct k_sigaction ka;
  467. sigset_t *oldset;
  468. /*
  469. * We want the common case to go fast, which
  470. * is why we may in certain cases get here from
  471. * kernel mode. Just return without doing anything
  472. * if so.
  473. */
  474. if (!user_mode(regs))
  475. return;
  476. if (current_thread_info()->status & TS_RESTORE_SIGMASK)
  477. oldset = &current->saved_sigmask;
  478. else
  479. oldset = &current->blocked;
  480. signr = get_signal_to_deliver(&info, &ka, regs, NULL);
  481. if (signr > 0) {
  482. handle_syscall_restart(save_r0, regs, &ka.sa);
  483. /* Whee! Actually deliver the signal. */
  484. if (handle_signal(signr, &ka, &info, oldset,
  485. regs, save_r0) == 0) {
  486. /*
  487. * A signal was successfully delivered; the saved
  488. * sigmask will have been stored in the signal frame,
  489. * and will be restored by sigreturn, so we can simply
  490. * clear the TS_RESTORE_SIGMASK flag
  491. */
  492. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  493. tracehook_signal_handler(signr, &info, &ka, regs,
  494. test_thread_flag(TIF_SINGLESTEP));
  495. }
  496. return;
  497. }
  498. /* Did we come from a system call? */
  499. if (regs->tra >= 0) {
  500. /* Restart the system call - no handlers present */
  501. if (regs->regs[0] == -ERESTARTNOHAND ||
  502. regs->regs[0] == -ERESTARTSYS ||
  503. regs->regs[0] == -ERESTARTNOINTR) {
  504. regs->regs[0] = save_r0;
  505. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  506. } else if (regs->regs[0] == -ERESTART_RESTARTBLOCK) {
  507. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  508. regs->regs[3] = __NR_restart_syscall;
  509. }
  510. }
  511. /*
  512. * If there's no signal to deliver, we just put the saved sigmask
  513. * back.
  514. */
  515. if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
  516. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  517. sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
  518. }
  519. }
  520. asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
  521. unsigned long thread_info_flags)
  522. {
  523. /* deal with pending signal delivery */
  524. if (thread_info_flags & _TIF_SIGPENDING)
  525. do_signal(regs, save_r0);
  526. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  527. clear_thread_flag(TIF_NOTIFY_RESUME);
  528. tracehook_notify_resume(regs);
  529. if (current->replacement_session_keyring)
  530. key_replace_session_keyring();
  531. }
  532. }