signal.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/kernel/signal.c
  4. *
  5. * Copyright (C) 1995-2009 Russell King
  6. */
  7. #include <linux/errno.h>
  8. #include <linux/random.h>
  9. #include <linux/signal.h>
  10. #include <linux/personality.h>
  11. #include <linux/uaccess.h>
  12. #include <linux/resume_user_mode.h>
  13. #include <linux/uprobes.h>
  14. #include <linux/syscalls.h>
  15. #include <asm/elf.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/traps.h>
  18. #include <asm/unistd.h>
  19. #include <asm/vfp.h>
  20. #include <asm/syscalls.h>
  21. #include "signal.h"
  22. extern const unsigned long sigreturn_codes[17];
  23. static unsigned long signal_return_offset;
  24. #ifdef CONFIG_IWMMXT
  25. static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame)
  26. {
  27. char kbuf[sizeof(*frame) + 8];
  28. struct iwmmxt_sigframe *kframe;
  29. int err = 0;
  30. /* the iWMMXt context must be 64 bit aligned */
  31. kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  32. if (test_thread_flag(TIF_USING_IWMMXT)) {
  33. kframe->magic = IWMMXT_MAGIC;
  34. kframe->size = IWMMXT_STORAGE_SIZE;
  35. iwmmxt_task_copy(current_thread_info(), &kframe->storage);
  36. } else {
  37. /*
  38. * For bug-compatibility with older kernels, some space
  39. * has to be reserved for iWMMXt even if it's not used.
  40. * Set the magic and size appropriately so that properly
  41. * written userspace can skip it reliably:
  42. */
  43. *kframe = (struct iwmmxt_sigframe) {
  44. .magic = DUMMY_MAGIC,
  45. .size = IWMMXT_STORAGE_SIZE,
  46. };
  47. }
  48. err = __copy_to_user(frame, kframe, sizeof(*kframe));
  49. return err;
  50. }
  51. static int restore_iwmmxt_context(char __user **auxp)
  52. {
  53. struct iwmmxt_sigframe __user *frame =
  54. (struct iwmmxt_sigframe __user *)*auxp;
  55. char kbuf[sizeof(*frame) + 8];
  56. struct iwmmxt_sigframe *kframe;
  57. /* the iWMMXt context must be 64 bit aligned */
  58. kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
  59. if (__copy_from_user(kframe, frame, sizeof(*frame)))
  60. return -1;
  61. /*
  62. * For non-iWMMXt threads: a single iwmmxt_sigframe-sized dummy
  63. * block is discarded for compatibility with setup_sigframe() if
  64. * present, but we don't mandate its presence. If some other
  65. * magic is here, it's not for us:
  66. */
  67. if (!test_thread_flag(TIF_USING_IWMMXT) &&
  68. kframe->magic != DUMMY_MAGIC)
  69. return 0;
  70. if (kframe->size != IWMMXT_STORAGE_SIZE)
  71. return -1;
  72. if (test_thread_flag(TIF_USING_IWMMXT)) {
  73. if (kframe->magic != IWMMXT_MAGIC)
  74. return -1;
  75. iwmmxt_task_restore(current_thread_info(), &kframe->storage);
  76. }
  77. *auxp += IWMMXT_STORAGE_SIZE;
  78. return 0;
  79. }
  80. #endif
  81. #ifdef CONFIG_VFP
  82. static int preserve_vfp_context(struct vfp_sigframe __user *frame)
  83. {
  84. struct vfp_sigframe kframe;
  85. int err = 0;
  86. memset(&kframe, 0, sizeof(kframe));
  87. kframe.magic = VFP_MAGIC;
  88. kframe.size = VFP_STORAGE_SIZE;
  89. err = vfp_preserve_user_clear_hwstate(&kframe.ufp, &kframe.ufp_exc);
  90. if (err)
  91. return err;
  92. return __copy_to_user(frame, &kframe, sizeof(kframe));
  93. }
  94. static int restore_vfp_context(char __user **auxp)
  95. {
  96. struct vfp_sigframe frame;
  97. int err;
  98. err = __copy_from_user(&frame, *auxp, sizeof(frame));
  99. if (err)
  100. return err;
  101. if (frame.magic != VFP_MAGIC || frame.size != VFP_STORAGE_SIZE)
  102. return -EINVAL;
  103. *auxp += sizeof(frame);
  104. return vfp_restore_user_hwstate(&frame.ufp, &frame.ufp_exc);
  105. }
  106. #endif
  107. /*
  108. * Do a signal return; undo the signal stack. These are aligned to 64-bit.
  109. */
  110. static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
  111. {
  112. struct sigcontext context;
  113. char __user *aux;
  114. sigset_t set;
  115. int err;
  116. err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
  117. if (err == 0)
  118. set_current_blocked(&set);
  119. err |= __copy_from_user(&context, &sf->uc.uc_mcontext, sizeof(context));
  120. if (err == 0) {
  121. regs->ARM_r0 = context.arm_r0;
  122. regs->ARM_r1 = context.arm_r1;
  123. regs->ARM_r2 = context.arm_r2;
  124. regs->ARM_r3 = context.arm_r3;
  125. regs->ARM_r4 = context.arm_r4;
  126. regs->ARM_r5 = context.arm_r5;
  127. regs->ARM_r6 = context.arm_r6;
  128. regs->ARM_r7 = context.arm_r7;
  129. regs->ARM_r8 = context.arm_r8;
  130. regs->ARM_r9 = context.arm_r9;
  131. regs->ARM_r10 = context.arm_r10;
  132. regs->ARM_fp = context.arm_fp;
  133. regs->ARM_ip = context.arm_ip;
  134. regs->ARM_sp = context.arm_sp;
  135. regs->ARM_lr = context.arm_lr;
  136. regs->ARM_pc = context.arm_pc;
  137. regs->ARM_cpsr = context.arm_cpsr;
  138. }
  139. err |= !valid_user_regs(regs);
  140. aux = (char __user *) sf->uc.uc_regspace;
  141. #ifdef CONFIG_IWMMXT
  142. if (err == 0)
  143. err |= restore_iwmmxt_context(&aux);
  144. #endif
  145. #ifdef CONFIG_VFP
  146. if (err == 0)
  147. err |= restore_vfp_context(&aux);
  148. #endif
  149. return err;
  150. }
  151. asmlinkage int sys_sigreturn(struct pt_regs *regs)
  152. {
  153. struct sigframe __user *frame;
  154. /* Always make any pending restarted system calls return -EINTR */
  155. current->restart_block.fn = do_no_restart_syscall;
  156. /*
  157. * Since we stacked the signal on a 64-bit boundary,
  158. * then 'sp' should be word aligned here. If it's
  159. * not, then the user is trying to mess with us.
  160. */
  161. if (regs->ARM_sp & 7)
  162. goto badframe;
  163. frame = (struct sigframe __user *)regs->ARM_sp;
  164. if (!access_ok(frame, sizeof (*frame)))
  165. goto badframe;
  166. if (restore_sigframe(regs, frame))
  167. goto badframe;
  168. return regs->ARM_r0;
  169. badframe:
  170. force_sig(SIGSEGV);
  171. return 0;
  172. }
  173. asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
  174. {
  175. struct rt_sigframe __user *frame;
  176. /* Always make any pending restarted system calls return -EINTR */
  177. current->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 rt_sigframe __user *)regs->ARM_sp;
  186. if (!access_ok(frame, sizeof (*frame)))
  187. goto badframe;
  188. if (restore_sigframe(regs, &frame->sig))
  189. goto badframe;
  190. if (restore_altstack(&frame->sig.uc.uc_stack))
  191. goto badframe;
  192. return regs->ARM_r0;
  193. badframe:
  194. force_sig(SIGSEGV);
  195. return 0;
  196. }
  197. static int
  198. setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set)
  199. {
  200. struct aux_sigframe __user *aux;
  201. struct sigcontext context;
  202. int err = 0;
  203. context = (struct sigcontext) {
  204. .arm_r0 = regs->ARM_r0,
  205. .arm_r1 = regs->ARM_r1,
  206. .arm_r2 = regs->ARM_r2,
  207. .arm_r3 = regs->ARM_r3,
  208. .arm_r4 = regs->ARM_r4,
  209. .arm_r5 = regs->ARM_r5,
  210. .arm_r6 = regs->ARM_r6,
  211. .arm_r7 = regs->ARM_r7,
  212. .arm_r8 = regs->ARM_r8,
  213. .arm_r9 = regs->ARM_r9,
  214. .arm_r10 = regs->ARM_r10,
  215. .arm_fp = regs->ARM_fp,
  216. .arm_ip = regs->ARM_ip,
  217. .arm_sp = regs->ARM_sp,
  218. .arm_lr = regs->ARM_lr,
  219. .arm_pc = regs->ARM_pc,
  220. .arm_cpsr = regs->ARM_cpsr,
  221. .trap_no = current->thread.trap_no,
  222. .error_code = current->thread.error_code,
  223. .fault_address = current->thread.address,
  224. .oldmask = set->sig[0],
  225. };
  226. err |= __copy_to_user(&sf->uc.uc_mcontext, &context, sizeof(context));
  227. err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
  228. aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
  229. #ifdef CONFIG_IWMMXT
  230. if (err == 0)
  231. err |= preserve_iwmmxt_context(&aux->iwmmxt);
  232. #endif
  233. #ifdef CONFIG_VFP
  234. if (err == 0)
  235. err |= preserve_vfp_context(&aux->vfp);
  236. #endif
  237. err |= __put_user(0, &aux->end_magic);
  238. return err;
  239. }
  240. static inline void __user *
  241. get_sigframe(struct ksignal *ksig, struct pt_regs *regs, int framesize)
  242. {
  243. unsigned long sp = sigsp(regs->ARM_sp, ksig);
  244. void __user *frame;
  245. /*
  246. * ATPCS B01 mandates 8-byte alignment
  247. */
  248. frame = (void __user *)((sp - framesize) & ~7);
  249. /*
  250. * Check that we can actually write to the signal frame.
  251. */
  252. if (!access_ok(frame, framesize))
  253. frame = NULL;
  254. return frame;
  255. }
  256. static int
  257. setup_return(struct pt_regs *regs, struct ksignal *ksig,
  258. unsigned long __user *rc, void __user *frame)
  259. {
  260. unsigned long handler = (unsigned long)ksig->ka.sa.sa_handler;
  261. unsigned long handler_fdpic_GOT = 0;
  262. unsigned long retcode;
  263. unsigned int idx, thumb = 0;
  264. unsigned long cpsr = regs->ARM_cpsr & ~(PSR_f | PSR_E_BIT);
  265. bool fdpic = IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC) &&
  266. (current->personality & FDPIC_FUNCPTRS);
  267. if (fdpic) {
  268. unsigned long __user *fdpic_func_desc =
  269. (unsigned long __user *)handler;
  270. if (__get_user(handler, &fdpic_func_desc[0]) ||
  271. __get_user(handler_fdpic_GOT, &fdpic_func_desc[1]))
  272. return 1;
  273. }
  274. cpsr |= PSR_ENDSTATE;
  275. /*
  276. * Maybe we need to deliver a 32-bit signal to a 26-bit task.
  277. */
  278. if (ksig->ka.sa.sa_flags & SA_THIRTYTWO)
  279. cpsr = (cpsr & ~MODE_MASK) | USR_MODE;
  280. #ifdef CONFIG_ARM_THUMB
  281. if (elf_hwcap & HWCAP_THUMB) {
  282. /*
  283. * The LSB of the handler determines if we're going to
  284. * be using THUMB or ARM mode for this signal handler.
  285. */
  286. thumb = handler & 1;
  287. /*
  288. * Clear the If-Then Thumb-2 execution state. ARM spec
  289. * requires this to be all 000s in ARM mode. Snapdragon
  290. * S4/Krait misbehaves on a Thumb=>ARM signal transition
  291. * without this.
  292. *
  293. * We must do this whenever we are running on a Thumb-2
  294. * capable CPU, which includes ARMv6T2. However, we elect
  295. * to always do this to simplify the code; this field is
  296. * marked UNK/SBZP for older architectures.
  297. */
  298. cpsr &= ~PSR_IT_MASK;
  299. if (thumb) {
  300. cpsr |= PSR_T_BIT;
  301. } else
  302. cpsr &= ~PSR_T_BIT;
  303. }
  304. #endif
  305. if (ksig->ka.sa.sa_flags & SA_RESTORER) {
  306. retcode = (unsigned long)ksig->ka.sa.sa_restorer;
  307. if (fdpic) {
  308. /*
  309. * We need code to load the function descriptor.
  310. * That code follows the standard sigreturn code
  311. * (6 words), and is made of 3 + 2 words for each
  312. * variant. The 4th copied word is the actual FD
  313. * address that the assembly code expects.
  314. */
  315. idx = 6 + thumb * 3;
  316. if (ksig->ka.sa.sa_flags & SA_SIGINFO)
  317. idx += 5;
  318. if (__put_user(sigreturn_codes[idx], rc ) ||
  319. __put_user(sigreturn_codes[idx+1], rc+1) ||
  320. __put_user(sigreturn_codes[idx+2], rc+2) ||
  321. __put_user(retcode, rc+3))
  322. return 1;
  323. goto rc_finish;
  324. }
  325. } else {
  326. idx = thumb << 1;
  327. if (ksig->ka.sa.sa_flags & SA_SIGINFO)
  328. idx += 3;
  329. /*
  330. * Put the sigreturn code on the stack no matter which return
  331. * mechanism we use in order to remain ABI compliant
  332. */
  333. if (__put_user(sigreturn_codes[idx], rc) ||
  334. __put_user(sigreturn_codes[idx+1], rc+1))
  335. return 1;
  336. rc_finish:
  337. #ifdef CONFIG_MMU
  338. if (cpsr & MODE32_BIT) {
  339. struct mm_struct *mm = current->mm;
  340. /*
  341. * 32-bit code can use the signal return page
  342. * except when the MPU has protected the vectors
  343. * page from PL0
  344. */
  345. retcode = mm->context.sigpage + signal_return_offset +
  346. (idx << 2) + thumb;
  347. } else
  348. #endif
  349. {
  350. /*
  351. * Ensure that the instruction cache sees
  352. * the return code written onto the stack.
  353. */
  354. flush_icache_range((unsigned long)rc,
  355. (unsigned long)(rc + 3));
  356. retcode = ((unsigned long)rc) + thumb;
  357. }
  358. }
  359. regs->ARM_r0 = ksig->sig;
  360. regs->ARM_sp = (unsigned long)frame;
  361. regs->ARM_lr = retcode;
  362. regs->ARM_pc = handler;
  363. if (fdpic)
  364. regs->ARM_r9 = handler_fdpic_GOT;
  365. regs->ARM_cpsr = cpsr;
  366. return 0;
  367. }
  368. static int
  369. setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
  370. {
  371. struct sigframe __user *frame = get_sigframe(ksig, regs, sizeof(*frame));
  372. int err = 0;
  373. if (!frame)
  374. return 1;
  375. /*
  376. * Set uc.uc_flags to a value which sc.trap_no would never have.
  377. */
  378. err = __put_user(0x5ac3c35a, &frame->uc.uc_flags);
  379. err |= setup_sigframe(frame, regs, set);
  380. if (err == 0)
  381. err = setup_return(regs, ksig, frame->retcode, frame);
  382. return err;
  383. }
  384. static int
  385. setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
  386. {
  387. struct rt_sigframe __user *frame = get_sigframe(ksig, regs, sizeof(*frame));
  388. int err = 0;
  389. if (!frame)
  390. return 1;
  391. err |= copy_siginfo_to_user(&frame->info, &ksig->info);
  392. err |= __put_user(0, &frame->sig.uc.uc_flags);
  393. err |= __put_user(NULL, &frame->sig.uc.uc_link);
  394. err |= __save_altstack(&frame->sig.uc.uc_stack, regs->ARM_sp);
  395. err |= setup_sigframe(&frame->sig, regs, set);
  396. if (err == 0)
  397. err = setup_return(regs, ksig, frame->sig.retcode, frame);
  398. if (err == 0) {
  399. /*
  400. * For realtime signals we must also set the second and third
  401. * arguments for the signal handler.
  402. * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06
  403. */
  404. regs->ARM_r1 = (unsigned long)&frame->info;
  405. regs->ARM_r2 = (unsigned long)&frame->sig.uc;
  406. }
  407. return err;
  408. }
  409. /*
  410. * OK, we're invoking a handler
  411. */
  412. static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
  413. {
  414. sigset_t *oldset = sigmask_to_save();
  415. int ret;
  416. /*
  417. * Perform fixup for the pre-signal frame.
  418. */
  419. rseq_signal_deliver(ksig, regs);
  420. /*
  421. * Set up the stack frame
  422. */
  423. if (ksig->ka.sa.sa_flags & SA_SIGINFO)
  424. ret = setup_rt_frame(ksig, oldset, regs);
  425. else
  426. ret = setup_frame(ksig, oldset, regs);
  427. /*
  428. * Check that the resulting registers are actually sane.
  429. */
  430. ret |= !valid_user_regs(regs);
  431. signal_setup_done(ret, ksig, 0);
  432. }
  433. /*
  434. * Note that 'init' is a special process: it doesn't get signals it doesn't
  435. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  436. * mistake.
  437. *
  438. * Note that we go through the signals twice: once to check the signals that
  439. * the kernel can handle, and then we build all the user-level signal handling
  440. * stack-frames in one go after that.
  441. */
  442. static int do_signal(struct pt_regs *regs, int syscall)
  443. {
  444. unsigned int retval = 0, continue_addr = 0, restart_addr = 0;
  445. struct ksignal ksig;
  446. int restart = 0;
  447. /*
  448. * If we were from a system call, check for system call restarting...
  449. */
  450. if (syscall) {
  451. continue_addr = regs->ARM_pc;
  452. restart_addr = continue_addr - (thumb_mode(regs) ? 2 : 4);
  453. retval = regs->ARM_r0;
  454. /*
  455. * Prepare for system call restart. We do this here so that a
  456. * debugger will see the already changed PSW.
  457. */
  458. switch (retval) {
  459. case -ERESTART_RESTARTBLOCK:
  460. restart -= 2;
  461. fallthrough;
  462. case -ERESTARTNOHAND:
  463. case -ERESTARTSYS:
  464. case -ERESTARTNOINTR:
  465. restart++;
  466. regs->ARM_r0 = regs->ARM_ORIG_r0;
  467. regs->ARM_pc = restart_addr;
  468. break;
  469. }
  470. }
  471. /*
  472. * Get the signal to deliver. When running under ptrace, at this
  473. * point the debugger may change all our registers ...
  474. */
  475. /*
  476. * Depending on the signal settings we may need to revert the
  477. * decision to restart the system call. But skip this if a
  478. * debugger has chosen to restart at a different PC.
  479. */
  480. if (get_signal(&ksig)) {
  481. /* handler */
  482. if (unlikely(restart) && regs->ARM_pc == restart_addr) {
  483. if (retval == -ERESTARTNOHAND ||
  484. retval == -ERESTART_RESTARTBLOCK
  485. || (retval == -ERESTARTSYS
  486. && !(ksig.ka.sa.sa_flags & SA_RESTART))) {
  487. regs->ARM_r0 = -EINTR;
  488. regs->ARM_pc = continue_addr;
  489. }
  490. }
  491. handle_signal(&ksig, regs);
  492. } else {
  493. /* no handler */
  494. restore_saved_sigmask();
  495. if (unlikely(restart) && regs->ARM_pc == restart_addr) {
  496. regs->ARM_pc = continue_addr;
  497. return restart;
  498. }
  499. }
  500. return 0;
  501. }
  502. asmlinkage int
  503. do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
  504. {
  505. /*
  506. * The assembly code enters us with IRQs off, but it hasn't
  507. * informed the tracing code of that for efficiency reasons.
  508. * Update the trace code with the current status.
  509. */
  510. trace_hardirqs_off();
  511. do {
  512. if (likely(thread_flags & _TIF_NEED_RESCHED)) {
  513. schedule();
  514. } else {
  515. if (unlikely(!user_mode(regs)))
  516. return 0;
  517. local_irq_enable();
  518. if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
  519. int restart = do_signal(regs, syscall);
  520. if (unlikely(restart)) {
  521. /*
  522. * Restart without handlers.
  523. * Deal with it without leaving
  524. * the kernel space.
  525. */
  526. return restart;
  527. }
  528. syscall = 0;
  529. } else if (thread_flags & _TIF_UPROBE) {
  530. uprobe_notify_resume(regs);
  531. } else {
  532. resume_user_mode_work(regs);
  533. }
  534. }
  535. local_irq_disable();
  536. thread_flags = read_thread_flags();
  537. } while (thread_flags & _TIF_WORK_MASK);
  538. return 0;
  539. }
  540. struct page *get_signal_page(void)
  541. {
  542. unsigned long ptr;
  543. unsigned offset;
  544. struct page *page;
  545. void *addr;
  546. page = alloc_pages(GFP_KERNEL, 0);
  547. if (!page)
  548. return NULL;
  549. addr = page_address(page);
  550. /* Poison the entire page */
  551. memset32(addr, __opcode_to_mem_arm(0xe7fddef1),
  552. PAGE_SIZE / sizeof(u32));
  553. /* Give the signal return code some randomness */
  554. offset = 0x200 + (get_random_u16() & 0x7fc);
  555. signal_return_offset = offset;
  556. /* Copy signal return handlers into the page */
  557. memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
  558. /* Flush out all instructions in this page */
  559. ptr = (unsigned long)addr;
  560. flush_icache_range(ptr, ptr + PAGE_SIZE);
  561. return page;
  562. }
  563. #ifdef CONFIG_DEBUG_RSEQ
  564. asmlinkage void do_rseq_syscall(struct pt_regs *regs)
  565. {
  566. rseq_syscall(regs);
  567. }
  568. #endif
  569. /*
  570. * Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as
  571. * changes likely come with new fields that should be added below.
  572. */
  573. static_assert(NSIGILL == 11);
  574. static_assert(NSIGFPE == 15);
  575. static_assert(NSIGSEGV == 10);
  576. static_assert(NSIGBUS == 5);
  577. static_assert(NSIGTRAP == 6);
  578. static_assert(NSIGCHLD == 6);
  579. static_assert(NSIGSYS == 2);
  580. static_assert(sizeof(siginfo_t) == 128);
  581. static_assert(__alignof__(siginfo_t) == 4);
  582. static_assert(offsetof(siginfo_t, si_signo) == 0x00);
  583. static_assert(offsetof(siginfo_t, si_errno) == 0x04);
  584. static_assert(offsetof(siginfo_t, si_code) == 0x08);
  585. static_assert(offsetof(siginfo_t, si_pid) == 0x0c);
  586. static_assert(offsetof(siginfo_t, si_uid) == 0x10);
  587. static_assert(offsetof(siginfo_t, si_tid) == 0x0c);
  588. static_assert(offsetof(siginfo_t, si_overrun) == 0x10);
  589. static_assert(offsetof(siginfo_t, si_status) == 0x14);
  590. static_assert(offsetof(siginfo_t, si_utime) == 0x18);
  591. static_assert(offsetof(siginfo_t, si_stime) == 0x1c);
  592. static_assert(offsetof(siginfo_t, si_value) == 0x14);
  593. static_assert(offsetof(siginfo_t, si_int) == 0x14);
  594. static_assert(offsetof(siginfo_t, si_ptr) == 0x14);
  595. static_assert(offsetof(siginfo_t, si_addr) == 0x0c);
  596. static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x10);
  597. static_assert(offsetof(siginfo_t, si_lower) == 0x14);
  598. static_assert(offsetof(siginfo_t, si_upper) == 0x18);
  599. static_assert(offsetof(siginfo_t, si_pkey) == 0x14);
  600. static_assert(offsetof(siginfo_t, si_perf_data) == 0x10);
  601. static_assert(offsetof(siginfo_t, si_perf_type) == 0x14);
  602. static_assert(offsetof(siginfo_t, si_perf_flags) == 0x18);
  603. static_assert(offsetof(siginfo_t, si_band) == 0x0c);
  604. static_assert(offsetof(siginfo_t, si_fd) == 0x10);
  605. static_assert(offsetof(siginfo_t, si_call_addr) == 0x0c);
  606. static_assert(offsetof(siginfo_t, si_syscall) == 0x10);
  607. static_assert(offsetof(siginfo_t, si_arch) == 0x14);