ftrace_low.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Split from entry_64.S
  4. */
  5. #include <linux/magic.h>
  6. #include <asm/ppc_asm.h>
  7. #include <asm/asm-offsets.h>
  8. #include <asm/ftrace.h>
  9. #include <asm/ppc-opcode.h>
  10. #include <asm/export.h>
  11. #ifdef CONFIG_PPC64
  12. .pushsection ".tramp.ftrace.text","aw",@progbits;
  13. .globl ftrace_tramp_text
  14. ftrace_tramp_text:
  15. .space 64
  16. .popsection
  17. .pushsection ".tramp.ftrace.init","aw",@progbits;
  18. .globl ftrace_tramp_init
  19. ftrace_tramp_init:
  20. .space 64
  21. .popsection
  22. #endif
  23. _GLOBAL(mcount)
  24. _GLOBAL(_mcount)
  25. EXPORT_SYMBOL(_mcount)
  26. mflr r12
  27. mtctr r12
  28. mtlr r0
  29. bctr
  30. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  31. _GLOBAL(return_to_handler)
  32. /* need to save return values */
  33. #ifdef CONFIG_PPC64
  34. std r4, -32(r1)
  35. std r3, -24(r1)
  36. /* save TOC */
  37. std r2, -16(r1)
  38. std r31, -8(r1)
  39. mr r31, r1
  40. stdu r1, -112(r1)
  41. /*
  42. * We might be called from a module.
  43. * Switch to our TOC to run inside the core kernel.
  44. */
  45. LOAD_PACA_TOC()
  46. #else
  47. stwu r1, -16(r1)
  48. stw r3, 8(r1)
  49. stw r4, 12(r1)
  50. #endif
  51. bl ftrace_return_to_handler
  52. nop
  53. /* return value has real return address */
  54. mtlr r3
  55. #ifdef CONFIG_PPC64
  56. ld r1, 0(r1)
  57. ld r4, -32(r1)
  58. ld r3, -24(r1)
  59. ld r2, -16(r1)
  60. ld r31, -8(r1)
  61. #else
  62. lwz r3, 8(r1)
  63. lwz r4, 12(r1)
  64. addi r1, r1, 16
  65. #endif
  66. /* Jump back to real return address */
  67. blr
  68. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */