signal.c 16 KB

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