thunk.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. * Subject to the GNU public license, v.2. No warranty of any kind.
  6. * $Id: thunk.S,v 1.2 2002/03/13 20:06:58 ak Exp $
  7. */
  8. #include <linux/config.h>
  9. #include <linux/linkage.h>
  10. #include <asm/dwarf2.h>
  11. #include <asm/calling.h>
  12. #include <asm/rwlock.h>
  13. /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
  14. .macro thunk name,func
  15. .globl \name
  16. \name:
  17. CFI_STARTPROC
  18. SAVE_ARGS
  19. call \func
  20. jmp restore
  21. CFI_ENDPROC
  22. .endm
  23. /* rdi: arg1 ... normal C conventions. rax is passed from C. */
  24. .macro thunk_retrax name,func
  25. .globl \name
  26. \name:
  27. CFI_STARTPROC
  28. SAVE_ARGS
  29. call \func
  30. jmp restore_norax
  31. CFI_ENDPROC
  32. .endm
  33. .section .sched.text
  34. #ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
  35. thunk rwsem_down_read_failed_thunk,rwsem_down_read_failed
  36. thunk rwsem_down_write_failed_thunk,rwsem_down_write_failed
  37. thunk rwsem_wake_thunk,rwsem_wake
  38. thunk rwsem_downgrade_thunk,rwsem_downgrade_wake
  39. #endif
  40. thunk __down_failed,__down
  41. thunk_retrax __down_failed_interruptible,__down_interruptible
  42. thunk_retrax __down_failed_trylock,__down_trylock
  43. thunk __up_wakeup,__up
  44. #ifdef CONFIG_TRACE_IRQFLAGS
  45. thunk trace_hardirqs_on_thunk,trace_hardirqs_on
  46. thunk trace_hardirqs_off_thunk,trace_hardirqs_off
  47. #endif
  48. /* SAVE_ARGS below is used only for the .cfi directives it contains. */
  49. CFI_STARTPROC
  50. SAVE_ARGS
  51. restore:
  52. RESTORE_ARGS
  53. ret
  54. CFI_ENDPROC
  55. CFI_STARTPROC
  56. SAVE_ARGS
  57. restore_norax:
  58. RESTORE_ARGS 1
  59. ret
  60. CFI_ENDPROC
  61. #ifdef CONFIG_SMP
  62. /* Support for read/write spinlocks. */
  63. .text
  64. /* rax: pointer to rwlock_t */
  65. ENTRY(__write_lock_failed)
  66. lock
  67. addl $RW_LOCK_BIAS,(%rax)
  68. 1: rep
  69. nop
  70. cmpl $RW_LOCK_BIAS,(%rax)
  71. jne 1b
  72. lock
  73. subl $RW_LOCK_BIAS,(%rax)
  74. jnz __write_lock_failed
  75. ret
  76. /* rax: pointer to rwlock_t */
  77. ENTRY(__read_lock_failed)
  78. lock
  79. incl (%rax)
  80. 1: rep
  81. nop
  82. cmpl $1,(%rax)
  83. js 1b
  84. lock
  85. decl (%rax)
  86. js __read_lock_failed
  87. ret
  88. #endif