ftrace_64_pg.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Split from ftrace_64.S
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/magic.h>
  10. #include <asm/ppc_asm.h>
  11. #include <asm/asm-offsets.h>
  12. #include <asm/ftrace.h>
  13. #include <asm/ppc-opcode.h>
  14. #include <asm/export.h>
  15. _GLOBAL_TOC(ftrace_caller)
  16. lbz r3, PACA_FTRACE_ENABLED(r13)
  17. cmpdi r3, 0
  18. beqlr
  19. /* Taken from output of objdump from lib64/glibc */
  20. mflr r3
  21. ld r11, 0(r1)
  22. stdu r1, -112(r1)
  23. std r3, 128(r1)
  24. ld r4, 16(r11)
  25. subi r3, r3, MCOUNT_INSN_SIZE
  26. .globl ftrace_call
  27. ftrace_call:
  28. bl ftrace_stub
  29. nop
  30. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  31. .globl ftrace_graph_call
  32. ftrace_graph_call:
  33. b ftrace_graph_stub
  34. _GLOBAL(ftrace_graph_stub)
  35. #endif
  36. ld r0, 128(r1)
  37. mtlr r0
  38. addi r1, r1, 112
  39. _GLOBAL(ftrace_stub)
  40. blr
  41. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  42. _GLOBAL(ftrace_graph_caller)
  43. /* load r4 with local address */
  44. ld r4, 128(r1)
  45. subi r4, r4, MCOUNT_INSN_SIZE
  46. /* Grab the LR out of the caller stack frame */
  47. ld r11, 112(r1)
  48. ld r3, 16(r11)
  49. bl prepare_ftrace_return
  50. nop
  51. /*
  52. * prepare_ftrace_return gives us the address we divert to.
  53. * Change the LR in the callers stack frame to this.
  54. */
  55. ld r11, 112(r1)
  56. std r3, 16(r11)
  57. ld r0, 128(r1)
  58. mtlr r0
  59. addi r1, r1, 112
  60. blr
  61. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */