signal_32.c 17 KB

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