thunk_64.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <asm/dwarf2.h>
  10. #include <asm/calling.h>
  11. #include <asm/asm.h>
  12. /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
  13. .macro THUNK name, func, put_ret_addr_in_rdi=0
  14. .globl \name
  15. \name:
  16. CFI_STARTPROC
  17. /* this one pushes 9 elems, the next one would be %rIP */
  18. pushq_cfi_reg rdi
  19. pushq_cfi_reg rsi
  20. pushq_cfi_reg rdx
  21. pushq_cfi_reg rcx
  22. pushq_cfi_reg rax
  23. pushq_cfi_reg r8
  24. pushq_cfi_reg r9
  25. pushq_cfi_reg r10
  26. pushq_cfi_reg r11
  27. .if \put_ret_addr_in_rdi
  28. /* 9*8(%rsp) is return addr on stack */
  29. movq_cfi_restore 9*8, rdi
  30. .endif
  31. call \func
  32. jmp restore
  33. CFI_ENDPROC
  34. _ASM_NOKPROBE(\name)
  35. .endm
  36. #ifdef CONFIG_TRACE_IRQFLAGS
  37. THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
  38. THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
  39. #endif
  40. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  41. THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
  42. #endif
  43. #ifdef CONFIG_PREEMPT
  44. THUNK ___preempt_schedule, preempt_schedule
  45. #ifdef CONFIG_CONTEXT_TRACKING
  46. THUNK ___preempt_schedule_context, preempt_schedule_context
  47. #endif
  48. #endif
  49. #if defined(CONFIG_TRACE_IRQFLAGS) \
  50. || defined(CONFIG_DEBUG_LOCK_ALLOC) \
  51. || defined(CONFIG_PREEMPT)
  52. CFI_STARTPROC
  53. CFI_ADJUST_CFA_OFFSET 9*8
  54. restore:
  55. popq_cfi_reg r11
  56. popq_cfi_reg r10
  57. popq_cfi_reg r9
  58. popq_cfi_reg r8
  59. popq_cfi_reg rax
  60. popq_cfi_reg rcx
  61. popq_cfi_reg rdx
  62. popq_cfi_reg rsi
  63. popq_cfi_reg rdi
  64. ret
  65. CFI_ENDPROC
  66. _ASM_NOKPROBE(restore)
  67. #endif