kprobes.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. * Kernel Probes (KProbes)
  3. * arch/mips/kernel/kprobes.c
  4. *
  5. * Copyright 2006 Sony Corp.
  6. * Copyright 2010 Cavium Networks
  7. *
  8. * Some portions copied from the powerpc version.
  9. *
  10. * Copyright (C) IBM Corporation, 2002, 2004
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; version 2 of the License.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/kprobes.h>
  26. #include <linux/preempt.h>
  27. #include <linux/uaccess.h>
  28. #include <linux/kdebug.h>
  29. #include <linux/slab.h>
  30. #include <asm/ptrace.h>
  31. #include <asm/branch.h>
  32. #include <asm/break.h>
  33. #include <asm/inst.h>
  34. static const union mips_instruction breakpoint_insn = {
  35. .b_format = {
  36. .opcode = spec_op,
  37. .code = BRK_KPROBE_BP,
  38. .func = break_op
  39. }
  40. };
  41. static const union mips_instruction breakpoint2_insn = {
  42. .b_format = {
  43. .opcode = spec_op,
  44. .code = BRK_KPROBE_SSTEPBP,
  45. .func = break_op
  46. }
  47. };
  48. DEFINE_PER_CPU(struct kprobe *, current_kprobe);
  49. DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
  50. static int __kprobes insn_has_delayslot(union mips_instruction insn)
  51. {
  52. switch (insn.i_format.opcode) {
  53. /*
  54. * This group contains:
  55. * jr and jalr are in r_format format.
  56. */
  57. case spec_op:
  58. switch (insn.r_format.func) {
  59. case jr_op:
  60. case jalr_op:
  61. break;
  62. default:
  63. goto insn_ok;
  64. }
  65. /*
  66. * This group contains:
  67. * bltz_op, bgez_op, bltzl_op, bgezl_op,
  68. * bltzal_op, bgezal_op, bltzall_op, bgezall_op.
  69. */
  70. case bcond_op:
  71. /*
  72. * These are unconditional and in j_format.
  73. */
  74. case jal_op:
  75. case j_op:
  76. /*
  77. * These are conditional and in i_format.
  78. */
  79. case beq_op:
  80. case beql_op:
  81. case bne_op:
  82. case bnel_op:
  83. case blez_op:
  84. case blezl_op:
  85. case bgtz_op:
  86. case bgtzl_op:
  87. /*
  88. * These are the FPA/cp1 branch instructions.
  89. */
  90. case cop1_op:
  91. #ifdef CONFIG_CPU_CAVIUM_OCTEON
  92. case lwc2_op: /* This is bbit0 on Octeon */
  93. case ldc2_op: /* This is bbit032 on Octeon */
  94. case swc2_op: /* This is bbit1 on Octeon */
  95. case sdc2_op: /* This is bbit132 on Octeon */
  96. #endif
  97. return 1;
  98. default:
  99. break;
  100. }
  101. insn_ok:
  102. return 0;
  103. }
  104. /*
  105. * insn_has_ll_or_sc function checks whether instruction is ll or sc
  106. * one; putting breakpoint on top of atomic ll/sc pair is bad idea;
  107. * so we need to prevent it and refuse kprobes insertion for such
  108. * instructions; cannot do much about breakpoint in the middle of
  109. * ll/sc pair; it is upto user to avoid those places
  110. */
  111. static int __kprobes insn_has_ll_or_sc(union mips_instruction insn)
  112. {
  113. int ret = 0;
  114. switch (insn.i_format.opcode) {
  115. case ll_op:
  116. case lld_op:
  117. case sc_op:
  118. case scd_op:
  119. ret = 1;
  120. break;
  121. default:
  122. break;
  123. }
  124. return ret;
  125. }
  126. int __kprobes arch_prepare_kprobe(struct kprobe *p)
  127. {
  128. union mips_instruction insn;
  129. union mips_instruction prev_insn;
  130. int ret = 0;
  131. insn = p->addr[0];
  132. if (insn_has_ll_or_sc(insn)) {
  133. pr_notice("Kprobes for ll and sc instructions are not"
  134. "supported\n");
  135. ret = -EINVAL;
  136. goto out;
  137. }
  138. if ((probe_kernel_read(&prev_insn, p->addr - 1,
  139. sizeof(mips_instruction)) == 0) &&
  140. insn_has_delayslot(prev_insn)) {
  141. pr_notice("Kprobes for branch delayslot are not supported\n");
  142. ret = -EINVAL;
  143. goto out;
  144. }
  145. /* insn: must be on special executable page on mips. */
  146. p->ainsn.insn = get_insn_slot();
  147. if (!p->ainsn.insn) {
  148. ret = -ENOMEM;
  149. goto out;
  150. }
  151. /*
  152. * In the kprobe->ainsn.insn[] array we store the original
  153. * instruction at index zero and a break trap instruction at
  154. * index one.
  155. *
  156. * On MIPS arch if the instruction at probed address is a
  157. * branch instruction, we need to execute the instruction at
  158. * Branch Delayslot (BD) at the time of probe hit. As MIPS also
  159. * doesn't have single stepping support, the BD instruction can
  160. * not be executed in-line and it would be executed on SSOL slot
  161. * using a normal breakpoint instruction in the next slot.
  162. * So, read the instruction and save it for later execution.
  163. */
  164. if (insn_has_delayslot(insn))
  165. memcpy(&p->ainsn.insn[0], p->addr + 1, sizeof(kprobe_opcode_t));
  166. else
  167. memcpy(&p->ainsn.insn[0], p->addr, sizeof(kprobe_opcode_t));
  168. p->ainsn.insn[1] = breakpoint2_insn;
  169. p->opcode = *p->addr;
  170. out:
  171. return ret;
  172. }
  173. void __kprobes arch_arm_kprobe(struct kprobe *p)
  174. {
  175. *p->addr = breakpoint_insn;
  176. flush_insn_slot(p);
  177. }
  178. void __kprobes arch_disarm_kprobe(struct kprobe *p)
  179. {
  180. *p->addr = p->opcode;
  181. flush_insn_slot(p);
  182. }
  183. void __kprobes arch_remove_kprobe(struct kprobe *p)
  184. {
  185. if (p->ainsn.insn) {
  186. free_insn_slot(p->ainsn.insn, 0);
  187. p->ainsn.insn = NULL;
  188. }
  189. }
  190. static void save_previous_kprobe(struct kprobe_ctlblk *kcb)
  191. {
  192. kcb->prev_kprobe.kp = kprobe_running();
  193. kcb->prev_kprobe.status = kcb->kprobe_status;
  194. kcb->prev_kprobe.old_SR = kcb->kprobe_old_SR;
  195. kcb->prev_kprobe.saved_SR = kcb->kprobe_saved_SR;
  196. kcb->prev_kprobe.saved_epc = kcb->kprobe_saved_epc;
  197. }
  198. static void restore_previous_kprobe(struct kprobe_ctlblk *kcb)
  199. {
  200. __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
  201. kcb->kprobe_status = kcb->prev_kprobe.status;
  202. kcb->kprobe_old_SR = kcb->prev_kprobe.old_SR;
  203. kcb->kprobe_saved_SR = kcb->prev_kprobe.saved_SR;
  204. kcb->kprobe_saved_epc = kcb->prev_kprobe.saved_epc;
  205. }
  206. static void set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
  207. struct kprobe_ctlblk *kcb)
  208. {
  209. __this_cpu_write(current_kprobe, p);
  210. kcb->kprobe_saved_SR = kcb->kprobe_old_SR = (regs->cp0_status & ST0_IE);
  211. kcb->kprobe_saved_epc = regs->cp0_epc;
  212. }
  213. /**
  214. * evaluate_branch_instrucion -
  215. *
  216. * Evaluate the branch instruction at probed address during probe hit. The
  217. * result of evaluation would be the updated epc. The insturction in delayslot
  218. * would actually be single stepped using a normal breakpoint) on SSOL slot.
  219. *
  220. * The result is also saved in the kprobe control block for later use,
  221. * in case we need to execute the delayslot instruction. The latter will be
  222. * false for NOP instruction in dealyslot and the branch-likely instructions
  223. * when the branch is taken. And for those cases we set a flag as
  224. * SKIP_DELAYSLOT in the kprobe control block
  225. */
  226. static int evaluate_branch_instruction(struct kprobe *p, struct pt_regs *regs,
  227. struct kprobe_ctlblk *kcb)
  228. {
  229. union mips_instruction insn = p->opcode;
  230. long epc;
  231. int ret = 0;
  232. epc = regs->cp0_epc;
  233. if (epc & 3)
  234. goto unaligned;
  235. if (p->ainsn.insn->word == 0)
  236. kcb->flags |= SKIP_DELAYSLOT;
  237. else
  238. kcb->flags &= ~SKIP_DELAYSLOT;
  239. ret = __compute_return_epc_for_insn(regs, insn);
  240. if (ret < 0)
  241. return ret;
  242. if (ret == BRANCH_LIKELY_TAKEN)
  243. kcb->flags |= SKIP_DELAYSLOT;
  244. kcb->target_epc = regs->cp0_epc;
  245. return 0;
  246. unaligned:
  247. pr_notice("%s: unaligned epc - sending SIGBUS.\n", current->comm);
  248. force_sig(SIGBUS, current);
  249. return -EFAULT;
  250. }
  251. static void prepare_singlestep(struct kprobe *p, struct pt_regs *regs,
  252. struct kprobe_ctlblk *kcb)
  253. {
  254. int ret = 0;
  255. regs->cp0_status &= ~ST0_IE;
  256. /* single step inline if the instruction is a break */
  257. if (p->opcode.word == breakpoint_insn.word ||
  258. p->opcode.word == breakpoint2_insn.word)
  259. regs->cp0_epc = (unsigned long)p->addr;
  260. else if (insn_has_delayslot(p->opcode)) {
  261. ret = evaluate_branch_instruction(p, regs, kcb);
  262. if (ret < 0) {
  263. pr_notice("Kprobes: Error in evaluating branch\n");
  264. return;
  265. }
  266. }
  267. regs->cp0_epc = (unsigned long)&p->ainsn.insn[0];
  268. }
  269. /*
  270. * Called after single-stepping. p->addr is the address of the
  271. * instruction whose first byte has been replaced by the "break 0"
  272. * instruction. To avoid the SMP problems that can occur when we
  273. * temporarily put back the original opcode to single-step, we
  274. * single-stepped a copy of the instruction. The address of this
  275. * copy is p->ainsn.insn.
  276. *
  277. * This function prepares to return from the post-single-step
  278. * breakpoint trap. In case of branch instructions, the target
  279. * epc to be restored.
  280. */
  281. static void __kprobes resume_execution(struct kprobe *p,
  282. struct pt_regs *regs,
  283. struct kprobe_ctlblk *kcb)
  284. {
  285. if (insn_has_delayslot(p->opcode))
  286. regs->cp0_epc = kcb->target_epc;
  287. else {
  288. unsigned long orig_epc = kcb->kprobe_saved_epc;
  289. regs->cp0_epc = orig_epc + 4;
  290. }
  291. }
  292. static int __kprobes kprobe_handler(struct pt_regs *regs)
  293. {
  294. struct kprobe *p;
  295. int ret = 0;
  296. kprobe_opcode_t *addr;
  297. struct kprobe_ctlblk *kcb;
  298. addr = (kprobe_opcode_t *) regs->cp0_epc;
  299. /*
  300. * We don't want to be preempted for the entire
  301. * duration of kprobe processing
  302. */
  303. preempt_disable();
  304. kcb = get_kprobe_ctlblk();
  305. /* Check we're not actually recursing */
  306. if (kprobe_running()) {
  307. p = get_kprobe(addr);
  308. if (p) {
  309. if (kcb->kprobe_status == KPROBE_HIT_SS &&
  310. p->ainsn.insn->word == breakpoint_insn.word) {
  311. regs->cp0_status &= ~ST0_IE;
  312. regs->cp0_status |= kcb->kprobe_saved_SR;
  313. goto no_kprobe;
  314. }
  315. /*
  316. * We have reentered the kprobe_handler(), since
  317. * another probe was hit while within the handler.
  318. * We here save the original kprobes variables and
  319. * just single step on the instruction of the new probe
  320. * without calling any user handlers.
  321. */
  322. save_previous_kprobe(kcb);
  323. set_current_kprobe(p, regs, kcb);
  324. kprobes_inc_nmissed_count(p);
  325. prepare_singlestep(p, regs, kcb);
  326. kcb->kprobe_status = KPROBE_REENTER;
  327. if (kcb->flags & SKIP_DELAYSLOT) {
  328. resume_execution(p, regs, kcb);
  329. restore_previous_kprobe(kcb);
  330. preempt_enable_no_resched();
  331. }
  332. return 1;
  333. } else {
  334. if (addr->word != breakpoint_insn.word) {
  335. /*
  336. * The breakpoint instruction was removed by
  337. * another cpu right after we hit, no further
  338. * handling of this interrupt is appropriate
  339. */
  340. ret = 1;
  341. goto no_kprobe;
  342. }
  343. p = __this_cpu_read(current_kprobe);
  344. if (p->break_handler && p->break_handler(p, regs))
  345. goto ss_probe;
  346. }
  347. goto no_kprobe;
  348. }
  349. p = get_kprobe(addr);
  350. if (!p) {
  351. if (addr->word != breakpoint_insn.word) {
  352. /*
  353. * The breakpoint instruction was removed right
  354. * after we hit it. Another cpu has removed
  355. * either a probepoint or a debugger breakpoint
  356. * at this address. In either case, no further
  357. * handling of this interrupt is appropriate.
  358. */
  359. ret = 1;
  360. }
  361. /* Not one of ours: let kernel handle it */
  362. goto no_kprobe;
  363. }
  364. set_current_kprobe(p, regs, kcb);
  365. kcb->kprobe_status = KPROBE_HIT_ACTIVE;
  366. if (p->pre_handler && p->pre_handler(p, regs)) {
  367. /* handler has already set things up, so skip ss setup */
  368. return 1;
  369. }
  370. ss_probe:
  371. prepare_singlestep(p, regs, kcb);
  372. if (kcb->flags & SKIP_DELAYSLOT) {
  373. kcb->kprobe_status = KPROBE_HIT_SSDONE;
  374. if (p->post_handler)
  375. p->post_handler(p, regs, 0);
  376. resume_execution(p, regs, kcb);
  377. preempt_enable_no_resched();
  378. } else
  379. kcb->kprobe_status = KPROBE_HIT_SS;
  380. return 1;
  381. no_kprobe:
  382. preempt_enable_no_resched();
  383. return ret;
  384. }
  385. static inline int post_kprobe_handler(struct pt_regs *regs)
  386. {
  387. struct kprobe *cur = kprobe_running();
  388. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  389. if (!cur)
  390. return 0;
  391. if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
  392. kcb->kprobe_status = KPROBE_HIT_SSDONE;
  393. cur->post_handler(cur, regs, 0);
  394. }
  395. resume_execution(cur, regs, kcb);
  396. regs->cp0_status |= kcb->kprobe_saved_SR;
  397. /* Restore back the original saved kprobes variables and continue. */
  398. if (kcb->kprobe_status == KPROBE_REENTER) {
  399. restore_previous_kprobe(kcb);
  400. goto out;
  401. }
  402. reset_current_kprobe();
  403. out:
  404. preempt_enable_no_resched();
  405. return 1;
  406. }
  407. static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
  408. {
  409. struct kprobe *cur = kprobe_running();
  410. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  411. if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
  412. return 1;
  413. if (kcb->kprobe_status & KPROBE_HIT_SS) {
  414. resume_execution(cur, regs, kcb);
  415. regs->cp0_status |= kcb->kprobe_old_SR;
  416. reset_current_kprobe();
  417. preempt_enable_no_resched();
  418. }
  419. return 0;
  420. }
  421. /*
  422. * Wrapper routine for handling exceptions.
  423. */
  424. int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
  425. unsigned long val, void *data)
  426. {
  427. struct die_args *args = (struct die_args *)data;
  428. int ret = NOTIFY_DONE;
  429. switch (val) {
  430. case DIE_BREAK:
  431. if (kprobe_handler(args->regs))
  432. ret = NOTIFY_STOP;
  433. break;
  434. case DIE_SSTEPBP:
  435. if (post_kprobe_handler(args->regs))
  436. ret = NOTIFY_STOP;
  437. break;
  438. case DIE_PAGE_FAULT:
  439. /* kprobe_running() needs smp_processor_id() */
  440. preempt_disable();
  441. if (kprobe_running()
  442. && kprobe_fault_handler(args->regs, args->trapnr))
  443. ret = NOTIFY_STOP;
  444. preempt_enable();
  445. break;
  446. default:
  447. break;
  448. }
  449. return ret;
  450. }
  451. int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
  452. {
  453. struct jprobe *jp = container_of(p, struct jprobe, kp);
  454. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  455. kcb->jprobe_saved_regs = *regs;
  456. kcb->jprobe_saved_sp = regs->regs[29];
  457. memcpy(kcb->jprobes_stack, (void *)kcb->jprobe_saved_sp,
  458. MIN_JPROBES_STACK_SIZE(kcb->jprobe_saved_sp));
  459. regs->cp0_epc = (unsigned long)(jp->entry);
  460. return 1;
  461. }
  462. /* Defined in the inline asm below. */
  463. void jprobe_return_end(void);
  464. void __kprobes jprobe_return(void)
  465. {
  466. /* Assembler quirk necessitates this '0,code' business. */
  467. asm volatile(
  468. "break 0,%0\n\t"
  469. ".globl jprobe_return_end\n"
  470. "jprobe_return_end:\n"
  471. : : "n" (BRK_KPROBE_BP) : "memory");
  472. }
  473. int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
  474. {
  475. struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
  476. if (regs->cp0_epc >= (unsigned long)jprobe_return &&
  477. regs->cp0_epc <= (unsigned long)jprobe_return_end) {
  478. *regs = kcb->jprobe_saved_regs;
  479. memcpy((void *)kcb->jprobe_saved_sp, kcb->jprobes_stack,
  480. MIN_JPROBES_STACK_SIZE(kcb->jprobe_saved_sp));
  481. preempt_enable_no_resched();
  482. return 1;
  483. }
  484. return 0;
  485. }
  486. /*
  487. * Function return probe trampoline:
  488. * - init_kprobes() establishes a probepoint here
  489. * - When the probed function returns, this probe causes the
  490. * handlers to fire
  491. */
  492. static void __used kretprobe_trampoline_holder(void)
  493. {
  494. asm volatile(
  495. ".set push\n\t"
  496. /* Keep the assembler from reordering and placing JR here. */
  497. ".set noreorder\n\t"
  498. "nop\n\t"
  499. ".global kretprobe_trampoline\n"
  500. "kretprobe_trampoline:\n\t"
  501. "nop\n\t"
  502. ".set pop"
  503. : : : "memory");
  504. }
  505. void kretprobe_trampoline(void);
  506. void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
  507. struct pt_regs *regs)
  508. {
  509. ri->ret_addr = (kprobe_opcode_t *) regs->regs[31];
  510. /* Replace the return addr with trampoline addr */
  511. regs->regs[31] = (unsigned long)kretprobe_trampoline;
  512. }
  513. /*
  514. * Called when the probe at kretprobe trampoline is hit
  515. */
  516. static int __kprobes trampoline_probe_handler(struct kprobe *p,
  517. struct pt_regs *regs)
  518. {
  519. struct kretprobe_instance *ri = NULL;
  520. struct hlist_head *head, empty_rp;
  521. struct hlist_node *tmp;
  522. unsigned long flags, orig_ret_address = 0;
  523. unsigned long trampoline_address = (unsigned long)kretprobe_trampoline;
  524. INIT_HLIST_HEAD(&empty_rp);
  525. kretprobe_hash_lock(current, &head, &flags);
  526. /*
  527. * It is possible to have multiple instances associated with a given
  528. * task either because an multiple functions in the call path
  529. * have a return probe installed on them, and/or more than one return
  530. * return probe was registered for a target function.
  531. *
  532. * We can handle this because:
  533. * - instances are always inserted at the head of the list
  534. * - when multiple return probes are registered for the same
  535. * function, the first instance's ret_addr will point to the
  536. * real return address, and all the rest will point to
  537. * kretprobe_trampoline
  538. */
  539. hlist_for_each_entry_safe(ri, tmp, head, hlist) {
  540. if (ri->task != current)
  541. /* another task is sharing our hash bucket */
  542. continue;
  543. if (ri->rp && ri->rp->handler)
  544. ri->rp->handler(ri, regs);
  545. orig_ret_address = (unsigned long)ri->ret_addr;
  546. recycle_rp_inst(ri, &empty_rp);
  547. if (orig_ret_address != trampoline_address)
  548. /*
  549. * This is the real return address. Any other
  550. * instances associated with this task are for
  551. * other calls deeper on the call stack
  552. */
  553. break;
  554. }
  555. kretprobe_assert(ri, orig_ret_address, trampoline_address);
  556. instruction_pointer(regs) = orig_ret_address;
  557. reset_current_kprobe();
  558. kretprobe_hash_unlock(current, &flags);
  559. preempt_enable_no_resched();
  560. hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
  561. hlist_del(&ri->hlist);
  562. kfree(ri);
  563. }
  564. /*
  565. * By returning a non-zero value, we are telling
  566. * kprobe_handler() that we don't want the post_handler
  567. * to run (and have re-enabled preemption)
  568. */
  569. return 1;
  570. }
  571. int __kprobes arch_trampoline_kprobe(struct kprobe *p)
  572. {
  573. if (p->addr == (kprobe_opcode_t *)kretprobe_trampoline)
  574. return 1;
  575. return 0;
  576. }
  577. static struct kprobe trampoline_p = {
  578. .addr = (kprobe_opcode_t *)kretprobe_trampoline,
  579. .pre_handler = trampoline_probe_handler
  580. };
  581. int __init arch_init_kprobes(void)
  582. {
  583. return register_kprobe(&trampoline_p);
  584. }