thunk_64.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Save registers before calling assembly functions. This avoids
  3. * disturbance of register allocation in some inline assembly constructs.
  4. * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
  5. * Added trace_hardirqs callers - Copyright 2007 Steven Rostedt, Red Hat, Inc.
  6. * Subject to the GNU public license, v.2. No warranty of any kind.
  7. */
  8. #include <linux/linkage.h>
  9. #include "calling.h"
  10. #include <asm/asm.h>
  11. /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
  12. .macro THUNK name, func, put_ret_addr_in_rdi=0
  13. .globl \name
  14. \name:
  15. /* this one pushes 9 elems, the next one would be %rIP */
  16. pushq %rdi
  17. pushq %rsi
  18. pushq %rdx
  19. pushq %rcx
  20. pushq %rax
  21. pushq %r8
  22. pushq %r9
  23. pushq %r10
  24. pushq %r11
  25. .if \put_ret_addr_in_rdi
  26. /* 9*8(%rsp) is return addr on stack */
  27. movq 9*8(%rsp), %rdi
  28. .endif
  29. call \func
  30. jmp restore
  31. _ASM_NOKPROBE(\name)
  32. .endm
  33. #ifdef CONFIG_TRACE_IRQFLAGS
  34. THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
  35. THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
  36. #endif
  37. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  38. THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
  39. #endif
  40. #ifdef CONFIG_PREEMPT
  41. THUNK ___preempt_schedule, preempt_schedule
  42. THUNK ___preempt_schedule_notrace, preempt_schedule_notrace
  43. #endif
  44. #if defined(CONFIG_TRACE_IRQFLAGS) \
  45. || defined(CONFIG_DEBUG_LOCK_ALLOC) \
  46. || defined(CONFIG_PREEMPT)
  47. restore:
  48. popq %r11
  49. popq %r10
  50. popq %r9
  51. popq %r8
  52. popq %rax
  53. popq %rcx
  54. popq %rdx
  55. popq %rsi
  56. popq %rdi
  57. ret
  58. _ASM_NOKPROBE(restore)
  59. #endif