signal_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. synchronize_user_stack();
  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. /* Checks if the fp is valid. We always build rt signal frames which
  217. * are 16-byte aligned, therefore we can always enforce that the
  218. * restore frame has that property as well.
  219. */
  220. static bool invalid_frame_pointer(void __user *fp)
  221. {
  222. if (((unsigned long) fp) & 15)
  223. return true;
  224. return false;
  225. }
  226. struct rt_signal_frame {
  227. struct sparc_stackf ss;
  228. siginfo_t info;
  229. struct pt_regs regs;
  230. __siginfo_fpu_t __user *fpu_save;
  231. stack_t stack;
  232. sigset_t mask;
  233. __siginfo_rwin_t *rwin_save;
  234. };
  235. void do_rt_sigreturn(struct pt_regs *regs)
  236. {
  237. unsigned long tpc, tnpc, tstate, ufp;
  238. struct rt_signal_frame __user *sf;
  239. __siginfo_fpu_t __user *fpu_save;
  240. __siginfo_rwin_t __user *rwin_save;
  241. sigset_t set;
  242. int err;
  243. /* Always make any pending restarted system calls return -EINTR */
  244. current->restart_block.fn = do_no_restart_syscall;
  245. synchronize_user_stack ();
  246. sf = (struct rt_signal_frame __user *)
  247. (regs->u_regs [UREG_FP] + STACK_BIAS);
  248. /* 1. Make sure we are not getting garbage from the user */
  249. if (invalid_frame_pointer(sf))
  250. goto segv;
  251. if (get_user(ufp, &sf->regs.u_regs[UREG_FP]))
  252. goto segv;
  253. if ((ufp + STACK_BIAS) & 0x7)
  254. goto segv;
  255. err = __get_user(tpc, &sf->regs.tpc);
  256. err |= __get_user(tnpc, &sf->regs.tnpc);
  257. if (test_thread_flag(TIF_32BIT)) {
  258. tpc &= 0xffffffff;
  259. tnpc &= 0xffffffff;
  260. }
  261. err |= ((tpc | tnpc) & 3);
  262. /* 2. Restore the state */
  263. err |= __get_user(regs->y, &sf->regs.y);
  264. err |= __get_user(tstate, &sf->regs.tstate);
  265. err |= copy_from_user(regs->u_regs, sf->regs.u_regs, sizeof(regs->u_regs));
  266. /* User can only change condition codes and %asi in %tstate. */
  267. regs->tstate &= ~(TSTATE_ASI | TSTATE_ICC | TSTATE_XCC);
  268. regs->tstate |= (tstate & (TSTATE_ASI | TSTATE_ICC | TSTATE_XCC));
  269. err |= __get_user(fpu_save, &sf->fpu_save);
  270. if (!err && fpu_save)
  271. err |= restore_fpu_state(regs, fpu_save);
  272. err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
  273. err |= restore_altstack(&sf->stack);
  274. if (err)
  275. goto segv;
  276. err |= __get_user(rwin_save, &sf->rwin_save);
  277. if (!err && rwin_save) {
  278. if (restore_rwin_state(rwin_save))
  279. goto segv;
  280. }
  281. regs->tpc = tpc;
  282. regs->tnpc = tnpc;
  283. /* Prevent syscall restart. */
  284. pt_regs_clear_syscall(regs);
  285. set_current_blocked(&set);
  286. return;
  287. segv:
  288. force_sig(SIGSEGV, current);
  289. }
  290. static inline void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long framesize)
  291. {
  292. unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
  293. /*
  294. * If we are on the alternate signal stack and would overflow it, don't.
  295. * Return an always-bogus address instead so we will die with SIGSEGV.
  296. */
  297. if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
  298. return (void __user *) -1L;
  299. /* This is the X/Open sanctioned signal stack switching. */
  300. sp = sigsp(sp, ksig) - framesize;
  301. /* Always align the stack frame. This handles two cases. First,
  302. * sigaltstack need not be mindful of platform specific stack
  303. * alignment. Second, if we took this signal because the stack
  304. * is not aligned properly, we'd like to take the signal cleanly
  305. * and report that.
  306. */
  307. sp &= ~15UL;
  308. return (void __user *) sp;
  309. }
  310. static inline int
  311. setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
  312. {
  313. struct rt_signal_frame __user *sf;
  314. int wsaved, err, sf_size;
  315. void __user *tail;
  316. /* 1. Make sure everything is clean */
  317. synchronize_user_stack();
  318. save_and_clear_fpu();
  319. wsaved = get_thread_wsaved();
  320. sf_size = sizeof(struct rt_signal_frame);
  321. if (current_thread_info()->fpsaved[0] & FPRS_FEF)
  322. sf_size += sizeof(__siginfo_fpu_t);
  323. if (wsaved)
  324. sf_size += sizeof(__siginfo_rwin_t);
  325. sf = (struct rt_signal_frame __user *)
  326. get_sigframe(ksig, regs, sf_size);
  327. if (invalid_frame_pointer (sf)) {
  328. do_exit(SIGILL); /* won't return, actually */
  329. return -EINVAL;
  330. }
  331. tail = (sf + 1);
  332. /* 2. Save the current process state */
  333. err = copy_to_user(&sf->regs, regs, sizeof (*regs));
  334. if (current_thread_info()->fpsaved[0] & FPRS_FEF) {
  335. __siginfo_fpu_t __user *fpu_save = tail;
  336. tail += sizeof(__siginfo_fpu_t);
  337. err |= save_fpu_state(regs, fpu_save);
  338. err |= __put_user((u64)fpu_save, &sf->fpu_save);
  339. } else {
  340. err |= __put_user(0, &sf->fpu_save);
  341. }
  342. if (wsaved) {
  343. __siginfo_rwin_t __user *rwin_save = tail;
  344. tail += sizeof(__siginfo_rwin_t);
  345. err |= save_rwin_state(wsaved, rwin_save);
  346. err |= __put_user((u64)rwin_save, &sf->rwin_save);
  347. set_thread_wsaved(0);
  348. } else {
  349. err |= __put_user(0, &sf->rwin_save);
  350. }
  351. /* Setup sigaltstack */
  352. err |= __save_altstack(&sf->stack, regs->u_regs[UREG_FP]);
  353. err |= copy_to_user(&sf->mask, sigmask_to_save(), sizeof(sigset_t));
  354. if (!wsaved) {
  355. err |= copy_in_user((u64 __user *)sf,
  356. (u64 __user *)(regs->u_regs[UREG_FP] +
  357. STACK_BIAS),
  358. sizeof(struct reg_window));
  359. } else {
  360. struct reg_window *rp;
  361. rp = &current_thread_info()->reg_window[wsaved - 1];
  362. err |= copy_to_user(sf, rp, sizeof(struct reg_window));
  363. }
  364. if (ksig->ka.sa.sa_flags & SA_SIGINFO)
  365. err |= copy_siginfo_to_user(&sf->info, &ksig->info);
  366. else {
  367. err |= __put_user(ksig->sig, &sf->info.si_signo);
  368. err |= __put_user(SI_NOINFO, &sf->info.si_code);
  369. }
  370. if (err)
  371. return err;
  372. /* 3. signal handler back-trampoline and parameters */
  373. regs->u_regs[UREG_FP] = ((unsigned long) sf) - STACK_BIAS;
  374. regs->u_regs[UREG_I0] = ksig->sig;
  375. regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
  376. /* The sigcontext is passed in this way because of how it
  377. * is defined in GLIBC's /usr/include/bits/sigcontext.h
  378. * for sparc64. It includes the 128 bytes of siginfo_t.
  379. */
  380. regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
  381. /* 5. signal handler */
  382. regs->tpc = (unsigned long) ksig->ka.sa.sa_handler;
  383. regs->tnpc = (regs->tpc + 4);
  384. if (test_thread_flag(TIF_32BIT)) {
  385. regs->tpc &= 0xffffffff;
  386. regs->tnpc &= 0xffffffff;
  387. }
  388. /* 4. return to kernel instructions */
  389. regs->u_regs[UREG_I7] = (unsigned long)ksig->ka.ka_restorer;
  390. return 0;
  391. }
  392. static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
  393. struct sigaction *sa)
  394. {
  395. switch (regs->u_regs[UREG_I0]) {
  396. case ERESTART_RESTARTBLOCK:
  397. case ERESTARTNOHAND:
  398. no_system_call_restart:
  399. regs->u_regs[UREG_I0] = EINTR;
  400. regs->tstate |= (TSTATE_ICARRY|TSTATE_XCARRY);
  401. break;
  402. case ERESTARTSYS:
  403. if (!(sa->sa_flags & SA_RESTART))
  404. goto no_system_call_restart;
  405. /* fallthrough */
  406. case ERESTARTNOINTR:
  407. regs->u_regs[UREG_I0] = orig_i0;
  408. regs->tpc -= 4;
  409. regs->tnpc -= 4;
  410. }
  411. }
  412. /* Note that 'init' is a special process: it doesn't get signals it doesn't
  413. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  414. * mistake.
  415. */
  416. static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
  417. {
  418. struct ksignal ksig;
  419. int restart_syscall;
  420. bool has_handler;
  421. /* It's a lot of work and synchronization to add a new ptrace
  422. * register for GDB to save and restore in order to get
  423. * orig_i0 correct for syscall restarts when debugging.
  424. *
  425. * Although it should be the case that most of the global
  426. * registers are volatile across a system call, glibc already
  427. * depends upon that fact that we preserve them. So we can't
  428. * just use any global register to save away the orig_i0 value.
  429. *
  430. * In particular %g2, %g3, %g4, and %g5 are all assumed to be
  431. * preserved across a system call trap by various pieces of
  432. * code in glibc.
  433. *
  434. * %g7 is used as the "thread register". %g6 is not used in
  435. * any fixed manner. %g6 is used as a scratch register and
  436. * a compiler temporary, but it's value is never used across
  437. * a system call. Therefore %g6 is usable for orig_i0 storage.
  438. */
  439. if (pt_regs_is_syscall(regs) &&
  440. (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
  441. regs->u_regs[UREG_G6] = orig_i0;
  442. #ifdef CONFIG_COMPAT
  443. if (test_thread_flag(TIF_32BIT)) {
  444. do_signal32(regs);
  445. return;
  446. }
  447. #endif
  448. has_handler = get_signal(&ksig);
  449. restart_syscall = 0;
  450. if (pt_regs_is_syscall(regs) &&
  451. (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
  452. restart_syscall = 1;
  453. orig_i0 = regs->u_regs[UREG_G6];
  454. }
  455. if (has_handler) {
  456. if (restart_syscall)
  457. syscall_restart(orig_i0, regs, &ksig.ka.sa);
  458. signal_setup_done(setup_rt_frame(&ksig, regs), &ksig, 0);
  459. } else {
  460. if (restart_syscall) {
  461. switch (regs->u_regs[UREG_I0]) {
  462. case ERESTARTNOHAND:
  463. case ERESTARTSYS:
  464. case ERESTARTNOINTR:
  465. /* replay the system call when we are done */
  466. regs->u_regs[UREG_I0] = orig_i0;
  467. regs->tpc -= 4;
  468. regs->tnpc -= 4;
  469. pt_regs_clear_syscall(regs);
  470. case ERESTART_RESTARTBLOCK:
  471. regs->u_regs[UREG_G1] = __NR_restart_syscall;
  472. regs->tpc -= 4;
  473. regs->tnpc -= 4;
  474. pt_regs_clear_syscall(regs);
  475. }
  476. }
  477. restore_saved_sigmask();
  478. }
  479. }
  480. void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
  481. {
  482. user_exit();
  483. if (thread_info_flags & _TIF_SIGPENDING)
  484. do_signal(regs, orig_i0);
  485. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  486. clear_thread_flag(TIF_NOTIFY_RESUME);
  487. tracehook_notify_resume(regs);
  488. }
  489. user_enter();
  490. }