ptrace.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1992 Ross Biro
  7. * Copyright (C) Linus Torvalds
  8. * Copyright (C) 1994, 95, 96, 97, 98, 2000 Ralf Baechle
  9. * Copyright (C) 1996 David S. Miller
  10. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  11. * Copyright (C) 1999 MIPS Technologies, Inc.
  12. * Copyright (C) 2000 Ulf Carlsson
  13. *
  14. * At this time Linux/MIPS64 only supports syscall tracing, even for 32-bit
  15. * binaries.
  16. */
  17. #include <linux/compiler.h>
  18. #include <linux/context_tracking.h>
  19. #include <linux/elf.h>
  20. #include <linux/kernel.h>
  21. #include <linux/sched.h>
  22. #include <linux/mm.h>
  23. #include <linux/errno.h>
  24. #include <linux/ptrace.h>
  25. #include <linux/regset.h>
  26. #include <linux/smp.h>
  27. #include <linux/user.h>
  28. #include <linux/security.h>
  29. #include <linux/tracehook.h>
  30. #include <linux/audit.h>
  31. #include <linux/seccomp.h>
  32. #include <linux/ftrace.h>
  33. #include <asm/byteorder.h>
  34. #include <asm/cpu.h>
  35. #include <asm/dsp.h>
  36. #include <asm/fpu.h>
  37. #include <asm/mipsregs.h>
  38. #include <asm/mipsmtregs.h>
  39. #include <asm/pgtable.h>
  40. #include <asm/page.h>
  41. #include <asm/syscall.h>
  42. #include <asm/uaccess.h>
  43. #include <asm/bootinfo.h>
  44. #include <asm/reg.h>
  45. #define CREATE_TRACE_POINTS
  46. #include <trace/events/syscalls.h>
  47. /*
  48. * Called by kernel/ptrace.c when detaching..
  49. *
  50. * Make sure single step bits etc are not set.
  51. */
  52. void ptrace_disable(struct task_struct *child)
  53. {
  54. /* Don't load the watchpoint registers for the ex-child. */
  55. clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
  56. }
  57. /*
  58. * Read a general register set. We always use the 64-bit format, even
  59. * for 32-bit kernels and for 32-bit processes on a 64-bit kernel.
  60. * Registers are sign extended to fill the available space.
  61. */
  62. int ptrace_getregs(struct task_struct *child, __s64 __user *data)
  63. {
  64. struct pt_regs *regs;
  65. int i;
  66. if (!access_ok(VERIFY_WRITE, data, 38 * 8))
  67. return -EIO;
  68. regs = task_pt_regs(child);
  69. for (i = 0; i < 32; i++)
  70. __put_user((long)regs->regs[i], data + i);
  71. __put_user((long)regs->lo, data + EF_LO - EF_R0);
  72. __put_user((long)regs->hi, data + EF_HI - EF_R0);
  73. __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
  74. __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
  75. __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
  76. __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
  77. return 0;
  78. }
  79. /*
  80. * Write a general register set. As for PTRACE_GETREGS, we always use
  81. * the 64-bit format. On a 32-bit kernel only the lower order half
  82. * (according to endianness) will be used.
  83. */
  84. int ptrace_setregs(struct task_struct *child, __s64 __user *data)
  85. {
  86. struct pt_regs *regs;
  87. int i;
  88. if (!access_ok(VERIFY_READ, data, 38 * 8))
  89. return -EIO;
  90. regs = task_pt_regs(child);
  91. for (i = 0; i < 32; i++)
  92. __get_user(regs->regs[i], data + i);
  93. __get_user(regs->lo, data + EF_LO - EF_R0);
  94. __get_user(regs->hi, data + EF_HI - EF_R0);
  95. __get_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
  96. /* badvaddr, status, and cause may not be written. */
  97. return 0;
  98. }
  99. int ptrace_getfpregs(struct task_struct *child, __u32 __user *data)
  100. {
  101. int i;
  102. unsigned int tmp;
  103. if (!access_ok(VERIFY_WRITE, data, 33 * 8))
  104. return -EIO;
  105. if (tsk_used_math(child)) {
  106. fpureg_t *fregs = get_fpu_regs(child);
  107. for (i = 0; i < 32; i++)
  108. __put_user(fregs[i], i + (__u64 __user *) data);
  109. } else {
  110. for (i = 0; i < 32; i++)
  111. __put_user((__u64) -1, i + (__u64 __user *) data);
  112. }
  113. __put_user(child->thread.fpu.fcr31, data + 64);
  114. preempt_disable();
  115. if (cpu_has_fpu) {
  116. unsigned int flags;
  117. if (cpu_has_mipsmt) {
  118. unsigned int vpflags = dvpe();
  119. flags = read_c0_status();
  120. __enable_fpu();
  121. __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp));
  122. write_c0_status(flags);
  123. evpe(vpflags);
  124. } else {
  125. flags = read_c0_status();
  126. __enable_fpu();
  127. __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp));
  128. write_c0_status(flags);
  129. }
  130. } else {
  131. tmp = 0;
  132. }
  133. preempt_enable();
  134. __put_user(tmp, data + 65);
  135. return 0;
  136. }
  137. int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
  138. {
  139. fpureg_t *fregs;
  140. int i;
  141. if (!access_ok(VERIFY_READ, data, 33 * 8))
  142. return -EIO;
  143. fregs = get_fpu_regs(child);
  144. for (i = 0; i < 32; i++)
  145. __get_user(fregs[i], i + (__u64 __user *) data);
  146. __get_user(child->thread.fpu.fcr31, data + 64);
  147. /* FIR may not be written. */
  148. return 0;
  149. }
  150. int ptrace_get_watch_regs(struct task_struct *child,
  151. struct pt_watch_regs __user *addr)
  152. {
  153. enum pt_watch_style style;
  154. int i;
  155. if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
  156. return -EIO;
  157. if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs)))
  158. return -EIO;
  159. #ifdef CONFIG_32BIT
  160. style = pt_watch_style_mips32;
  161. #define WATCH_STYLE mips32
  162. #else
  163. style = pt_watch_style_mips64;
  164. #define WATCH_STYLE mips64
  165. #endif
  166. __put_user(style, &addr->style);
  167. __put_user(current_cpu_data.watch_reg_use_cnt,
  168. &addr->WATCH_STYLE.num_valid);
  169. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  170. __put_user(child->thread.watch.mips3264.watchlo[i],
  171. &addr->WATCH_STYLE.watchlo[i]);
  172. __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff,
  173. &addr->WATCH_STYLE.watchhi[i]);
  174. __put_user(current_cpu_data.watch_reg_masks[i],
  175. &addr->WATCH_STYLE.watch_masks[i]);
  176. }
  177. for (; i < 8; i++) {
  178. __put_user(0, &addr->WATCH_STYLE.watchlo[i]);
  179. __put_user(0, &addr->WATCH_STYLE.watchhi[i]);
  180. __put_user(0, &addr->WATCH_STYLE.watch_masks[i]);
  181. }
  182. return 0;
  183. }
  184. int ptrace_set_watch_regs(struct task_struct *child,
  185. struct pt_watch_regs __user *addr)
  186. {
  187. int i;
  188. int watch_active = 0;
  189. unsigned long lt[NUM_WATCH_REGS];
  190. u16 ht[NUM_WATCH_REGS];
  191. if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
  192. return -EIO;
  193. if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs)))
  194. return -EIO;
  195. /* Check the values. */
  196. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  197. __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]);
  198. #ifdef CONFIG_32BIT
  199. if (lt[i] & __UA_LIMIT)
  200. return -EINVAL;
  201. #else
  202. if (test_tsk_thread_flag(child, TIF_32BIT_ADDR)) {
  203. if (lt[i] & 0xffffffff80000000UL)
  204. return -EINVAL;
  205. } else {
  206. if (lt[i] & __UA_LIMIT)
  207. return -EINVAL;
  208. }
  209. #endif
  210. __get_user(ht[i], &addr->WATCH_STYLE.watchhi[i]);
  211. if (ht[i] & ~0xff8)
  212. return -EINVAL;
  213. }
  214. /* Install them. */
  215. for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
  216. if (lt[i] & 7)
  217. watch_active = 1;
  218. child->thread.watch.mips3264.watchlo[i] = lt[i];
  219. /* Set the G bit. */
  220. child->thread.watch.mips3264.watchhi[i] = ht[i];
  221. }
  222. if (watch_active)
  223. set_tsk_thread_flag(child, TIF_LOAD_WATCH);
  224. else
  225. clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
  226. return 0;
  227. }
  228. /* regset get/set implementations */
  229. static int gpr_get(struct task_struct *target,
  230. const struct user_regset *regset,
  231. unsigned int pos, unsigned int count,
  232. void *kbuf, void __user *ubuf)
  233. {
  234. struct pt_regs *regs = task_pt_regs(target);
  235. return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
  236. regs, 0, sizeof(*regs));
  237. }
  238. static int gpr_set(struct task_struct *target,
  239. const struct user_regset *regset,
  240. unsigned int pos, unsigned int count,
  241. const void *kbuf, const void __user *ubuf)
  242. {
  243. struct pt_regs newregs;
  244. int ret;
  245. ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  246. &newregs,
  247. 0, sizeof(newregs));
  248. if (ret)
  249. return ret;
  250. *task_pt_regs(target) = newregs;
  251. return 0;
  252. }
  253. static int fpr_get(struct task_struct *target,
  254. const struct user_regset *regset,
  255. unsigned int pos, unsigned int count,
  256. void *kbuf, void __user *ubuf)
  257. {
  258. return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
  259. &target->thread.fpu,
  260. 0, sizeof(elf_fpregset_t));
  261. /* XXX fcr31 */
  262. }
  263. static int fpr_set(struct task_struct *target,
  264. const struct user_regset *regset,
  265. unsigned int pos, unsigned int count,
  266. const void *kbuf, const void __user *ubuf)
  267. {
  268. return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  269. &target->thread.fpu,
  270. 0, sizeof(elf_fpregset_t));
  271. /* XXX fcr31 */
  272. }
  273. enum mips_regset {
  274. REGSET_GPR,
  275. REGSET_FPR,
  276. };
  277. static const struct user_regset mips_regsets[] = {
  278. [REGSET_GPR] = {
  279. .core_note_type = NT_PRSTATUS,
  280. .n = ELF_NGREG,
  281. .size = sizeof(unsigned int),
  282. .align = sizeof(unsigned int),
  283. .get = gpr_get,
  284. .set = gpr_set,
  285. },
  286. [REGSET_FPR] = {
  287. .core_note_type = NT_PRFPREG,
  288. .n = ELF_NFPREG,
  289. .size = sizeof(elf_fpreg_t),
  290. .align = sizeof(elf_fpreg_t),
  291. .get = fpr_get,
  292. .set = fpr_set,
  293. },
  294. };
  295. static const struct user_regset_view user_mips_view = {
  296. .name = "mips",
  297. .e_machine = ELF_ARCH,
  298. .ei_osabi = ELF_OSABI,
  299. .regsets = mips_regsets,
  300. .n = ARRAY_SIZE(mips_regsets),
  301. };
  302. static const struct user_regset mips64_regsets[] = {
  303. [REGSET_GPR] = {
  304. .core_note_type = NT_PRSTATUS,
  305. .n = ELF_NGREG,
  306. .size = sizeof(unsigned long),
  307. .align = sizeof(unsigned long),
  308. .get = gpr_get,
  309. .set = gpr_set,
  310. },
  311. [REGSET_FPR] = {
  312. .core_note_type = NT_PRFPREG,
  313. .n = ELF_NFPREG,
  314. .size = sizeof(elf_fpreg_t),
  315. .align = sizeof(elf_fpreg_t),
  316. .get = fpr_get,
  317. .set = fpr_set,
  318. },
  319. };
  320. static const struct user_regset_view user_mips64_view = {
  321. .name = "mips",
  322. .e_machine = ELF_ARCH,
  323. .ei_osabi = ELF_OSABI,
  324. .regsets = mips64_regsets,
  325. .n = ARRAY_SIZE(mips_regsets),
  326. };
  327. const struct user_regset_view *task_user_regset_view(struct task_struct *task)
  328. {
  329. #ifdef CONFIG_32BIT
  330. return &user_mips_view;
  331. #endif
  332. #ifdef CONFIG_MIPS32_O32
  333. if (test_thread_flag(TIF_32BIT_REGS))
  334. return &user_mips_view;
  335. #endif
  336. return &user_mips64_view;
  337. }
  338. long arch_ptrace(struct task_struct *child, long request,
  339. unsigned long addr, unsigned long data)
  340. {
  341. int ret;
  342. void __user *addrp = (void __user *) addr;
  343. void __user *datavp = (void __user *) data;
  344. unsigned long __user *datalp = (void __user *) data;
  345. switch (request) {
  346. /* when I and D space are separate, these will need to be fixed. */
  347. case PTRACE_PEEKTEXT: /* read word at location addr. */
  348. case PTRACE_PEEKDATA:
  349. ret = generic_ptrace_peekdata(child, addr, data);
  350. break;
  351. /* Read the word at location addr in the USER area. */
  352. case PTRACE_PEEKUSR: {
  353. struct pt_regs *regs;
  354. unsigned long tmp = 0;
  355. regs = task_pt_regs(child);
  356. ret = 0; /* Default return value. */
  357. switch (addr) {
  358. case 0 ... 31:
  359. tmp = regs->regs[addr];
  360. break;
  361. case FPR_BASE ... FPR_BASE + 31:
  362. if (tsk_used_math(child)) {
  363. fpureg_t *fregs = get_fpu_regs(child);
  364. #ifdef CONFIG_32BIT
  365. /*
  366. * The odd registers are actually the high
  367. * order bits of the values stored in the even
  368. * registers - unless we're using r2k_switch.S.
  369. */
  370. if (addr & 1)
  371. tmp = (unsigned long) (fregs[((addr & ~1) - 32)] >> 32);
  372. else
  373. tmp = (unsigned long) (fregs[(addr - 32)] & 0xffffffff);
  374. #endif
  375. #ifdef CONFIG_64BIT
  376. tmp = fregs[addr - FPR_BASE];
  377. #endif
  378. } else {
  379. tmp = -1; /* FP not yet used */
  380. }
  381. break;
  382. case PC:
  383. tmp = regs->cp0_epc;
  384. break;
  385. case CAUSE:
  386. tmp = regs->cp0_cause;
  387. break;
  388. case BADVADDR:
  389. tmp = regs->cp0_badvaddr;
  390. break;
  391. case MMHI:
  392. tmp = regs->hi;
  393. break;
  394. case MMLO:
  395. tmp = regs->lo;
  396. break;
  397. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  398. case ACX:
  399. tmp = regs->acx;
  400. break;
  401. #endif
  402. case FPC_CSR:
  403. tmp = child->thread.fpu.fcr31;
  404. break;
  405. case FPC_EIR: { /* implementation / version register */
  406. unsigned int flags;
  407. #ifdef CONFIG_MIPS_MT_SMTC
  408. unsigned long irqflags;
  409. unsigned int mtflags;
  410. #endif /* CONFIG_MIPS_MT_SMTC */
  411. preempt_disable();
  412. if (!cpu_has_fpu) {
  413. preempt_enable();
  414. break;
  415. }
  416. #ifdef CONFIG_MIPS_MT_SMTC
  417. /* Read-modify-write of Status must be atomic */
  418. local_irq_save(irqflags);
  419. mtflags = dmt();
  420. #endif /* CONFIG_MIPS_MT_SMTC */
  421. if (cpu_has_mipsmt) {
  422. unsigned int vpflags = dvpe();
  423. flags = read_c0_status();
  424. __enable_fpu();
  425. __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
  426. write_c0_status(flags);
  427. evpe(vpflags);
  428. } else {
  429. flags = read_c0_status();
  430. __enable_fpu();
  431. __asm__ __volatile__("cfc1\t%0,$0": "=r" (tmp));
  432. write_c0_status(flags);
  433. }
  434. #ifdef CONFIG_MIPS_MT_SMTC
  435. emt(mtflags);
  436. local_irq_restore(irqflags);
  437. #endif /* CONFIG_MIPS_MT_SMTC */
  438. preempt_enable();
  439. break;
  440. }
  441. case DSP_BASE ... DSP_BASE + 5: {
  442. dspreg_t *dregs;
  443. if (!cpu_has_dsp) {
  444. tmp = 0;
  445. ret = -EIO;
  446. goto out;
  447. }
  448. dregs = __get_dsp_regs(child);
  449. tmp = (unsigned long) (dregs[addr - DSP_BASE]);
  450. break;
  451. }
  452. case DSP_CONTROL:
  453. if (!cpu_has_dsp) {
  454. tmp = 0;
  455. ret = -EIO;
  456. goto out;
  457. }
  458. tmp = child->thread.dsp.dspcontrol;
  459. break;
  460. default:
  461. tmp = 0;
  462. ret = -EIO;
  463. goto out;
  464. }
  465. ret = put_user(tmp, datalp);
  466. break;
  467. }
  468. /* when I and D space are separate, this will have to be fixed. */
  469. case PTRACE_POKETEXT: /* write the word at location addr. */
  470. case PTRACE_POKEDATA:
  471. ret = generic_ptrace_pokedata(child, addr, data);
  472. break;
  473. case PTRACE_POKEUSR: {
  474. struct pt_regs *regs;
  475. ret = 0;
  476. regs = task_pt_regs(child);
  477. switch (addr) {
  478. case 0 ... 31:
  479. regs->regs[addr] = data;
  480. break;
  481. case FPR_BASE ... FPR_BASE + 31: {
  482. fpureg_t *fregs = get_fpu_regs(child);
  483. if (!tsk_used_math(child)) {
  484. /* FP not yet used */
  485. memset(&child->thread.fpu, ~0,
  486. sizeof(child->thread.fpu));
  487. child->thread.fpu.fcr31 = 0;
  488. }
  489. #ifdef CONFIG_32BIT
  490. /*
  491. * The odd registers are actually the high order bits
  492. * of the values stored in the even registers - unless
  493. * we're using r2k_switch.S.
  494. */
  495. if (addr & 1) {
  496. fregs[(addr & ~1) - FPR_BASE] &= 0xffffffff;
  497. fregs[(addr & ~1) - FPR_BASE] |= ((unsigned long long) data) << 32;
  498. } else {
  499. fregs[addr - FPR_BASE] &= ~0xffffffffLL;
  500. fregs[addr - FPR_BASE] |= data;
  501. }
  502. #endif
  503. #ifdef CONFIG_64BIT
  504. fregs[addr - FPR_BASE] = data;
  505. #endif
  506. break;
  507. }
  508. case PC:
  509. regs->cp0_epc = data;
  510. break;
  511. case MMHI:
  512. regs->hi = data;
  513. break;
  514. case MMLO:
  515. regs->lo = data;
  516. break;
  517. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  518. case ACX:
  519. regs->acx = data;
  520. break;
  521. #endif
  522. case FPC_CSR:
  523. child->thread.fpu.fcr31 = data;
  524. break;
  525. case DSP_BASE ... DSP_BASE + 5: {
  526. dspreg_t *dregs;
  527. if (!cpu_has_dsp) {
  528. ret = -EIO;
  529. break;
  530. }
  531. dregs = __get_dsp_regs(child);
  532. dregs[addr - DSP_BASE] = data;
  533. break;
  534. }
  535. case DSP_CONTROL:
  536. if (!cpu_has_dsp) {
  537. ret = -EIO;
  538. break;
  539. }
  540. child->thread.dsp.dspcontrol = data;
  541. break;
  542. default:
  543. /* The rest are not allowed. */
  544. ret = -EIO;
  545. break;
  546. }
  547. break;
  548. }
  549. case PTRACE_GETREGS:
  550. ret = ptrace_getregs(child, datavp);
  551. break;
  552. case PTRACE_SETREGS:
  553. ret = ptrace_setregs(child, datavp);
  554. break;
  555. case PTRACE_GETFPREGS:
  556. ret = ptrace_getfpregs(child, datavp);
  557. break;
  558. case PTRACE_SETFPREGS:
  559. ret = ptrace_setfpregs(child, datavp);
  560. break;
  561. case PTRACE_GET_THREAD_AREA:
  562. ret = put_user(task_thread_info(child)->tp_value, datalp);
  563. break;
  564. case PTRACE_GET_WATCH_REGS:
  565. ret = ptrace_get_watch_regs(child, addrp);
  566. break;
  567. case PTRACE_SET_WATCH_REGS:
  568. ret = ptrace_set_watch_regs(child, addrp);
  569. break;
  570. default:
  571. ret = ptrace_request(child, request, addr, data);
  572. break;
  573. }
  574. out:
  575. return ret;
  576. }
  577. /*
  578. * Notification of system call entry/exit
  579. * - triggered by current->work.syscall_trace
  580. */
  581. asmlinkage void syscall_trace_enter(struct pt_regs *regs)
  582. {
  583. long ret = 0;
  584. user_exit();
  585. /* do the secure computing check first */
  586. secure_computing_strict(regs->regs[2]);
  587. if (test_thread_flag(TIF_SYSCALL_TRACE) &&
  588. tracehook_report_syscall_entry(regs))
  589. ret = -1;
  590. if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
  591. trace_sys_enter(regs, regs->regs[2]);
  592. audit_syscall_entry(__syscall_get_arch(),
  593. regs->regs[2],
  594. regs->regs[4], regs->regs[5],
  595. regs->regs[6], regs->regs[7]);
  596. }
  597. /*
  598. * Notification of system call entry/exit
  599. * - triggered by current->work.syscall_trace
  600. */
  601. asmlinkage void syscall_trace_leave(struct pt_regs *regs)
  602. {
  603. /*
  604. * We may come here right after calling schedule_user()
  605. * or do_notify_resume(), in which case we can be in RCU
  606. * user mode.
  607. */
  608. user_exit();
  609. audit_syscall_exit(regs);
  610. if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
  611. trace_sys_exit(regs, regs->regs[2]);
  612. if (test_thread_flag(TIF_SYSCALL_TRACE))
  613. tracehook_report_syscall_exit(regs, 0);
  614. user_enter();
  615. }