signal.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * linux/arch/arm/kernel/signal.c
  3. *
  4. * Copyright (C) 1995-2009 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/errno.h>
  11. #include <linux/signal.h>
  12. #include <linux/personality.h>
  13. #include <linux/uaccess.h>
  14. #include <linux/tracehook.h>
  15. #include <asm/elf.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/ucontext.h>
  18. #include <asm/unistd.h>
  19. #include <asm/vfp.h>
  20. #include "signal.h"
  21. /*
  22. * For ARM syscalls, we encode the syscall number into the instruction.
  23. */
  24. #define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE))
  25. #define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE))
  26. /*
  27. * With EABI, the syscall number has to be loaded into r7.
  28. */
  29. #define MOV_R7_NR_SIGRETURN (0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE))
  30. #define MOV_R7_NR_RT_SIGRETURN (0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
  31. /*
  32. * For Thumb syscalls, we pass the syscall number via r7. We therefore
  33. * need two 16-bit instructions.
  34. */
  35. #define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
  36. #define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
  37. const unsigned long sigreturn_codes[7] = {
  38. MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN,
  39. MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
  40. };
  41. #ifdef CONFIG_CRUNCH
  42. static int preserve_crunch_context(struct crunch_sigframe __user *frame)
  43. {
  44. char kbuf[sizeof(*frame) + 8];
  45. struct crunch_sigframe *kframe;
  46. /* the crunch context must be 64 bit aligned */
  47. kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  48. kframe->magic = CRUNCH_MAGIC;
  49. kframe->size = CRUNCH_STORAGE_SIZE;
  50. crunch_task_copy(current_thread_info(), &kframe->storage);
  51. return __copy_to_user(frame, kframe, sizeof(*frame));
  52. }
  53. static int restore_crunch_context(struct crunch_sigframe __user *frame)
  54. {
  55. char kbuf[sizeof(*frame) + 8];
  56. struct crunch_sigframe *kframe;
  57. /* the crunch context must be 64 bit aligned */
  58. kframe = (struct crunch_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  59. if (__copy_from_user(kframe, frame, sizeof(*frame)))
  60. return -1;
  61. if (kframe->magic != CRUNCH_MAGIC ||
  62. kframe->size != CRUNCH_STORAGE_SIZE)
  63. return -1;
  64. crunch_task_restore(current_thread_info(), &kframe->storage);
  65. return 0;
  66. }
  67. #endif
  68. #ifdef CONFIG_IWMMXT
  69. static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame)
  70. {
  71. char kbuf[sizeof(*frame) + 8];
  72. struct iwmmxt_sigframe *kframe;
  73. /* the iWMMXt context must be 64 bit aligned */
  74. kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  75. kframe->magic = IWMMXT_MAGIC;
  76. kframe->size = IWMMXT_STORAGE_SIZE;
  77. iwmmxt_task_copy(current_thread_info(), &kframe->storage);
  78. return __copy_to_user(frame, kframe, sizeof(*frame));
  79. }
  80. static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame)
  81. {
  82. char kbuf[sizeof(*frame) + 8];
  83. struct iwmmxt_sigframe *kframe;
  84. /* the iWMMXt context must be 64 bit aligned */
  85. kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  86. if (__copy_from_user(kframe, frame, sizeof(*frame)))
  87. return -1;
  88. if (kframe->magic != IWMMXT_MAGIC ||
  89. kframe->size != IWMMXT_STORAGE_SIZE)
  90. return -1;
  91. iwmmxt_task_restore(current_thread_info(), &kframe->storage);
  92. return 0;
  93. }
  94. #endif
  95. #ifdef CONFIG_VFP
  96. static int preserve_vfp_context(struct vfp_sigframe __user *frame)
  97. {
  98. const unsigned long magic = VFP_MAGIC;
  99. const unsigned long size = VFP_STORAGE_SIZE;
  100. int err = 0;
  101. __put_user_error(magic, &frame->magic, err);
  102. __put_user_error(size, &frame->size, err);
  103. if (err)
  104. return -EFAULT;
  105. return vfp_preserve_user_clear_hwstate(&frame->ufp, &frame->ufp_exc);
  106. }
  107. static int restore_vfp_context(struct vfp_sigframe __user *frame)
  108. {
  109. unsigned long magic;
  110. unsigned long size;
  111. int err = 0;
  112. __get_user_error(magic, &frame->magic, err);
  113. __get_user_error(size, &frame->size, err);
  114. if (err)
  115. return -EFAULT;
  116. if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE)
  117. return -EINVAL;
  118. return vfp_restore_user_hwstate(&frame->ufp, &frame->ufp_exc);
  119. }
  120. #endif
  121. /*
  122. * Do a signal return; undo the signal stack. These are aligned to 64-bit.
  123. */
  124. struct sigframe {
  125. struct ucontext uc;
  126. unsigned long retcode[2];
  127. };
  128. struct rt_sigframe {
  129. struct siginfo info;
  130. struct sigframe sig;
  131. };
  132. static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
  133. {
  134. struct aux_sigframe __user *aux;
  135. sigset_t set;
  136. int err;
  137. err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
  138. if (err == 0)
  139. set_current_blocked(&set);
  140. __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
  141. __get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
  142. __get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
  143. __get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
  144. __get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
  145. __get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
  146. __get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
  147. __get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
  148. __get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
  149. __get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
  150. __get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
  151. __get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
  152. __get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
  153. __get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
  154. __get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
  155. __get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
  156. __get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
  157. err |= !valid_user_regs(regs);
  158. aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
  159. #ifdef CONFIG_CRUNCH
  160. if (err == 0)
  161. err |= restore_crunch_context(&aux->crunch);
  162. #endif
  163. #ifdef CONFIG_IWMMXT
  164. if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
  165. err |= restore_iwmmxt_context(&aux->iwmmxt);
  166. #endif
  167. #ifdef CONFIG_VFP
  168. if (err == 0)
  169. err |= restore_vfp_context(&aux->vfp);
  170. #endif
  171. return err;
  172. }
  173. asmlinkage int sys_sigreturn(struct pt_regs *regs)
  174. {
  175. struct sigframe __user *frame;
  176. /* Always make any pending restarted system calls return -EINTR */
  177. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  178. /*
  179. * Since we stacked the signal on a 64-bit boundary,
  180. * then 'sp' should be word aligned here. If it's
  181. * not, then the user is trying to mess with us.
  182. */
  183. if (regs->ARM_sp & 7)
  184. goto badframe;
  185. frame = (struct sigframe __user *)regs->ARM_sp;
  186. if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
  187. goto badframe;
  188. if (restore_sigframe(regs, frame))
  189. goto badframe;
  190. return regs->ARM_r0;
  191. badframe:
  192. force_sig(SIGSEGV, current);
  193. return 0;
  194. }
  195. asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
  196. {
  197. struct rt_sigframe __user *frame;
  198. /* Always make any pending restarted system calls return -EINTR */
  199. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  200. /*
  201. * Since we stacked the signal on a 64-bit boundary,
  202. * then 'sp' should be word aligned here. If it's
  203. * not, then the user is trying to mess with us.
  204. */
  205. if (regs->ARM_sp & 7)
  206. goto badframe;
  207. frame = (struct rt_sigframe __user *)regs->ARM_sp;
  208. if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
  209. goto badframe;
  210. if (restore_sigframe(regs, &frame->sig))
  211. goto badframe;
  212. if (restore_altstack(&frame->sig.uc.uc_stack))
  213. goto badframe;
  214. return regs->ARM_r0;
  215. badframe:
  216. force_sig(SIGSEGV, current);
  217. return 0;
  218. }
  219. static int
  220. setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set)
  221. {
  222. struct aux_sigframe __user *aux;
  223. int err = 0;
  224. __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
  225. __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
  226. __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
  227. __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
  228. __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
  229. __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
  230. __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
  231. __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
  232. __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
  233. __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
  234. __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
  235. __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
  236. __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
  237. __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
  238. __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
  239. __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
  240. __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
  241. __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err);
  242. __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err);
  243. __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err);
  244. __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err);
  245. err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
  246. aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
  247. #ifdef CONFIG_CRUNCH
  248. if (err == 0)
  249. err |= preserve_crunch_context(&aux->crunch);
  250. #endif
  251. #ifdef CONFIG_IWMMXT
  252. if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
  253. err |= preserve_iwmmxt_context(&aux->iwmmxt);
  254. #endif
  255. #ifdef CONFIG_VFP
  256. if (err == 0)
  257. err |= preserve_vfp_context(&aux->vfp);
  258. #endif
  259. __put_user_error(0, &aux->end_magic, err);
  260. return err;
  261. }
  262. static inline void __user *
  263. get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize)
  264. {
  265. unsigned long sp = regs->ARM_sp;
  266. void __user *frame;
  267. /*
  268. * This is the X/Open sanctioned signal stack switching.
  269. */
  270. if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
  271. sp = current->sas_ss_sp + current->sas_ss_size;
  272. /*
  273. * ATPCS B01 mandates 8-byte alignment
  274. */
  275. frame = (void __user *)((sp - framesize) & ~7);
  276. /*
  277. * Check that we can actually write to the signal frame.
  278. */
  279. if (!access_ok(VERIFY_WRITE, frame, framesize))
  280. frame = NULL;
  281. return frame;
  282. }
  283. static int
  284. setup_return(struct pt_regs *regs, struct k_sigaction *ka,
  285. unsigned long __user *rc, void __user *frame, int usig)
  286. {
  287. unsigned long handler = (unsigned long)ka->sa.sa_handler;
  288. unsigned long retcode;
  289. int thumb = 0;
  290. unsigned long cpsr = regs->ARM_cpsr & ~(PSR_f | PSR_E_BIT);
  291. cpsr |= PSR_ENDSTATE;
  292. /*
  293. * Maybe we need to deliver a 32-bit signal to a 26-bit task.
  294. */
  295. if (ka->sa.sa_flags & SA_THIRTYTWO)
  296. cpsr = (cpsr & ~MODE_MASK) | USR_MODE;
  297. #ifdef CONFIG_ARM_THUMB
  298. if (elf_hwcap & HWCAP_THUMB) {
  299. /*
  300. * The LSB of the handler determines if we're going to
  301. * be using THUMB or ARM mode for this signal handler.
  302. */
  303. thumb = handler & 1;
  304. if (thumb) {
  305. cpsr |= PSR_T_BIT;
  306. #if __LINUX_ARM_ARCH__ >= 7
  307. /* clear the If-Then Thumb-2 execution state */
  308. cpsr &= ~PSR_IT_MASK;
  309. #endif
  310. } else
  311. cpsr &= ~PSR_T_BIT;
  312. }
  313. #endif
  314. if (ka->sa.sa_flags & SA_RESTORER) {
  315. retcode = (unsigned long)ka->sa.sa_restorer;
  316. } else {
  317. unsigned int idx = thumb << 1;
  318. if (ka->sa.sa_flags & SA_SIGINFO)
  319. idx += 3;
  320. if (__put_user(sigreturn_codes[idx], rc) ||
  321. __put_user(sigreturn_codes[idx+1], rc+1))
  322. return 1;
  323. if (cpsr & MODE32_BIT) {
  324. /*
  325. * 32-bit code can use the new high-page
  326. * signal return code support.
  327. */
  328. retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
  329. } else {
  330. /*
  331. * Ensure that the instruction cache sees
  332. * the return code written onto the stack.
  333. */
  334. flush_icache_range((unsigned long)rc,
  335. (unsigned long)(rc + 2));
  336. retcode = ((unsigned long)rc) + thumb;
  337. }
  338. }
  339. regs->ARM_r0 = usig;
  340. regs->ARM_sp = (unsigned long)frame;
  341. regs->ARM_lr = retcode;
  342. regs->ARM_pc = handler;
  343. regs->ARM_cpsr = cpsr;
  344. return 0;
  345. }
  346. static int
  347. setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *regs)
  348. {
  349. struct sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
  350. int err = 0;
  351. if (!frame)
  352. return 1;
  353. /*
  354. * Set uc.uc_flags to a value which sc.trap_no would never have.
  355. */
  356. __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err);
  357. err |= setup_sigframe(frame, regs, set);
  358. if (err == 0)
  359. err = setup_return(regs, ka, frame->retcode, frame, usig);
  360. return err;
  361. }
  362. static int
  363. setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
  364. sigset_t *set, struct pt_regs *regs)
  365. {
  366. struct rt_sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
  367. int err = 0;
  368. if (!frame)
  369. return 1;
  370. err |= copy_siginfo_to_user(&frame->info, info);
  371. __put_user_error(0, &frame->sig.uc.uc_flags, err);
  372. __put_user_error(NULL, &frame->sig.uc.uc_link, err);
  373. err |= __save_altstack(&frame->sig.uc.uc_stack, regs->ARM_sp);
  374. err |= setup_sigframe(&frame->sig, regs, set);
  375. if (err == 0)
  376. err = setup_return(regs, ka, frame->sig.retcode, frame, usig);
  377. if (err == 0) {
  378. /*
  379. * For realtime signals we must also set the second and third
  380. * arguments for the signal handler.
  381. * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06
  382. */
  383. regs->ARM_r1 = (unsigned long)&frame->info;
  384. regs->ARM_r2 = (unsigned long)&frame->sig.uc;
  385. }
  386. return err;
  387. }
  388. /*
  389. * OK, we're invoking a handler
  390. */
  391. static void
  392. handle_signal(unsigned long sig, struct k_sigaction *ka,
  393. siginfo_t *info, struct pt_regs *regs)
  394. {
  395. struct thread_info *thread = current_thread_info();
  396. struct task_struct *tsk = current;
  397. sigset_t *oldset = sigmask_to_save();
  398. int usig = sig;
  399. int ret;
  400. /*
  401. * translate the signal
  402. */
  403. if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap)
  404. usig = thread->exec_domain->signal_invmap[usig];
  405. /*
  406. * Set up the stack frame
  407. */
  408. if (ka->sa.sa_flags & SA_SIGINFO)
  409. ret = setup_rt_frame(usig, ka, info, oldset, regs);
  410. else
  411. ret = setup_frame(usig, ka, oldset, regs);
  412. /*
  413. * Check that the resulting registers are actually sane.
  414. */
  415. ret |= !valid_user_regs(regs);
  416. if (ret != 0) {
  417. force_sigsegv(sig, tsk);
  418. return;
  419. }
  420. signal_delivered(sig, info, ka, regs, 0);
  421. }
  422. /*
  423. * Note that 'init' is a special process: it doesn't get signals it doesn't
  424. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  425. * mistake.
  426. *
  427. * Note that we go through the signals twice: once to check the signals that
  428. * the kernel can handle, and then we build all the user-level signal handling
  429. * stack-frames in one go after that.
  430. */
  431. static int do_signal(struct pt_regs *regs, int syscall)
  432. {
  433. unsigned int retval = 0, continue_addr = 0, restart_addr = 0;
  434. struct k_sigaction ka;
  435. siginfo_t info;
  436. int signr;
  437. int restart = 0;
  438. /*
  439. * If we were from a system call, check for system call restarting...
  440. */
  441. if (syscall) {
  442. continue_addr = regs->ARM_pc;
  443. restart_addr = continue_addr - (thumb_mode(regs) ? 2 : 4);
  444. retval = regs->ARM_r0;
  445. /*
  446. * Prepare for system call restart. We do this here so that a
  447. * debugger will see the already changed PSW.
  448. */
  449. switch (retval) {
  450. case -ERESTART_RESTARTBLOCK:
  451. restart -= 2;
  452. case -ERESTARTNOHAND:
  453. case -ERESTARTSYS:
  454. case -ERESTARTNOINTR:
  455. restart++;
  456. regs->ARM_r0 = regs->ARM_ORIG_r0;
  457. regs->ARM_pc = restart_addr;
  458. break;
  459. }
  460. }
  461. /*
  462. * Get the signal to deliver. When running under ptrace, at this
  463. * point the debugger may change all our registers ...
  464. */
  465. signr = get_signal_to_deliver(&info, &ka, regs, NULL);
  466. /*
  467. * Depending on the signal settings we may need to revert the
  468. * decision to restart the system call. But skip this if a
  469. * debugger has chosen to restart at a different PC.
  470. */
  471. if (regs->ARM_pc != restart_addr)
  472. restart = 0;
  473. if (signr > 0) {
  474. if (unlikely(restart)) {
  475. if (retval == -ERESTARTNOHAND ||
  476. retval == -ERESTART_RESTARTBLOCK
  477. || (retval == -ERESTARTSYS
  478. && !(ka.sa.sa_flags & SA_RESTART))) {
  479. regs->ARM_r0 = -EINTR;
  480. regs->ARM_pc = continue_addr;
  481. }
  482. }
  483. handle_signal(signr, &ka, &info, regs);
  484. return 0;
  485. }
  486. restore_saved_sigmask();
  487. if (unlikely(restart))
  488. regs->ARM_pc = continue_addr;
  489. return restart;
  490. }
  491. asmlinkage int
  492. do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
  493. {
  494. do {
  495. if (likely(thread_flags & _TIF_NEED_RESCHED)) {
  496. schedule();
  497. } else {
  498. if (unlikely(!user_mode(regs)))
  499. return 0;
  500. local_irq_enable();
  501. if (thread_flags & _TIF_SIGPENDING) {
  502. int restart = do_signal(regs, syscall);
  503. if (unlikely(restart)) {
  504. /*
  505. * Restart without handlers.
  506. * Deal with it without leaving
  507. * the kernel space.
  508. */
  509. return restart;
  510. }
  511. syscall = 0;
  512. } else {
  513. clear_thread_flag(TIF_NOTIFY_RESUME);
  514. tracehook_notify_resume(regs);
  515. }
  516. }
  517. local_irq_disable();
  518. thread_flags = current_thread_info()->flags;
  519. } while (thread_flags & _TIF_WORK_MASK);
  520. return 0;
  521. }