signal_64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * arch/sparc64/kernel/signal.c
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. * Copyright (C) 1995, 2008 David S. Miller (davem@davemloft.net)
  6. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  7. * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
  8. * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  9. */
  10. #ifdef CONFIG_COMPAT
  11. #include <linux/compat.h> /* for compat_old_sigset_t */
  12. #endif
  13. #include <linux/sched.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/tracehook.h>
  20. #include <linux/unistd.h>
  21. #include <linux/mm.h>
  22. #include <linux/tty.h>
  23. #include <linux/binfmts.h>
  24. #include <linux/bitops.h>
  25. #include <linux/context_tracking.h>
  26. #include <asm/uaccess.h>
  27. #include <asm/ptrace.h>
  28. #include <asm/pgtable.h>
  29. #include <asm/fpumacro.h>
  30. #include <asm/uctx.h>
  31. #include <asm/siginfo.h>
  32. #include <asm/visasm.h>
  33. #include <asm/switch_to.h>
  34. #include <asm/cacheflush.h>
  35. #include "sigutil.h"
  36. #include "systbls.h"
  37. #include "kernel.h"
  38. #include "entry.h"
  39. /* {set, get}context() needed for 64-bit SparcLinux userland. */
  40. asmlinkage void sparc64_set_context(struct pt_regs *regs)
  41. {
  42. struct ucontext __user *ucp = (struct ucontext __user *)
  43. regs->u_regs[UREG_I0];
  44. enum ctx_state prev_state = exception_enter();
  45. mc_gregset_t __user *grp;
  46. unsigned long pc, npc, tstate;
  47. unsigned long fp, i7;
  48. unsigned char fenab;
  49. int err;
  50. flush_user_windows();
  51. if (get_thread_wsaved() ||
  52. (((unsigned long)ucp) & (sizeof(unsigned long)-1)) ||
  53. (!__access_ok(ucp, sizeof(*ucp))))
  54. goto do_sigsegv;
  55. grp = &ucp->uc_mcontext.mc_gregs;
  56. err = __get_user(pc, &((*grp)[MC_PC]));
  57. err |= __get_user(npc, &((*grp)[MC_NPC]));
  58. if (err || ((pc | npc) & 3))
  59. goto do_sigsegv;
  60. if (regs->u_regs[UREG_I1]) {
  61. sigset_t set;
  62. if (_NSIG_WORDS == 1) {
  63. if (__get_user(set.sig[0], &ucp->uc_sigmask.sig[0]))
  64. goto do_sigsegv;
  65. } else {
  66. if (__copy_from_user(&set, &ucp->uc_sigmask, sizeof(sigset_t)))
  67. goto do_sigsegv;
  68. }
  69. set_current_blocked(&set);
  70. }
  71. if (test_thread_flag(TIF_32BIT)) {
  72. pc &= 0xffffffff;
  73. npc &= 0xffffffff;
  74. }
  75. regs->tpc = pc;
  76. regs->tnpc = npc;
  77. err |= __get_user(regs->y, &((*grp)[MC_Y]));
  78. err |= __get_user(tstate, &((*grp)[MC_TSTATE]));
  79. regs->tstate &= ~(TSTATE_ASI | TSTATE_ICC | TSTATE_XCC);
  80. regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
  81. err |= __get_user(regs->u_regs[UREG_G1], (&(*grp)[MC_G1]));
  82. err |= __get_user(regs->u_regs[UREG_G2], (&(*grp)[MC_G2]));
  83. err |= __get_user(regs->u_regs[UREG_G3], (&(*grp)[MC_G3]));
  84. err |= __get_user(regs->u_regs[UREG_G4], (&(*grp)[MC_G4]));
  85. err |= __get_user(regs->u_regs[UREG_G5], (&(*grp)[MC_G5]));
  86. err |= __get_user(regs->u_regs[UREG_G6], (&(*grp)[MC_G6]));
  87. /* Skip %g7 as that's the thread register in userspace. */
  88. err |= __get_user(regs->u_regs[UREG_I0], (&(*grp)[MC_O0]));
  89. err |= __get_user(regs->u_regs[UREG_I1], (&(*grp)[MC_O1]));
  90. err |= __get_user(regs->u_regs[UREG_I2], (&(*grp)[MC_O2]));
  91. err |= __get_user(regs->u_regs[UREG_I3], (&(*grp)[MC_O3]));
  92. err |= __get_user(regs->u_regs[UREG_I4], (&(*grp)[MC_O4]));
  93. err |= __get_user(regs->u_regs[UREG_I5], (&(*grp)[MC_O5]));
  94. err |= __get_user(regs->u_regs[UREG_I6], (&(*grp)[MC_O6]));
  95. err |= __get_user(regs->u_regs[UREG_I7], (&(*grp)[MC_O7]));
  96. err |= __get_user(fp, &(ucp->uc_mcontext.mc_fp));
  97. err |= __get_user(i7, &(ucp->uc_mcontext.mc_i7));
  98. err |= __put_user(fp,
  99. (&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[6])));
  100. err |= __put_user(i7,
  101. (&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[7])));
  102. err |= __get_user(fenab, &(ucp->uc_mcontext.mc_fpregs.mcfpu_enab));
  103. if (fenab) {
  104. unsigned long *fpregs = current_thread_info()->fpregs;
  105. unsigned long fprs;
  106. fprs_write(0);
  107. err |= __get_user(fprs, &(ucp->uc_mcontext.mc_fpregs.mcfpu_fprs));
  108. if (fprs & FPRS_DL)
  109. err |= copy_from_user(fpregs,
  110. &(ucp->uc_mcontext.mc_fpregs.mcfpu_fregs),
  111. (sizeof(unsigned int) * 32));
  112. if (fprs & FPRS_DU)
  113. err |= copy_from_user(fpregs+16,
  114. ((unsigned long __user *)&(ucp->uc_mcontext.mc_fpregs.mcfpu_fregs))+16,
  115. (sizeof(unsigned int) * 32));
  116. err |= __get_user(current_thread_info()->xfsr[0],
  117. &(ucp->uc_mcontext.mc_fpregs.mcfpu_fsr));
  118. err |= __get_user(current_thread_info()->gsr[0],
  119. &(ucp->uc_mcontext.mc_fpregs.mcfpu_gsr));
  120. regs->tstate &= ~TSTATE_PEF;
  121. }
  122. if (err)
  123. goto do_sigsegv;
  124. out:
  125. exception_exit(prev_state);
  126. return;
  127. do_sigsegv:
  128. force_sig(SIGSEGV, current);
  129. goto out;
  130. }
  131. asmlinkage void sparc64_get_context(struct pt_regs *regs)
  132. {
  133. struct ucontext __user *ucp = (struct ucontext __user *)
  134. regs->u_regs[UREG_I0];
  135. enum ctx_state prev_state = exception_enter();
  136. mc_gregset_t __user *grp;
  137. mcontext_t __user *mcp;
  138. unsigned long fp, i7;
  139. unsigned char fenab;
  140. int err;
  141. synchronize_user_stack();
  142. if (get_thread_wsaved() || clear_user(ucp, sizeof(*ucp)))
  143. goto do_sigsegv;
  144. #if 1
  145. fenab = 0; /* IMO get_context is like any other system call, thus modifies FPU state -jj */
  146. #else
  147. fenab = (current_thread_info()->fpsaved[0] & FPRS_FEF);
  148. #endif
  149. mcp = &ucp->uc_mcontext;
  150. grp = &mcp->mc_gregs;
  151. /* Skip over the trap instruction, first. */
  152. if (test_thread_flag(TIF_32BIT)) {
  153. regs->tpc = (regs->tnpc & 0xffffffff);
  154. regs->tnpc = (regs->tnpc + 4) & 0xffffffff;
  155. } else {
  156. regs->tpc = regs->tnpc;
  157. regs->tnpc += 4;
  158. }
  159. err = 0;
  160. if (_NSIG_WORDS == 1)
  161. err |= __put_user(current->blocked.sig[0],
  162. (unsigned long __user *)&ucp->uc_sigmask);
  163. else
  164. err |= __copy_to_user(&ucp->uc_sigmask, &current->blocked,
  165. sizeof(sigset_t));
  166. err |= __put_user(regs->tstate, &((*grp)[MC_TSTATE]));
  167. err |= __put_user(regs->tpc, &((*grp)[MC_PC]));
  168. err |= __put_user(regs->tnpc, &((*grp)[MC_NPC]));
  169. err |= __put_user(regs->y, &((*grp)[MC_Y]));
  170. err |= __put_user(regs->u_regs[UREG_G1], &((*grp)[MC_G1]));
  171. err |= __put_user(regs->u_regs[UREG_G2], &((*grp)[MC_G2]));
  172. err |= __put_user(regs->u_regs[UREG_G3], &((*grp)[MC_G3]));
  173. err |= __put_user(regs->u_regs[UREG_G4], &((*grp)[MC_G4]));
  174. err |= __put_user(regs->u_regs[UREG_G5], &((*grp)[MC_G5]));
  175. err |= __put_user(regs->u_regs[UREG_G6], &((*grp)[MC_G6]));
  176. err |= __put_user(regs->u_regs[UREG_G7], &((*grp)[MC_G7]));
  177. err |= __put_user(regs->u_regs[UREG_I0], &((*grp)[MC_O0]));
  178. err |= __put_user(regs->u_regs[UREG_I1], &((*grp)[MC_O1]));
  179. err |= __put_user(regs->u_regs[UREG_I2], &((*grp)[MC_O2]));
  180. err |= __put_user(regs->u_regs[UREG_I3], &((*grp)[MC_O3]));
  181. err |= __put_user(regs->u_regs[UREG_I4], &((*grp)[MC_O4]));
  182. err |= __put_user(regs->u_regs[UREG_I5], &((*grp)[MC_O5]));
  183. err |= __put_user(regs->u_regs[UREG_I6], &((*grp)[MC_O6]));
  184. err |= __put_user(regs->u_regs[UREG_I7], &((*grp)[MC_O7]));
  185. err |= __get_user(fp,
  186. (&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[6])));
  187. err |= __get_user(i7,
  188. (&(((struct reg_window __user *)(STACK_BIAS+regs->u_regs[UREG_I6]))->ins[7])));
  189. err |= __put_user(fp, &(mcp->mc_fp));
  190. err |= __put_user(i7, &(mcp->mc_i7));
  191. err |= __put_user(fenab, &(mcp->mc_fpregs.mcfpu_enab));
  192. if (fenab) {
  193. unsigned long *fpregs = current_thread_info()->fpregs;
  194. unsigned long fprs;
  195. fprs = current_thread_info()->fpsaved[0];
  196. if (fprs & FPRS_DL)
  197. err |= copy_to_user(&(mcp->mc_fpregs.mcfpu_fregs), fpregs,
  198. (sizeof(unsigned int) * 32));
  199. if (fprs & FPRS_DU)
  200. err |= copy_to_user(
  201. ((unsigned long __user *)&(mcp->mc_fpregs.mcfpu_fregs))+16, fpregs+16,
  202. (sizeof(unsigned int) * 32));
  203. err |= __put_user(current_thread_info()->xfsr[0], &(mcp->mc_fpregs.mcfpu_fsr));
  204. err |= __put_user(current_thread_info()->gsr[0], &(mcp->mc_fpregs.mcfpu_gsr));
  205. err |= __put_user(fprs, &(mcp->mc_fpregs.mcfpu_fprs));
  206. }
  207. if (err)
  208. goto do_sigsegv;
  209. out:
  210. exception_exit(prev_state);
  211. return;
  212. do_sigsegv:
  213. force_sig(SIGSEGV, current);
  214. goto out;
  215. }
  216. struct rt_signal_frame {
  217. struct sparc_stackf ss;
  218. siginfo_t info;
  219. struct pt_regs regs;
  220. __siginfo_fpu_t __user *fpu_save;
  221. stack_t stack;
  222. sigset_t mask;
  223. __siginfo_rwin_t *rwin_save;
  224. };
  225. void do_rt_sigreturn(struct pt_regs *regs)
  226. {
  227. struct rt_signal_frame __user *sf;
  228. unsigned long tpc, tnpc, tstate;
  229. __siginfo_fpu_t __user *fpu_save;
  230. __siginfo_rwin_t __user *rwin_save;
  231. sigset_t set;
  232. int err;
  233. /* Always make any pending restarted system calls return -EINTR */
  234. current->restart_block.fn = do_no_restart_syscall;
  235. synchronize_user_stack ();
  236. sf = (struct rt_signal_frame __user *)
  237. (regs->u_regs [UREG_FP] + STACK_BIAS);
  238. /* 1. Make sure we are not getting garbage from the user */
  239. if (((unsigned long) sf) & 3)
  240. goto segv;
  241. err = get_user(tpc, &sf->regs.tpc);
  242. err |= __get_user(tnpc, &sf->regs.tnpc);
  243. if (test_thread_flag(TIF_32BIT)) {
  244. tpc &= 0xffffffff;
  245. tnpc &= 0xffffffff;
  246. }
  247. err |= ((tpc | tnpc) & 3);
  248. /* 2. Restore the state */
  249. err |= __get_user(regs->y, &sf->regs.y);
  250. err |= __get_user(tstate, &sf->regs.tstate);
  251. err |= copy_from_user(regs->u_regs, sf->regs.u_regs, sizeof(regs->u_regs));
  252. /* User can only change condition codes and %asi in %tstate. */
  253. regs->tstate &= ~(TSTATE_ASI | TSTATE_ICC | TSTATE_XCC);
  254. regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
  255. err |= __get_user(fpu_save, &sf->fpu_save);
  256. if (!err && fpu_save)
  257. err |= restore_fpu_state(regs, fpu_save);
  258. err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
  259. err |= restore_altstack(&sf->stack);
  260. if (err)
  261. goto segv;
  262. err |= __get_user(rwin_save, &sf->rwin_save);
  263. if (!err && rwin_save) {
  264. if (restore_rwin_state(rwin_save))
  265. goto segv;
  266. }
  267. regs->tpc = tpc;
  268. regs->tnpc = tnpc;
  269. /* Prevent syscall restart. */
  270. pt_regs_clear_syscall(regs);
  271. set_current_blocked(&set);
  272. return;
  273. segv:
  274. force_sig(SIGSEGV, current);
  275. }
  276. /* Checks if the fp is valid */
  277. static int invalid_frame_pointer(void __user *fp)
  278. {
  279. if (((unsigned long) fp) & 15)
  280. return 1;
  281. return 0;
  282. }
  283. static inline void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long framesize)
  284. {
  285. unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
  286. /*
  287. * If we are on the alternate signal stack and would overflow it, don't.
  288. * Return an always-bogus address instead so we will die with SIGSEGV.
  289. */
  290. if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
  291. return (void __user *) -1L;
  292. /* This is the X/Open sanctioned signal stack switching. */
  293. sp = sigsp(sp, ksig) - framesize;
  294. /* Always align the stack frame. This handles two cases. First,
  295. * sigaltstack need not be mindful of platform specific stack
  296. * alignment. Second, if we took this signal because the stack
  297. * is not aligned properly, we'd like to take the signal cleanly
  298. * and report that.
  299. */
  300. sp &= ~15UL;
  301. return (void __user *) sp;
  302. }
  303. static inline int
  304. setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
  305. {
  306. struct rt_signal_frame __user *sf;
  307. int wsaved, err, sf_size;
  308. void __user *tail;
  309. /* 1. Make sure everything is clean */
  310. synchronize_user_stack();
  311. save_and_clear_fpu();
  312. wsaved = get_thread_wsaved();
  313. sf_size = sizeof(struct rt_signal_frame);
  314. if (current_thread_info()->fpsaved[0] & FPRS_FEF)
  315. sf_size += sizeof(__siginfo_fpu_t);
  316. if (wsaved)
  317. sf_size += sizeof(__siginfo_rwin_t);
  318. sf = (struct rt_signal_frame __user *)
  319. get_sigframe(ksig, regs, sf_size);
  320. if (invalid_frame_pointer (sf)) {
  321. do_exit(SIGILL); /* won't return, actually */
  322. return -EINVAL;
  323. }
  324. tail = (sf + 1);
  325. /* 2. Save the current process state */
  326. err = copy_to_user(&sf->regs, regs, sizeof (*regs));
  327. if (current_thread_info()->fpsaved[0] & FPRS_FEF) {
  328. __siginfo_fpu_t __user *fpu_save = tail;
  329. tail += sizeof(__siginfo_fpu_t);
  330. err |= save_fpu_state(regs, fpu_save);
  331. err |= __put_user((u64)fpu_save, &sf->fpu_save);
  332. } else {
  333. err |= __put_user(0, &sf->fpu_save);
  334. }
  335. if (wsaved) {
  336. __siginfo_rwin_t __user *rwin_save = tail;
  337. tail += sizeof(__siginfo_rwin_t);
  338. err |= save_rwin_state(wsaved, rwin_save);
  339. err |= __put_user((u64)rwin_save, &sf->rwin_save);
  340. set_thread_wsaved(0);
  341. } else {
  342. err |= __put_user(0, &sf->rwin_save);
  343. }
  344. /* Setup sigaltstack */
  345. err |= __save_altstack(&sf->stack, regs->u_regs[UREG_FP]);
  346. err |= copy_to_user(&sf->mask, sigmask_to_save(), sizeof(sigset_t));
  347. if (!wsaved) {
  348. err |= copy_in_user((u64 __user *)sf,
  349. (u64 __user *)(regs->u_regs[UREG_FP] +
  350. STACK_BIAS),
  351. sizeof(struct reg_window));
  352. } else {
  353. struct reg_window *rp;
  354. rp = &current_thread_info()->reg_window[wsaved - 1];
  355. err |= copy_to_user(sf, rp, sizeof(struct reg_window));
  356. }
  357. if (ksig->ka.sa.sa_flags & SA_SIGINFO)
  358. err |= copy_siginfo_to_user(&sf->info, &ksig->info);
  359. else {
  360. err |= __put_user(ksig->sig, &sf->info.si_signo);
  361. err |= __put_user(SI_NOINFO, &sf->info.si_code);
  362. }
  363. if (err)
  364. return err;
  365. /* 3. signal handler back-trampoline and parameters */
  366. regs->u_regs[UREG_FP] = ((unsigned long) sf) - STACK_BIAS;
  367. regs->u_regs[UREG_I0] = ksig->sig;
  368. regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
  369. /* The sigcontext is passed in this way because of how it
  370. * is defined in GLIBC's /usr/include/bits/sigcontext.h
  371. * for sparc64. It includes the 128 bytes of siginfo_t.
  372. */
  373. regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
  374. /* 5. signal handler */
  375. regs->tpc = (unsigned long) ksig->ka.sa.sa_handler;
  376. regs->tnpc = (regs->tpc + 4);
  377. if (test_thread_flag(TIF_32BIT)) {
  378. regs->tpc &= 0xffffffff;
  379. regs->tnpc &= 0xffffffff;
  380. }
  381. /* 4. return to kernel instructions */
  382. regs->u_regs[UREG_I7] = (unsigned long)ksig->ka.ka_restorer;
  383. return 0;
  384. }
  385. static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
  386. struct sigaction *sa)
  387. {
  388. switch (regs->u_regs[UREG_I0]) {
  389. case ERESTART_RESTARTBLOCK:
  390. case ERESTARTNOHAND:
  391. no_system_call_restart:
  392. regs->u_regs[UREG_I0] = EINTR;
  393. regs->tstate |= (TSTATE_ICARRY|TSTATE_XCARRY);
  394. break;
  395. case ERESTARTSYS:
  396. if (!(sa->sa_flags & SA_RESTART))
  397. goto no_system_call_restart;
  398. /* fallthrough */
  399. case ERESTARTNOINTR:
  400. regs->u_regs[UREG_I0] = orig_i0;
  401. regs->tpc -= 4;
  402. regs->tnpc -= 4;
  403. }
  404. }
  405. /* Note that 'init' is a special process: it doesn't get signals it doesn't
  406. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  407. * mistake.
  408. */
  409. static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
  410. {
  411. struct ksignal ksig;
  412. int restart_syscall;
  413. bool has_handler;
  414. /* It's a lot of work and synchronization to add a new ptrace
  415. * register for GDB to save and restore in order to get
  416. * orig_i0 correct for syscall restarts when debugging.
  417. *
  418. * Although it should be the case that most of the global
  419. * registers are volatile across a system call, glibc already
  420. * depends upon that fact that we preserve them. So we can't
  421. * just use any global register to save away the orig_i0 value.
  422. *
  423. * In particular %g2, %g3, %g4, and %g5 are all assumed to be
  424. * preserved across a system call trap by various pieces of
  425. * code in glibc.
  426. *
  427. * %g7 is used as the "thread register". %g6 is not used in
  428. * any fixed manner. %g6 is used as a scratch register and
  429. * a compiler temporary, but it's value is never used across
  430. * a system call. Therefore %g6 is usable for orig_i0 storage.
  431. */
  432. if (pt_regs_is_syscall(regs) &&
  433. (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
  434. regs->u_regs[UREG_G6] = orig_i0;
  435. #ifdef CONFIG_COMPAT
  436. if (test_thread_flag(TIF_32BIT)) {
  437. do_signal32(regs);
  438. return;
  439. }
  440. #endif
  441. has_handler = get_signal(&ksig);
  442. restart_syscall = 0;
  443. if (pt_regs_is_syscall(regs) &&
  444. (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
  445. restart_syscall = 1;
  446. orig_i0 = regs->u_regs[UREG_G6];
  447. }
  448. if (has_handler) {
  449. if (restart_syscall)
  450. syscall_restart(orig_i0, regs, &ksig.ka.sa);
  451. signal_setup_done(setup_rt_frame(&ksig, regs), &ksig, 0);
  452. } else {
  453. if (restart_syscall) {
  454. switch (regs->u_regs[UREG_I0]) {
  455. case ERESTARTNOHAND:
  456. case ERESTARTSYS:
  457. case ERESTARTNOINTR:
  458. /* replay the system call when we are done */
  459. regs->u_regs[UREG_I0] = orig_i0;
  460. regs->tpc -= 4;
  461. regs->tnpc -= 4;
  462. pt_regs_clear_syscall(regs);
  463. case ERESTART_RESTARTBLOCK:
  464. regs->u_regs[UREG_G1] = __NR_restart_syscall;
  465. regs->tpc -= 4;
  466. regs->tnpc -= 4;
  467. pt_regs_clear_syscall(regs);
  468. }
  469. }
  470. restore_saved_sigmask();
  471. }
  472. }
  473. void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
  474. {
  475. user_exit();
  476. if (thread_info_flags & _TIF_SIGPENDING)
  477. do_signal(regs, orig_i0);
  478. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  479. clear_thread_flag(TIF_NOTIFY_RESUME);
  480. tracehook_notify_resume(regs);
  481. }
  482. user_enter();
  483. }