thunk.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /* SAVE_ARGS below is used only for the .cfi directives it contains. */
  45. CFI_STARTPROC
  46. SAVE_ARGS
  47. restore:
  48. RESTORE_ARGS
  49. ret
  50. CFI_ENDPROC
  51. CFI_STARTPROC
  52. SAVE_ARGS
  53. restore_norax:
  54. RESTORE_ARGS 1
  55. ret
  56. CFI_ENDPROC
  57. #ifdef CONFIG_SMP
  58. /* Support for read/write spinlocks. */
  59. .text
  60. /* rax: pointer to rwlock_t */
  61. ENTRY(__write_lock_failed)
  62. lock
  63. addl $RW_LOCK_BIAS,(%rax)
  64. 1: rep
  65. nop
  66. cmpl $RW_LOCK_BIAS,(%rax)
  67. jne 1b
  68. lock
  69. subl $RW_LOCK_BIAS,(%rax)
  70. jnz __write_lock_failed
  71. ret
  72. /* rax: pointer to rwlock_t */
  73. ENTRY(__read_lock_failed)
  74. lock
  75. incl (%rax)
  76. 1: rep
  77. nop
  78. cmpl $1,(%rax)
  79. js 1b
  80. lock
  81. decl (%rax)
  82. js __read_lock_failed
  83. ret
  84. #endif