thunk.S 1.9 KB

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