signal_32.c 17 KB

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