thunk_64.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <asm/export.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. .type \name, @function
  16. \name:
  17. pushq %rbp
  18. movq %rsp, %rbp
  19. pushq %rdi
  20. pushq %rsi
  21. pushq %rdx
  22. pushq %rcx
  23. pushq %rax
  24. pushq %r8
  25. pushq %r9
  26. pushq %r10
  27. pushq %r11
  28. .if \put_ret_addr_in_rdi
  29. /* 8(%rbp) is return addr on stack */
  30. movq 8(%rbp), %rdi
  31. .endif
  32. call \func
  33. jmp .L_restore
  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. THUNK ___preempt_schedule_notrace, preempt_schedule_notrace
  46. EXPORT_SYMBOL(___preempt_schedule)
  47. EXPORT_SYMBOL(___preempt_schedule_notrace)
  48. #endif
  49. #if defined(CONFIG_TRACE_IRQFLAGS) \
  50. || defined(CONFIG_DEBUG_LOCK_ALLOC) \
  51. || defined(CONFIG_PREEMPT)
  52. .L_restore:
  53. popq %r11
  54. popq %r10
  55. popq %r9
  56. popq %r8
  57. popq %rax
  58. popq %rcx
  59. popq %rdx
  60. popq %rsi
  61. popq %rdi
  62. popq %rbp
  63. ret
  64. _ASM_NOKPROBE(.L_restore)
  65. #endif