signal32.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * Based on arch/arm/kernel/signal.c
  3. *
  4. * Copyright (C) 1995-2009 Russell King
  5. * Copyright (C) 2012 ARM Ltd.
  6. * Modified by Will Deacon <will.deacon@arm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <linux/compat.h>
  21. #include <linux/signal.h>
  22. #include <linux/syscalls.h>
  23. #include <linux/ratelimit.h>
  24. #include <asm/esr.h>
  25. #include <asm/fpsimd.h>
  26. #include <asm/signal32.h>
  27. #include <asm/uaccess.h>
  28. #include <asm/unistd.h>
  29. struct compat_sigcontext {
  30. /* We always set these two fields to 0 */
  31. compat_ulong_t trap_no;
  32. compat_ulong_t error_code;
  33. compat_ulong_t oldmask;
  34. compat_ulong_t arm_r0;
  35. compat_ulong_t arm_r1;
  36. compat_ulong_t arm_r2;
  37. compat_ulong_t arm_r3;
  38. compat_ulong_t arm_r4;
  39. compat_ulong_t arm_r5;
  40. compat_ulong_t arm_r6;
  41. compat_ulong_t arm_r7;
  42. compat_ulong_t arm_r8;
  43. compat_ulong_t arm_r9;
  44. compat_ulong_t arm_r10;
  45. compat_ulong_t arm_fp;
  46. compat_ulong_t arm_ip;
  47. compat_ulong_t arm_sp;
  48. compat_ulong_t arm_lr;
  49. compat_ulong_t arm_pc;
  50. compat_ulong_t arm_cpsr;
  51. compat_ulong_t fault_address;
  52. };
  53. struct compat_ucontext {
  54. compat_ulong_t uc_flags;
  55. compat_uptr_t uc_link;
  56. compat_stack_t uc_stack;
  57. struct compat_sigcontext uc_mcontext;
  58. compat_sigset_t uc_sigmask;
  59. int __unused[32 - (sizeof (compat_sigset_t) / sizeof (int))];
  60. compat_ulong_t uc_regspace[128] __attribute__((__aligned__(8)));
  61. };
  62. struct compat_vfp_sigframe {
  63. compat_ulong_t magic;
  64. compat_ulong_t size;
  65. struct compat_user_vfp {
  66. compat_u64 fpregs[32];
  67. compat_ulong_t fpscr;
  68. } ufp;
  69. struct compat_user_vfp_exc {
  70. compat_ulong_t fpexc;
  71. compat_ulong_t fpinst;
  72. compat_ulong_t fpinst2;
  73. } ufp_exc;
  74. } __attribute__((__aligned__(8)));
  75. #define VFP_MAGIC 0x56465001
  76. #define VFP_STORAGE_SIZE sizeof(struct compat_vfp_sigframe)
  77. #define FSR_WRITE_SHIFT (11)
  78. struct compat_aux_sigframe {
  79. struct compat_vfp_sigframe vfp;
  80. /* Something that isn't a valid magic number for any coprocessor. */
  81. unsigned long end_magic;
  82. } __attribute__((__aligned__(8)));
  83. struct compat_sigframe {
  84. struct compat_ucontext uc;
  85. compat_ulong_t retcode[2];
  86. };
  87. struct compat_rt_sigframe {
  88. struct compat_siginfo info;
  89. struct compat_sigframe sig;
  90. };
  91. #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
  92. static inline int put_sigset_t(compat_sigset_t __user *uset, sigset_t *set)
  93. {
  94. compat_sigset_t cset;
  95. cset.sig[0] = set->sig[0] & 0xffffffffull;
  96. cset.sig[1] = set->sig[0] >> 32;
  97. return copy_to_user(uset, &cset, sizeof(*uset));
  98. }
  99. static inline int get_sigset_t(sigset_t *set,
  100. const compat_sigset_t __user *uset)
  101. {
  102. compat_sigset_t s32;
  103. if (copy_from_user(&s32, uset, sizeof(*uset)))
  104. return -EFAULT;
  105. set->sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
  106. return 0;
  107. }
  108. int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
  109. {
  110. int err;
  111. if (!access_ok(VERIFY_WRITE, to, sizeof(*to)))
  112. return -EFAULT;
  113. /* If you change siginfo_t structure, please be sure
  114. * this code is fixed accordingly.
  115. * It should never copy any pad contained in the structure
  116. * to avoid security leaks, but must copy the generic
  117. * 3 ints plus the relevant union member.
  118. * This routine must convert siginfo from 64bit to 32bit as well
  119. * at the same time.
  120. */
  121. err = __put_user(from->si_signo, &to->si_signo);
  122. err |= __put_user(from->si_errno, &to->si_errno);
  123. err |= __put_user((short)from->si_code, &to->si_code);
  124. if (from->si_code < 0)
  125. err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad,
  126. SI_PAD_SIZE);
  127. else switch (from->si_code & __SI_MASK) {
  128. case __SI_KILL:
  129. err |= __put_user(from->si_pid, &to->si_pid);
  130. err |= __put_user(from->si_uid, &to->si_uid);
  131. break;
  132. case __SI_TIMER:
  133. err |= __put_user(from->si_tid, &to->si_tid);
  134. err |= __put_user(from->si_overrun, &to->si_overrun);
  135. err |= __put_user(from->si_int, &to->si_int);
  136. break;
  137. case __SI_POLL:
  138. err |= __put_user(from->si_band, &to->si_band);
  139. err |= __put_user(from->si_fd, &to->si_fd);
  140. break;
  141. case __SI_FAULT:
  142. err |= __put_user((compat_uptr_t)(unsigned long)from->si_addr,
  143. &to->si_addr);
  144. #ifdef BUS_MCEERR_AO
  145. /*
  146. * Other callers might not initialize the si_lsb field,
  147. * so check explicitely for the right codes here.
  148. */
  149. if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
  150. err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
  151. #endif
  152. break;
  153. case __SI_CHLD:
  154. err |= __put_user(from->si_pid, &to->si_pid);
  155. err |= __put_user(from->si_uid, &to->si_uid);
  156. err |= __put_user(from->si_status, &to->si_status);
  157. err |= __put_user(from->si_utime, &to->si_utime);
  158. err |= __put_user(from->si_stime, &to->si_stime);
  159. break;
  160. case __SI_RT: /* This is not generated by the kernel as of now. */
  161. case __SI_MESGQ: /* But this is */
  162. err |= __put_user(from->si_pid, &to->si_pid);
  163. err |= __put_user(from->si_uid, &to->si_uid);
  164. err |= __put_user(from->si_int, &to->si_int);
  165. break;
  166. case __SI_SYS:
  167. err |= __put_user((compat_uptr_t)(unsigned long)
  168. from->si_call_addr, &to->si_call_addr);
  169. err |= __put_user(from->si_syscall, &to->si_syscall);
  170. err |= __put_user(from->si_arch, &to->si_arch);
  171. break;
  172. default: /* this is just in case for now ... */
  173. err |= __put_user(from->si_pid, &to->si_pid);
  174. err |= __put_user(from->si_uid, &to->si_uid);
  175. break;
  176. }
  177. return err;
  178. }
  179. int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
  180. {
  181. memset(to, 0, sizeof *to);
  182. if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) ||
  183. copy_from_user(to->_sifields._pad,
  184. from->_sifields._pad, SI_PAD_SIZE))
  185. return -EFAULT;
  186. return 0;
  187. }
  188. /*
  189. * VFP save/restore code.
  190. */
  191. static int compat_preserve_vfp_context(struct compat_vfp_sigframe __user *frame)
  192. {
  193. struct fpsimd_state *fpsimd = &current->thread.fpsimd_state;
  194. compat_ulong_t magic = VFP_MAGIC;
  195. compat_ulong_t size = VFP_STORAGE_SIZE;
  196. compat_ulong_t fpscr, fpexc;
  197. int err = 0;
  198. /*
  199. * Save the hardware registers to the fpsimd_state structure.
  200. * Note that this also saves V16-31, which aren't visible
  201. * in AArch32.
  202. */
  203. fpsimd_preserve_current_state();
  204. /* Place structure header on the stack */
  205. __put_user_error(magic, &frame->magic, err);
  206. __put_user_error(size, &frame->size, err);
  207. /*
  208. * Now copy the FP registers. Since the registers are packed,
  209. * we can copy the prefix we want (V0-V15) as it is.
  210. * FIXME: Won't work if big endian.
  211. */
  212. err |= __copy_to_user(&frame->ufp.fpregs, fpsimd->vregs,
  213. sizeof(frame->ufp.fpregs));
  214. /* Create an AArch32 fpscr from the fpsr and the fpcr. */
  215. fpscr = (fpsimd->fpsr & VFP_FPSCR_STAT_MASK) |
  216. (fpsimd->fpcr & VFP_FPSCR_CTRL_MASK);
  217. __put_user_error(fpscr, &frame->ufp.fpscr, err);
  218. /*
  219. * The exception register aren't available so we fake up a
  220. * basic FPEXC and zero everything else.
  221. */
  222. fpexc = (1 << 30);
  223. __put_user_error(fpexc, &frame->ufp_exc.fpexc, err);
  224. __put_user_error(0, &frame->ufp_exc.fpinst, err);
  225. __put_user_error(0, &frame->ufp_exc.fpinst2, err);
  226. return err ? -EFAULT : 0;
  227. }
  228. static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
  229. {
  230. struct fpsimd_state fpsimd;
  231. compat_ulong_t magic = VFP_MAGIC;
  232. compat_ulong_t size = VFP_STORAGE_SIZE;
  233. compat_ulong_t fpscr;
  234. int err = 0;
  235. __get_user_error(magic, &frame->magic, err);
  236. __get_user_error(size, &frame->size, err);
  237. if (err)
  238. return -EFAULT;
  239. if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE)
  240. return -EINVAL;
  241. /*
  242. * Copy the FP registers into the start of the fpsimd_state.
  243. * FIXME: Won't work if big endian.
  244. */
  245. err |= __copy_from_user(fpsimd.vregs, frame->ufp.fpregs,
  246. sizeof(frame->ufp.fpregs));
  247. /* Extract the fpsr and the fpcr from the fpscr */
  248. __get_user_error(fpscr, &frame->ufp.fpscr, err);
  249. fpsimd.fpsr = fpscr & VFP_FPSCR_STAT_MASK;
  250. fpsimd.fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
  251. /*
  252. * We don't need to touch the exception register, so
  253. * reload the hardware state.
  254. */
  255. if (!err)
  256. fpsimd_update_current_state(&fpsimd);
  257. return err ? -EFAULT : 0;
  258. }
  259. static int compat_restore_sigframe(struct pt_regs *regs,
  260. struct compat_sigframe __user *sf)
  261. {
  262. int err;
  263. sigset_t set;
  264. struct compat_aux_sigframe __user *aux;
  265. err = get_sigset_t(&set, &sf->uc.uc_sigmask);
  266. if (err == 0) {
  267. sigdelsetmask(&set, ~_BLOCKABLE);
  268. set_current_blocked(&set);
  269. }
  270. __get_user_error(regs->regs[0], &sf->uc.uc_mcontext.arm_r0, err);
  271. __get_user_error(regs->regs[1], &sf->uc.uc_mcontext.arm_r1, err);
  272. __get_user_error(regs->regs[2], &sf->uc.uc_mcontext.arm_r2, err);
  273. __get_user_error(regs->regs[3], &sf->uc.uc_mcontext.arm_r3, err);
  274. __get_user_error(regs->regs[4], &sf->uc.uc_mcontext.arm_r4, err);
  275. __get_user_error(regs->regs[5], &sf->uc.uc_mcontext.arm_r5, err);
  276. __get_user_error(regs->regs[6], &sf->uc.uc_mcontext.arm_r6, err);
  277. __get_user_error(regs->regs[7], &sf->uc.uc_mcontext.arm_r7, err);
  278. __get_user_error(regs->regs[8], &sf->uc.uc_mcontext.arm_r8, err);
  279. __get_user_error(regs->regs[9], &sf->uc.uc_mcontext.arm_r9, err);
  280. __get_user_error(regs->regs[10], &sf->uc.uc_mcontext.arm_r10, err);
  281. __get_user_error(regs->regs[11], &sf->uc.uc_mcontext.arm_fp, err);
  282. __get_user_error(regs->regs[12], &sf->uc.uc_mcontext.arm_ip, err);
  283. __get_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
  284. __get_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
  285. __get_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
  286. __get_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
  287. /*
  288. * Avoid compat_sys_sigreturn() restarting.
  289. */
  290. regs->syscallno = ~0UL;
  291. err |= !valid_user_regs(&regs->user_regs);
  292. aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace;
  293. if (err == 0)
  294. err |= compat_restore_vfp_context(&aux->vfp);
  295. return err;
  296. }
  297. asmlinkage int compat_sys_sigreturn(struct pt_regs *regs)
  298. {
  299. struct compat_sigframe __user *frame;
  300. /* Always make any pending restarted system calls return -EINTR */
  301. current->restart_block.fn = do_no_restart_syscall;
  302. /*
  303. * Since we stacked the signal on a 64-bit boundary,
  304. * then 'sp' should be word aligned here. If it's
  305. * not, then the user is trying to mess with us.
  306. */
  307. if (regs->compat_sp & 7)
  308. goto badframe;
  309. frame = (struct compat_sigframe __user *)regs->compat_sp;
  310. if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
  311. goto badframe;
  312. if (compat_restore_sigframe(regs, frame))
  313. goto badframe;
  314. return regs->regs[0];
  315. badframe:
  316. if (show_unhandled_signals)
  317. pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n",
  318. current->comm, task_pid_nr(current), __func__,
  319. regs->pc, regs->compat_sp);
  320. force_sig(SIGSEGV, current);
  321. return 0;
  322. }
  323. asmlinkage int compat_sys_rt_sigreturn(struct pt_regs *regs)
  324. {
  325. struct compat_rt_sigframe __user *frame;
  326. /* Always make any pending restarted system calls return -EINTR */
  327. current->restart_block.fn = do_no_restart_syscall;
  328. /*
  329. * Since we stacked the signal on a 64-bit boundary,
  330. * then 'sp' should be word aligned here. If it's
  331. * not, then the user is trying to mess with us.
  332. */
  333. if (regs->compat_sp & 7)
  334. goto badframe;
  335. frame = (struct compat_rt_sigframe __user *)regs->compat_sp;
  336. if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
  337. goto badframe;
  338. if (compat_restore_sigframe(regs, &frame->sig))
  339. goto badframe;
  340. if (compat_restore_altstack(&frame->sig.uc.uc_stack))
  341. goto badframe;
  342. return regs->regs[0];
  343. badframe:
  344. if (show_unhandled_signals)
  345. pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n",
  346. current->comm, task_pid_nr(current), __func__,
  347. regs->pc, regs->compat_sp);
  348. force_sig(SIGSEGV, current);
  349. return 0;
  350. }
  351. static void __user *compat_get_sigframe(struct ksignal *ksig,
  352. struct pt_regs *regs,
  353. int framesize)
  354. {
  355. compat_ulong_t sp = sigsp(regs->compat_sp, ksig);
  356. void __user *frame;
  357. /*
  358. * ATPCS B01 mandates 8-byte alignment
  359. */
  360. frame = compat_ptr((compat_uptr_t)((sp - framesize) & ~7));
  361. /*
  362. * Check that we can actually write to the signal frame.
  363. */
  364. if (!access_ok(VERIFY_WRITE, frame, framesize))
  365. frame = NULL;
  366. return frame;
  367. }
  368. static void compat_setup_return(struct pt_regs *regs, struct k_sigaction *ka,
  369. compat_ulong_t __user *rc, void __user *frame,
  370. int usig)
  371. {
  372. compat_ulong_t handler = ptr_to_compat(ka->sa.sa_handler);
  373. compat_ulong_t retcode;
  374. compat_ulong_t spsr = regs->pstate & ~(PSR_f | COMPAT_PSR_E_BIT);
  375. int thumb;
  376. /* Check if the handler is written for ARM or Thumb */
  377. thumb = handler & 1;
  378. if (thumb)
  379. spsr |= COMPAT_PSR_T_BIT;
  380. else
  381. spsr &= ~COMPAT_PSR_T_BIT;
  382. /* The IT state must be cleared for both ARM and Thumb-2 */
  383. spsr &= ~COMPAT_PSR_IT_MASK;
  384. /* Restore the original endianness */
  385. spsr |= COMPAT_PSR_ENDSTATE;
  386. if (ka->sa.sa_flags & SA_RESTORER) {
  387. retcode = ptr_to_compat(ka->sa.sa_restorer);
  388. } else {
  389. /* Set up sigreturn pointer */
  390. unsigned int idx = thumb << 1;
  391. if (ka->sa.sa_flags & SA_SIGINFO)
  392. idx += 3;
  393. retcode = AARCH32_VECTORS_BASE +
  394. AARCH32_KERN_SIGRET_CODE_OFFSET +
  395. (idx << 2) + thumb;
  396. }
  397. regs->regs[0] = usig;
  398. regs->compat_sp = ptr_to_compat(frame);
  399. regs->compat_lr = retcode;
  400. regs->pc = handler;
  401. regs->pstate = spsr;
  402. }
  403. static int compat_setup_sigframe(struct compat_sigframe __user *sf,
  404. struct pt_regs *regs, sigset_t *set)
  405. {
  406. struct compat_aux_sigframe __user *aux;
  407. int err = 0;
  408. __put_user_error(regs->regs[0], &sf->uc.uc_mcontext.arm_r0, err);
  409. __put_user_error(regs->regs[1], &sf->uc.uc_mcontext.arm_r1, err);
  410. __put_user_error(regs->regs[2], &sf->uc.uc_mcontext.arm_r2, err);
  411. __put_user_error(regs->regs[3], &sf->uc.uc_mcontext.arm_r3, err);
  412. __put_user_error(regs->regs[4], &sf->uc.uc_mcontext.arm_r4, err);
  413. __put_user_error(regs->regs[5], &sf->uc.uc_mcontext.arm_r5, err);
  414. __put_user_error(regs->regs[6], &sf->uc.uc_mcontext.arm_r6, err);
  415. __put_user_error(regs->regs[7], &sf->uc.uc_mcontext.arm_r7, err);
  416. __put_user_error(regs->regs[8], &sf->uc.uc_mcontext.arm_r8, err);
  417. __put_user_error(regs->regs[9], &sf->uc.uc_mcontext.arm_r9, err);
  418. __put_user_error(regs->regs[10], &sf->uc.uc_mcontext.arm_r10, err);
  419. __put_user_error(regs->regs[11], &sf->uc.uc_mcontext.arm_fp, err);
  420. __put_user_error(regs->regs[12], &sf->uc.uc_mcontext.arm_ip, err);
  421. __put_user_error(regs->compat_sp, &sf->uc.uc_mcontext.arm_sp, err);
  422. __put_user_error(regs->compat_lr, &sf->uc.uc_mcontext.arm_lr, err);
  423. __put_user_error(regs->pc, &sf->uc.uc_mcontext.arm_pc, err);
  424. __put_user_error(regs->pstate, &sf->uc.uc_mcontext.arm_cpsr, err);
  425. __put_user_error((compat_ulong_t)0, &sf->uc.uc_mcontext.trap_no, err);
  426. /* set the compat FSR WnR */
  427. __put_user_error(!!(current->thread.fault_code & ESR_ELx_WNR) <<
  428. FSR_WRITE_SHIFT, &sf->uc.uc_mcontext.error_code, err);
  429. __put_user_error(current->thread.fault_address, &sf->uc.uc_mcontext.fault_address, err);
  430. __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err);
  431. err |= put_sigset_t(&sf->uc.uc_sigmask, set);
  432. aux = (struct compat_aux_sigframe __user *) sf->uc.uc_regspace;
  433. if (err == 0)
  434. err |= compat_preserve_vfp_context(&aux->vfp);
  435. __put_user_error(0, &aux->end_magic, err);
  436. return err;
  437. }
  438. /*
  439. * 32-bit signal handling routines called from signal.c
  440. */
  441. int compat_setup_rt_frame(int usig, struct ksignal *ksig,
  442. sigset_t *set, struct pt_regs *regs)
  443. {
  444. struct compat_rt_sigframe __user *frame;
  445. int err = 0;
  446. frame = compat_get_sigframe(ksig, regs, sizeof(*frame));
  447. if (!frame)
  448. return 1;
  449. err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
  450. __put_user_error(0, &frame->sig.uc.uc_flags, err);
  451. __put_user_error(0, &frame->sig.uc.uc_link, err);
  452. err |= __compat_save_altstack(&frame->sig.uc.uc_stack, regs->compat_sp);
  453. err |= compat_setup_sigframe(&frame->sig, regs, set);
  454. if (err == 0) {
  455. compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig);
  456. regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info;
  457. regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc;
  458. }
  459. return err;
  460. }
  461. int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
  462. struct pt_regs *regs)
  463. {
  464. struct compat_sigframe __user *frame;
  465. int err = 0;
  466. frame = compat_get_sigframe(ksig, regs, sizeof(*frame));
  467. if (!frame)
  468. return 1;
  469. __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err);
  470. err |= compat_setup_sigframe(frame, regs, set);
  471. if (err == 0)
  472. compat_setup_return(regs, &ksig->ka, frame->retcode, frame, usig);
  473. return err;
  474. }
  475. void compat_setup_restart_syscall(struct pt_regs *regs)
  476. {
  477. regs->regs[7] = __NR_compat_restart_syscall;
  478. }